Results 1 to 11 of 11

Thread: how to show the progres of an operation without any loops

  1. #1
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default how to show the progres of an operation without any loops

    Hi I would show the progress of an operation in the case I don't have a loop with iterations.

    for example:
    Qt Code:
    1. ....code...
    2. bool ret = routine( some param ); //this take long time
    3. ...more code
    To copy to clipboard, switch view to plain text mode 

    How can I inform the user that the program is not blocked in this case?
    The QProgressDialog need a loop with some iterations to be updated and is not my case.

    Best Regards
    Franco Amato

  2. #2
    Join Date
    Jan 2007
    Posts
    92
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default Re: how to show the progres of an operation without any loops

    You can use QTimer. If you dont wanna use iterations you can use QProcess also. When process will be exited there is signal called ProcessExited() will be triggered and you can stop timer at that time. Mean while if you want to display progressBar to let user know that something is going on the background and update progressbar so on.
    connect(m_pTimer, SIGNAL(timeout()), this, SLOT(Somemethod()));

  3. #3
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to show the progres of an operation without any loops

    Quote Originally Posted by user_mail07 View Post
    You can use QTimer. If you dont wanna use iterations you can use QProcess also. When process will be exited there is signal called ProcessExited() will be triggered and you can stop timer at that time. Mean while if you want to display progressBar to let user know that something is going on the background and update progressbar so on.
    connect(m_pTimer, SIGNAL(timeout()), this, SLOT(Somemethod()));
    Sorry but I don't understand.
    QProcess is not used to start an external program? How can I use it in this case?
    Franco Amato

  4. #4
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to show the progres of an operation without any loops

    Quote Originally Posted by franco.amato View Post
    Sorry but I don't understand.
    QProcess is not used to start an external program? How can I use it in this case?
    QProcess can start an external process very well. And user_mail07's solution is good for your case.
    If you haven't written the code of the process, then you have no idea about the status of the process, means its still running or its completed. So QProcess gives you the virtual power to get noticed when the process is done.
    So use of QTimer from start of QProcess, and till QProcess ends, and showing the QProgressBar inbetween will do the trick.
    However you will never know the actual status of the process untill your process is not returning any signal or notification about the current status.

  5. #5
    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 show the progres of an operation without any loops

    You can use QProcess only to start an external process. Not to du it with a member function. So I would go with a QProgressDialog which only shows a busy bar (without indicating how long something will take time, and start the function via QtConcurrentRun, that will keep your gui respondable.

  6. #6
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to show the progres of an operation without any loops

    Quote Originally Posted by Lykurg View Post
    You can use QProcess only to start an external process. Not to du it with a member function. So I would go with a QProgressDialog which only shows a busy bar (without indicating how long something will take time, and start the function via QtConcurrentRun, that will keep your gui respondable.
    Hi Lykurg,
    thank you. Can you help me with some lines of code?

    Regards
    Franco Amato

  7. #7
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to show the progres of an operation without any loops

    Put your routine into a thread. When the thread completes, send a signal to your main app (signal/slot mechanism). Whilst that is happening in the background, you can use things like QProgressDialog or others.

  8. #8
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to show the progres of an operation without any loops

    Quote Originally Posted by fatjuicymole View Post
    Put your routine into a thread. When the thread completes, send a signal to your main app (signal/slot mechanism). Whilst that is happening in the background, you can use things like QProgressDialog or others.
    Some code please?

    Thanx in advance
    Franco Amato

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to show the progres of an operation without any loops

    Quote Originally Posted by franco.amato View Post
    Some code please?
    Here we go again...

    Moving the thread to "Newbie", it's obviously a newbie problem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to show the progres of an operation without any loops

    Quote Originally Posted by wysota View Post
    Here we go again...

    Moving the thread to "Newbie", it's obviously a newbie problem.
    Wysota what's for newbie and for not-newbie for you? For me, and I'm sure for others users, is not so obviously
    Franco Amato

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to show the progres of an operation without any loops

    Quote Originally Posted by franco.amato View Post
    Wysota what's for newbie and for not-newbie for you? For me, and I'm sure for others users, is not so obviously
    Constantly asking for working code is definitely newbie. Trust me, it's better this way - people have much more patience for people writing in the newbie section than for those claming to be "programmers".
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. How show progress of slow a operation?
    By shud in forum Qt Programming
    Replies: 9
    Last Post: 3rd December 2009, 22:10
  2. Message loops of different GUI toolkits
    By elizabeth.h1 in forum Qt Programming
    Replies: 4
    Last Post: 29th July 2009, 08:30
  3. for loops in c++
    By baray98 in forum General Programming
    Replies: 16
    Last Post: 19th January 2009, 14:09
  4. Show progress of a time consuming operation
    By rainman110 in forum Newbie
    Replies: 7
    Last Post: 10th February 2008, 12:07
  5. QApplication and widgets' loops
    By Placido Currò in forum Qt Programming
    Replies: 7
    Last Post: 31st January 2008, 12:13

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.