×
Namespaces

Variants
Actions
(Difference between revisions)

Archived:Send SMS using Qt Mobility

From Nokia Developer Wiki
Jump to: navigation, search
seppo_fn (Talk | contribs)
m
copyeditor (Talk | contribs)
m
Line 1: Line 1:
[[Category:Qt for Symbian]][[Category:Qt for Symbian]]
+
[[Category:Qt for Symbian]][[Category:Qt for Symbian]][[Category:Code Examples]][[Category:Code Snippet]]
 +
{{KBCS}}
 
'''Author Skumar rao'''  
 
'''Author Skumar rao'''  
 
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"  
 
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"  
 
|-
 
|-
|'''ID''' ||  
+
|'''ID''' || CS001616
|'''Creation date''' || 15th Mar 2010
+
|'''Creation date''' || July 7 2010
 
|-
 
|-
 
|'''Platform''' || S60 5th Edition, Maemo 5
 
|'''Platform''' || S60 5th Edition, Maemo 5
Line 23: Line 24:
  
 
== Overview ==  
 
== Overview ==  
The below code shows how to send a SMS using Qt Mobility
+
The following code shows how to send an SMS using Qt Mobility.
  
 
== Keywords ==
 
== Keywords ==
Line 34: Line 35:
 
</code>
 
</code>
  
Using Messaging needs [[ReadUserData]] and [[WriteUserData]] capabilities from the ''user granted'' category.
+
The use of Messaging requires the [[ReadUserData]] and [[WriteUserData]] capabilities from the '''user granted''' category.
It also needs [[ReadDeviceData]] and [[WriteDeviceData]] capabilities from ''open signed online'' category. Read more about [[Capabilities]].
+
It also requires the [[ReadDeviceData]] and [[WriteDeviceData]] capabilities from the '''open signed online''' category. Read more about [[Capabilities]].
  
 
<code cpp>
 
<code cpp>

Revision as of 12:58, 7 July 2010

Template:KBCS Author Skumar rao

ID CS001616 Creation date July 7 2010
Platform S60 5th Edition, Maemo 5 Tested on devices Nokia N97 Mini, Nokia N900
Category Qt Subcategory Qt Mobility API


Keywords (APIs, classes, methods, functions): QMessageServiceAction, QMessageId

Tip.pngTip: Read this article before moving forward: Setting up environment for Qt Mobility API

Contents

Overview

The following code shows how to send an SMS using Qt Mobility.

Keywords

Project configuration file (.Pro file)

  • Add the Qt Mobility project configuration option in the .Pro file as shown below
CONFIG += mobility
MOBILITY += messaging

The use of Messaging requires the ReadUserData and WriteUserData capabilities from the user granted category. It also requires the ReadDeviceData and WriteDeviceData capabilities from the open signed online category. Read more about Capabilities.

symbian {
TARGET.CAPABILITY = ReadUserData \
WriteUserData \
ReadDeviceData \
WriteDeviceData
}

Headers

#include <qtmessaging.h>
 
private slots:
void messageStateChanged(QMessageServiceAction::State s);
private:
QMessageServiceAction m_MessageServiceAction;
QMessageId m_sendId;

Source file

// connect messages state-change signal to our slot, to get notification    
connect(&m_MessageServiceAction, SIGNAL(stateChanged(QMessageServiceAction::State)), this, SLOT(messageStateChanged(QMessageServiceAction::State)));
 
void send_sms::QtSendSMSMessage(QString address, QString body) {
// Prepare QMessage with address & body
QMessage message;
message.setType(QMessage::Sms);
message.setTo(QMessageAddress(address, QMessageAddress::Phone));
message.setBody(body);
 
if (iMessageServiceAction.send(message)) {
sendId = message.id();
}
else {
// message sending failed
}
}
 
void send_sms::messageStateChanged(QMessageServiceAction::State s) {
if (s == QMessageServiceAction::Successful) {
// message send successful
}
else {
// message sending failed
}
}

Classes

Reference links

--skumar_rao 02:41, 16 March 2010 (UTC)

338 page views in the last 30 days.
×