![]() |
How to run a sh script from QML button?
Hi i'm beginning with QML and i would like to know how i execute a script.sh with a QML button.
I have the script.sh: Code:
#!/bin/sh Code:
ToolButton { I must package the sh file with QT or i must write the sh script inside QML? |
Re: How to run a sh script from QML button?
You can't do it purely in QML. You would need to write a simple class in Qt that uses QProcess to launch the script.
scriptlauncher.h Code:
#ifndef SCRIPTLAUNCHER_H Code:
#include "scriptlauncher.h" Code:
#include "scriptlauncher.h" Code:
ToolButton { EDIT: Here's a nice example of using GConf in Qt/QML: http://harmattan-dev.nokia.com/docs/..._to_GConf.html |
Re: How to run a sh script from QML button?
Wow i thought that QML was more complete :)
Thank you marxian, i'm going to try what happens |
Re: How to run a sh script from QML button?
And this is just what I was looking to do with my next app! Will try it out!
|
Re: How to run a sh script from QML button?
i'm stuck with this errors:
main.cpp: In function 'int main(int, char**)': main.cpp:16: error: 'view' was not declared in this scope This is my main.cpp Code:
#include <QtGui/QApplication> |
Re: How to run a sh script from QML button?
Quote:
|
Re: How to run a sh script from QML button?
Ok! no errors.
Now, where i place the "script.sh" file? under QML "Other files"? And then it executes with "onClicked: scriptLauncher.launchScript()"? or i must add for ex: "onClicked: scriptLauncher.launchScript(/opt/something/string.sh)"? |
Re: How to run a sh script from QML button?
Quote:
AFAIU the m_procces location is done in the slot (were "sh script.sh" is in Marxian's example) This is were you need to put "sh /opt/mypackage/script/myscript.sh" onClicked can be left alone. |
Re: How to run a sh script from QML button?
i added the script folder with script.sh inside but (with right click to project, add existing file) when i install i explore the opt folder on phone and i only see "bin" and "qml" folders.
This is the pro file: OTHER_FILES += \ qtc_packaging/debian_harmattan/rules \ qtc_packaging/debian_harmattan/README \ qtc_packaging/debian_harmattan/manifest.aegis \ qtc_packaging/debian_harmattan/copyright \ qtc_packaging/debian_harmattan/control \ qtc_packaging/debian_harmattan/compat \ qtc_packaging/debian_harmattan/changelog \ script/script.sh |
Re: How to run a sh script from QML button?
Quote:
Code:
script.path = /opt/<application_name>/script |
All times are GMT. The time now is 23:09. |
vBulletin® Version 3.8.8