I don't think this is what I'm looking for.
Q_SLOT can only be used with a method DECLARATION:
Q_SLOT int myMethod1( int a, int b );
Q_SLOT int myMethod1( int a, int b );
To copy to clipboard, switch view to plain text mode
which in this case would result in redeclaration/overloading error
Or am I wrong? How am I supposed to use it?
I have created this hack for the MOC precompiler:
#define MY_SLOTS( x )
#define MY_METHODS() \
public: \
int myMethod1( int a, int b ) { ... }; \
int myMethod2( int a, int b ) { ... }; \
int myMethod3( int a, int b ) { ... }; \
int myMethod4( int a, int b ) { ... };
{
Q_OBJECT
MY_METHODS();
MY_SLOTS(
public slots:
int myMethod1( int a, int b );
int myMethod3( int a, int b );
private:
)
};
#define MY_SLOTS( x )
#define MY_METHODS() \
public: \
int myMethod1( int a, int b ) { ... }; \
int myMethod2( int a, int b ) { ... }; \
int myMethod3( int a, int b ) { ... }; \
int myMethod4( int a, int b ) { ... };
class MyClass : public QObject
{
Q_OBJECT
MY_METHODS();
MY_SLOTS(
public slots:
int myMethod1( int a, int b );
int myMethod3( int a, int b );
private:
)
};
To copy to clipboard, switch view to plain text mode
The compiler simply ignores everything within MY_SLOTS(...) and does not redeclare following methods.
But MOC does interpret this part and generates the code I need.
Bookmarks