Results 1 to 13 of 13

Thread: To get the program execution back to main gui ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: To get the program execution back to main gui ?

    Quote Originally Posted by Krish View Post
    I have tried this i mean with qapp->processEvents(); but it showed me error that qapp is not declared in this scope.
    You forgot to #include <QApplication>


    Thanks now i came to know what actually happens when this function gets called. It checks for any pending event during the execution in do_something(); so that if user clicks any button or does something it will also be executed as:-
    Qt Code:
    1. Void Square::do_something()
    2. {
    3. for(i=o;i<100000000;i++) {
    4. qapp->processEvents();
    5. ...
    6. ....}
    7. }
    To copy to clipboard, switch view to plain text mode 
    Correct.

    But sir how can i use qapp created in main.cpp in the outer .cpp class? Those are separate files. I have only included its header in sample.cpp where all slots are implemented. qapp is not even detected in Sample.cpp, giving same error. Or do i have to include any file in Square.cpp?
    As you already noticed processEvents is a static method, so you can use it anywhere you want, just include the class' headers.

  2. The following user says thank you to wysota for this useful post:

    Krish (9th April 2008)

  3. #2
    Join Date
    Feb 2008
    Posts
    74
    Thanks
    31
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: To get the program execution back to main gui ?

    Hey! Thanks Wysota sir its working now

    Ok but i have other question/ doubt. As now i can execute all other slots even if execution is busy, can't i stop the busy execution if takes really long time say more than 10- 20 mins?

    Or do i have to use QThreads in which i can in one thread keep GUI alive and in other thread call this busy function. And if it exceeds the waiting limit of user he can stop it with void QThread::terminate (); as we kill the QProcess with kill(); ?

    Thanks again in advance.
    Last edited by Krish; 9th April 2008 at 17:37.

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

    Default Re: To get the program execution back to main gui ?

    If you want to have total control, you should use threads or implement your functionality based on events (divide whole process into smaller chunks, etc.).

  5. The following user says thank you to wysota for this useful post:

    Krish (9th April 2008)

Similar Threads

  1. QProcess problem (Main program hangs)
    By sincnarf in forum Qt Programming
    Replies: 5
    Last Post: 11th October 2007, 09:26
  2. QT MySQL
    By sabeeshcs in forum Newbie
    Replies: 6
    Last Post: 12th January 2007, 04:19
  3. Replies: 5
    Last Post: 4th August 2006, 23:44

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.