Results 1 to 4 of 4

Thread: QButtonGroup buttonClicked signal/slot problem

  1. #1

    Default QButtonGroup buttonClicked signal/slot problem

    Hello,

    I'm connecting a QButtonGroup buttonClicked(int) signal to a slot in my MainWindow class as follows:

    QObject::connect( leftButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(onLeftButtonClicked(int)));

    The connect works and I get the event. However, when my slot gets the event, id is always -1, no matter which button I press.

    The slot looks like:

    void MainWindow:nLeftButtonClicked(int id)
    {
    switch(id)
    ...

    I have 8 buttons in the group. Any idea why I don't get the proper value?

    I'm using Qt 4.3.4 on Windows XP SP2.

    Thanks,
    David

  2. #2
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QButtonGroup buttonClicked signal/slot problem

    have u called setId() for every button?

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

    Plixil (7th August 2010)

  4. #3

    Default Re: QButtonGroup buttonClicked signal/slot problem

    Yes, this solved my problem. Thanks!

    I guess what I don't understand is why QButtonGroup doesn't just init the id with a static incremementer automatically such that you'd get the id's in the order they were added without having to call setId.

    -david

  5. #4
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QButtonGroup buttonClicked signal/slot problem

    lets not expect Qt to do everything for us..there has to be a reason we get paid for what we do

Similar Threads

  1. Replies: 16
    Last Post: 28th October 2008, 22:00
  2. Replies: 2
    Last Post: 20th September 2007, 12:27
  3. problem with signal/slot
    By ihoss in forum Newbie
    Replies: 2
    Last Post: 24th August 2007, 22:59

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.