[bt-devel] Qt Only

Gary Holmlund gary.holmlund at gmail.com
Sun Feb 22 20:19:06 MST 2009


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)
 ---------------------------------------

Gary




More information about the bt-devel mailing list