Reply
Thread Tools
Posts: 15 | Thanked: 2 times | Joined on Sep 2012
#1
Hello!

I have done few basic applications for my own usage and fun. I haven't found any kind of information of how to execute a command through terminal? For instance, let's say that I would like to simply display a basic functions such as showing the IP.

How am I able to do that? Do I need to call the command through SSH or directly into terminal?

Appreciated!
 
coderus's Avatar
Posts: 6,436 | Thanked: 12,701 times | Joined on Nov 2011 @ Ängelholm, Sweden
#2
what is your application language?
__________________
Telegram | Openrepos | GitHub | Revolut donations
 
Posts: 15 | Thanked: 2 times | Joined on Sep 2012
#3
Oops..

Well, mainly I've used QML and I would like to stick with that because it was the easiest for me to understand for some reason.

But if it can not be done with QML then any other options?
 
marxian's Avatar
Posts: 2,448 | Thanked: 9,523 times | Joined on Aug 2010 @ Wigan, UK
#4
See this post: http://talk.maemo.org/showpost.php?p...45&postcount=2
__________________
'Men of high position are allowed, by a special act of grace, to accomodate their reasoning to the answer they need. Logic is only required in those of lesser rank.' - J K Galbraith

My website

GitHub
 
Posts: 15 | Thanked: 2 times | Joined on Sep 2012
#5
Nice one, exactly what I was looking for. Thank you very much!

But I have a question which I couldn't figure out - at least not yet. Let's say I'd like to list the current files and folders in directory "/home/user/" for example, how I do that?

EDIT * I do know that using 'ls' or 'ls -a' lists the files and folders, but how I make the list using using TextArea for example.

I don't actually need that one yet, but for future projects if I need it some day.
 
marxian's Avatar
Posts: 2,448 | Thanked: 9,523 times | Joined on Aug 2010 @ Wigan, UK
#6
Originally Posted by KullasH View Post
Nice one, exactly what I was looking for. Thank you very much!

But I have a question which I couldn't figure out - at least not yet. Let's say I'd like to list the current files and folders in directory "/home/user/" for example, how I do that?

EDIT * I do know that using 'ls' or 'ls -a' lists the files and folders, but how I make the list using using TextArea for example.

I don't actually need that one yet, but for future projects if I need it some day.
The example at the bottom of that post (see https://github.com/marx1an/qt-compon...rocessPage.qml) shows exactly that use case, except a Label (inside a Flickable) is used to display results instead of a TextArea. Here's a simple example using a TextArea:

Code:
Page {
    id: root

    Process {
        id: process

        workingDirectory: "/home/user"
        command: "ls"
        onFinished: textArea.text = process.readAllStandardOutput()
    }

    TextArea {
        id: textArea

        anchors.centerIn: parent
    }

    Component.onCompleted: process.start()
}
To list files in /home/user, you can either set the workingDirectory property of the Process element to "/home/user" and set the command property to "ls", or you can simply set the command property to "ls /home/user".
__________________
'Men of high position are allowed, by a special act of grace, to accomodate their reasoning to the answer they need. Logic is only required in those of lesser rank.' - J K Galbraith

My website

GitHub
 

The Following 2 Users Say Thank You to marxian For This Useful Post:
Posts: 15 | Thanked: 2 times | Joined on Sep 2012
#7
Sweetness! Thank you very much mate.
 

The Following User Says Thank You to KullasH For This Useful Post:
Posts: 15 | Thanked: 2 times | Joined on Sep 2012
#8
Hmm.. I have a problem that I just can not figure out by myself.

When I use your qdeclarativesettings.h and *.cpp files it complains about the <QDeclarativeProcess> in main.cpp file. Well, I found your qdeclarativeprocess.h and *.cpp files and that made it.

However it now complains about "...\main.cpp:13: error: no matching function for call to 'qmlRegisterUncreatableType(const char [24], int, int, const char [10])'". Here's the main.cpp file:

Code:
#include <QtGui/QApplication>
#include <QtDeclarative>
#include "qmlapplicationviewer.h"
#include "qdeclarativeprocess.h"
#include "qdeclarativesettings.h"

Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QScopedPointer<QApplication> app(createApplication(argc, argv));
    QmlApplicationViewer viewer;

    qmlRegisterType<QDeclarativeProcess>("org.component.Processes", 1, 0, "Process");
    qmlRegisterUncreatableType<QDeclarativeProcessEnums>("org.component.Processes", 1, 0, "Processes");

    viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    viewer.setMainQmlFile(QLatin1String("qml/filecontrol/main.qml"));
    viewer.showExpanded();

    return app->exec();
}
If I try without the line it complains about (line 13: qmlRegisterUncreatableType<QDeclarativeProcessEnum s>) it works without any problems. Well, then it only displays onError statement in my *.qml file and not the onFinished state.

Any advice what I'm doing wrong here? I have added *.cpp and *.h files in *.pro file so that should not be a problem.
 
marxian's Avatar
Posts: 2,448 | Thanked: 9,523 times | Joined on Aug 2010 @ Wigan, UK
#9
Originally Posted by KullasH View Post
Hmm.. I have a problem that I just can not figure out by myself.

When I use your qdeclarativesettings.h and *.cpp files it complains about the <QDeclarativeProcess> in main.cpp file. Well, I found your qdeclarativeprocess.h and *.cpp files and that made it.

However it now complains about "...\main.cpp:13: error: no matching function for call to 'qmlRegisterUncreatableType(const char [24], int, int, const char [10])'". Here's the main.cpp file:

Code:
#include <QtGui/QApplication>
#include <QtDeclarative>
#include "qmlapplicationviewer.h"
#include "qdeclarativeprocess.h"
#include "qdeclarativesettings.h"

Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QScopedPointer<QApplication> app(createApplication(argc, argv));
    QmlApplicationViewer viewer;

    qmlRegisterType<QDeclarativeProcess>("org.component.Processes", 1, 0, "Process");
    qmlRegisterUncreatableType<QDeclarativeProcessEnums>("org.component.Processes", 1, 0, "Processes");

    viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    viewer.setMainQmlFile(QLatin1String("qml/filecontrol/main.qml"));
    viewer.showExpanded();

    return app->exec();
}
If I try without the line it complains about (line 13: qmlRegisterUncreatableType<QDeclarativeProcessEnum s>) it works without any problems. Well, then it only displays onError statement in my *.qml file and not the onFinished state.

Any advice what I'm doing wrong here? I have added *.cpp and *.h files in *.pro file so that should not be a problem.
There is a missing argument (the error string) in your call to qmlRegisterUncreatableType. The error string can be anything you like, for example:

Code:
qmlRegisterUncreatableType<QDeclarativeProcessEnums>("org.component.Processes", 1, 0, "Processes", "Cannot be created in QML");
__________________
'Men of high position are allowed, by a special act of grace, to accomodate their reasoning to the answer they need. Logic is only required in those of lesser rank.' - J K Galbraith

My website

GitHub
 

The Following User Says Thank You to marxian For This Useful Post:
Posts: 15 | Thanked: 2 times | Joined on Sep 2012
#10
EDIT: Alles goed! Just noticed that of course the SSH commands can not work if not using N9 itself for testing.

Originally Posted by marxian View Post
There is a missing argument (the error string) in your call to qmlRegisterUncreatableType. The error string can be anything you like, for example:

Code:
qmlRegisterUncreatableType<QDeclarativeProcessEnums>("org.component.Processes", 1, 0, "Processes", "Cannot be created in QML");
Ah, missed that one. Never ever used qmlRegisterUncreatableType and your example did not include the error string so... But thanks anyways!

It still gives me only error no matter what command I'm trying to execute. I've tried 'ls' 'ls -a' 'ls /' etc. I've also tried with and without the workingDirectory property. I've tried to call the Process QML from Page QML's Component.onCompleted and on button click. Neither of 'em have worked.

Last edited by KullasH; 2013-04-30 at 04:45.
 
Reply


 
Forum Jump


All times are GMT. The time now is 14:13.