Skip to content

Commit 62add21

Browse files
committed
Updated README.md based off of feedback
1 parent 94a9767 commit 62add21

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

examples/qt_with_qmake/README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,22 @@ It is possible to use libsigc++ with Qt. However, because of the signals/slots
44
mechanism of Qt, there is some setup that must be done in order for this to
55
happen correctly.
66

7+
The official Qt documentation may be found here: https://doc.qt.io/qt-5/signalsandslots.html#using-qt-with-3rd-party-signals-and-slots
8+
79
Steps to use libsigc++ with Qt:
810
1. In your .pro file, add `CONFIG += no_keywords`. This configures Qt to not
9-
define the keywords `emit`, `signals`, and `slot`.
11+
define the macros `emit`, `signals`, and `slot`. These are keywords for moc,
12+
which preprocesses the source files in order to use Qt signals/slots.
1013
2. In your header files, change the `signals:` section of your class to instead
1114
be `Q_SIGNALS`
1215
3. In your header files, change the `public slots:` section of your class to
1316
instead be `public Q_SLOTS:`
1417
4. In any class that you emit a signal, change `emit` to be `Q_EMIT`.
1518

19+
In general, using the Q\_ macros is a good idea if your code is a library
20+
intended to be used by people other than yourself, as they may be using
21+
code(e.g. libsigc++/boost signals) that will conflict with Qt(moc) keywords.
22+
1623
Here's an example of a class before and after this conversion(note: irrelevant
1724
code has been removed):
1825

@@ -43,3 +50,18 @@ public Q_SLOTS:
4350
Since libsigc++ simply requires a slot to be a function, you can call Qt
4451
slots easily using libsigc++. Similarly, a function that is a libsigc++ slot
4552
can also be used as a Qt slot.
53+
54+
# Other Build Systems
55+
If you are not using qmake to build your Qt project, you must tell your
56+
buildsystem to define `QT_NO_KEYWORDS`. If you're using CMake, this may
57+
be done like the following:
58+
59+
```
60+
add_definitions(-DQT_NO_KEYWORDS)
61+
```
62+
63+
or in a more modern CMake way:
64+
65+
```
66+
target_compile_definitions(some_target PRIVATE QT_NO_KEYWORDS)
67+
```

0 commit comments

Comments
 (0)