[Qt-interest] Qt example borderlayout, access to widgets from different panels does not work

Malyushytsky, Alex alex at wai.com
Wed Jan 20 10:28:40 CET 2010


It looks like are mixing access state to different properties:
 - checkable : bool
 - checked : bool

setCheckable changes checkable property. Checkable(true) means button is ABLE to have 2 states: checked and unchecked.

But to set and check 'checked' property you use other access functions:

bool isChecked () const
void setChecked ( bool )

Read documentation.

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