Results 1 to 2 of 2

Thread: Anoying problem, Object::connect: No such slot

  1. #1
    Join Date
    Mar 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Anoying problem, Object::connect: No such slot

    Hey everyone

    I am bit new with qt4 and I have a program that is having a bit of problems connecting a button. I am not sure how much code I should provide, but in my header file have I created a slot:
    void btnPressed( ros::Publisher& _publisher );

    in my source file I then connect to the slot by:
    connect( buttons.back() ,SIGNAL(pressed()), this, SLOT( btnPressed( publisherList.back() ) ) );

    While it compiles fine, then during execution do I get:
    Object::connect: No such slot SamplePlugin::btnPressed( publisherList.back() )

    If I remove the use of input parameters for btnPressed, then it works fine, but the structure of my program is deeply depended that I can provide a publisher through connect(). I have searched alot on the net, seen people who have experienced same error message, but I could not find any error in my code and I have also seen examples of working code using input parameters, where I cant see much deviation from my own.
    Is there anyone who have an idea what might be wrong?

    Regards

    Sebastian

  2. #2
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Anoying problem, Object::connect: No such slot

    Hi Sebastian!

    You cannot pass a parameter in this way, sadly!

    The proper qt way of doing this is with a QSignalMapper.

    Alternatives are to use QObject::sender() in your slot or to use the boost::bind function or LibQxt's QxtMetaObject::bind as a slot, but thats either not nice Qt-OOP code or not easy to setup for a beginner.

    HIH

    Johannes

Similar Threads

  1. Connect signal from base to slot of sub-sub-object
    By donglebob in forum Qt Programming
    Replies: 15
    Last Post: 30th October 2008, 20:54
  2. Object::connect: Parentheses expected, slot...
    By bnilsson in forum Qt Programming
    Replies: 5
    Last Post: 5th April 2008, 16:02
  3. Replies: 21
    Last Post: 5th January 2008, 16:44
  4. Replies: 2
    Last Post: 8th October 2007, 16:02
  5. Replies: 3
    Last Post: 24th September 2007, 09:20

Tags for this Thread

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.