Results 1 to 8 of 8

Thread: check box and signal

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Lightbulb check box and signal

    Hi, I'm trying to do this:
    Qt Code:
    1. connect( checkBox, SIGNAL(toggled(bool)), this, SLOT (activeOption() ));
    2. connect( checkBox2, SIGNAL(toggled(bool)), this, SLOT (activeOption() ));
    To copy to clipboard, switch view to plain text mode 
    problem is that check box belog to button group exclusive of 2 check box; When I active check1 start my SLOT and SLOT starts a second time because when checking the fisrt box, I de-checking the second too (is exclusive); I need something like:
    connect( checkBox2, SIGNAL(checked()).....but it is not a signal?
    is there a signal?
    Thanks
    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: check box and signal

    emm..why you dont want get bool flag(checked/unchecked) in your slot
    a life without programming is like an empty bottle

  3. #3
    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: check box and signal

    Since you have the check boxes in a button group, you can use:
    QButtonGroup::clicked(int id) [signal]

    At least in Qt4, the corresponding signal is emitted for the check box that was "checked".

  4. The following user says thank you to jpn for this useful post:

    mickey (20th March 2006)

  5. #4
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: check box and signal

    Quote Originally Posted by zlatko
    emm..why you dont want get bool flag(checked/unchecked) in your slot
    because I'd like the SLOT starts only when checkBox is checked and avoid control of a bool inside SLOT; I resolve so:
    Qt Code:
    1. connect(buttonGroupEquation, SIGNAL(clicked(int)), this, SLOT (activeOption(int) ));
    To copy to clipboard, switch view to plain text mode 
    clicked(int) say to SLOT who is the sender too; Thanks
    Regards

  6. #5
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: check box and signal

    Is it possible to change checked window's contens (caption and icon) regarding to this button check state? I mean, how do I rewrite non virtual slot to do this?
    Qt 5.3 Opensource & Creator 3.1.2

  7. #6
    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: check box and signal

    Quote Originally Posted by MarkoSan View Post
    Is it possible to change checked window's contens (caption and icon) regarding to this button check state? I mean, how do I rewrite non virtual slot to do this?
    Could you elaborate a bit? What is a checked window? What non-virtual slot?
    J-P Nurmi

  8. #7
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: check box and signal

    Ok, here we go:

    The checked button term is used in qt QPushButton documentation and it refers to a button, which supports toggle button. And here is my problem, since i do not know how to make a code that will:

    1) in button state ON set a predefined text and icon
    2) in button state OFF set a different predefined text and icon
    Qt 5.3 Opensource & Creator 3.1.2

  9. #8
    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: check box and signal

    Construct a QIcon with two pixmaps, one for each state. To update button text, you can simply connect to toggled(bool) signal and set the button text in the corresponding slot, or you can reimplement for example QAbstractButton::checkStateSet() and change the button text there.
    J-P Nurmi

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.