PDA

View Full Version : How to change the Label text



grsandeep85
15th September 2009, 11:43
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]

Lykurg
15th September 2009, 12:49
I am not sure what you want to do exactly but you can reimplement QWidget::keyPressEvent() or install a event filter (QObject::installEventFilter()).

scascio
15th September 2009, 13:57
Maybe help to remeber that keyboard events are sent to your widget only if it got the focus.