Results 1 to 4 of 4

Thread: Problem with connect() (enum-type as parameter)

  1. #1
    Join Date
    Mar 2008
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Problem with connect() (enum-type as parameter)

    Hi all,

    the call of QObject::connect() in my program fails at runtime with the following message:
    "Object::connect: No such slot Monitor::testSlot()"

    If I leave out the parameters from the slots definition it works.
    The types of the parameters are std::string and an enum-type.

    Do I have to register the enum-type with qRegisterMetaType() ?
    I tried, but it seems to make no difference. The same error still occurs.

    What else can be the reason for this error?


    Thanks in advance

    Alu

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem with connect() (enum-type as parameter)

    The enum should be registered using Q_ENUM, but I'm not sure if this is your problem. When do you get the above error message? When you pass parameters or not?

  3. #3
    Join Date
    Mar 2008
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Problem with connect() (enum-type as parameter)

    I get the error when parameters are passed.
    When I use uint instead of the enum-type it works.

    The strange thing is: I call QObject::connect() in another part of the program -- with the same enum-type as argument to signals and slots -- and there's no error message. But this connections don't work. Nothing happens after the signal is emitted!?
    (The only difference is that it is a direct connection (within one thread) in this case and a queued connection (between two threads) in the case described in the first post.)

    Is this all the same error or is it about two different issues?


    Alu

    EDIT: After another critical view it turned out that none of the connects works right. In the second case the connect returns false, but no error message occurs.
    Last edited by alu23; 8th May 2008 at 15:26.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem with connect() (enum-type as parameter)

    Queued connections require parameters to be serialized, so you have to use Q_ENUM to create a meta-type for the enum and then use qRegisterMetaType to register it with QVariant. Anyway the error you get implies you pass the slot signature without parameters, so I suggest you check your connect() code - make sure the slot is declared as a slot and everything else is in place.

Similar Threads

  1. dummy question(Error)
    By Masih in forum Qt Programming
    Replies: 12
    Last Post: 20th July 2007, 00:38

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.