PDA

View Full Version : passing arguments from command line to QT application



Tomasz
7th September 2010, 15:44
Hello!

I've got problem with passing arguments from command line to application:



#include <QtGui/QApplication>
#include "mainwindow.h"

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;

w.show();

w.myVariable = QString(argv[1]).toInt();

return a.exec();
}


myVariable is public. And it has very weird values. When I pass that argument to function which is printing that value on console at startup everything is ok. How can I do it?

thanks in advance
best regards
Tomasz

wysota
7th September 2010, 15:49
Use QCoreAppliction::arguments() instead of argv.