Results 1 to 3 of 3

Thread: Problem with QProgress in Qt4

  1. #1
    Join Date
    May 2006
    Posts
    5
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Problem with QProgress in Qt4

    Hi all,

    I'm new in this forum, and also new to Qt4. I have a problem with the new QProgess in Qt4. I need to start an application (a browser) from my application and I have successfully done that in Qt 3 using something similar to this:

    Qt Code:
    1. QProcess process;
    2. process.setArguments(QStringList() << "mozilla" << url);
    3. if(process.start())
    4. return true;
    5. else
    6. {
    7. process.setArguments(QStringList() << "konqueror" << url);
    8. if (process.start())
    9. return true;
    10. }
    11. return false;
    To copy to clipboard, switch view to plain text mode 

    For Qt 4 version, I tried to change
    if (process.start()) with
    if (QProcess::startDetached("mozilla", QStringList() << url)) return true;
    But QProcess::startDetached always returns true even though I dont have mozilla executable (even if I change "mozilla" to "asdf", it still returns true) .

    I tried to use QProcess::start() and QProcess::waitForFinished() but seems that it just makes my application freezing even though the browser was successfully started .

    Any suggestions? Thanks for your help

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with QProgress in Qt4

    You might try something like this:
    Qt Code:
    1. QProcess *process = new QProcess();
    2. connect( process, SIGNAL( finished( int, QProcess::ExitStatus ) ), process, SLOT( deleteLater() ) );
    3.  
    4. process->setArguments( QStringList() << "konqueror" << url );
    5. if( process->waitForStarted() ) {
    6. return true;
    7. }
    8.  
    9. process->setArguments( QStringList() << "mozilla" << url );
    10. if( process->waitForStarted() ) {
    11. return true;
    12. }
    13.  
    14. delete process;
    15. return false;
    To copy to clipboard, switch view to plain text mode 
    But IMO it will be better if you implement a class, for example BrowserLauncher, that would use only non-blocking methods.

    Check this: http://qds.berlios.de/services.html#Launcher
    Last edited by jacek; 7th May 2006 at 13:21.

  3. The following user says thank you to jacek for this useful post:

    fyanardi (7th May 2006)

  4. #3
    Join Date
    May 2006
    Posts
    5
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with QProgress in Qt4

    Hi, thanks for your help, it solved my problem. But from the documentation I read that Qt4's QProcess no longer has setArgument method, so I changed it to: process->start( "konqueror", QStringList() << url );

    Thanks

Similar Threads

  1. deployment problem: msvc++ 2008 Express, Qt 4.4.3
    By vonCZ in forum Qt Programming
    Replies: 7
    Last Post: 10th November 2008, 14:38
  2. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  3. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  4. problem with paint and erase in frame
    By M.A.M in forum Qt Programming
    Replies: 9
    Last Post: 4th May 2008, 20:17
  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.