6int main(
int argc,
char **argv)
12bool verbose = parser.
isSet(
"verbose");
23bool verbose = parser.
isSet(verboseOption);
64if (command ==
"resize") {
66 parser.
addPositionalArgument(
"resize",
"Resize the object to a new size.",
"resize [resize_options]");
The QCommandLineOption class defines a possible command-line option. \inmodule QtCore.
The QCommandLineParser class provides a means for handling the command line options.
bool parse(const QStringList &arguments)
Parses the command line arguments.
void addPositionalArgument(const QString &name, const QString &description, const QString &syntax=QString())
Defines an additional argument to the application, for the benefit of the help text.
QStringList positionalArguments() const
Returns a list of positional arguments.
bool addOption(const QCommandLineOption &commandLineOption)
Adds the option option to look for while parsing.
bool isSet(const QString &name) const
Checks whether the option name was passed to the application.
void process(const QStringList &arguments)
Processes the command line arguments.
void clearPositionalArguments()
Clears the definitions of additional arguments from the help text.
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
static QStringList arguments()
bool isEmpty() const noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
QApplication app(argc, argv)
[0]