Created
September 14, 2011 01:03
-
-
Save uranusjr/1215612 to your computer and use it in GitHub Desktop.
Test for qApp argument reading
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <QCoreApplication> | |
#include <Test.h> | |
int main(int argc, char *argv[]) | |
{ | |
QCoreApplication app(argc, argv); | |
Test t; | |
return app.exec(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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