I try to understand what PyQt does. And one of the first things I didn't, was:
QApplication(sys.argv)
Why do I have to give QApplication this argument? I know what sys.argv
does. But in my Scripts I wouldn't need it.
I try to understand what PyQt does. And one of the first things I didn't, was:
QApplication(sys.argv)
Why do I have to give QApplication this argument? I know what sys.argv
does. But in my Scripts I wouldn't need it.
This calls the constructor of the C++ class QApplication
. It uses sys.argv
(argc
and argv
in C++) to initialize the QT application. There are a bunch of arguments that you can pass to QT, like styles, debugging stuff and so on.
Take a look at this for a full list of the options.
sys.argv
. At the very least it contains the name of the executable, which QT may or may not use. –
Monostich QApplication
takes a list of strings as input.
So you can forward sys.argv or simply an empty list:
app = QApplication([])
© 2022 - 2024 — McMap. All rights reserved.