Results 1 to 3 of 3

Thread: QLabel Set text not work after A few minutes

  1. #1
    Join Date
    Oct 2010
    Location
    Iran
    Posts
    27
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default QLabel Set text not work after A few minutes

    Hi

    QLabel Set text not Changed after A few minutes

    Code:
    Qt Code:
    1. int i;
    2. i = `MyNewValue` ;
    3. ui->A_DP->setText(QString::number(i))
    4.  
    5. qDebug()<<"lable value : "<<ui->A_P->text();
    To copy to clipboard, switch view to plain text mode 

    qlable show old fixed value But qDebug print new value ?!

    note : SetText Call from QtConcurrent function

    Qt ver: 4.8.3 (qws)
    OS: debian 2.6.32-5-686

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QLabel Set text not work after A few minutes

    read my sig.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QLabel Set text not work after A few minutes

    Your code, my comments:
    Qt Code:
    1. int i;
    2. i = `MyNewValue` ; // << Will not compile. i is an int this is not. Backtick quotes are not valid in C++.
    3. ui->A_DP->setText(QString::number(i)) // << Needs ; to compile. Sets A_DP's text
    4.  
    5. qDebug()<<"lable value : "<<ui->A_P->text(); // << Outputs the text of a different control
    To copy to clipboard, switch view to plain text mode 
    As amleto says, if you are going to post code snippets make sure they are at least valid code... and the easiest way to do that is copy and paste from a compiling program.

    note : SetText Call from QtConcurrent function
    Accessing elements of the (typically private) GUI from a thread other than the main one, and doing so without synchronisation is a Bad Thing.
    From the Threads and QObjects docs:
    Although QObject is reentrant, the GUI classes, notably QWidget and all its subclasses, are not reentrant. They can only be used from the main thread.
    Use signal/slot connection or rethink why you want to do this.

Similar Threads

  1. QLabel with text and icon
    By franco.amato in forum Newbie
    Replies: 8
    Last Post: 27th January 2011, 01:05
  2. QTcpSocket slows down in receiving after several minutes
    By cutie.monkey in forum Qt Programming
    Replies: 1
    Last Post: 9th December 2009, 21:14
  3. How to enabled button, when i changed lineedit`s text ?
    By newermind in forum Qt Programming
    Replies: 8
    Last Post: 13th August 2009, 08:57
  4. How to right-justify QLabel text
    By JimDaniel in forum Qt Programming
    Replies: 2
    Last Post: 30th January 2008, 08:55
  5. Squeeze text in QLabel
    By jiveaxe in forum Qt Programming
    Replies: 5
    Last Post: 6th September 2007, 10:45

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.