Results 1 to 3 of 3

Thread: How to change the Label text

  1. #1
    Join Date
    Jul 2009
    Location
    Bangalore
    Posts
    68
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default 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]
    Thanks & Regards
    Sandeep G.R.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default 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()).

  3. #3
    Join Date
    Sep 2009
    Posts
    140
    Thanks
    4
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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.

Similar Threads

  1. Replies: 15
    Last Post: 31st January 2020, 19:25
  2. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 10:49
  3. QCheckBox with long text label
    By Ferdous in forum Newbie
    Replies: 5
    Last Post: 29th October 2011, 20:05
  4. Replies: 1
    Last Post: 24th October 2006, 17:40
  5. Can't change the text display of a QTreeview item.
    By johnny_sparx in forum Qt Programming
    Replies: 3
    Last Post: 2nd June 2006, 02:03

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.