The Qt Mobility project is developing new Qt APIs. These APIs will benefit all Qt developers. This presentation shall provide an overview of the APIs and demonstrate the use of some the APIs through an example application. This presentation shall fuel ideas for usage of the new APIs in your own projects.
Presentation by Alex Luddy held during Qt Developer Days 2009.
http://qt.nokia.com/developer/learning/elearning
8. Qt Mobility Details
• The Mobility project is creating Qt APIs
• APIs will have supported functional back-ends on
all platforms where it makes sense
• Some APIs on Qt labs now
7
9. The Story of Bob the Developer
• Wants to make a mobile application
• Wants the application to be cross-platform
• A Web feed reader…
8
10. Bearer Management
• Enables roaming between
connections
• Choose most appropriate
connection
• Manage connections
9
15. Bearer Management Example
void BearerCloud::configurationAdded(
const QNetworkConfiguration& configuration)
{
const QNetworkConfiguration::StateFlags state =
config.state();
// position in cloud based on state
}
14
16. Back to Bob
• Efficient Internet connection
• Web feed reader with contact interest
information…
15
17. Contacts
• Work with contact data
• Add custom data
• Introspect contact data
• Enumerate contact stores
– Local and remote
16
19. Contacts Example: Show Contacts
// prepare fetch request
QContactManager* manager = new QContactManager();
QContactFetchRequest* fetchRequest = new QContactFetchRequest;
fetchRequest->setManager(manager);
connect(fetchRequest,
SIGNAL(progress(QContactFetchRequest*,bool)), this,
SLOT(showContacts(QContactFetchRequest*,bool)));
m_fetchRequest->start()
18
20. Contacts Example: Show Contacts
void Example::showContacts(QContactFetchRequest* request,
bool appendOnly)
{
QList<QContact> results = request->contacts();
// handle append only case
// access contacts for display
for (int i = 0; i < results.size(); ++i) {
QString display = results[i].displayLabel().label();
// ...
19
21. Back to Bob
• Efficient Internet connection
• Access contact details
– Add “interest” as custom data
• Web feed reader that can send messages to
contacts about relevant information..
20
22. Messaging
• Send (Email, SMS, MMS)
• Work with stored/remote messages
• Access message accounts
• New message notifications
• Retrieve
21
24. Messaging Example: Send Message
// get to address
QString to =
contact.detail<QContactEmailAddress>().emailAddress();
// prepare message
QMessage message;
message.setType(QMessage::Email);
message.setTo(QMessageAddress(to, QMessageAddress::Email));
message.setSubject(“Boating”);
message.setBody(“Here is a link you might like...”);
23
25. Messaging Example: Send Message
// send
QMessageServiceAction service;
connect(&service,
SIGNAL(stateChanged(QMessageServiceAction::State)), this,
SLOT(stateChanged(QMessageServiceAction::State)));
service.sendMessage(message);
// check send result
void MessageSender::stateChanged(
QMessageServiceAction::State state)
{
if (state == QMessageServiceAction::Successful)
// all good
24
26. Back to Bob
• Efficient Internet connection
• Access contact details
• Send messages to contacts
• The “I am going to be late”
application…
25
27. Location
• Where am I?
– Stream location data
• Be notified when within range of a
location
• Underlying location technology
agnostic
26
30. Location Example
// create source
source = new QNmeaPositionInfoSource(
QNmeaPositionInfoSource::SimulationMode, this);
// open NMEA data file and set as device for source
source->setUpdateInterval(1500);
connect(source, SIGNAL(positionUpdated(QGeoPositionInfo)),
this, SLOT(positionUpdated(QGeoPositionInfo)));
29
32. Back to Bob
• Efficient use of network
• Accessing contact details
• Sending messages to contacts
• Knows where user is
31
33. Other APIs for Application Developers
• Multimedia
• System Information
• Calendar (coming next year)
• Sensors (coming next year)
• More to come…
32
34. System Developer APIs
• Use case is focused more on development of a
system rather than an application
• Publish and subscribe
• Service framework
33
35. Publish and Subscribe
• Unifies various sources of hierarchical data into a
single consistent model
• Uses QVariant
/Device/Buttons = 3
/Device/Buttons/1/Name = Context
/Device/Buttons/1/Usable = true
/Device/Buttons/2/Name = Select
34
36. Service Framework
• Discover and work with
services
• Central service registry
• XML definition
• Out-of-process support
coming next year
35