Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Q_OBJECT in template class and order of slots
Forum Updated to NodeBB v4.3 + New Features

Q_OBJECT in template class and order of slots

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    p-himik
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dangelog
      wrote on last edited by
      #2

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

      Software Engineer
      KDAB (UK) Ltd., a KDAB Group company

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved