(→Build the project with Qt Creator) |
|||
| Line 7: | Line 7: | ||
[[Category:application-developer]] | [[Category:application-developer]] | ||
[[Category:linux]] | [[Category:linux]] | ||
| - | |||
| - | |||
= Introduction = | = Introduction = | ||
Contents |
This tutorial introduces developing for MeeGo x86 devices on Linux. It explains the basic application development workflow, focusing on how the tools in the SDK work together.
It does not go into detail about Qt, the MeeGo APIs, or how to make an application integrate with the MeeGo environment.
If you've got a MeeGo device:
See Getting started with the MeeGo SDK for Linux for instructions. You should also install Qt Creator, as explained in the same instructions.
See these instructions.
With everything installed, you should now be able to run the Simulator from the MeeGo environment.
While you currently need to run startmeego as root, it is possible to use the meego user for development work if you wish:
su meego
Leave the startmeego script running, and start Qt Creator with:
qtcreator &
This runs Qt Creator on the host (not inside Xephyr):
To setup the project:
Next write some code:
Then configure the project:
Now you're all set to run the application.
From inside Qt Creator, click on the big green arrow (bottom-left corner) to run the application. This will build it first (using the Qt Version you set up) then run it on display :2 (inside the Xephyr simulated MeeGo desktop).
In the Simulator, you might need to click on the MyZone icon (the house icon) to reveal the application running behind it:
This means running the application from Qt Creator, but with debugging turned on, so you can watch the state of the application while it's running under Xephyr.
In the previous sections, we built the debugging helper for the version of Qt we're using. This needs to be done first, otherwise you can't debug the application.
To put Qt Creator into debug mode, click on the bug icon in the left-hand toolbar. This adds some extra panels to the window which are used to show the stack, watch expressions etc..
Next, you need something to debug. I added a Push Button to the form:
Then added a click handler for it, so that when the button is clicked, a message string is assigned into a variable then output to the console. The code looks like this:
/* file: Headers/mainwindow.h */
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow {
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
protected:
void changeEvent(QEvent *e);
private:
Ui::MainWindow *ui;
private slots:
void on_pushButton_clicked();
};
#endif // MAINWINDOW_H
/* file: Sources/mainwindow.cpp */
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include <QString>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void MainWindow::on_pushButton_clicked()
{
QString message;
message = "I have been well and truly clicked";
qDebug() << message;
}
Most of this is boilerplate generated when I started the project, but the MainWindow::on_pushButton_clicked method is mine. Notice how it also needs to be defined as a private slot in the header file.
Add a breakpoint next to the line where you want the debugger to break by clicking in the editor margin. It looks like this:
(See the red circle on line 34 after message is initialized.)
To run the application in debug mode, click on the green arrow with a bug overlaid on it (bottom left). This starts the application inside Xephyr:
Now, click on the button. The program should pause at the breakpoint. Switch back to Qt Creator and look at the debug panels:
Notice how the Locals and Watchers tab reports the message variable set to "I have been well and truly clicked".
For more information about using Qt Creator in debug mode, see [1].
If you have a real MeeGo device available, it's also possible to run and debug your application on it using Qt Creator.
The device requires some configuration and extra packages before you can deploy from Qt Creator to it. Install them from the command line as follows:
sudo zypper install openssh-server
To start it manually (you'll need to do this just after you've installed it, otherwise it won't be available until you reboot):
sudo /etc/init.d/sshd start
To add it to the init sequence so it starts at boot time:
sudo chkconfig --add sshd
sudo zypper install gdb-gdbserver
In Qt Creator (still running from the chroot):
Once you've completed this, you should be able to deploy and run the application on the netbook:

Here's an example of what the application looks like running on a netbook:
This works almost the same on a remote device as it does inside the Simulator.
If you used the same code as above, try clicking on the Click me button in the application (running on the netbook). The application should pause at the breakpoint; and in Qt Creator, the message variable should then be visible in the Locals and Watchers tab, set to "I have been well and truly clicked". (No screenshot this time, as Qt Creator looks the same as it does for local debugging.)