How to create a console application with command line arguments in Qt?
-
I have looked at this online and seen various approaches such as using QApplication or QCoreApplication. I would like to use Qt objects for the application and parse the command line. For example to parse a command line such as:
myapp -foo bar -qaz 10
Which approach is best?
-
I have looked at this online and seen various approaches such as using QApplication or QCoreApplication. I would like to use Qt objects for the application and parse the command line. For example to parse a command line such as:
myapp -foo bar -qaz 10
Which approach is best?
@Guerrian
You can pick whichever kind of QApplication is best for your program, and you can access command-line arguments either viaQCoreApplication::arguments()
(if you don't need a GUI) or other Qt classes, or from the C++main(argc, argv)
as you please. -
I have looked at this online and seen various approaches such as using QApplication or QCoreApplication. I would like to use Qt objects for the application and parse the command line. For example to parse a command line such as:
myapp -foo bar -qaz 10
Which approach is best?
@Guerrian
Qt has for this a adequately named class QCommandLineParserMight be helpful 😉
-
I have looked at this online and seen various approaches such as using QApplication or QCoreApplication. I would like to use Qt objects for the application and parse the command line. For example to parse a command line such as:
myapp -foo bar -qaz 10
Which approach is best?
-
I have looked at this online and seen various approaches such as using QApplication or QCoreApplication. I would like to use Qt objects for the application and parse the command line. For example to parse a command line such as:
myapp -foo bar -qaz 10
Which approach is best?