Revision as of 19:07, 15 March 2010 by skumar_rao (Talk | contribs)

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

Message receive notification 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): QMessageStore

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



Circle through all messages including SMS, MMS and Email from device


Project configuration file (.Pro file)

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

Header File

#include <qtmessaging.h>
private slots:
void messageAdded(const QMessageId &id, const QMessageStore::NotificationFilterIdSet &matchingFilterIds);
QMessageStore* msgStore;
QMessageFilter msgFilter;
QMessageStore::NotificationFilterId msgFilterId;

Source File

void send_notification::initialization() {    
msgStore = QMessageStore::instance();
QMessageFolderFilter folderFilter(QMessageFolderFilter::byDisplayName("Inbox"));
msgFilter = QMessageFilter::byParentFolderId(folderFilter);
void send_notification::register_to_receive_msgs() {
msgFilterId = msgStore->registerNotificationFilter(msgFilter);
connect(msgStore, SIGNAL(messageUpdated(QMessageId, QMessageStore::NotificationFilterIdSet)), this, SLOT(messageAdded(QMessageId, QMessageStore::NotificationFilterIdSet)));
void send_notification::deregister_to_receive_msgs() {
disconnect(msgStore, SIGNAL(messageAdded(QMessageId, QMessageStore::NotificationFilterIdSet)), this, SLOT(messageAdded(QMessageId, QMessageStore::NotificationFilterIdSet)));
void send_notification::messageAdded(const QMessageId &id, const QMessageStore::NotificationFilterIdSet &matchingFilterIds) {
if(id.isValid()) {
QMessage msgReceived(id);
QMessageContentContainer bodyPart = msgReceived.find(msgReceived.bodyId());
// bodyPart.isContentAvailable() : returns true if there is message body
QString bodyText = bodyPart.textContent();
QString msgSender = msgReceived.from().recipient();
else {
// Ignore this state


  • QMessageStore
  • QMessageFilter
  • QMessageStore::NotificationFilterId
  • QMessage

Reference links

95 page views in the last 30 days.