Results 1 to 9 of 9

Thread: Problem with return a.exec(). I need a solution here...

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2010
    Location
    /home/hakermania/
    Posts
    233
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    129
    Thanked 3 Times in 3 Posts

    Question Problem with return a.exec(). I need a solution here...

    Hello developers!



    My application is both console and GUI, depending on the arguments it takes.

    So, the code is as follows:

    Qt Code:
    1. #include.....
    2.  
    3. //..
    4.  
    5. class EarthTimer (bla bla, making a subclass of QTimer....
    6.  
    7. ..
    8. //here we connect the timer with the timers_slot() function
    9. }
    10.  
    11. int main(int argc, char *argv[])
    12. {
    13. QApplication a(argc, argv);
    14. EarthTimer earthtimer;
    15. earthtimer.start(1800000); //30 min
    16. return a.exec(); //we have started the timer but we have to call this otherwise the application will immediately close
    17.  
    18.  
    19. }
    20.  
    21. void timers_slot(){
    22. //doing some specific job
    23. ..//code
    24. ..
    25. ..
    26. if(something_is_true){
    27. MainWindow w;
    28. w.show();
    29. /*here I am trying to start the GUI, what it does is to go through the constructor
    30. of the MainWindow class and then exits, without showing the GUI, I guess I have
    31. to call return a.exec() again, but a is not declared here and cannot be global :(*/
    32. }
    33. }
    To copy to clipboard, switch view to plain text mode 

    Ι think the comments are pretty specific, but if someone didn't get it:
    I call return a.exec() after starting the timer so as to avoid program's quit, and then if something is true in the timers_slot() I am trying to open the GUI. It goes through the constructor of the GUI but it does not show anything. I assume I have to call return a.exec() again there but it is declared in main() function and cannot be global.
    May I create another QApplication and return it there?
    Last edited by hakermania; 3rd July 2011 at 20:29.
    When you 're trying to help somebody in the newbie section, don't forget that he is a newbie. Be specific and give examples.

Similar Threads

  1. QDialog problem with exec()
    By nomadscarecrow in forum Qt Programming
    Replies: 3
    Last Post: 23rd April 2010, 18:40
  2. How to make QMenu.exec() return a QWidgetAction
    By gregsan in forum Qt Programming
    Replies: 5
    Last Post: 15th April 2010, 00:04
  3. Replies: 0
    Last Post: 16th March 2010, 12:24
  4. QProcess and kfmclient exec problem
    By ramazangirgin in forum Qt Programming
    Replies: 5
    Last Post: 6th June 2008, 08:31
  5. Problem and solution about QSA 1.2.0 compilation
    By Dwarf007 in forum Installation and Deployment
    Replies: 5
    Last Post: 7th March 2006, 16:52

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.