Results 1 to 3 of 3

Thread: QCheckBox value

  1. #1
    Join Date
    Sep 2008
    Posts
    13
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default QCheckBox value

    Hi all! I'm working with QCheckBox and I can't find any way of assigning a value to it. Here's an example of what I'm trying to do:

    I have a list of languages, and the user can select one or more of them. So I create a list of this languages, each one is a QCheckBox:

    [] English
    [] French
    [] German
    [] Spanish

    The thing is, when I create this checkboxes, how can I tell Qt that the value of the first one is EN, the value of the second one is FR, etc...? (like the value attribute used in HTML). I need this in order to know which language codes have been checked.

    Right now what I'm doing is subclass QCheckBox to add a custom propertie named value, but I wonder if I'm missing anything, maybe QT already has a way to do this and I just didn't find it!

    Any help will be appreciated, thanks!

  2. #2
    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: QCheckBox value

    QObject supports dynamic properties since Qt 4.2. See QObject::setProperty() for more details.
    J-P Nurmi

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

    Koas (19th January 2009)

  4. #3
    Join Date
    Sep 2008
    Posts
    13
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QCheckBox value

    Thanks a lot, that's exactly what I was looking for!

Similar Threads

  1. How to change defualt color of QCheckbox box?
    By darshan.hardas in forum Qt Programming
    Replies: 3
    Last Post: 12th November 2008, 13:24
  2. inserting QCheckBox into the Header
    By ru_core in forum Qt Programming
    Replies: 16
    Last Post: 16th April 2008, 19:26
  3. QCheckBox dependency
    By jd in forum Qt Programming
    Replies: 2
    Last Post: 1st April 2008, 13:12
  4. QCheckbox
    By sonuani in forum Qt Programming
    Replies: 1
    Last Post: 19th February 2008, 13:12
  5. Insert QCheckBox into QTableView
    By wind in forum Qt Programming
    Replies: 3
    Last Post: 8th October 2006, 16:15

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.