[bt-devel] Qt Only
Eeli Kaikkonen
eekaikko at mail.student.oulu.fi
Mon Feb 23 02:01:15 MST 2009
Quoting Gary Holmlund <gary.holmlund at gmail.com>:
> Gary Holmlund wrote:
>>
>> I have checked in the Qt only version. I believe it is complete
>> except for command line options not working.
>>
>> I have tried to remove the KDE parts of the CMakeLists.txt but I
>> have not been successful. If there is someone more knowledgeable
>> about cmake issues I would appreciate help looking at it. I am
>> attaching my modified version. It compiles everything but fails at
>> link time.
>>
>> BibleTime compiles correctly with the currently checked in
>> CMakeList.txt, but still requires your computer to have KDE
>> libraries.
>>
>> Gary
> The CMakeList.txt file does not have any KDE in it now. We should be
> ready to compile for window or mac.
>
> I figured out the CMakeList.txt issues. There are two ways for a Qt
> class to compile the extra signal/slots code that is generated by the
> moc process. The first includes the extra code adding a #include
> "<filename>.moc" statement to each cpp file using signals/slots. The
> second is to have the extra code generated as a cpp file and compile it
> separate from the Qt class. In the CMakeList.txt file the QT4_AUTOMOC
> statement is used if you have the first way and the QT4_WRAP_CPP is
> used for the second way. In BibleTime sources we have a mixture for Qt
> class that use both ways. The cmake KDE macros handle a mixture of both
> cases. With the cmake Qt macros you must choose one or the other.
>
> I changed numerous cpp files to add an include moc entry and used the
> QT4_AUTOMOC macro. This was the simpler case because it does not
> require us to maintain a list of the .h files that need to be moc'ed.
>
> So as a general rule if you are creating a new class that uses
> signals/slots (has a Q_OBJECT line) in the header, you should put a
> include moc line in the cpp file. Example:
>
> ----- btactioncollection.h -----------
> (lines removed)
> class BtActionCollection : public QObject
> {
> Q_OBJECT
> public:
> BtActionCollection(QObject* parent);
> (lines removed)
> ---------------------------------------
>
> ----- btactioncollection.cpp ---------
> (lines removed)
> #include "btactioncollection.h"
> #include "btactioncollection.moc"
>
> BtActionCollection::BtActionCollection(QObject* parent)
> : QObject(parent)
> {
> }
> (lines removed)
> ---------------------------------------
>
Very good, thanks. #include ".moc" is a good way to do it. I used it
originally and it was used in every file, but apparantly the build
system was changed and new files "just worked" without that #include.
Therefore they were different.
--Eeli Kaikkonen
More information about the bt-devel
mailing list