Results 1 to 3 of 3

Thread: no such signal QListBox::currentChanged()

  1. #1
    Join Date
    Mar 2006
    Posts
    2
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default no such signal QListBox::currentChanged()

    Hi, I've been struggling for a few hours with this error now so I joined these boards. I would be most obliged if you could help me figure this out. I'm posting this in the newbie forum because this is my first Qt program and it seems I'm making some silly mistake.

    I have a MainForm class, which has various QWidgets as members and a DotListBox class, which inherits from QListBox. When I try to connect the DotListBox::currentChanged() signal to the MainForm::currentChanged slot, I get a "no such signal error" at run-time.

    This is mainform.h. The program's main function just constructs this object and calls MainForm::execute().

    Qt Code:
    1. class MainForm : public QObject
    2. {
    3. Q_OBJECT
    4. private:
    5. Points points;
    6. QHBox hbox;
    7. QVBox vbox;
    8. DotListBox listbox;
    9. QPushButton remove;
    10. DotWidget dots;
    11. public slots:
    12. void currentChanged(QListBoxItem *);
    13. void removeClicked();
    14. public:
    15. MainForm(int argc, char *argv[]);
    16. ~MainForm();
    17. int Execute();
    18. };
    To copy to clipboard, switch view to plain text mode 

    This is the constructor of MainForm:

    Qt Code:
    1. MainForm::MainForm(int argc, char *argv[])
    2. : points()
    3. , app(argc, argv)
    4. , hbox(0)
    5. , vbox(&hbox)
    6. , listbox(&vbox, &points)
    7. , remove("&Remove", &vbox)
    8. , quit("&Quit", &vbox)
    9. , dots(&hbox, &points)
    10. {
    11. QObject::connect(
    12. &quit, SIGNAL(clicked()),
    13. &app, SLOT(quit())
    14. );
    15. QObject::connect(
    16. &listbox, SIGNAL(currentChanged()),
    17. this, SLOT(currentChanged())
    18. );
    19. QObject::connect(
    20. &remove, SIGNAL(clicked()),
    21. this, SLOT(removeClicked())
    22. );
    23. }
    To copy to clipboard, switch view to plain text mode 

    The signals related to the quit and remove buttons connect fine to their slots.

    This is the dotlistbox.h header file:

    Qt Code:
    1. class DotListBox : public QListBox, public Observer
    2. {
    3. private:
    4. Points *points;
    5. public:
    6. DotListBox(QWidget *parent, Points *p = NULL);
    7. virtual ~DotListBox();
    8. void Update();
    9. };
    To copy to clipboard, switch view to plain text mode 

    As you can see, it also inherits from an Observer class, of which it implements the Update() function. The problem is that I can't connect the currentChanged() signal of my derived listbox to the currentChanged() slot of MainForm.

    Qt Code:
    1. ./dots
    2. Xlib: extension "XInputExtension" missing on display ":1.0".
    3. Failed to get list of devices
    4. QObject::connect: No such signal QListBox::currentChanged()
    5. QObject::connect: (sender name: 'mylistbox')
    6. QObject::connect: (receiver name: 'unnamed')
    To copy to clipboard, switch view to plain text mode 

    (The Xlib error seems to be FreeBSD specific, I'm blissfully ignoring that for the moment.)

    My hunch is that the problem is that DotListBox is derived from QListBox and that the signal slots don't get inherited, but I'm not sure.

    Thanks in advance for any help.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: no such signal QListBox::currentChanged()

    Quote Originally Posted by jopie bakker
    QObject::connect: No such signal QListBox::currentChanged()
    QObject::connect: (sender name: 'mylistbox')
    QObject::connect: (receiver name: 'unnamed')
    But there's no such signal indeed.

    Try:
    Qt Code:
    1. connect( &listbox, SIGNAL( currentChanged( QListBoxItem * ) ),
    2. this, SLOT( currentChanged( QListBoxItem * ) ) );
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to jacek for this useful post:

    jopie bakker (2nd March 2006)

  4. #3
    Join Date
    Mar 2006
    Posts
    2
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: no such signal QListBox::currentChanged()

    Thanks! I had already tried to add the type to the SIGNAL() macro, but not to the SLOT() macro. So specifying the types for both the source and the destination does it.

Similar Threads

  1. pthread instead QThread
    By brevleq in forum Qt Programming
    Replies: 8
    Last Post: 23rd December 2008, 07:16
  2. Connection of custon signals/slots
    By brevleq in forum Qt Programming
    Replies: 2
    Last Post: 23rd December 2008, 07:04
  3. Possible signal mapper problem
    By MarkoSan in forum Qt Programming
    Replies: 13
    Last Post: 25th January 2008, 13:11
  4. Replies: 2
    Last Post: 17th May 2006, 21:01

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.