The Following User Says Thank You to flotron For This Useful Post: | ||
|
2012-10-25
, 23:19
|
|
Posts: 2,448 |
Thanked: 9,523 times |
Joined on Aug 2010
@ Wigan, UK
|
#2
|
#ifndef SCRIPTLAUNCHER_H #define SCRIPTLAUNCHER_H #include <QObject> #include <QProcess> class ScriptLauncher : public QObject { Q_OBJECT public: explicit ScriptLauncher(QObject *parent = 0); Q_INVOKABLE void launchScript(); private: QProcess *m_process; }; #endif
#include "scriptlauncher.h" ScriptLauncher::ScriptLauncher(QObject *parent) : QObject(parent), m_process(new QProcess(this)) { } void ScriptLauncher::launchScript() { m_process->start("sh script.sh"); }
#include "scriptlauncher.h" ... ScriptLauncher launcher; QDeclarativeContext *context = view->rootContext(); context->setContextProperty("scriptLauncher", &launcher);
ToolButton { id: myButton x: 121 y: 410 width: 119 height: 62 onClicked: scriptLauncher.launchScript() }
The Following 10 Users Say Thank You to marxian For This Useful Post: | ||
|
2012-10-25
, 23:47
|
|
Posts: 418 |
Thanked: 506 times |
Joined on Jan 2012
@ Argentina
|
#3
|
|
2012-10-26
, 00:18
|
|
Posts: 794 |
Thanked: 784 times |
Joined on Sep 2007
@ /Canada/Ontario/GTA
|
#4
|
|
2012-10-26
, 00:22
|
|
Posts: 418 |
Thanked: 506 times |
Joined on Jan 2012
@ Argentina
|
#5
|
#include <QtGui/QApplication> #include "qmlapplicationviewer.h" #include "scriptlauncher.h" #include "qdeclarativecontext.h" Q_DECL_EXPORT int main(int argc, char *argv[]) { QScopedPointer<QApplication> app(createApplication(argc, argv)); QmlApplicationViewer viewer; viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); viewer.setMainQmlFile(QLatin1String("qml/untitled/main.qml")); viewer.showExpanded(); ScriptLauncher launcher; QDeclarativeContext *context = view->rootContext(); context->setContextProperty("scriptLauncher", &launcher); return app->exec(); }
|
2012-10-26
, 00:36
|
|
Posts: 2,448 |
Thanked: 9,523 times |
Joined on Aug 2010
@ Wigan, UK
|
#6
|
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> #include "qmlapplicationviewer.h" #include "scriptlauncher.h" #include "qdeclarativecontext.h" Q_DECL_EXPORT int main(int argc, char *argv[]) { QScopedPointer<QApplication> app(createApplication(argc, argv)); QmlApplicationViewer viewer; viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); viewer.setMainQmlFile(QLatin1String("qml/untitled/main.qml")); viewer.showExpanded(); ScriptLauncher launcher; QDeclarativeContext *context = view->rootContext(); context->setContextProperty("scriptLauncher", &launcher); return app->exec(); }
|
2012-10-26
, 02:18
|
|
Posts: 418 |
Thanked: 506 times |
Joined on Jan 2012
@ Argentina
|
#7
|
|
2012-10-26
, 06:40
|
Posts: 2,290 |
Thanked: 4,134 times |
Joined on Apr 2010
@ UK
|
#8
|
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)"?
The Following User Says Thank You to sixwheeledbeast For This Useful Post: | ||
|
2012-10-26
, 16:08
|
|
Posts: 418 |
Thanked: 506 times |
Joined on Jan 2012
@ Argentina
|
#9
|
|
2012-10-26
, 16:36
|
|
Posts: 2,448 |
Thanked: 9,523 times |
Joined on Aug 2010
@ Wigan, UK
|
#10
|
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
script.path = /opt/<application_name>/script script.files += script/script.sh INSTALLS += script
I have the script.sh:
I must package the sh file with QT or i must write the sh script inside QML?
Bigger Icons (MetroUI)
Charging Indicator
s60.com.ar