[Qt-interest] Qt example borderlayout, access to widgets from different panels does not work
Malyushytsky, Alex
alex at wai.com
Wed Jan 20 11:09:16 CET 2010
It looks like my first impression was incorrect, and I should stop posting at 1 am.
But I would mention if you provided minimum code which can reproduce you problem, it would be easier to understand the problem.
Example you refer seems were modified by you and has nothing to do with code you provided.
As far I understand you are trying compare 2 different properties:
"down : bool" and "checked : bool"
If button is checkable you should use isChecked() to check the button state and setChecked ( ) to change the state of the button.
qDebug() << "Patient Mic pusbutton: " << northCtrlsButtons->patientMic_PB->isChecked();
should return false, cause By default, the button is unchecked and you seems did not set state explicitly in NorthControlsWidget constructor.
After first click on the button ctrlButtonPressed() will be called and isChecked() should return true, cause button state will be toggled.
Regards,
Alex
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of S. Aguinaga
Sent: Tuesday, January 19, 2010 9:54 PM
To: qt-interest at trolltech.com
Subject: [Qt-interest] Qt example borderlayout, access to widgets from different panels does not work
In the mature example:
layouts/borderlayout/borderlayout.pro
I have a widget on the 'North' panel of my layout, and want to access it in the central layout, but
it fails to read the accurate 'state' of the my widget: pushbutton->setCheckable(true);
When read from a Slot in the Central widget (or Panel) it reads that status (isChecked()) is 'false' wen the
button has been toggled to the 'down' position.
The code to access the status of the push button is:
northCtrlsButtons = new NorthControlsWidget(this);
qDebug() << "Patient Mic pusbutton: " << northCtrlsButtons->patientMic_PB->isChecked();
qDebug() << "Patient Mic pusbutton: " << northCtrlsButtons->patientMic_PB->isDown();
Am I doing this the wrong way? Has anyone used this successfully?
-+--+--+--+--+--+--+--+--+--+--+--+
from the NorthControlsWidget class definition:
patientMic_PB = new QPushButton(tr("Patient Mic"), this);
patientMic_PB->setCheckable( true );
...
connect( patientMic_PB, SIGNAL(toggled(bool)), this, SLOT( ctrlButtonPressed() ));
// have also used the signal 'clicked()' with same effect
}
void NorthControlsWidget::ctrlButtonPressed()
{
qDebug() << "Patient Mic pusbutton: " << patientMic_PB->isChecked();
}
The above slot which is still defined in the same file it does read the correct status.
Qt system running on Mac OS, Using Qt version 4.6.0
// Salvador
---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.
"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."
"Please consider our environment before printing this email."
More information about the Qt-interest-old
mailing list