Getting Started with the Trolltech Greenphone SDK
Qtopia development will make any Qt or KDE developer feel right at home, as it is quite compatible with the desktop version of Qt. There are a few minor differences, as we will see in the example application in the Greenphone SDK found at ~/projects/application.
The style lately, with C++ in general and Qt v4.x in particular, is to include a header named after the class we want declared. This saves ever having to guess which header contains a class' declaration. In the following example, we have the old way commented out and the easier-to-remember method following it:
// main.cpp
#include "example.h"
// #include <qtopia/qtopiaapplication.h>
#include <QtopiaApplication>
QTOPIA_ADD_APPLICATION("example", Example)
QTOPIA_MAIN
// end of main.cpp
The function formerly known as main() has been deprecated in Qtopia in favor of two macros.
In the above example, the QTOPIA_ADD_APPLICATION macro is used to create an instance of the main application window. The first parameter is the executable name, and the second parameter is the base class of the application window class.
The QTOPIA_MAIN macro expands out either to the traditional main() function if building a traditional application or to the entry point needed if building a quick launcher plugin.
Inside our example.h, we find the class declaration for our main window, which we have sub-classed from a generic QWidget:
#ifndef EXAMPLE_H
#define EXAMPLE_H
#include "ui_examplebase.h"
class ExampleBase : public QWidget, public Ui_ExampleBase
{
public:
ExampleBase( QWidget *parent = 0, Qt::WFlags f = 0 );
virtual ~ExampleBase();
};
class Example : public ExampleBase
{
Q_OBJECT
public:
Example( QWidget *parent = 0, Qt::WFlags f = 0 );
virtual ~Example();
private slots:
void goodBye();
};
#endif // EXAMPLE_H
This class uses a form created using the Qt Designer GUI building tool, so we see an include file called ui_examplebase.h that brings in its declaration. In Qt, headers with names starting with ui_ typically are Designer-generated. This is followed by our class' immediate ancestor called ExampleBase. This base class inherits from both QWidget and the class defined by the GUI builder called Ui_ExampleBase.
Note:
As a brief reminder to newer users of Qt, classes generated by Designer do not have a base widget that contains all the other widgets inside it. The code in the generated class instantiates child widgets of only whatever parent widget instance is passed into its constructor. This is a reason why we see multiple inheritance used with classes derived from Qt Designer-generated code—it provides a single widget from which to hang other widgets.
Our main window is an instance of the Example class derived from ExampleBase. It makes use of a technique called signals and slots—a method used by Trolltech that allows great flexibility for defining how a function is invoked. The invoking side of the connection is called a SIGNAL(), and the invokee side is called a SLOT(). They are joined together using a method called connect() that allows a many-to-many connection relationship. Qt uses a preprocessor to add metadata processing to add to C++ dynamic invocation and object introspection effectively and elegantly—elements available in other OOP languages.
Our final code example shows the implementation of our classes:
#include "example.h"
#include <QPushButton>
ExampleBase::ExampleBase( QWidget *parent, Qt::WFlags f )
: QWidget( parent, f )
{
setupUi( this );
}
ExampleBase::~ExampleBase() { }
Example::Example( QWidget *parent, Qt::WFlags f )
: ExampleBase( parent, f )
{
connect(quit, SIGNAL(clicked()), this, SLOT(goodBye()));
}
Example::~Example() { }
void Example::goodBye()
{
close();
}
Our ExampleBase class' constructor calls the Designer-generated setupUi() method to have the form-defined child widgets created and their layout and other properties set. Without that step, it would be a generic QWidget.
The next interesting thing we see is the constructor for the Example class. It calls the connect() method to join the clicked() signal on the Qt Designer-generated QPushButton called quit with our goodBye() slot. This allows us to exit the example program by clicking the QPushButton labeled Quit.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
- RSS Feeds
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- Validate an E-Mail Address with PHP, the Right Way
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Download the Free Red Hat White Paper "Using an Open Source Framework to Catch the Bad Guy"
- Tech Tip: Really Simple HTTP Server with Python
- Readers' Choice Awards
- Android is Linux -- why no better inter-operation
2 hours 13 min ago - Connecting Android device to desktop Linux via USB
2 hours 42 min ago - Find new cell phone and tablet pc
3 hours 40 min ago - Epistle
5 hours 9 min ago - Automatically updating Guest Additions
6 hours 17 min ago - I like your topic on android
7 hours 4 min ago - Reply to comment | Linux Journal
7 hours 25 min ago - This is the easiest tutorial
13 hours 39 min ago - Ahh, the Koolaid.
19 hours 18 min ago - git-annex assistant
1 day 1 hour ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?





Comments
reply this post
Don't you understand that this is correct time to get the loans, which can make you dreams real.
hi i have a graduation
hi
i have a graduation project and i want to develop aprogram on green phone but i still need help please if any one has experience please email me
mohamed.gamal21@yahoo.com
RIP Linux Greenphone
It's a shame that this happens
http://www.linuxdevices.com/news/NS6964769377.html
Greenphone
Is this phone available to buy for use as a regular phone? My contract is almost up and I want a Linux smartphone...
Great info. Thanks.
Great info. Thanks.
Beating the OpenMoko to It
Thanks for a refreshing review (and a sigh of relief after Ty's take, which left room for doubt).