Results 1 to 3 of 3

Thread: Which QCheckBox has been checked?

  1. #1
    Join Date
    Jul 2009
    Location
    Valladolid, Spain
    Posts
    125
    Thanks
    16
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Which QCheckBox has been checked?

    I have 3 QCheckBox'es and I would like to know which one has been checked.
    I use this to connect them:
    Qt Code:
    1. QObject.connect(self.ui.checkbox1, SIGNAL("toggled(bool)"), self.__on_check)
    2. QObject.connect(self.ui.checkbox2, SIGNAL("toggled(bool)"), self.__on_check)
    3. QObject.connect(self.ui.checkbox3, SIGNAL("toggled(bool)"), self.__on_check)
    To copy to clipboard, switch view to plain text mode 
    (this is python)

    Thanks

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Which QCheckBox has been checked?

    You could use QObject::sender() in the slot code to pick the triggering object.

    Alternatively, you could use a QSignalMapper or put your check boxes into a QButtonGroup. Both these options allow your slot to receive a parameter identifying the clicked button.

  3. #3
    Join Date
    Jul 2009
    Location
    Valladolid, Spain
    Posts
    125
    Thanks
    16
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Which QCheckBox has been checked?

    Yeah! That worked great (self.sender())
    Thanks

Similar Threads

  1. QCheckBox with long text label
    By Ferdous in forum Newbie
    Replies: 5
    Last Post: 29th October 2011, 20:05
  2. Delete if row checked
    By wirasto in forum Qt Programming
    Replies: 2
    Last Post: 11th July 2009, 15:16
  3. QCheckBox value
    By Koas in forum Qt Programming
    Replies: 2
    Last Post: 19th January 2009, 14:33
  4. inserting QCheckBox into the Header
    By ru_core in forum Qt Programming
    Replies: 16
    Last Post: 16th April 2008, 20:26
  5. Which QCheckBox is checked?
    By Craig.Smith in forum Qt Programming
    Replies: 2
    Last Post: 9th November 2007, 15:52

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.