Menu

Main Menu
Talk Get Daily Search

Member's Online

    User Name
    Password

    Need assistance from QT programmer

    Reply
    Page 1 of 18 | 1   2     3   11 | Next | Last
    d-iivil | # 1 | 2010-07-16, 08:07 | Report

    Hi there,

    I have a scenario like this:
    - I've drawn a simple UI in Nokia QT Designer:


    - 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.

    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by d-iivil; 2010-07-16 at 08:09.
    The Following User Says Thank You to d-iivil For This Useful Post:
    maluka

     
    Venemo | # 2 | 2010-07-16, 08:35 | Report

    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!

    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by Venemo; 2010-07-16 at 08:39.
    The Following 9 Users Say Thank You to Venemo For This Useful Post:
    d-iivil, maluka, Rauha, rm42, sbock, sixwheeledbeast, twaelti, w00t, ZogG

     
    d-iivil | # 3 | 2010-07-16, 08:39 | Report

    Originally Posted by Venemo View Post
    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.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    d-iivil | # 4 | 2010-07-16, 09:07 | Report

    Heh, well, got it running on the device.

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

    Edit | Forward | Quote | Quick Reply | Thanks
    Attached Images
      
    The Following User Says Thank You to d-iivil For This Useful Post:
    maluka

     
    Nathraiben | # 5 | 2010-07-16, 09:08 | Report

    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
    • 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.

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to Nathraiben For This Useful Post:
    ZogG

     
    d-iivil | # 6 | 2010-07-16, 09:14 | Report

    Originally Posted by Nathraiben View Post
    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
    • 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.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    Nathraiben | # 7 | 2010-07-16, 09:21 | Report

    Originally Posted by D-Iivil View Post
    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 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.

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 2 Users Say Thank You to Nathraiben For This Useful Post:
    d-iivil, ZogG

     
    Nathraiben | # 8 | 2010-07-16, 09:28 | Report

    Originally Posted by D-Iivil View Post
    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).

    Edit | Forward | Quote | Quick Reply | Thanks

     
    TNiga | # 9 | 2010-07-16, 09:33 | Report

    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);
    }

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 2 Users Say Thank You to TNiga For This Useful Post:
    d-iivil, ZogG

     
    d-iivil | # 10 | 2010-07-16, 09:37 | Report

    Originally Posted by TNiga View Post
    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

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to d-iivil For This Useful Post:
    ZogG

     
    Page 1 of 18 | 1   2     3   11 | Next | Last
vBulletin® Version 3.8.8
Normal Logout