(→Creating a Hello World) |
(→Creating a Hello World) |
||
| Line 37: | Line 37: | ||
3. To create an application that uses the QSystemInfo headers to print out the system's current country code, replace the existing example code in your <code>main.cpp</code> file with the following example code: | 3. To create an application that uses the QSystemInfo headers to print out the system's current country code, replace the existing example code in your <code>main.cpp</code> file with the following example code: | ||
<pre> | <pre> | ||
| - | + | #include <QApplication> | |
| - | + | #include <QLabel> | |
| + | #include <QSystemInfo> | ||
| + | using namespace QtMobility; | ||
| - | + | int main(int argc, char *argv[]) | |
| - | + | { | |
| - | + | QApplication app(argc, argv); | |
| - | + | QSystemInfo s; | |
| - | + | QLabel *label = new QLabel(QObject::tr("hello ").append(s.currentCountryCode())); | |
| - | + | label->show(); | |
| - | + | label->resize(100,30); | |
| - | + | return app.exec(); | |
| - | + | } | |
| - | + | </pre> | |
| - | + | ||
| - | + | ||
4. Replace the corresponding lines in your <code>.pro</code> file with the following System Information API declaration: | 4. Replace the corresponding lines in your <code>.pro</code> file with the following System Information API declaration: | ||
| - | <pre> CONFIG += mobility | + | <pre> |
| - | + | CONFIG += mobility | |
| + | MOBILITY += systeminfo | ||
| + | </pre> | ||
Do not remove the existing code in the file. | Do not remove the existing code in the file. | ||
Note: This page is work-in-progress (26 Oct 2010).
This page explains how to create a Hello World application with Qt Creator and run it on a MeeGo device (real or emulated).
Contents |
To create a project:
To create a Hello World application:
For more information on the Hello World created here, see the Qt Mobility Quickstart Example.
1. In Qt Creator, select Edit mode.
2. To view your project files, open Forms, Headers, and Sources folders in Projects sidebar.
3. To create an application that uses the QSystemInfo headers to print out the system's current country code, replace the existing example code in your main.cpp file with the following example code:
#include <QApplication>
#include <QLabel>
#include <QSystemInfo>
using namespace QtMobility;
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QSystemInfo s;
QLabel *label = new QLabel(QObject::tr("hello ").append(s.currentCountryCode()));
label->show();
label->resize(100,30);
return app.exec();
}
4. Replace the corresponding lines in your .pro file with the following System Information API declaration:
CONFIG += mobility MOBILITY += systeminfo
Do not remove the existing code in the file.
5. In the File menu, select Save All.
Your application is now ready to be configured for building.
To configure your Hello World for building:
Draft content to be verified, reviewed and finalized for MeeGo 1.1.
If you run your Hello World application, an .rpm package is created automatically.
If you want to create a package of your Hello World application without running it, click Build All or select Build > Build Project "<project name>".
Compile Output view shows the message "Package created." and an .rpm package file (<project name>-<project version>-<release version>.<device architecture>.rpm) has been created in the build-specific project subdirectory ("<project name>-build-meego").
The process is slightly different, depending on whether you are deploying to a real device or an emulated one.
However, in both cases, the mode of access is the same: Qt Creator will deploy and install an RPM on the device, then run its executable.
To configure device access:
To configure access to an emulated device:
To run your Hello World on your device: