PDA

View Full Version : QCheckBox value



Koas
19th January 2009, 09:48
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! :)

jpn
19th January 2009, 13:25
QObject supports dynamic properties since Qt 4.2. See QObject::setProperty() for more details.

Koas
19th January 2009, 13:33
Thanks a lot, that's exactly what I was looking for!