For my application I had to derive QtCoreApplication and use QCommandLineParser. I declared QCommandLineOptions instances in a separate namespace and wanted to declare the parser in this namepsace as well. However I get an error that I don't quite understand.
namespace
{
QCommandLineParser parser;
const QCommandLineOption optA("optA", "defaultOptA");
parser.addOption(optA); <-- error: unknown type name 'parser'
}
MyApp::MyApp(int argc, char *argv[])
:QCoreApplication(argc, argv)
{
setApplicationName("My App");
}
I have also tried declaring a QList<QCommandLineOption>
so that I can add the options to it and add it the parser in on go using QCommandLineParser::addOptions
, but that does not work either.
namespace
{
QList<QCommandLineOption> options;
const QCommandLineOption optA("optA", "defaultOptA");
options << optA; <-- error: unknown type name 'options'
}
MyApp::MyApp(int argc, char *argv[])
:QCoreApplication(argc, argv)
{
setApplicationName("MyApp);
}
What am I doing wrong in both cases ?