PDA

View Full Version : Can't get isChecked() properties but get everything else from dock



devdon
16th December 2011, 10:58
All the following code produces the same result: I query the radio/checkbox buttons on a simple dock and can successfully get all the correct information from the buttons except for the currently checked state. What is returned is always the default checked state as set in ui->, not the checked state as it appears on screen after checking it. I'm providing the code and the output. Is there anything in the rest of the extensive program, such as an event filter or something that is too big or I can't think of to post, that could interfere with this?



QAbstractButton* qb = ui->accBtnGrp->checkedButton();
qDebug()<< qb << "Checked Btn:"<< qb;

QList<QAbstractButton*>btns = ui->accBtnGrp->buttons();

foreach(QAbstractButton* b, btns ) {
qDebug()<< b << "Checkable:"<< b->isCheckable();
qDebug()<< b << "Checked:"<< b->isChecked();

}

bool cb = ui->ckbx_DottedNote->isChecked();
qDebug()<< ui->ckbx_DottedNote << "Checkable:"<< ui->ckbx_DottedNote->isCheckable();
qDebug()<< ui->ckbx_DottedNote << "Checked:"<< ui->ckbx_DottedNote->isChecked();


In the results below, the "Normal" rbtn shows "Checked" but on screen it is actually the sharp button that was clicked and is now the checked button.The checkbox is also checked but since it is not checked by default it polls as false. All buttons (except the checkbox which is separate) are autoexclusive and are in the same buttongroup.


QRadioButton(0x3b61a78, name = "rbtn_Normal") Checked Btn: QRadioButton(0x3b61a78, name = "rbtn_Normal")
QRadioButton(0x3b61a78, name = "rbtn_Normal") Checkable: true
QRadioButton(0x3b61a78, name = "rbtn_Normal") Checked: true
QRadioButton(0x3b61a58, name = "rbtn_Sharp") Checkable: true
QRadioButton(0x3b61a58, name = "rbtn_Sharp") Checked: false
QRadioButton(0x3b61a98, name = "rbtn_Natural") Checkable: true
QRadioButton(0x3b61a98, name = "rbtn_Natural") Checked: false
QRadioButton(0x3b61af8, name = "rbtn_Flat") Checkable: true
QRadioButton(0x3b61af8, name = "rbtn_Flat") Checked: false
QCheckBox(0x3b61b18, name = "ckbx_DottedNote") Checkable: true
QCheckBox(0x3b61b18, name = "ckbx_DottedNote") Checked: false

Jonny174
16th December 2011, 11:08
Try use this:


QCheckBox::checkState() & Qt::Checked (Qt::Unchecked and Qt::PartiallyChecked)

devdon
16th December 2011, 11:17
checkState() returns 0 on the checkbox, which is the same value as returned by isChecked().

devdon
16th December 2011, 19:49
An Update is that if I use setChecked() on the dock buttons, then isChecked() returns the correct information , but the visual buttons are not changed. It is almost as if I am working on phantom buttons behind the scenes and not the ones I see in the dock.

Added after 17 minutes:

SOLVED: I was calling the routines on implied "this" when I should have been calling them on the active pointer. Oh well. Thanks anyway.