Archived:How to send and receive SMS in Qt for Symbian
S60 5th Edition
This code snippets shows how to get send and receive messages in Qt. Mobile Extension APIs contains class XQMessaging and XQMessage which provide a way to send and receive messages.
This snippet requires ReadUserData , NetworkServices, WriteUserData ,UserEnvironment and LocalServices. Self-signing is not possible because a Developer certificate is needed.
- Download the latest Qt for S60 distribution from Qt.
- Install Qt for S60:Installing Qt on S60
- Check this link for installation guide: How to install the package.
- Go through this article: Getting started with Qt for S60
- Go through this article: How to use Mobile Extension APIs
Add following lines to your .pro file.
symbian:LIBS += -lsendas2 \
symbian:TARGET.CAPABILITY = NetworkServices \
For sending SMS we need to create message with XQMessage class. After creating message, send it using send() method of XQMessaging class. The following source code demostrate how to send SMS.
if (messaging.send(message) == XQMessaging::NoError)
msgBox.setText(tr("SMS was sent successfully"));
XQMessaging class emitt a signal messageReceived() when SMS is received, with reference of XQMessage class which has message body and sender information. so we need to catch that signal in your slots. The following source code demostrate how to receive SMS.
/* implement signal ans slots to listen all incoming message */
/* messaging is declared of type XQMessaging in header file.
* the slot receiveSMS() will get called on al incomming message */
connect(&messaging, SIGNAL(messageReceived(const XQMessage&)), this, SLOT(receiveSMS(const XQMessage&)));
/* receive incomming message */
void QtSMSOperation::receiveSMS(const XQMessage& message)
/* message.sender() contains the cell number of sender
* and message.body contain body part of message */
- The Code Example will show how to send and receive messages in Qt and is tested on Nokia 5800 XpressMusic.