Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Feb 2012

    IAP one click buy question

    I'm using the ButtonQMLPlugin from the one click buy example.
    In my QML file I want to know when the purchase was successful.
    I want to know when purchased() gets emitted but I'm not having any luck!
    I get this error code when running my app:
    [Qt Message] Button/RestoreButton.qml:29 ButtonQmlUi is not a type

    Here is my QML code:
    import QtQuick 1.0
    import ButtonQmlPlugin 1.0
    Rectangle {
        id: screen
        width: 220
        height: 146
        signal click
        onClick: {
        property alias cbLabelTextMainName: oneClickBuyButton.cbLabelTextMainName
        property alias cbLabelTextMainDescription: oneClickBuyButton.cbLabelTextMainDescription
        property alias cbLabelTextMainPrice: oneClickBuyButton.cbLabelTextMainPrice
        property alias cbLabelTextOperation: oneClickBuyButton.cbLabelTextOperation
        property alias cbGifVisibility: animationGif.visible
        ButtonQmlUi {
            onPurchased: {
                if( status==="OK") {
                   if( productID === "111111" ) {
                       //do stuff here

    I thought that is the right way to receive a signal?

    Out of interest here is the ButtonQMLUi.h file which processes the payment fine if I take out my attempt to receive that signal
    #ifndef EXAMPLEITEM_H
    #define EXAMPLEITEM_H
    #include <QDeclarativeItem>
    #include <QMap>
    #include <QVariant>
    #include <QRectF>
    #include <QTime>
    #include <iapclient.h>
    class QDeclarativeEngine;
    class QDeclarativeView;
    class QTranslator;
    class QLabel;
    class ButtonQmlUi : public QDeclarativeItem
            // status and tools needed by PageStack
            Q_PROPERTY(QString resourceId READ getResourceId WRITE setResourceId NOTIFY resourceIdChanged)
            Q_PROPERTY(QString cbLabelTextMainName READ getcbLabelTextMainName WRITE setcbLabelTextMainName NOTIFY cbLabelTextMainNameChanged)
            Q_PROPERTY(QString cbLabelTextMainDescription READ getcbLabelTextMainDescription WRITE setcbLabelTextMainDescription NOTIFY cbLabelTextMainDescriptionChanged)
            Q_PROPERTY(QString cbLabelTextMainPrice READ getcbLabelTextMainPrice WRITE setcbLabelTextMainPrice NOTIFY cbLabelTextMainPriceChanged)
            Q_PROPERTY(QString cbLabelTextOperation READ getcbLabelTextOperation WRITE setcbLabelTextOperation NOTIFY cbLabelTextOperationChanged)
            Q_PROPERTY(bool cbLoading READ getcbLoading WRITE setcbLoading NOTIFY cbLoadingChanged)
            void _setResourceId( const QString &theResourceId );
        public slots:
            void onPressed();
            void onPurchaseCompleted( int requestId, QString status, QString purchaseTicket );
            void onRestorationCompleted( int requestId, QString status, QString purchaseTicket );
            void onRestorableProductsReceived( int requestId, QString status, IAPClient::ProductDataList items );
            void onProductDataReceived( int requestId, QString status, IAPClient::ProductDataHash productData );
            void showLoading();
            void hideLoading();
            void purchased();
            void error();
            void resourceIdChanged();
            void cbLabelTextMainNameChanged();
            void cbLabelTextMainDescriptionChanged();
            void cbLabelTextMainPriceChanged();
            void cbLabelTextOperationChanged();
            void cbLoadingChanged();
            const QString getResourceId();
            void setResourceId(const QString);
            const QString getcbLabelTextMainName();
            void setcbLabelTextMainName(const QString);
            const QString getcbLabelTextMainDescription();
            void setcbLabelTextMainDescription(const QString);
            const QString getcbLabelTextMainPrice();
            void setcbLabelTextMainPrice(const QString);
            const QString getcbLabelTextOperation();
            void setcbLabelTextOperation(const QString);
            const bool getcbLoading();
            void setcbLoading(const bool);
            ButtonQmlUi(QDeclarativeItem *parent = 0);
            virtual ~ButtonQmlUi();
            void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
        //    void verifyTicket( const QString &thePurchaseTicket );
        //    QNetworkAccessManager *mNAM;
        //    QNetworkReply *mNReply;
            IAPClient *mIapClient;
            QString m_resourceId;
            QString m_cbLabelTextMainName;
            QString m_cbLabelTextMainDescription;
            QString m_cbLabelTextMainPrice;
            QString m_cbLabelTextOperation;
            bool m_cbLoading;
            bool mIsRestorable;
            IAPClient::DrmType mIsRestorableDRM;
            int mRestorableReqId;
            int mRestoreReqId;
            int mPurchaseReqId;
            QLabel *mProcessLabel;
            QLabel *mProcessLabelText;
            QLabel *mProcessLabelTextOperation;
            QLabel *mProcessLabelTextMain;
    #endif // EXAMPLEITEM_H
    I am trying to receive the purchased signal from the ButtonQMLplugin in a QML file and I can't get it to work

    Thanks for your help
    Last edited by symbianyucca; 2013-01-01 at 10:48. Reason: copied the misplaced posts in here

  2. #2
    Regular Contributor
    Join Date
    Feb 2012

    Re: IAP one click buy question

    I mustn't understand the implementation of signals and slots done here very well. It turns out that the class is called OneClickBuy and not ButtonQMLUi.

    Later on in the RestoreButton.QML file is this code:
            id: oneClickBuyButton
            resourceId: "111111"
    	    cbLabelTextMainName: ""
        	cbLabelTextMainDescription: ""
        	cbLabelTextMainPrice: ""
    	    cbLoading: true 
            onPurchased: {
    I have added the onPurchased handler there and it works.


    Edit: I found where the type name is set so I'm posting for completeness:
    The plugin has this line of code in the plugin header:
    void ButtonPlugin::registerTypes(const char *uri)
        qmlRegisterType<ButtonQmlUi>(uri, 1, 0, "OneClickBuy");
    Last edited by CLTSchwarz; 2013-01-01 at 18:12. Reason: Completeness

Similar Threads

  1. Need suggestions regarding Map Click
    By SecondInnings in forum Symbian
    Replies: 7
    Last Post: 2011-09-29, 15:20
  2. joystick righ click and left click and right menu option
    By omoshtagh in forum Mobile Java General
    Replies: 3
    Last Post: 2009-03-18, 09:56
  3. Beep or Click?
    By slitchfield in forum Symbian
    Replies: 12
    Last Post: 2008-06-17, 19:33
  4. MMP click
    By miriamgs in forum Symbian Tools & SDKs
    Replies: 0
    Last Post: 2005-02-09, 13:39

Posting Permissions

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