maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Open desktop aplications using QProcess (https://talk.maemo.org/showthread.php?t=80997)

metRo_ 2011-12-20 01:34

Open desktop aplications using QProcess
 
I want to run an aplication using the information i got in aplication.desktop file. Per example for circus game i got the following information:

Name: "Circus"
Exec: "/usr/bin/single-instance /usr/bin/incrediblecircus"
Icon: "incrediblecircus"

How i use the QProcess to run /usr/bin/single-instance /usr/bin/incrediblecircus ?! Thanks :)

EDITED: It worked my bad :| but per example with maps it doesn't work:

Code:

QProcess p;
    //p.start("/usr/bin/single-instance /usr/bin/incrediblecircus");
    p.start("/usr/bin/invoker --type=e /usr/bin/maps -u %U");
    p.waitForFinished(-1);
    QString output = p.readAllStandardOutput();
    qDebug() << output;
    qDebug() << "e:" + p.readAllStandardError();

The error:
Quote:

""
"e:1324345036614 QEventLoop: Cannot be used without QApplication
1324345036636 QDBusConnection: system D-Bus connection created before QCoreApplication. Application may misbehave.
1324345036661 "[ERROR] Unsupported uri at void AppState::setGeoParamsUri(const QString&)"
1324345036705 Using the meego graphics system
1324345036812 MApplicationService: registerService() registering failed
"
QProcess: Destroyed while process is still running.

marxian 2011-12-20 02:07

Re: Open desktop aplications using QProcess
 
Quote:

Originally Posted by metRo_ (Post 1139732)
I want to run an aplication using the information i got in aplication.desktop file. Per example for circus game i got the following information:

Name: "Circus"
Exec: "/usr/bin/single-instance /usr/bin/incrediblecircus"
Icon: "incrediblecircus"

How i use the QProcess to run /usr/bin/single-instance /usr/bin/incrediblecircus ?! Thanks :)

EDITED: It worked my bad :| but per example with maps it doesn't work:

Code:

QProcess p;
    //p.start("/usr/bin/single-instance /usr/bin/incrediblecircus");
    p.start("/usr/bin/invoker --type=e /usr/bin/maps -u %U");
    p.waitForFinished(-1);
    QString output = p.readAllStandardOutput();
    qDebug() << output;
    qDebug() << "e:" + p.readAllStandardError();

The error:

The problem is that you are including the arguments in the program name. In the desktop file, the %U refers to a URI that is passed to the program when it is launched. If you want to launch Maps without any arguments, you should use

Code:

p.start("/usr/bin/invoker --type=e /usr/bin/maps");
If you want to pass an argument, you should use

Code:

QStringList args;
args << "-u" << your_argument;
p.start("/usr/bin/invoker --type=e /usr/bin/maps", args);


metRo_ 2011-12-20 08:47

Re: Open desktop aplications using QProcess
 
Quote:

Originally Posted by marxian (Post 1139746)
The problem is that you are including the arguments in the program name. In the desktop file, the %U refers to a URI that is passed to the program when it is launched. If you want to launch Maps without any arguments, you should use

Code:

p.start("/usr/bin/invoker --type=e /usr/bin/maps");
If you want to pass an argument, you should use

Code:

QStringList args;
args << "-u" << your_argument;
p.start("/usr/bin/invoker --type=e /usr/bin/maps", args);


Thanks :)

I knew that i need to pass the arguments as a argument of the function start but my problem is that i don't know what to do with "/usr/bin/invoker --type=e"

thanks again :)

metRo_ 2011-12-24 22:52

Re: Open desktop aplications using QProcess
 
I can't run notes app per example :s

QStringList args;
args << "-showWindow" << "%U";
p->start("/usr/bin/invoker --wait-term --delay=10 --type=m /usr/bin/notes", args);

and still doesn't work if not include the arguments :s

Can you help me?


All times are GMT. The time now is 09:16.

vBulletin® Version 3.8.8