Q_OBJECT in template class and order of slots



  • Since template classes cannot contain Q_OBJECT macro and i really need templates i wrote the code similar to this:
    @
    class ObjectParent : public QObject
    {
    Q_OBJECT
    ...
    public slots:
    void slot1(){...};
    void slot2(){...};
    };

    template< typename T >
    class TemplateParent : public ObjectParent
    {
    T t_;
    ...
    };

    class TemplateArgument {...};

    class MyClass : public TemplateParent< TemplateArgument >
    {
    Q_OBJECT
    ...
    };@

    Then i connect some signals to slot1 and slot2 of MyClass instances. First compilations and launches - everything works smoothly. Today i got "no such slot: MyClass::slot2()". Tried to add another "public slots" right before slot2() declaration, tried to do complete rebuild - nothing. Then i just swapped slot1() and slot2() declarations (and definitions since they are in the header too) and everything works again!

    What was the reason for QObject::connect() didn't find slot2() slot and why complete rebuilding did nothing where just swapping of two slots' declarations did the thing?



  • If you put together a minimal testcase you could submit a bug report, although I'm not sure you're in a supported case there (cf. [[doc:moc]] limitations).


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.