Hi all,
I have developed a simple program for sending SMS which run well on both Simulator and on the real phone.
The problem is that: in the previous version of Nokia QtSDK(1.0.2), My program run well but in Nokia QtSDK(v.1.1).
Please see the code below:
.Pro file
deployment.priCode:# Add files and directories to ship with the application # by adapting the examples below. # file1.source = myfile # dir1.source = mydir DEPLOYMENTFOLDERS = # file1 dir1 # Avoid auto screen rotation #DEFINES += ORIENTATIONLOCK # Needs to be defined for Symbian #DEFINES += NETWORKACCESS symbian:TARGET.UID3 = 0xE0ABC611 # If your application uses the Qt Mobility libraries, uncomment # the following lines and add the respective components to the # MOBILITY variable. CONFIG += mobility MOBILITY +=messaging symbian { TARGET.CAPABILITY += LocalServices ReadUserData WriteUserData NetworkServices UserEnvironment ReadDeviceData WriteDeviceData } SOURCES += main.cpp mainwindow.cpp HEADERS += mainwindow.h FORMS += mainwindow.ui # Please do not modify the following two lines. Required for deployment. include(deployment.pri) qtcAddDeployment()
.h fileCode:defineTest(qtcAddDeployment) { for(deploymentfolder, DEPLOYMENTFOLDERS) { item = item$${deploymentfolder} itemsources = $${item}.sources $$itemsources = $$eval($${deploymentfolder}.source) itempath = $${item}.path $$itempath= $$eval($${deploymentfolder}.target) export($$itemsources) export($$itempath) DEPLOYMENT += $$item } MAINPROFILEPWD = $$PWD symbian { ICON = $${TARGET}.svg TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 contains(DEFINES, ORIENTATIONLOCK):LIBS += -lavkon -leikcore -lcone contains(DEFINES, NETWORKACCESS):TARGET.CAPABILITY += NetworkServices } else:win32 { copyCommand = for(deploymentfolder, DEPLOYMENTFOLDERS) { source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) source = $$replace(source, /, \\) sourcePathSegments = $$split(source, \\) target = $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(sourcePathSegments) target = $$replace(target, /, \\) !isEqual(source,$$target) { !isEmpty(copyCommand):copyCommand += && copyCommand += $(COPY_DIR) \"$$source\" \"$$target\" } } !isEmpty(copyCommand) { copyCommand = @echo Copying application data... && $$copyCommand copydeploymentfolders.commands = $$copyCommand first.depends = $(first) copydeploymentfolders export(first.depends) export(copydeploymentfolders.commands) QMAKE_EXTRA_TARGETS += first copydeploymentfolders } } else:unix { maemo5 { installPrefix = /opt/usr desktopfile.path = /usr/share/applications/hildon } else { installPrefix = /usr/local desktopfile.path = /usr/share/applications copyCommand = for(deploymentfolder, DEPLOYMENTFOLDERS) { source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) source = $$replace(source, \\, /) macx { target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target) } else { target = $$OUT_PWD/$$eval($${deploymentfolder}.target) } target = $$replace(target, \\, /) sourcePathSegments = $$split(source, /) targetFullPath = $$target/$$last(sourcePathSegments) !isEqual(source,$$targetFullPath) { !isEmpty(copyCommand):copyCommand += && copyCommand += $(MKDIR) \"$$target\" copyCommand += && $(COPY_DIR) \"$$source\" \"$$target\" } } !isEmpty(copyCommand) { copyCommand = @echo Copying application data... && $$copyCommand copydeploymentfolders.commands = $$copyCommand first.depends = $(first) copydeploymentfolders export(first.depends) export(copydeploymentfolders.commands) QMAKE_EXTRA_TARGETS += first copydeploymentfolders } } for(deploymentfolder, DEPLOYMENTFOLDERS) { item = item$${deploymentfolder} itemfiles = $${item}.files $$itemfiles = $$eval($${deploymentfolder}.source) itempath = $${item}.path $$itempath = $${installPrefix}/share/$${TARGET}/$$eval($${deploymentfolder}.target) export($$itemfiles) export($$itempath) INSTALLS += $$item } icon.files = $${TARGET}.png icon.path = /usr/share/icons/hicolor/64x64/apps desktopfile.files = $${TARGET}.desktop target.path = $${installPrefix}/bin export(icon.files) export(icon.path) export(desktopfile.files) export(desktopfile.path) export(target.path) INSTALLS += desktopfile icon target } export (ICON) export (INSTALLS) export (DEPLOYMENT) export (TARGET.EPOCHEAPSIZE) export (TARGET.CAPABILITY) export (LIBS) export (QMAKE_EXTRA_TARGETS) }
.cpp fileCode:// checksum 0x9a77 version 0x20001 #ifndef MAINWINDOW_H #define MAINWINDOW_H #include "QMessage" #include "QMessageService" #include <QtGui/QMainWindow> QTM_USE_NAMESPACE namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: enum ScreenOrientation { ScreenOrientationLockPortrait, ScreenOrientationLockLandscape, ScreenOrientationAuto }; explicit MainWindow(QWidget *parent = 0); virtual ~MainWindow(); void setOrientation(ScreenOrientation orientation); void showExpanded(); QMessage message; QMessageService * m_service; bool sendSMS(); private slots: void on_pushButton_clicked(); void stateChanged(QMessageService::State s); private: Ui::MainWindow *ui; }; #endif // MAINWINDOW_H
Code:#include "mainwindow.h" #include "ui_mainwindow.h" #include <QtCore/QCoreApplication> #include "QMessage" #include "QMessageBox" #include "QMessageService" #if defined(Q_OS_SYMBIAN) && defined(ORIENTATIONLOCK) #include <eikenv.h> #include <eikappui.h> #include <aknenv.h> #include <aknappui.h> #endif // Q_OS_SYMBIAN && ORIENTATIONLOCK QTM_USE_NAMESPACE MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; } void MainWindow::setOrientation(ScreenOrientation orientation) { #ifdef Q_OS_SYMBIAN if (orientation != ScreenOrientationAuto) { #if defined(ORIENTATIONLOCK) const CAknAppUiBase::TAppUiOrientation uiOrientation = (orientation == ScreenOrientationLockPortrait) ? CAknAppUi::EAppUiOrientationPortrait : CAknAppUi::EAppUiOrientationLandscape; CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi()); TRAPD(error, if (appUi) appUi->SetOrientationL(uiOrientation); ); Q_UNUSED(error) #else // ORIENTATIONLOCK qWarning("'ORIENTATIONLOCK' needs to be defined on Symbian when locking the orientation."); #endif // ORIENTATIONLOCK } #elif defined(Q_WS_MAEMO_5) Qt::WidgetAttribute attribute; switch (orientation) { case ScreenOrientationLockPortrait: attribute = Qt::WA_Maemo5PortraitOrientation; break; case ScreenOrientationLockLandscape: attribute = Qt::WA_Maemo5LandscapeOrientation; break; case ScreenOrientationAuto: default: attribute = Qt::WA_Maemo5AutoOrientation; break; } setAttribute(attribute, true); #else // Q_OS_SYMBIAN Q_UNUSED(orientation); #endif // Q_OS_SYMBIAN } void MainWindow::showExpanded() { #ifdef Q_OS_SYMBIAN showFullScreen(); #elif defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) showMaximized(); #else show(); #endif } void MainWindow::on_pushButton_clicked() { if( sendSMS()){ QMessageBox::information(this,"SMS","Sending Success"); } } bool MainWindow::sendSMS(){ message.setType(QMessage::Sms); QMessageAddress::Type addressType = QMessageAddress::Phone; QMessageAddressList to; QString body= ""; QString longitude = "001"; QString latitude = "002"; to.append(QMessageAddress(addressType,"012930824")); message.setTo(to); body = "Lat : "+ latitude + "\n" + "\n Lon : " + longitude+"\n"; message.setBody(body); return m_service->send(message); } void MainWindow::stateChanged(QMessageService::State s){ if(s==QMessageService::FinishedState){ QMessageBox::information(this,"Send SMS","Message sent"); } else if(s==QMessageService::CanceledState){ QMessageBox::warning(this,"Send SMS","Sending message failed"); } }




