You Are Here:

Community: Wiki

This page was last modified on 31 October 2009, at 14:06.

How to send and receive messages in Qt for Symbian

From Forum Nokia Wiki

Reviewer Approved   


ID ... Creation date June 27, 2009
Platform S60 3rd Edition, FP1, FP2
S60 5th Edition
Tested on devices Nokia 5800 XpressMusic
Category Qt for S60 Subcategory Messaging


Keywords (APIs, classes, methods, functions): XQMessaging::send (), XQMessage

Overview

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.

Preconditions

Headers required

#include "XQMessaging.h"
#include "XQMessage.h"

.pro file

Add following lines to your .pro file.

symbian:LIBS += -lsendas2 \
-lmsgs \
-letext \
-lefsrv \
-lcharconv \
-lgsmu
symbian:TARGET.CAPABILITY = NetworkServices \
LocalServices \
ReadUserData \
WriteUserData \
UserEnvironment

Send SMS

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.

Source code

void QtSMSOperation::sendSMS()
{
XQMessaging messaging;
XQMessage message(QStringList("98433487876"),QString("Testing"));
 
if (messaging.send(message) == XQMessaging::NoError)
{
QMessageBox msgBox;
msgBox.setText(tr("SMS was sent successfully"));
msgBox.exec();
}
}

Receive SMS

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 */
QtSMSOperation::QtSMSOperation(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
/* 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&)));
messaging.startReceiving(XQMessaging::MsgTypeSMS);
}
 
/* 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 */

QMessageBox::information(0,message.sender(),message.body());
}

Code Example

  • The Code Example will show how to send and receive messages in Qt and is tested on Nokia 5800 XpressMusic.

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fCreatingE5fTicE2dTacE2dToeE5fusingE5fE51tE5fforE5fSymbianX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZE71tQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qfnZuserE5ftagQSxE71tX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ