Skip to content

Instantly share code, notes, and snippets.

@uranusjr
Created September 14, 2011 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uranusjr/1215612 to your computer and use it in GitHub Desktop.
Save uranusjr/1215612 to your computer and use it in GitHub Desktop.
Test for qApp argument reading
#include <QCoreApplication>
#include <Test.h>
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
Test t;
return app.exec();
}
#include <QObject>
#include <QCoreApplication>
#include <QStringList>
#include <QDebug>
class Test : public QObject
{
public:
Test(QObject *parent = 0) : QObject(parent)
{
int d1, d2;
QStringList args = qApp->arguments();
d1 = args[1].toInt();
d2 = args[2].toInt();
qDebug() << d1 << d2;
}
};
QT += core
QT -= gui
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
# Input
HEADERS += Test.h
SOURCES += main.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment