How to change the Label text
Hi All,
I am using QLable when i press a button from the keyboard text of the label has to change, how to proceed with this. i have a code snippet.
[CODE]
case Qt::Key_I: //Mapped with plane key
tab_plane++;
qDebug( "Key Press Event:F1" );
qDebug("%d",tab_plane);
key_i_pushButton->setFocus();
if ( 1 == tab_plane )
{
planelabel->setText("PLANE\n[ZX]");
}
else if ( 2 == tab_plane )
{
planelabel->setText("PLANE\n[XY]");
}
else if ( 3 == tab_plane )
{
planelabel->setText("PLANE\n[YZ]");
tab_plane = 0;
}
break;
[\CODE]
Re: How to change the Label text
I am not sure what you want to do exactly but you can reimplement QWidget::keyPressEvent() or install a event filter (QObject::installEventFilter()).
Re: How to change the Label text
Maybe help to remeber that keyboard events are sent to your widget only if it got the focus.