Revision as of 17:27, 15 March 2010 by skumar_rao (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Archived:Send SMS using Qt Mobility

From Nokia Developer Wiki
Jump to: navigation, search
ID Creation date 15th Mar 2010
Platform S60 5th Edition Tested on devices Nokia N97 Mini
Category Qt for Symbian Subcategory Qt Mobility API

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

Underconstruction.pngUnder Construction: This article is under construction and it may have outstanding issues. If you have any comments please use the comments tab.

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



The below code shows how to send a SMS using Qt Mobility


Project configuration file (.Pro file)

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


#include <qtmessaging.h>
<code cpp>
<code cpp>
private slots:
void messageStateChanged(QMessageServiceAction::State s);
QMessageServiceAction m_MessageServiceAction;
QMessageId m_sendId;
<code cpp>
=== Source file ===
<code cpp>
// connect messageseives statechange 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.setTo(QMessageAddress(address, QMessageAddress::Phone));
if (iMessageServiceAction.send(message)) {
sendId = message.id();
else {
// message sending failed
void send_sms::messageStateChanged(QMessageServiceAction::State s) {
if (s == QMessageServiceAction::Successful) {
// message send successfull
else {
// message sending failed
<code cpp>
* QMessageServiceAction
* QMessageId
== Reference links==
* [http://qt.nokia.com/ Qt - cross-platform application and UI framework]
* [http://labs.trolltech.com/page/Projects/QtMobility Qt Mobility API]
* [http://qt.nokia.com/developer/new-qt-apis New Qt APIs Beta - Mobility Project]
* SDK help
165 page views in the last 30 days.