×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Nov 2010
    Location
    Phnom Penh
    Posts
    33

    What's wrong with my Code in Nokia QtSDK v1.1

    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
    Code:
    # 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()
    deployment.pri
    Code:
    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)
    }
    .h file
    Code:
    // 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
    .cpp file
    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");
            }
    }

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: What's wrong with my Code in Nokia QtSDK v1.1

    Symptoms? What have you learned from debugging?

  3. #3
    Registered User
    Join Date
    Nov 2010
    Location
    Phnom Penh
    Posts
    33

    Re: What's wrong with my Code in Nokia QtSDK v1.1

    Quote Originally Posted by danhicksbyron View Post
    Symptoms? What have you learned from debugging?
    + On the Qt Simulator, it will crash with exit code -1073741819

    + When build on the real phone, it show error like these:
    - /Test/SMS51/mainwindow.h:12: error: QMessage: No such file or directory
    - /Test/SMS51/mainwindow.h:13: error: QMessageService: No such file or directory
    - /Test/SMS51/mainwindow.h:17: error: expected constructor, destructor, or type conversion before 'namespace'
    - /Test/SMS51/mainwindow.h:36: error: 'QMessage' does not name a type
    - /Test/SMS51/mainwindow.h:37: error: ISO C++ forbids declaration of 'QMessageService' with no type
    - /Test/SMS51/mainwindow.h:37: error: expected ';' before '*' token
    - /Test/SMS51/mainwindow.h:42: error: 'QMessageService' has not been declared
    - /Test/SMS51/mainwindow.h:42: error: expected ',' or '...' before 's'
    - /Test/SMS51/mainwindow.h:45: error: 'Ui' has not been declared
    - /Test/SMS51/mainwindow.h:45: error: ISO C++ forbids declaration of 'MainWindow' with no type
    - /Test/SMS51/mainwindow.h:45: error: expected ';' before '*' token

  4. #4
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: What's wrong with my Code in Nokia QtSDK v1.1

    You should use angle brackets when including system files, for example
    Code:
    #include <QMessageService>

Similar Threads

  1. What's wrong with my keycapture code?
    By forumz in forum Symbian
    Replies: 3
    Last Post: 2009-04-02, 16:40
  2. Replies: 8
    Last Post: 2006-11-08, 03:09
  3. What's wrong with my code?
    By ninidotnet in forum Symbian User Interface
    Replies: 2
    Last Post: 2006-09-28, 02:31
  4. Progress bars: what's wrong with my code?
    By bobline in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2003-05-29, 18:10
  5. What's wrong in my code?
    By paspau in forum General Messaging
    Replies: 2
    Last Post: 2002-07-22, 10:38

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •