PDA

View Full Version : QDataWidgetMapper with QGroupBox



Nightfox
18th September 2009, 00:56
I'm trying to get a QGroupBox cheked state to change with an QDataWidgetMapper. I'm using a model with several controls and the QDataWidgetMapper being one of them. I want a group of controls to be displayed or hidden based on the value in the QDataWidgetMapper that can take on the value 0 or 1.

For all of the controls it's no problem, but for the QGroupBox I can't get it to react.




mapper = new QDataWidgetMapper(this);
mapper->setModel(mymodel);

QLabel *lbl_acc_code = new QLabel("Code",this);
QLineEdit *txt_acc_code = new QLineEdit(this);
lbl_acc_code->setBuddy(txt_acc_code);
mapper->addMapping(txt_acc_code, 0);

QLabel *lbl_acc_name = new QLabel("Name",this);
QLineEdit *txt_acc_name = new QLineEdit(this);
mapper->addMapping(txt_acc_name, 1);

QGroupBox *groupBox = new QGroupBox(tr("Incl. controls"),this);
groupBox->setCheckable(true);
groupBox->setChecked(false);
//mapper->addMapping(groupBox,2) ; //I've tried this
//The mapper has the value 0 or 1 at position 2. This should determine if the group is checked or not
mapper->addMapping(groupBox,2,"setChecked(bool)") ; //This doesn't work either


I've even tried to add a dummy checkbox to connect to the mapper and then signal/slot with the groupbox.

Is it possible to connect the QGroupBoxs checked state to the mapper?

Thanks

Nightfox
10th October 2009, 14:23
Guys!!

I've tried everything now and I'm still not able to bind the mapper with the groupbox (setChecked property) in a way that it works.

Can this really be true that no one can help me out with problem?

Let me know thanks!

tzioboro
22nd October 2009, 17:17
the group is checked or not
mapper->addMapping(groupBox,2,"setChecked(bool)") ; //This doesn't work either


I've even tried to add a dummy checkbox to connect to the mapper and then signal/slot with the groupbox.

Is it possible to connect the QGroupBoxs checked state to the mapper?

Thanks

Did you try


mapper->addMapping(groupBox,2,"checked") ;


Please refer to documentation, "checked" is name of the porperty setChecked(bool) is name of the slot to set that property.

Hope it helps