PDA

View Full Version : application parameter problem..



triperzonak
4th February 2009, 09:24
hi,

i have created an application(exe) from QT that requires parameter. This program will be called by other application (not build by qt) passing the parameter needed however the program is not working..

if i try to access it through command prompt the application shows, but when it was called by the other application it never shows but the application is running in the task manager.

Then i try to remove qapplication on the main and its uis and do simulation creating a file if it was called with the parameter and after it was called, the file was created.



int main(int argc, char *argv[])
{
QString parameter1 = argv[1];

QApplication app( argc, argv);
QMessageBox::information(0,"",parameter1);
createfile(parameter1);

/*with qapplication the messagebox is not showing and file was never created means also ui will not work cause it will require qapplication (i already tried it with ui)*/
}




int main(int argc, char *argv[])
{
QString parameter1 = argv[1];
createfile(parameter1);
}
/*the file was created*/


any tips guys? :confused:

spirit
4th February 2009, 09:32
take a look at this method


QStringList QCoreApplication::arguments ()

triperzonak
5th February 2009, 01:50
what will i do with it? i already get the parameter but the UI is not showing it is only at d task manager.. the problem is the exe itself the other program is calling "ShellExecute" which means any exe should run but mine which is build by qt is not, what do you think the solution for this?.. am i missing something?

heres the code again.. after it was called the ui is not showing but it is on task manager..



int main(int argc, char *argv[])
{

QApplication app( argc, argv);
QStringList argu = QCoreApplication::arguments();

QMessageBox::information(0,"",argu[1]);

MainDialogclass win;
win.show();
app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
return app.exec();
}


note: "on command prompt it is showing"
should i set the working directory or something?

thx in advance

spirit
5th February 2009, 06:39
does the message box itself?

triperzonak
5th February 2009, 10:34
the messagebox is not showing and the ui is not showing..

spirit
5th February 2009, 10:57
works fine for me


#include <QtGui>
#include <QApplication>

int main(int argc, char **argv)
{
QApplication app(argc, argv);

const QStringList arguments = app.arguments();

QMessageBox::information(0, "information", QString::number(arguments.size()));

return 0;
}

Lesiok
5th February 2009, 12:00
Are You confident that argu[1] exists ? This is SECOND argument on list.

triperzonak
9th February 2009, 01:56
yup.. cause im passing parameter..

i think this is the problem of shellexecute() and not qt.