Results 1 to 2 of 2

Thread: Thread Issue: Unable to update UI

  1. #1
    Join Date
    Mar 2014
    Posts
    15
    Thanks
    1
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Thread Issue: Unable to update UI

    Hi,
    I am developing an Qt application.
    It has one loop which keep on running for long time and at the same time i want to update the value in Ui.
    Whats happening in my case is UI become unresponsive for some time.

    I have created a background thread and running the loop in that thread but it seems that only this thread is running and result is not updated in UI. Only final value of loop is printed in Ui.
    Eg if loop runs 7000 times then only 7000 is displayed in UI, rest of values are not displayed.

    Code :
    Qt Code:
    1. class bgthread :Qthread
    2. {
    3. run()
    4. {
    5. loopFunction()
    6. }
    7. }
    8.  
    9. loopfunction()
    10. {
    11. emit valuechanged(i);
    12. }
    13.  
    14.  
    15. class guiCreate:Qmainwindow
    16. {
    17. connect(bgThread,SIGNAL(valuechanged(int)),this,SLOT(updateui(int)));
    18.  
    19. }
    20.  
    21. guiCreate::updateui(int i)
    22. {
    23. iterationQLabel->setText(QString::number(i));
    24. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by anda_skoa; 27th May 2014 at 17:45. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Thread Issue: Unable to update UI

    Paste some actual code and use code tags.

    Cheers,
    _

Similar Threads

  1. unable to update label from another thread
    By dhanya.v in forum Qt Programming
    Replies: 1
    Last Post: 4th October 2012, 12:05
  2. use Thread update many GUI
    By phuong_90 in forum Qt Programming
    Replies: 6
    Last Post: 20th November 2011, 05:23
  3. unable to get uni-code inputs from another thread
    By Mohammad in forum Qt Programming
    Replies: 3
    Last Post: 15th November 2011, 14:56
  4. Unable to update QTableWidget which is on Different QWidget from MainWindow
    By sagar.mangalwedhekar in forum Qt Programming
    Replies: 1
    Last Post: 12th March 2010, 07:07

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.