Why do I need "sys.argv" to run QApplication in PyQt?

I am trying to understand what PyQt does. And one of the first things that I did not do was:

QApplication(sys.argv) 

Why do I need to give QApplication this argument? I know what sys.argv does. But in my scripts I won’t need it.

+5
source share
2 answers

This calls the constructor of the C ++ QApplication class. It uses sys.argv ( argc and argv in C ++) to initialize a QT application. There are many arguments that you can pass into QT, such as styles, debugging materials, etc.

See this for a complete list of options.

+4
source

QApplication takes a list of strings as input.

So you can forward sys.argv or just an empty list:

 app = QApplication([]) 
+2
source

Source: https://habr.com/ru/post/1211064/


All Articles