MantisBT - VTK
View Issue Details
0005544VTK(No Category)public2007-08-20 17:262008-04-01 13:02
Clinton Stimpson 
0005544: QVTKWidget uses QT keywords that interfere with Boost signals / slots
Qt #defines three lower-case words to appear as an extension to C++: signals, slots, and emit. This interferes with other use of those terms, e.g. a method named emit() is not possible. Nor is an alternative implementation of signals and slots.

The way around this is to #define QT_NO_KEYWORDS on the compiler invocation and change the code as follows:

signals -> Q_SIGNALS
slots -> Q_SLOTS
emit foo() -> foo()

Removing these keywords now allows us to use them as normal and leaves the door open for using the Boost implementation of signals & slots alongside Qt’s, should that prove useful. See [^] for a comparison.
The following is a diff of the changes:
the_wild_kingdom>p4 diff -du QVTKWidget.h
==== //depot/src/vtk-5.0.3/GUISupport/Qt/QVTKWidget.h#1 - C:/perforce/misp-MAIN\import\src\vtk-5.0.3\GUISupport\Qt\QVTKWidget.h ====
@@ -137,7 +137,7 @@

     virtual QPaintEngine* paintEngine() const;

- signals:
     // Description:
     // This signal will be emitted whenever a mouse event occurs
     // within the QVTK window
@@ -153,7 +153,7 @@
     void cachedImageClean();

- public slots:
+ public Q_SLOTS:
     // Description:
     // This will mark the cached image as dirty. This slot is automatically
     // invoked whenever the render window has a render event or the widget is
@@ -230,7 +230,7 @@
     static OSStatus DirtyRegionProcessor(EventHandlerCallRef er, EventRef event, void*);

- private slots:
+ private Q_SLOTS:
     void internalMacFixRect();

@@ -277,7 +277,7 @@
   // Overloaded destroy timer method for destroying Qt timers.
   virtual int DestroyTimer();

-public slots:
+public Q_SLOTS:
   // timer event slot
   virtual void TimerEvent();

No tags attached.
Issue History
2007-08-20 17:26alexiukNew Issue
2008-01-28 14:57Clinton StimpsonStatusbacklog => tabled
2008-01-28 14:57Clinton StimpsonAssigned To => Clinton Stimpson
2008-01-28 15:21Clinton StimpsonNote Added: 0010310
2008-04-01 11:36Maik BeckmannNote Added: 0011016
2008-04-01 13:02Clinton StimpsonStatustabled => closed
2008-04-01 13:02Clinton StimpsonNote Added: 0011018
2008-04-01 13:02Clinton StimpsonResolutionopen => fixed
2011-06-16 13:11Zack GalbreathCategory => (No Category)

Clinton Stimpson   
2008-01-28 15:21   
Do you have a suggested patch that would still build with Qt version < 4.1?
Maik Beckmann   
2008-04-01 11:36   
I tried to do some preprocessor action, but qt3-moc refuses everything accept

IMHO the best solution is to use configure_file. When QT_NO_KEYWORDS is supported we do
 @Q_SIGNALS@ -> signals
 @Q_SLOTS@ -> slots

-- Maik
Clinton Stimpson   
2008-04-01 13:02   
I didn't think of a configured header. Thanks.

/cvsroot/VTK/VTK/GUISupport/Qt/QVTKWidget.h,v <-- QVTKWidget.h
new revision: delete; previous revision: 1.16
/cvsroot/VTK/VTK/GUISupport/Qt/,v <--
initial revision: 1.1
/cvsroot/VTK/VTK/vtkIncludeDirectories.cmake,v <-- vtkIncludeDirectories.cmake
new revision: 1.48; previous revision: 1.47
/cvsroot/VTK/VTK/GUISupport/Qt/CMakeLists.txt,v <-- GUISupport/Qt/CMakeLists.txt
new revision: 1.40; previous revision: 1.39