Results 1 to 4 of 4

Thread: QProgreesDialog updating from within threadable function

  1. #1
    Join Date
    Apr 2010
    Location
    Moscow
    Posts
    31
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default QProgreesDialog updating from within threadable function

    Hi there. I have got a question for you, guys, which I really would like you to help me with.
    I have got a function with QString parameter and within the function long-time procedures take place. I execute this function with QFuture but I would like for the progress of operation to be indicated. For example I can declare the variable inside the function and which varies between 0 and 100. How can I arrange it and bind to QProgressDialog? Here goes the snippet:

    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. ui->setupUi(this);
    6. connect(this->ui->test_button, SIGNAL(clicked()), SLOT(call_algorithm()));
    7. }
    8.  
    9. void MainWindow::call_algorithm()
    10. {
    11. QFuture<void> future = QtConcurrent::run(algorithm, this->ui->jpg_name_edit->text());
    12. }
    13.  
    14. void algorithm(QString image_name)
    15. {
    16. //some code here =)
    17. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Apr 2010
    Location
    Rostov-na-Donu, Russia
    Posts
    153
    Thanks
    2
    Thanked 26 Times in 23 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QProgreesDialog updating from within threadable function

    In QtConcurent functions you can use either static functions ( like your algorythm ) or your class's member function, where you can emit a signal to show the progress of computations. See binding section in QtConcurent docs

  3. The following user says thank you to borisbn for this useful post:

    Astrologer (3rd May 2010)

  4. #3
    Join Date
    Apr 2010
    Location
    Moscow
    Posts
    31
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QProgreesDialog updating from within threadable function

    I have solved that. Thanks anyway.

  5. #4
    Join Date
    May 2010
    Posts
    61
    Thanks
    2
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QProgreesDialog updating from within threadable function

    Hi Astrologer,

    Could you post an example with the solution you found and adopted?

    Thanks,
    Wladek
    One second is long, everything longer than two seconds is definitely too long.

Similar Threads

  1. Replies: 0
    Last Post: 10th March 2010, 08:13
  2. Updating from Qt-4.4.3 to Qt-4.5.0 --Help Needed
    By swamyonline in forum Installation and Deployment
    Replies: 1
    Last Post: 9th February 2009, 11:37
  3. QListView not updating
    By Terabyte in forum Qt Programming
    Replies: 2
    Last Post: 6th January 2009, 07:10
  4. scrollArea not updating
    By user in forum Qt Programming
    Replies: 9
    Last Post: 3rd October 2007, 08:17
  5. Updating QGraphicsView
    By has2k1 in forum Newbie
    Replies: 2
    Last Post: 8th April 2007, 21:02

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
  •  
Qt is a trademark of The Qt Company.