Qt5 provides two functions to process command line arguments in QCommandLineParser
class. The signatures are:
process(const QStringList &arguments)
process(const QCoreApplication &app)
This works fine in C++
but Python
has no overloading feature nor signature detection. Apparently,
from PyQt5.QtCore import QCommandLineParser as qlp
qlp.process(("myapp", "-opt", "file"))
(example oversimplified to make the point)
references the process(const QCoreApplication &app)
variant and errors out because the argument in no QCoreApplication
instance.
At this step, I don't want to instantiate some kind of application object because I don't know yet if I'll run a QCoreApplication
or a QGuiApplication
, which is determined by parsing the arguments.
How can I force the desired variant?
Alternately, how can I preparse the command line arguments to check if I need a GUI or not? (But this alternative may need as much work as parsing the arguments with QCommandLineParser
)