Results 1 to 8 of 8

Thread: application parameter problem..

  1. #1
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default application parameter problem..

    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.

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QString parameter1 = argv[1];
    4.  
    5. QApplication app( argc, argv);
    6. QMessageBox::information(0,"",parameter1);
    7. createfile(parameter1);
    8.  
    9. /*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)*/
    10. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QString parameter1 = argv[1];
    4. createfile(parameter1);
    5. }
    6. /*the file was created*/
    To copy to clipboard, switch view to plain text mode 

    any tips guys?

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: application parameter problem..

    take a look at this method
    QStringList QCoreApplication::arguments ()
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: application parameter problem..

    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..

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3.  
    4. QApplication app( argc, argv);
    5. QStringList argu = QCoreApplication::arguments();
    6.  
    7. QMessageBox::information(0,"",argu[1]);
    8.  
    9. MainDialogclass win;
    10. win.show();
    11. app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
    12. return app.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 

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

    thx in advance

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: application parameter problem..

    does the message box itself?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. #5
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: application parameter problem..

    the messagebox is not showing and the ui is not showing..

  6. #6
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: application parameter problem..

    works fine for me
    Qt Code:
    1. #include <QtGui>
    2. #include <QApplication>
    3.  
    4. int main(int argc, char **argv)
    5. {
    6. QApplication app(argc, argv);
    7.  
    8. const QStringList arguments = app.arguments();
    9.  
    10. QMessageBox::information(0, "information", QString::number(arguments.size()));
    11.  
    12. return 0;
    13. }
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  7. #7
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: application parameter problem..

    Are You confident that argu[1] exists ? This is SECOND argument on list.

  8. #8
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: application parameter problem..

    yup.. cause im passing parameter..

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

Similar Threads

  1. GPRA application problem?
    By mellibra in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 18th December 2006, 06:37
  2. Basic: problem building designer application
    By kingslee in forum Qt Tools
    Replies: 2
    Last Post: 31st August 2006, 15:26
  3. Problem in creating thread in GUI application
    By jyoti kumar in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2006, 12:05
  4. Replies: 10
    Last Post: 28th April 2006, 15:48
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.