Results 1 to 13 of 13

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

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #10
    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 ?

    Thanks Sir,
    Quote Originally Posted by wysota View Post
    Yes you can, qApp is a global pointer to the application instance.
    I have tried this i mean with qapp->processEvents(); but it showed me error that qapp is not declared in this scope.

    Quote Originally Posted by wysota View Post
    It won't work that way. processEvents() has to be called inside your do_something function inside the loop at each (well... not each as in every but as in sometimes) iteration.
    There is no magic here. processEvents() performs a one time scan over pending events and processes them. You have to call it every time you want pending events to be processed.
    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 

    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?
    Qt Code:
    1. ////main.cpp////
    2. #include <QApplication>
    3. #include <QtGui>
    4. #include "sample.h"
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QApplication *qapp(argc, argv);
    9. sample *dialog = new sample;
    10. dialog->show();
    11. qapp->connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
    12. return app.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 

    Thanks again & sorry for disturbing you so much.
    Last edited by Krish; 8th April 2008 at 17:52.

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.