Results 1 to 6 of 6

Thread: QObject::connect: No such signal

  1. #1

    Exclamation QObject::connect: No such signal

    Hi,

    I am a newbie to qt... I thought I followed the obvious steps to define "signal" for a customized widget (in my example, BinaryButtonWg). i.e.,

    1. declare the signal in BinaryButtonWg.h
    2. connect signal and slot with same arguments
    3. emit signal

    ... But, somehow, there is always a complain of QObject::connect No such signal, when I try to connect the signal in my application of the BinaryButtonWg class.

    And, when I use dumpObjectInfo(), it showed

    OBJECT BinaryButtonWg::mask
    SIGNALS OUT
    <None>
    SIGNALS IN
    QHButtonGroup::unnamed



    I believe I could have missed out something fundamental.. I will appreciate your help.. Following are my codes of BinaryButtonWg:

    BinaryButtonWg.h
    Qt Code:
    1. #ifndef BINARYBUTTONWG_H
    2. #define BINARYBUTTONWG_H
    3.  
    4. #include <qwidget.h>
    5. #include <qhbuttongroup.h>
    6. #include <qvbox.h>
    7. #include <qsize.h>
    8.  
    9. class BinaryButtonWg : public QWidget
    10. {
    11. Q_OBJECT
    12. public:
    13. BinaryButtonWg(QSize bsize, unsigned int bitsize=8, QWidget *parent = 0, const char *name = 0 , const char *title = 0);
    14. ~BinaryButtonWg() {};
    15.  
    16.  
    17. public slots:
    18. void enableBits(unsigned int bits);
    19.  
    20. private slots:
    21. void buttonPressed(int buttonId);
    22. signals:
    23. void bbChanged(unsigned int newValue);
    24. private:
    25. QHButtonGroup* _bg;
    26. QVBox* _vb;
    27. unsigned int _value;
    28. unsigned int _bitsize;
    29.  
    30. };
    31.  
    32. #endif
    To copy to clipboard, switch view to plain text mode 

    In BinaryButtonWg.cpp,

    Qt Code:
    1. BinaryButtonWg::BinaryButtonWg(QSize bsize, unsigned int bitsize, QWidget *parent, const char *name , const char* title ): QWidget(parent, name, 0)
    2. {
    3. _bg = new QHButtonGroup(_vb);
    4. .
    5. .
    6. // this one work fine
    7. connect( _bg, SIGNAL( clicked(int) ), this, SLOT( buttonPressed(int)));
    8. }
    9.  
    10. void BinaryButtonWg::buttonPressed( int buttonId)
    11. {
    12. _value ^= (1 << buttonId);
    13. printf("buttonPressed! new value: 0x%02X\n", _value);
    14. emit this->bbChanged(_value);
    15. }
    To copy to clipboard, switch view to plain text mode 


    Rgds

    Casey
    Last edited by marcel; 18th February 2008 at 10:15. Reason: missing [code] tags

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QObject::connect: No such signal

    The connect statement must contain the exact signature of the signal and slot.
    The slot and signal take an unsigned int parameter, however you pass them to connect as taking an int.

    Modify the connect.

  3. #3

    Default Re: QObject::connect: No such signal

    Hello Marcel,

    thanks.. But, I actually did connect with unsigned int as seen in the test codes below:

    Qt Code:
    1. #include <qapplication.h>
    2. #include <qlayout.h>
    3. #include "BinaryButtonWg.h"
    4.  
    5. int main( int argc, char *argv[] )
    6. {
    7. QApplication app( argc, argv );
    8. QWidget* widget = new QWidget();
    9. widget->setFixedSize(QSize(500,300));
    10. QHBoxLayout* hlayout = new QHBoxLayout(widget);
    11. BinaryButtonWg maskbb(QSize(200, 40), 12, widget);
    12. BinaryButtonWg valuebb(QSize(200, 40), 12, widget);
    13. hlayout->addWidget( &maskbb);
    14. hlayout->addWidget( &valuebb);
    15. app.setMainWidget( widget );
    16. QObject::connect(&maskbb, SIGNAL( bbChanged(unsigned int newValue) ),
    17. &valuebb, SLOT( enableBits(unsigned int bits) ));
    18.  
    19. widget->show();
    20. return app.exec();
    21. }
    To copy to clipboard, switch view to plain text mode 

    But, still has the same complaint:

    QObject::connect: No such signal BinaryButtonWg::bbChanged(unsigned int newValue)
    QObject::connect: (sender name: 'unnamed')
    QObject::connect: (receiver name: 'unnamed')
    Thanks...

    Casey
    Last edited by jpn; 19th February 2008 at 07:47.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QObject::connect: No such signal

    Do not put parameter names to connect-statement:
    Qt Code:
    1. QObject::connect(&maskbb, SIGNAL( bbChanged(unsigned int) ),
    2. &valuebb, SLOT( enableBits(unsigned int) ));
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  5. #5

    Default Re: QObject::connect: No such signal

    If dumpObjectInfo() shows
    SIGNALS OUT
    <None>
    SIGNALS IN
    QHButtonGroup::unnamed

    will that have confirmed there is no out signal from the object? Are there alternatives of checking for SIGNALs other than dumpObjectInfo()?

    Thanks..

    Casey

  6. #6

    Default Re: QObject::connect: No such signal

    Hello J-P,

    thankyou !! that is the error...

    Casey

Similar Threads

  1. Possible signal mapper problem
    By MarkoSan in forum Qt Programming
    Replies: 13
    Last Post: 25th January 2008, 14:11
  2. Replies: 6
    Last Post: 21st September 2007, 14:51
  3. Replies: 2
    Last Post: 17th May 2006, 22:01
  4. no such signal QListBox::currentChanged()
    By jopie bakker in forum Newbie
    Replies: 2
    Last Post: 2nd March 2006, 16:17

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.