Results 1 to 6 of 6

Thread: In any program, it is necessary to use QAplication app ( argc,argv)?

  1. #1
    Join Date
    Jul 2014
    Posts
    95
    Thanks
    67

    Default In any program, it is necessary to use QAplication app ( argc,argv)?

    Hello
    In any program, it is necessary to use QAplication app ( argc,argv)???
    For example:
    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication app(argc, argv);
    4. ........................
    5. ........................
    6. return app.exec();
    7. }
    To copy to clipboard, switch view to plain text mode 
    thanks.

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: In any program, it is necessary to use QAplication app ( argc,argv)?

    From QApplication doc : The QApplication class manages the GUI application's control flow and main settings. So what do you think?

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

    rezas1000 (31st August 2014)

  4. #3
    Join Date
    Jul 2014
    Posts
    95
    Thanks
    67

    Default Re: In any program, it is necessary to use QAplication app ( argc,argv)?

    Quote Originally Posted by Lesiok View Post
    From QApplication doc : The QApplication class manages the GUI application's control flow and main settings. So what do you think?
    In fact:
    Should I Use It? (Such as the use of int main(int argc,char* argv[])

  5. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: In any program, it is necessary to use QAplication app ( argc,argv)?

    Are you asking whether it is necessary to have a QApplication instance or whether you have to pass argc and argv to its constructor?

    Cheers,
    _

  6. The following user says thank you to anda_skoa for this useful post:

    rezas1000 (31st August 2014)

  7. #5
    Join Date
    Jul 2014
    Posts
    95
    Thanks
    67

    Default Re: In any program, it is necessary to use QAplication app ( argc,argv)?

    Thank you.
    Will the following code should be in every program? And if necessary.why?

    Please explain some.thanks.
    Qt Code:
    1. QApplication app(argc, argv);
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. return app.exec();
    To copy to clipboard, switch view to plain text mode 

  8. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: In any program, it is necessary to use QAplication app ( argc,argv)?

    These are necessary for all QtWidget using applications which, obviously, is only a sub section of all possible programs.

    The first line creates an instance of the QApplication class, passing the program's commandline arguments to its constructor.
    The second line starts the event processing loop or short "event loop" and returns the method's result as the program's exit code.

    Cheers,
    _

  9. The following user says thank you to anda_skoa for this useful post:

    rezas1000 (31st August 2014)

Similar Threads

  1. Replies: 2
    Last Post: 8th August 2014, 19:08
  2. Replies: 6
    Last Post: 30th November 2012, 03:58
  3. QProcess: Socket descriptor in argv[]
    By Jonny174 in forum Qt Programming
    Replies: 3
    Last Post: 18th February 2012, 12:42
  4. QApplication(argc, argv)
    By SWEngineer in forum Newbie
    Replies: 4
    Last Post: 26th April 2011, 12:36
  5. how to use "argc" and "argv" ?
    By probine in forum Qt Programming
    Replies: 5
    Last Post: 9th December 2006, 19:03

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.