maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Need assistance from QT programmer (https://talk.maemo.org/showthread.php?t=58569)

d-iivil 2010-07-16 08:07

Need assistance from QT programmer
 
Hi there,

I have a scenario like this:
- I've drawn a simple UI in Nokia QT Designer:
http://i9.aijaa.com/b/00462/6426697.png

- I have a shell script wich does various file manipulations based on variables given

What I would like to do:
- convert that UI to native app which would launch my shell script with variables based on what's been chosen from drop down list's at the UI when hitting the "Apply changes" -button. In this case the command to be launched from the button would be:
/path/to/my/script/script.sh "Enable custom transitions" "Droid Sans" "Black"

I have zero knowledge on coding with anything else than PHP. I would highly appreciate if someone is intrested in helping me with the project :)

I think this could be done with Python(?) so I could later on easily edit the python "source" if I needed to add more options to the drop down lists?

Edit: and as bonus: this app should be launchable from N900's settings "application", not from program launcher menu.

Venemo 2010-07-16 08:35

Re: Need assistance from QT / Python programmer
 
Hello,

At the moment I can't write all the code for you, but I can give you some pointers about how to do it.
  • Install Nokia Qt SDK (1.0 final is the latest)
  • Install the newest Qt Creator snapshot from here:
    ftp://ftp.qt.nokia.com/qtcreator/snapshots/
    (The version in the SDK is quite crappy)
  • Launch the newly installed Qt Creator
  • Create a new Gui Application project
  • Set the Maemo 5 Qt 4.6 as build target
  • Add to it a class (or use the generated one) and copy-paste to its .ui file yours from the designer
  • If you wanna run your app on your device, install the "Mad Developer" package on it, set the USB driver to "usb_ether" (Etheret - USB networking), then plug it in your PC, select "PC Suite mode" (if usb_ether is selected, that will be used), and set up USB networking on your PC.
  • In Qt Creator, Tools/Options/Projects/Maemo device configurations -> set up a connection to your device.
    Type in its IP address, then the "developer" account, and type the password from the Mad Developer app's "developer password" button. Note that the password there is only valid until it is shown on the screen. If you connected with the password, you can generate and deploy an SSH key, and use that instead of the password.
  • Close the options dialog
  • Then, go to the "Projects" tab in the editor, and below the "Build steps", click on the arrow next to "Create Package", and check the "Skip packaging step" option
    - This will make it WAY faster to run your app.
  • Here is a tutorial about how to launch a process from a Qt app:
    http://wiki.forum.nokia.com/index.ph...Qt_for_Symbian
    (The tutorial has Symbian in its title, but it contains non-Symbian-specific code.)
  • For the shell scrips, you'll have to run "sh yourscript.sh" with QProcess
  • For generic C++ questions, you can search Google or ask on StackOverflow
  • If you want to make a .deb package, you can use Qt Creator's option to do so (but it is quite limited at the moment), or use MADDE and type "mad dpkg-buildpackage" into the command line (in your app's root folder)
  • There is a description somewhere in the Maemo Wiki about how to make it a Settings applet, but I couldn't find it now.

I know this was a very dense description, but I hope it will help!

d-iivil 2010-07-16 08:39

Re: Need assistance from QT / Python programmer
 
Quote:

Originally Posted by Venemo (Post 753632)
Hello,

At the moment I can't write all the code for you, but I can give you some pointers about how to do it.
  • Install Nokia Qt SDK (1.0 final is the latest)
  • Install the newest Qt Creator snapshot from here:
    ftp://ftp.qt.nokia.com/qtcreator/snapshots/
    (The version in the SDK is quite crappy)
  • Launch the newly installed Qt Creator
  • Create a new Gui Application project
  • Set the Maemo 5 Qt 4.6 as build target
  • Add to it a class (or use the generated one) and copy-paste to its .ui file yours from the designer
  • If you wanna run your app on your device, install the "Mad Developer" package on it, set the USB driver to "usb_ether" (Etheret - USB networking), then plug it in your PC, select "PC Suite mode" (if usb_ether is selected, that will be used), and set up USB networking on your PC.
  • In Qt Creator, Tools/Options/Projects/Maemo device configurations
  • Then, go to the "Projects" tab in the editor, and below the "Build steps", click on the arrow next to "Create Package", and check the "Skip packaging step" option
    - This will make it WAY faster to run your app.
  • Here is a tutorial about how to launch a process from a Qt app:
    http://wiki.forum.nokia.com/index.ph...Qt_for_Symbian
    (The tutorial has Symbian in its title, but it contains non-Symbian-specific code.)
  • For the shell scrips, you'll have to run "sh yourscript.sh" with QProcess
  • For generic C++ questions, you can search Google or ask on StackOverflow
  • If you want to make a .deb package, you can use Qt Creator's option to do so (but it is quite limited at the moment), or use MADDE and type "mad dpkg-buildpackage" into the command line (in your app's root folder)
  • There is a description somewhere in the Maemo Wiki about how to make it a Settings applet, but I couldn't find it now.

I know this was a very dense description, but I hope it will help!

Thanks for these! At least now I know a bit more what to google for :)
Already got mad developer working with QT Creator.

d-iivil 2010-07-16 09:07

Re: Need assistance from QT / Python programmer
 
2 Attachment(s)
Heh, well, got it running on the device.

Now the hardest part: how to make the buttons actually to do something :-P

Nathraiben 2010-07-16 09:08

Re: Need assistance from QT / Python programmer
 
Not sure whether I should post this, as right now I'm trying to blow the "embrace the future - develop with QT" - but coming from PHP, using Python and PyQt might indeed be the easier way to do it.

That would require to:
  • Download and install Eric (if on Linux - don't know what the Win-only bunch are using)
  • Err... well, that's pretty much it for preparations :p
  • Test-run your application by SSH-ing, use folder-sharing or simply copying your scripts to the device and simply run it with "python path/to/app.py" - Python doesn't need compiling.
  • For packaging, just follow the instructions on this wiki page and you're done.

Again, if you want to be future prove, go with C++ and Qt, but if you want to keep it easy (and maemo-only), Python and PyQt would do the trick without much hassle, especially when you're coming from a PHP background.

d-iivil 2010-07-16 09:14

Re: Need assistance from QT / Python programmer
 
Quote:

Originally Posted by Nathraiben (Post 753663)
Not sure whether I should post this, as right now I'm trying to blow the "embrace the future - develop with QT" - but coming from PHP, using Python and PyQt might indeed be the easier way to do it.

That would require to:
  • Download and install Eric (if on Linux - don't know what the Win-only bunch are using)
  • Err... well, that's pretty much it for preparations :p
  • Test-run your application by SSH-ing, use folder-sharing or simply copying your scripts to the device and simply run it with "python path/to/app.py" - Python doesn't need compiling.
  • For packaging, just follow the instructions on this wiki page and you're done.

Again, if you want to be future prove, go with C++ and Qt, but if you want to keep it easy (and maemo-only), Python and PyQt would do the trick without much hassle, especially when you're coming from a PHP background.

Yeah, Python would be easy to edit on the go and test new things because it does not need compiling. Including it to the deb-package would not be a problem also (I want to include that with my theme-package). Right now I'm just using that shell script and Zenity to display dialogs, but it's kind of... well.. not that user friendly since Zenity dialogs aren't hildonized completely etc.

Good thing seems to be that I can use the .ui -file with QT Creator and PyQT4.

Nathraiben 2010-07-16 09:21

Re: Need assistance from QT / Python programmer
 
Quote:

Originally Posted by D-Iivil (Post 753661)
Heh, well, got it running on the device.

Now the hardest part: how to make the buttons actually to do something :-P

Okay, first the obligatory warning: I'm pretty new to Qt, so I might be spouting a lot of nonsense, but here's how I got it to work:

In the constructor of your window widget, connect the "clicked" event of your button:

Code:

connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(hello()));
Note:
"ui" is the... well, UI :p defined by "ui(new Ui::MyWindowName)" in the constructor
"pushButton" is the name of your button
"hello()" is the name of a slot created in the next step


In the header file of the window widget, add the definition for a new slot (inside the class definition) :

Code:

protected slots:
        void hello();


Back in the implementation file of your window widget, define a function for that slot:

Code:

void MainWindow::hello()
{
    //Do whatever should be done when pressing the button
}


Just don't call the spot hello - that was obviously taken from my inevitable first Hello World app. :D

Nathraiben 2010-07-16 09:28

Re: Need assistance from QT / Python programmer
 
Quote:

Originally Posted by D-Iivil (Post 753667)
Good thing seems to be that I can use the .ui -file with QT Creator and PyQT4.

True, .ui files being usable with any of the Qt bindings is quite the blessing. And I was astonished how easy it is to work with them both in Eric (simply right-click and choose "Compile Form" to generate the .py file, then right-click and choose "Generate Dialog Code" to automatically generate everything you need for even-handling with a nice choose-your-events dialog) and in the QT SDK (no generating of event handlers, as far as I know, but at least fully automatic generation of the .cpp and .h upon saving the .ui file).

TNiga 2010-07-16 09:33

Re: Need assistance from QT / Python programmer
 
If you want to run your shell script in the button handler, you need to use function int QProcess::execute ( const QString & program, const QStringList & arguments ).

In above example from Nathraiben you would call it in function hello like this:
Code:

void MainWindow::hello()
{
    QStringList arguments;
    arguments << "Enable custom transitions" << "Droid Sans" << "Black";
    QProcess::execute("/path/to/my/script/script.sh", arguments);
}


d-iivil 2010-07-16 09:37

Re: Need assistance from QT / Python programmer
 
Quote:

Originally Posted by TNiga (Post 753681)
If you want to run your shell script in the button handler, you need to use function int QProcess::execute ( const QString & program, const QStringList & arguments ).

In above example from Nathraiben you would call it in function hello like this:
Code:

void MainWindow::hello()
{
    QStringList arguments;
    arguments << "Enable custom transitions" << "Droid Sans" << "Black";
    QProcess::execute("/path/to/my/script/script.sh", arguments);
}


Thanks for this, but how do I put the input from those select boxes as arguments?

And in which part of my project I should put these:
Code:

connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(hello()));
Code:

void MainWindow::hello()
{
    QStringList arguments;
    arguments << "Enable custom transitions" << "Droid Sans" << "Black";
    QProcess::execute("/path/to/my/script/script.sh", arguments);
}

I have these:
Forms:
- mainwindow-ui

Headers.
- mainwindow.h

Sources:
- main.cpp
- mainwindow.cpp


All times are GMT. The time now is 01:46.

vBulletin® Version 3.8.8