(→Creating a Hello World) |
Mohammad7410 (Talk | contribs) (→Creating a Hello World) |
||
| (17 intermediate revisions not shown) | |||
| Line 1: | Line 1: | ||
[[Category:meego-1.1]] | [[Category:meego-1.1]] | ||
| - | |||
| - | |||
This page explains how to create a Hello World application with Qt Creator and run it on a MeeGo device (real or emulated). | This page explains how to create a Hello World application with Qt Creator and run it on a MeeGo device (real or emulated). | ||
| + | |||
| + | '''Note that these instructions are applicable for both Linux and Windows versions of the SDK. However, the screenshots below are taken from the Linux SDK and contain Linux-style file and directory paths.''' | ||
== Prerequisites == | == Prerequisites == | ||
| - | * You have [[SDK/Docs/1.1/Getting_started_with_the_MeeGo_SDK_for_Linux| | + | * You have set up MeeGo SDK environment for [[SDK/Docs/1.1/Getting_started_with_the_MeeGo_SDK_for_Linux|Linux]] or [[SDK/Docs/1.1/Getting_started_with_the_MeeGo_SDK_for_Windows|Windows]]. |
| - | + | ||
== Creating a Hello World == | == Creating a Hello World == | ||
| Line 21: | Line 20: | ||
# Select MeeGo target(s) and click '''Next'''. | # Select MeeGo target(s) and click '''Next'''. | ||
#: [[File:Qt Creator selecting targets mobility.png|frame|none|Selecting the MeeGo target(s)]] | #: [[File:Qt Creator selecting targets mobility.png|frame|none|Selecting the MeeGo target(s)]] | ||
| + | #: These targets are the same as the ones you set up when configuring Qt Creator to use MADDE targets. ([[SDK/Docs/1.1/Getting_started_with_the_MeeGo_SDK_for_Windows#Configuring_Qt_Creator_to_use_the_MeeGo_toolchain.28s.29|Windows instructions]], [[SDK/Docs/1.1/Getting_started_with_the_MeeGo_SDK_for_Linux#Configuring_Qt_Creator_to_use_the_MeeGo_toolchain.28s.29|Linux instructions]]). Which means that the target name in the screen shot should be "MeeGo netbook" if you are following Windows instructions. | ||
# Name the files that will be automatically created for your project. | # Name the files that will be automatically created for your project. | ||
#: [[File:Qt Creator naming classes mobility.png|frame|none|Naming classes for your project]] | #: [[File:Qt Creator naming classes mobility.png|frame|none|Naming classes for your project]] | ||
| Line 29: | Line 29: | ||
'''To create a Hello World application:''' | '''To create a Hello World application:''' | ||
| - | For more information on the Hello World created here, see [http://apidocs.meego.com/qtmobility/quickstart.html the Qt Mobility Quickstart Example]. | + | For more information on the Hello World created here, see [http://apidocs.meego.com/1.0/qtmobility/quickstart.html the Qt Mobility Quickstart Example]. |
1. In Qt Creator, select '''Edit''' mode. | 1. In Qt Creator, select '''Edit''' mode. | ||
| Line 46: | Line 46: | ||
QApplication app(argc, argv); | QApplication app(argc, argv); | ||
QSystemInfo s; | QSystemInfo s; | ||
| - | QLabel | + | QLabel label(QObject::tr("hello ").append(s.currentCountryCode())); |
| - | label | + | label.show(); |
| - | label | + | label.resize(100,30); |
return app.exec(); | return app.exec(); | ||
} | } | ||
</pre> | </pre> | ||
| - | 4. | + | 4. Add following System Information API declaration in your <code>.pro</code> file: |
<pre> | <pre> | ||
CONFIG += mobility | CONFIG += mobility | ||
| Line 64: | Line 64: | ||
Your application is now ready to be configured for building. | Your application is now ready to be configured for building. | ||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
== Packaging the Hello World == | == Packaging the Hello World == | ||
| Line 88: | Line 80: | ||
For instructions on configuring device access, see: | For instructions on configuring device access, see: | ||
| - | |||
| - | |||
* [[SDK/Docs/1.1/Configuring_QEMU_runtimes#Configuring_access_to_an_emulated_device_in_Qt_Creator|QEMU image]] | * [[SDK/Docs/1.1/Configuring_QEMU_runtimes#Configuring_access_to_an_emulated_device_in_Qt_Creator|QEMU image]] | ||
| + | * [[SDK/Docs/1.1/Setting_up_Netbook#Configuring_device_access_in_Qt_Creator|Netbook]] | ||
| + | * [[SDK/Docs/1.1/Setting_up_N900_device#Configuring_device_access_in_Qt_Creator|N900]] | ||
== Running the Hello World == | == Running the Hello World == | ||
| Line 96: | Line 88: | ||
To run your Hello World on your device: | To run your Hello World on your device: | ||
# Switch to '''Projects''' mode [[File:Qt Creator Projects mode button.png]]. | # Switch to '''Projects''' mode [[File:Qt Creator Projects mode button.png]]. | ||
| - | # | + | # On the target toolbar, select '''MeeGo''' > '''Run''' to configure Run settings. |
# In '''Device configuration''' drop-down menu, select the device configuration you created when [[#Configuring device access in Qt Creator|configuring device access]]. | # In '''Device configuration''' drop-down menu, select the device configuration you created when [[#Configuring device access in Qt Creator|configuring device access]]. | ||
#: [[File:Qt Creator run settings mobility.png|800px]] | #: [[File:Qt Creator run settings mobility.png|800px]] | ||
| Line 109: | Line 101: | ||
For more information on debugging, see [[SDK/Docs/1.1/Debugging_with_Qt_Creator|Debugging with Qt Creator]]. | For more information on debugging, see [[SDK/Docs/1.1/Debugging_with_Qt_Creator|Debugging with Qt Creator]]. | ||
| + | |||
| + | == Running the Hello World on n900 Meego Community Edition == | ||
| + | |||
| + | As Meego Community Edition didn't provide theme to plain qt app, your app will look ugly on it. So install the meegotouch-qt-style. | ||
| + | <pre> | ||
| + | zypper refresh | ||
| + | zypper install meegotouch-qt-style | ||
| + | </pre> | ||
| + | |||
| + | As meegotouch-qt-style isn't stable enought to make it available for all qt apps, and made qmlviewer crash, we will desactivate for all apps by default. As none theme is setted in the preference, by default qt use meegotouch style. | ||
| + | |||
| + | Edit the file ~/.config/Trolltech.conf to add the following line at the beginning : | ||
| + | |||
| + | <pre> | ||
| + | [Qt] | ||
| + | style=plastique | ||
| + | </pre> | ||
| + | |||
| + | And then to apply the meegotouch style to your app, you can launch via command line with the argument -style meegotouch or use : | ||
| + | |||
| + | <pre> | ||
| + | QApplication::setStyle("meegotouch") | ||
| + | </pre> | ||
This page explains how to create a Hello World application with Qt Creator and run it on a MeeGo device (real or emulated).
Note that these instructions are applicable for both Linux and Windows versions of the SDK. However, the screenshots below are taken from the Linux SDK and contain Linux-style file and directory paths.
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(QObject::tr("hello ").append(s.currentCountryCode()));
label.show();
label.resize(100,30);
return app.exec();
}
4. Add following System Information API declaration in your .pro file:
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.
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").
Configuring device access in Qt Creator is slightly different depending on whether you are deploying to a real device or an emulated one.
However, the mode of access is the same: Qt Creator deploys and installs an .rpm package on the device, and runs the executable.
For instructions on configuring device access, see:
To run your Hello World on your device:
.
On a netbook image, the Hello World application runs as shown in the following screenshot:
For more information on debugging, see Debugging with Qt Creator.
As Meego Community Edition didn't provide theme to plain qt app, your app will look ugly on it. So install the meegotouch-qt-style.
zypper refresh zypper install meegotouch-qt-style
As meegotouch-qt-style isn't stable enought to make it available for all qt apps, and made qmlviewer crash, we will desactivate for all apps by default. As none theme is setted in the preference, by default qt use meegotouch style.
Edit the file ~/.config/Trolltech.conf to add the following line at the beginning :
[Qt] style=plastique
And then to apply the meegotouch style to your app, you can launch via command line with the argument -style meegotouch or use :
QApplication::setStyle("meegotouch")