Results 1 to 7 of 7

Thread: why we pass sys.argv to QtGui.QApplication() in main method and whats in it list?

  1. #1
    Join Date
    Nov 2012
    Posts
    35
    Thanks
    1
    Thanked 7 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question why we pass sys.argv to QtGui.QApplication() in main method and whats in it list?

    I started learning PyQt from zetcode, as far as i know sys.argv reads in the parameter from coomandline and first being the name of file itself, so if sys.argv is a list then what being passed to QtGui.QApplication() in

    Qt Code:
    1. def main():
    2. app = QtGui.QApplication(sys.argv)
    3. ex = Example()
    4. sys.exit(app.exec_())
    To copy to clipboard, switch view to plain text mode 

    and what is in the sys.argv list ?

  2. #2
    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: why we pass sys.argv to QtGui.QApplication() in main method and whats in it list?

    It's exactly what you said -- a list of command line parameters.
    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.


  3. #3
    Join Date
    Nov 2012
    Posts
    35
    Thanks
    1
    Thanked 7 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: why we pass sys.argv to QtGui.QApplication() in main method and whats in it list?

    what is explicitly passed in those list items when we say sys.argv ?i mean what are those command line parameters
    Last edited by krystosan; 29th November 2012 at 11:21.

  4. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: why we pass sys.argv to QtGui.QApplication() in main method and whats in it list?

    why don't you start your debugger and find out?

    whats in the argument is list exactly the options that you pass on the command line, in addition to the full pathname of the executing binary.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  5. #5
    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: why we pass sys.argv to QtGui.QApplication() in main method and whats in it list?

    Quote Originally Posted by krystosan View Post
    what is explicitly passed in those list items when we say sys.argv ?i mean what are those command line parameters
    Whatever you pass to the program.
    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.


  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: why we pass sys.argv to QtGui.QApplication() in main method and whats in it list?

    Python sys.argv is well documented.

    Qt is passed the command line arguments to allow it to see, react to, and remove a few options that it can use to set the program style or renderer. The known options are documented in the QApplication constructor docs.

  7. #7
    Join Date
    Nov 2012
    Posts
    35
    Thanks
    1
    Thanked 7 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: why we pass sys.argv to QtGui.QApplication() in main method and whats in it list?

    totally understood thanks

Similar Threads

  1. QtGui/QApplication: No such file or directory
    By codeslicer in forum Qt Programming
    Replies: 4
    Last Post: 9th December 2011, 15:29
  2. QApplication(argc, argv)
    By SWEngineer in forum Newbie
    Replies: 4
    Last Post: 26th April 2011, 12:36
  3. Replies: 13
    Last Post: 4th November 2010, 22:34
  4. Replies: 3
    Last Post: 6th October 2009, 08:38
  5. <QtGui/QApplication> vs. <QApplication>
    By seneca in forum Qt Programming
    Replies: 5
    Last Post: 25th January 2006, 10:58

Tags for this Thread

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.