public Q_SLOTS vs Q_INVOKABLE

Hello

I'm looking at some code examples and he uses public Q_SLOTS and to seems to me there is no difference between the public Q_SLOTS and Q_INVOKABLE. Is there a difference and what is? Thank you

Here is a link to the source. The statement in question is upload. For me, this could be a Q_INVOKABLE as there is no part of a signal/slot.

https://github.com/amonchakai/HFRBlack/BLOB/master/src/ImageUploaderController.hpp

https://github.com/amonchakai/HFRBlack/BLOB/master/src/ImageUploaderController.cpp

A Q_SLOT is Q_INVOKABLEbut not vice versa. A function like Q_INVOKABLE reporting allows you to call the function of QML (as long as you sign your class with qmlRegisterType()), but NOT to use as a receiver for a Q_SIGNAL. If, however, you declare your function like Q_SLOT then you can use it both ways. Although it does not not clear BlackBerry documentation or Qt, change a function with Q_SLOT declaration also makes Q_INVOKABLE.

Of course, you should not use the Q_SLOT modifier if you place your statement of function like this:

public slots:
    void mySlot();

Hope this clears up things.

Tags: BlackBerry Developers

Similar Questions

  • App rejected with application settings management

    Hello

    I am a new developer, and I'm trying to implement a configuration management in my application. I found some information on the forum and other Internet site. When I test it with the Simulator (10.2.1 and 10.3) and my devices (Blackberry Z30 and passport) it works without any problem.

    My question is when I am trying to release my app on BlackBerry World, BlackBerry test team rejected it and told me that they cannot launch my application when they tap the... I asked explanations more because I couldn't reproduce this problem and they sent me a video of the bug (every time they tap the add anything...).

    I still don't understand how they can have this question if the test tool with my devices, everything is ok...

    Can you help me understand what's wrong in my code that could explain this bug?

    Here is my code for layout management:

    main.cpp
    
    #include "applicationui.hpp"
    
    #include 
    
    #include 
    #include 
    
    #include 
    
    using namespace bb::cascades;
    
    int main(int argc, char **argv)
    {
        // this is where the server is started etc
        Application app(argc, argv);
    
        // localization support
        QTranslator translator;
        QString locale_string = QLocale().name();
        QString filename = QString( "PourcentagesFaciles_%1" ).arg( locale_string );
        if (translator.load(filename, "app/native/qm")) {
            app.installTranslator( &translator );
        }
        // create the application pane object to init UI etc.
        new ApplicationUI(&app);
        // we complete the transaction started in the app constructor and start the client event loop here
        return Application::exec();
        // when loop is exited the Application deletes the scene which deletes all its children (per qt rules for children)
    }
    
    Applicationui.hpp
    
    #ifndef ApplicationUI_HPP_
    #define ApplicationUI_HPP_
    
    #include 
    
    namespace bb {
        namespace cascades {
            class Application;
        }
    }
    
    class QTranslator;
    
    class ApplicationUI : public QObject
    {
        Q_OBJECT
        public:
        ApplicationUI(bb::cascades::Application *app);
        ~ApplicationUI();
    
        Q_INVOKABLE
        QString getValueFor(const QString &objectName, const QString &defaultValue);
        Q_INVOKABLE
        void saveValueFor(const QString &objectName, const QString &inputValue);
    };
    
    #endif /* ApplicationUI_HPP_ */
    
    applicationui.cpp
    
    #include "applicationui.hpp"
    
    #include 
    #include 
    #include 
    #include 
    #include 
    
    using namespace bb::cascades;
    
    ApplicationUI::ApplicationUI(bb::cascades::Application *app)
    : QObject(app)
    {
        QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
        qml->setContextProperty("_app", this);
    
        AbstractPane *root = qml->createRootObject();
    
        app->setScene(root);
    }
    
    ApplicationUI::~ApplicationUI()
    {
    
    }
    
    QString ApplicationUI::getValueFor(const QString &objectName, const QString &defaultValue)
    {
        QSettings settings;
    
        if (settings.value(objectName).isNull()) {
            return defaultValue;
        }
    
        return settings.value(objectName).toString();
    }
    
    void ApplicationUI::saveValueFor(const QString &objectName, const QString &inputValue)
    {
        QSettings settings;
    
        settings.setValue(objectName, QVariant(inputValue));
    }
    

    I found a solution to my problem by changing the code.

    I write the code in case someone had the same problem as me.

    main.cpp

    #include "applicationui.hpp"
    #include 
    
    #include 
    
    #include 
    #include 
    #include 
    
    #include 
    
    using ::bb::cascades::Application;
    
    Q_DECL_EXPORT int main(int argc, char **argv)
    {
        Application app(argc, argv);
    
        ApplicationUI mainApp;
    
        return Application::exec();
    }
    

    applicationui. HPP

    #ifndef ApplicationUI_HPP_
    #define ApplicationUI_HPP_
    
    #include 
    
    namespace bb
    {
        namespace cascades
        {
            class LocaleHandler;
        }
    }
    
    class QTranslator;
    
    class ApplicationUI : public QObject
    {
        Q_OBJECT
    
            public:
            ApplicationUI();
            ~ApplicationUI();
    
            Q_INVOKABLE QString getValueFor(const QString &objectName, const QString &defaultValue);
            Q_INVOKABLE void saveValueFor(const QString &objectName, const QString &inputValue);
    
            private:
    
            Q_SLOT void onSystemLanguageChanged();
    
            QTranslator* mTranslator;
    
            bb::cascades::LocaleHandler* mLocaleHandler;
    };
    
    #endif /* ApplicationUI_HPP_ */
    

    applicationui.cpp

    #include "applicationui.hpp"
    
    #include 
    #include 
    #include 
    #include 
    #include 
    
    using namespace bb::cascades;
    
    ApplicationUI::ApplicationUI()
    {
        QCoreApplication::setOrganizationName("test babou en carton");
        QCoreApplication::setApplicationName("test babou en carton");
    
        mTranslator = new QTranslator(this);
        mLocaleHandler = new LocaleHandler(this);
        onSystemLanguageChanged();
        bool connectResult = connect(mLocaleHandler, SIGNAL(systemLanguageChanged()), SLOT(onSystemLanguageChanged()));
        Q_UNUSED(connectResult);
    
        QmlDocument *qml = QmlDocument::create("asset:///main.qml");
        qml->setContextProperty("_app", this);
    
        if (!qml->hasErrors()) {
            AbstractPane *appPane = qml->createRootObject();
            if (appPane) {
                Application::instance()->setScene(appPane);
            }
        }
    }
    
    ApplicationUI::~ApplicationUI()
    {
    
    }
    
    QString ApplicationUI::getValueFor(const QString &objectName, const QString &defaultValue)
    {
        QSettings settings;
    
        if (settings.value(objectName).isNull()) {
            return defaultValue;
        }
    
        return settings.value(objectName).toString();
    }
    
    void ApplicationUI::saveValueFor(const QString &objectName, const QString &inputValue)
    {
        QSettings settings;
        settings.setValue(objectName, QVariant(inputValue));
    }
    
    void ApplicationUI::onSystemLanguageChanged()
    {
        QCoreApplication::instance()->removeTranslator(mTranslator);
    
        QString localeString = QLocale().name();
        QString fileName = QString("testBabouEnCarton_%1").arg(localeString);
        if (mTranslator->load(fileName, "app/native/qm")) {
            QCoreApplication::instance()->installTranslator(mTranslator);
        }
        qDebug() << "language " << localeString;
    }
    
  • BB10 network plugin fails on the second call

    Hi all

    I created a plugin(native extension) network that works very well when you call the first javascript application.

    The entrance to this extension is: {'url' ": '"http://example.com ', imeOut: '4'}

    When I try to call this plugin the next time, he demonstrated "operation cancelled" due to the delay. If I delete the time-out period of extension, not getting not response in onRequestFinished and it returns nothing for javascript application.

    Please, help me find an error code below.

    It is very urgent.

    Thanks in advance.

    template_js.hpp
    
    #ifndef TemplateJS_HPP_
    #define TemplateJS_HPP_
    
    #include 
    #include "../public/plugin.h"
    #include "template_ndk.hpp"
    
    class TemplateJS: public JSExt {
    
    public:
        explicit TemplateJS(const std::string& id);
        virtual ~TemplateJS();
        virtual bool CanDelete();
        virtual std::string InvokeMethod(const std::string& command);
        void NotifyEvent(const std::string& event);
        bool StartThread();
        std::string params;
    
    private:
        std::string m_id;
    
    };
    
    #endif /* TemplateJS_HPP_ */
    
    
    
    template_js.cpp
    
    #include #include "../public/tokenizer.h"#include #include "template_js.hpp"#include "template_ndk.hpp"
    
    using namespace std;
    
    /** * Default constructor. */TemplateJS::TemplateJS(const std::string& id) : m_id(id) {
    
    }
    
    /** * TemplateJS destructor. */TemplateJS::~TemplateJS() {
    
    }
    
    /** * This method returns the list of objects implemented by this native * extension. */char* onGetObjList() { static char name[] = "TemplateJS"; return name;}
    
    /** * This method is used by JNext to instantiate the TemplateJS object when * an object is created on the JavaScript server side. */JSExt* onCreateObject(const string& className, const string& id) { if (className == "TemplateJS") { return new TemplateJS(id); }
    
     return NULL;}
    
    /** * Method used by JNext to determine if the object can be deleted. */bool TemplateJS::CanDelete() { return true;}
    
    /** * It will be called from JNext JavaScript side with passed string. * This method implements the interface for the JavaScript to native binding * for invoking native code. This method is triggered when JNext.invoke is * called on the JavaScript side with this native objects id. */string TemplateJS::InvokeMethod(const string& command) { // command appears with parameters following after a space int index = command.find_first_of(" "); std::string strCommand = command.substr(0, index); std::string arg = command.substr(index + 1, command.length()); params = arg; if (strCommand == "doNSIRequest") { StartThread(); strCommand.append(";"); strCommand.append(command); return strCommand; }
    
     return "Unknown C++ method";}
    
    void* SignalThread(void* parent) { TemplateJS *pParent = static_cast(parent);
    
     int argc = 0; char **argv = NULL; QCoreApplication QCoreApplication(argc, argv); webworks::TemplateNDK *m_signalHandler = new webworks::TemplateNDK(pParent); m_signalHandler->doNetworkRequest();
    
     QCoreApplication::exec(); delete m_signalHandler; return NULL;}
    
    bool TemplateJS::StartThread(){
    
     pthread_attr_t thread_attr; pthread_attr_init(&thread_attr); pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED);
    
     pthread_t m_thread; pthread_create(&m_thread, &thread_attr, SignalThread, static_cast(this)); pthread_attr_destroy(&thread_attr); if (!m_thread) { return true; } else { return false; }}
    
    // Notifies JavaScript of an eventvoid TemplateJS::NotifyEvent(const std::string& event) { std::string eventString = m_id + " "; eventString.append(event); SendPluginEvent(eventString.c_str(), m_pContext);}
    
    template_ndk.hpp
    
    
    
    #ifndef TEMPLATENDK_HPP_#define TEMPLATENDK_HPP_
    
    #include #include #include #include #include 
    
    using namespace bb::device;
    
    class TemplateJS;
    
    namespace webworks {
    
    class TemplateNDK : public QObject {
    
     Q_OBJECT
    
    public: explicit TemplateNDK(TemplateJS *parent = NULL); virtual ~TemplateNDK(); void doNetworkRequest();
    
    public Q_SLOTS: void onRequestFinished(QNetworkReply *reply); void connectionStateChanged (bb::device::CellularConnectionState::Type connectionState); void onNetworkTimeOut();
    
    private: void doNSIRequest(); void disconnectService(); void parseXml(const QByteArray buffer, int httpCode, QString status, QString errorInfo); void parseJsonParams();
    
    private: TemplateJS *m_pParent; QNetworkAccessManager *_networkAccessManager; CellularDataInterface *_cellularDataInterface; int networkTimeout; std::string url;};
    
    } // namespace webworks
    
    #endif /* TEMPLATENDK_H_ */
    
    
    
    template_ndk.cpp
    
    #include #include #include #include #include #include #include #include "template_ndk.hpp"#include "template_js.hpp"
    
    namespace webworks {
    
    TemplateNDK::TemplateNDK(TemplateJS *parent) {
    
     m_pParent = parent; _networkAccessManager = 0; _cellularDataInterface = 0; networkTimeout = 0; url = "";
    
    }
    
    TemplateNDK::~TemplateNDK() {
    
     if (_networkAccessManager){ delete _networkAccessManager; _networkAccessManager = 0; } if (_cellularDataInterface) { if (_cellularDataInterface->connectionState() == CellularConnectionState::Connected) { disconnectService(); } delete _cellularDataInterface; _cellularDataInterface = 0; } if(m_pParent){ delete m_pParent; m_pParent = 0; }}
    
    void TemplateNDK::doNetworkRequest(){ _networkAccessManager = new QNetworkAccessManager(); _cellularDataInterface = new CellularDataInterface(); connect( _networkAccessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(onRequestFinished(QNetworkReply*)));
    
     connect(_cellularDataInterface, SIGNAL(connectionStateChanged(bb::device::CellularConnectionState::Type)), this, SLOT(connectionStateChanged(bb::device::CellularConnectionState::Type)));
    
     parseJsonParams();
    
     doNSIRequest();}
    
    void TemplateNDK::parseJsonParams() { std::string networkParams = m_pParent->params;
    
     // Parse the arg string as JSON Json::FastWriter writer; Json::Reader reader; Json::Value root; bool parse = reader.parse(networkParams, root);
    
     if (!parse) {
    
     QByteArray buffer(NULL); parseXml(buffer, 1, "fail", "Cannot parse input JSON object");
    
     } else {
    
     url = root["url"].asString(); int timeout = root["timeOutValue"].asInt(); networkTimeout = timeout * 1000; //converting into milliseconds
    
     }}
    
    /** * Set name for mobile data and attempt to activate the network connection if name is valid */
    
    void TemplateNDK::doNSIRequest() { _cellularDataInterface->setName("blackberry"); if (_cellularDataInterface->isValid()) { QString networkInterfaceName =_cellularDataInterface->networkInterfaceName();
    
     if (!networkInterfaceName.isEmpty()) { _cellularDataInterface->requestConnect(); } else { QByteArray buffer(NULL); QString strError = "Mobile data off"; parseXml(buffer, 1, "fail", strError); }
    
     } else { QByteArray buffer(NULL); QString strError = ""; if (_cellularDataInterface->networkInterfaceName() == ""){ strError = "No Sim Available"; }else{ strError = "Invalid cellular data services"; }
    
     parseXml(buffer, 1, "fail", strError); }}
    
    /** * Attempt to de-activate the network connection */
    
    void TemplateNDK::disconnectService(){ _cellularDataInterface->requestDisconnect(); unsetenv("SOCK_SO_BINDTODEVICE");}
    
    /** * Slot getting called after successful connection to Mobile data. * If connected then send server request else handling error */
    
    void TemplateNDK::connectionStateChanged (bb::device::CellularConnectionState::Type connectionState){ QString strError = ""; if (connectionState == CellularConnectionState::Connected) {
    
     int EOK = 0; if (setenv("SOCK_SO_BINDTODEVICE", _cellularDataInterface->networkInterfaceName().toAscii().constData(), 1) == EOK) { QNetworkRequest request = QNetworkRequest(); QString inputUrl = QString::fromUtf8(url.c_str()); request.setUrl(QUrl(inputUrl)); QNetworkReply* response = _networkAccessManager->get(request);
    
     QTimer *timer = new QTimer(response); timer->setSingleShot(true); connect(timer, SIGNAL(timeout()), this, SLOT(onNetworkTimeOut())); timer->start(networkTimeout);
    
     } else { strError = "Not connected to 2g/3g connection! Please try again"; }
    
     } else if (connectionState == CellularConnectionState::PendingConnect) { strError = "Pending Connect! Please try again";
    
     } else if (connectionState == CellularConnectionState::Disconnected) { strError = "Disconnected! Please try again"; unsetenv("SOCK_SO_BINDTODEVICE");
    
     } else { strError = "Not Connected! Please try again"; } if (!strError.isEmpty()){ QByteArray buffer(NULL); parseXml(buffer, 2, "fail", strError); }
    
    }
    
    void TemplateNDK::onNetworkTimeOut() { QTimer *timer = qobject_cast(sender()); QNetworkReply *response = qobject_cast(timer->parent()); response->abort();}
    
    /** * Handling response coming from server */void TemplateNDK::onRequestFinished(QNetworkReply *reply){ int httpStatusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); httpStatusCode = reply->error(); QString status = ""; QByteArray buffer(NULL); QString strErrorInfo = ""; if (reply->error() == QNetworkReply::NoError) {
    
     const int available = reply->bytesAvailable(); if (available > 0) { status = "success"; buffer = reply->readAll();
    
     }else{ status = "fail"; httpStatusCode = 2; strErrorInfo = "Response is null"; }
    
     } else {
    
     strErrorInfo = reply->errorString(); if (strErrorInfo.contains("\"\"")) { //case like: Protocol "" is unknown strErrorInfo = strErrorInfo.remove("\"\""); } status = "fail";
    
     } parseXml(buffer, httpStatusCode, status, strErrorInfo); reply->deleteLater();}
    
    /** * parses xml coming from server as response, Create JSON object and calling notify */void TemplateNDK::parseXml(const QByteArray buffer, int httpCode, QString status, QString errorInfo) { QXmlStreamReader xml; std::string event = "NSI_requestCallbackResult";
    
     // Parse the arg string as JSON Json::FastWriter writer; Json::Reader reader; Json::Value root;
    
     root["language"] = ""; root["subId2"] = ""; root["accountSubType"] = ""; root["status"] = status.toLocal8Bit().constData(); root["httpCode"] = httpCode; root["errorInfo"] = errorInfo.toLocal8Bit().constData();
    
     try{ if (!buffer.isNull()) { xml.addData(buffer);
    
     while (!xml.atEnd()) { xml.readNext();
    
     if (xml.isStartElement()) { if (xml.name() == "eamLanguage") { root["language"] = xml.readElementText().toLocal8Bit().constData();
    
     } if (xml.name() == "subId2") { root["subId2"] = xml.readElementText().toLocal8Bit().constData(); } if (xml.name() == "accountSubType") { root["accountSubType"] = xml.readElementText().toLocal8Bit().constData(); } }
    
     } } }catch (...) { QString status = "fail"; int httpCode = 2; QString strBuffer(buffer); QString errorInfo = "Exception:FormatException Function:parseXml ServerResponse: " + strBuffer;
    
     root["status"] = status.toLocal8Bit().constData(); root["httpCode"] = httpCode; root["errorInfo"] = errorInfo.toLocal8Bit().constData(); }
    
     m_pParent->NotifyEvent(event + " " + writer.write(root));
    
    }
    
    } /* namespace webworks */
    

    Finally I found the solution of the present.

    Question is due to every javascript function call new pthread is be created every time and existing thread is never destroyed. However, I assumed that this local variable of pthread_t destroyed but it is not run like that. If trying to kill thread existing manually using pthread_cancel(), application crashes. Application of network function is called in this thread and QNetworkAccessManager slot is never get called except for the first time.

    To solve it, I used a public global variable that allow to create the thread only once and give the signal for the following applications when native code receives a StartThread function call. For signalling, used pthread mutex lock and characteristic signal.

    Here is the code for the function StartThread:

    bool TemplateJS::StartThread()
    {
    
        parseJsonParams();
    
        if (!g1.g_isSignalThreadCreated) {
            g1.g_isSignalThreadCreated = true;
    
            pthread_attr_t thread_attr;
            pthread_attr_init(&thread_attr);
            pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED);
            pthread_t m_thread;
            pthread_create(&m_thread, &thread_attr, SignalThread, static_cast(this));
            pthread_attr_destroy(&thread_attr);
    
        } else {
            pthread_mutex_lock(&mutex);
            pthread_cond_signal(&cond);
            pthread_mutex_unlock(&mutex);
    
        }
        return true;
    }
    

    And here's the code must call after event notification.

    void TemplateNDK::Workerthread_waitForNextTime()
        {
            pthread_mutex_lock(&mutex);
            pthread_cond_wait(&cond, &mutex);
            pthread_mutex_unlock(&mutex);
    
            //keeps waiting here until get Signal from StartThread.
            doNetworkRequest();
        }
    
  • Strange behavior of ListView

    Hello
    I use following code:

     ListView {       id: listView listItemComponents: ListItemComponent {           Container {               id: listItemContainer               property string packageId: ListItemData.packageId               property variant packageDetailsPage               layout: AbsoluteLayout { }               WebImageView               {                   preferredHeight: 290                   preferredWidth: 751                   url: ListItemData.url;              }          }     }
    

    code for WebImageView:

    webimageview. HPP

    #ifndef WEBIMAGEVIEW_H_
    #define WEBIMAGEVIEW_H_
    
    #include 
    #include 
    #include 
    #include 
    using namespace bb::cascades;
    
    class WebImageView: public bb::cascades::ImageView {
        Q_OBJECT
        Q_PROPERTY (QUrl url READ url WRITE setUrl NOTIFY urlChanged)
        Q_PROPERTY (float loading READ loading NOTIFY loadingChanged)
    
    public:
        WebImageView();
        const QUrl& url() const;
        double loading() const;
    
        public Q_SLOTS:
        void setUrl(const QUrl& url);
        void clearCache();
    
        private Q_SLOTS:
        void imageLoaded();
        void dowloadProgressed(qint64,qint64);
    
        signals:
        void urlChanged();
        void loadingChanged();
    
    private:
        static QNetworkAccessManager * mNetManager;
        static QNetworkDiskCache * mNetworkDiskCache;
        QUrl mUrl;
        float mLoading;
    
        bool isARedirectedUrl(QNetworkReply *reply);
        void setURLToRedirectedUrl(QNetworkReply *reply);
    };
    
    #endif /* WEBIMAGEVIEW_H_ */
    

    webimageview.cpp

    #include "WebImageView.h"
    #include 
    #include 
    //#include 
    #include 
    
    using namespace bb::cascades;
    
    QNetworkAccessManager * WebImageView::mNetManager = new QNetworkAccessManager();
    //QNetworkDiskCache * WebImageView::mNetworkDiskCache = new QNetworkDiskCache();
    
    WebImageView::WebImageView() {
        // Initialize network cache
        //mNetworkDiskCache->setCacheDirectory(QDesktopServices::storageLocation(QDesktopServices::CacheLocation));
    
        // Set cache in manager
        //mNetManager->setCache(mNetworkDiskCache);
    
        // Set defaults
    
        mLoading = 0;
    }
    
    const QUrl& WebImageView::url() const {
        return mUrl;
    }
    
    void WebImageView::setUrl(const QUrl& url) {
        // Variables
    
            mUrl = url;
            mLoading = 0;
            qDebug()<<"url:: "<get(request);
    
            // Connect to signals
            QObject::connect(reply, SIGNAL(finished()), this, SLOT(imageLoaded()));
            QObject::connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(dowloadProgressed(qint64,qint64)));
    
            emit urlChanged();
    
    }
    
    double WebImageView::loading() const {
        return mLoading;
    }
    
    void WebImageView::imageLoaded() {
        // Get reply
        QNetworkReply * reply = qobject_cast(sender());
        QObject::disconnect(reply, SIGNAL(finished()), this, SLOT(imageLoaded()));
        QObject::disconnect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(dowloadProgressed(qint64,qint64)));
        if (reply->error() == QNetworkReply::NoError) {
            if (isARedirectedUrl(reply)) {
                setURLToRedirectedUrl(reply);
                return;
            } else {
                QByteArray imageData = reply->readAll();
                setImage(Image(imageData));
            }
        }
        // Memory management
        reply->deleteLater();
    }
    
    bool WebImageView::isARedirectedUrl(QNetworkReply *reply) {
        QUrl redirection = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
        return !redirection.isEmpty();
    }
    
    void WebImageView::setURLToRedirectedUrl(QNetworkReply *reply) {
        QUrl redirectionUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
        QUrl baseUrl = reply->url();
        QUrl resolvedUrl = baseUrl.resolved(redirectionUrl);
    
        setUrl(resolvedUrl.toString());
    }
    
    void WebImageView::clearCache() {
        //mNetworkDiskCache->clear();
    }
    
    void WebImageView::dowloadProgressed(qint64 bytes, qint64 total) {
        mLoading = double(bytes) / double(total);
    
        emit loadingChanged();
    }
    

    I use ListDataModel. and code above works fine and the loading of the images. But when there are more than 100 items in a list it shows the bad images in some WebImageView. When you scroll through random images change. I checked the url property of webImageView to the point where bad image is loaded, but there the right url.

    in this connection, blackberry says that view list follows MVC architecture, and QObject belonged to ListView objects are deleted when scrolling out of the area visible to the element to which they belong, or when the ListView itself is deleted. What is the cause of my problem? If not, this what's wrong with this code? Help, please...

    nik005 wrote:

    @ekke Yes. If I scroll slowly, it works fine.

    THX.

    Then, it's the same reason.

    as soon as I have a small reproducible application to create a problem, I'll add this thread and let you know

  • BB::LowMemoryWarningLevel comparison of compiler error

    new to this environment of development :-(

    https://developer.BlackBerry.com/Cascades/reference/libbb/memoryinfo_lowmemory.cpp.html

    the lines:

    If (level == bb::LowMemoryWarningLevel:LowPriority) {...}

    If (level == bb::LowMemoryWarningLevel:HighPriority) {...}

    have the compile error:

    no match for ' operator ==' in ' level == ".

    1U (bb::LowMemoryWarningLevel:Type)"

    Thanks for the tips

    There seems to be an error in the code example:

    (1) replace bb::LowMemoryWarningLevel by bb::LowMemoryWarningLevel:Type argument of the method.

    (2) replacevoid onAwake(); in slots with:

    public Q_SLOTS:
        void onLowMemory(bb::LowMemoryWarningLevel::Type level);
    

    After these changes, it compiles.

  • using WebService - json

    1. I need to load data

    import bb.cascades 1.0import bb.data 1.0Page { content: ListView { id: listView dataModel: dataModel //... } attachedObjects: [ GroupDataModel { id: dataModel }, DataSource { id: dataSource source: "http://192.168.1.251:410/Mobile/Service1.svc/english/Category?CountryID=1" onDataLoaded: { dataModel.insertList(data) } } ] onCreationCompleted: { dataSource.load();  }}
    

    1. QML FILE

    import bb.cascades 1.0import bb.data 1.0
    Page { content: Container { layout: StackLayout { orientation: LayoutOrientation.TopToBottom
    
     }
    
     TextField { id: countryID hintText: "Enter Country ID eg:'1'"  maxWidth: 400 verticalAlignment: VerticalAlignment.Center horizontalAlignment: HorizontalAlignment.Center textStyle.textAlign: TextAlign.Center
    }
    
     Button { id: btn
    
     text: "Send JSON Request" onClicked: { app.sendRequest(countryID.text);
    
     } verticalAlignment: VerticalAlignment.Center horizontalAlignment: HorizontalAlignment.Center }
    
     }}
     
    

    2 FILE OF THE HPP

    // Default empty project template#ifndef CALCI_HPP_#define CALCI_HPP_
    #include 
    
    namespace bb { namespace cascades { class Application; }}
    
    class controller : public QObject{ Q_OBJECTpublic: controller(bb::cascades::Application *app);
    
    public Q_SLOTS: void sendRequest(const QString &countryID);
    
    private Q_SLOTS:
    void onFinished();
    };
    
    #endif
     
    

    3 CPP FILE

     

    // Default empty project template#include "calci.hpp"
    #include #include #include #include #include #include #include #include 
    using namespace bb::cascades;using namespace bb::data;
    controller::controller(bb::cascades::Application *app): QObject(app){
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this); qml->setContextProperty("app", this);
    AbstractPane *root = qml->createRootObject();
    app->setScene(root);}
    
    void controller::sendRequest(const QString &countryID){
    QNetworkAccessManager* networkAccessManager = new QNetworkAccessManager(this);
    const QString queryUri = QString::fromLatin1("http://192.168.1.251:410/Mobile/Service1.svc/english/Category?CountryID=%1").arg(countryID);
    QNetworkRequest request(queryUri);
    QNetworkReply* reply = networkAccessManager->get(request);
    bool ok = connect(reply, SIGNAL(finished()), this, SLOT(onFinished())); Q_ASSERT(ok); Q_UNUSED(ok);}
    
    void controller::onFinished(){ QNetworkReply* reply = qobject_cast(sender()); QString response; if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 200) { JsonDataAccess jda; QVariantMap map = jda.loadFromBuffer(reply->readAll()).toMap();
    QVariantList addresses = map["GetCategoryResult"].toList();
    foreach(QVariant var, addresses) { QVariantMap addressMap = var.toMap();
    qDebug() << "CategoryName is " << addressMap["CategoryName"].toString(); qDebug() << "CategoryID is " << addressMap["CategoryID"].toString(); } } else { qDebug() << "Server returned code " << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); } }
    

    Finally I got the result for json web service

     

  • QGeoServiceProvider - what header include?

    #include 
    #include 
    #include 
    #include 
    
    namespace bb { namespace cascades { class Application; }}
    
    /*!
     * @brief Application pane object
     *
     *Use this object to create and init app UI, to create context objects, to register the new meta types etc.
     */
    class MyApp : public QObject
    {
        Q_OBJECT
    public:
        MyApp(bb::cascades::Application *app);
        virtual ~MyApp();
        void InitSearchProviders();
    
    public Q_SLOTS:
        void onArmed();
        void onArmedOpen();
        void share(QString string);
        void openUrl(QString string);
    
    private:
        bb::cascades::Invocation* m_pInvocation;
        QGeoServiceProvider* m_pSearchProvider;  // There is a error -- class undefined
        QGeoSearchManager* m_pSearchManager; // There is a error -- class undefined
    };
    

    What did I miss?

    QtMobilitySubset::QGeoServiceProvider* m_pSearchProvider;
    QtMobilitySubset::QGeoSearchManager* m_pSearchManager;
    

    Namespace...

  • Group data model does not

    Hello

    I am developing a revision update for my app BB10 stunts and I use a data model to pull in the elements of the application do not forget; the only problem I encounter is that I can't get the data model of the group work so that I can arrange the items by the first character instead the data are currently presented as Z - A, even if I could get it to display in A - Z would be enough, but what I am looking to achieve is to get the model to display in A - Z and then sort by the first character, while a header for each letter is displayed.

    Here is the list (QML) and my data model (C++)

    ListView {
                                dataModel: _noteBook.model
    
                                listItemComponents: ListItemComponent {
                                    type: "item"
    
                                    StandardListItem {
                                        title: ListItemData.title
                                        description: ListItemData.status
                                    }
                                }
    
                                onTriggered: {
                                    clearSelection()
                                    select(indexPath)
    
                                    _noteBook.setCurrentNote(indexPath)
    
                                    _noteBook.viewNote();
                                    navigationPane.push(noteViewer.createObject())
                                }
                            }
    

    NoteBook.cpp

    #include "NoteBook.hpp"
    
    #include "NoteEditor.hpp"
    #include "NoteViewer.hpp"
    
    #include 
    
    using namespace bb::cascades;
    using namespace bb::pim::notebook;
    
    //! [0]
    NoteBook::NoteBook(QObject *parent)
        : QObject(parent)
        , m_notebookService(new NotebookService(this))
        , m_model(new GroupDataModel(this))
        , m_noteViewer(new NoteViewer(m_notebookService, this))
        , m_noteEditor(new NoteEditor(m_notebookService, this))
    {
        // First Character grouping in data model
        m_model->setGrouping(ItemGrouping::FirstChar);
    
        // Ensure to invoke the filterNotes() method whenever a note has been added, changed or removed
        bool ok = connect(m_notebookService, SIGNAL(notebookEntriesAdded(QList)), SLOT(filterNotes()));
        Q_ASSERT(ok);
        ok = connect(m_notebookService, SIGNAL(notebookEntriesUpdated(QList)), SLOT(filterNotes()));
        Q_ASSERT(ok);
        ok = connect(m_notebookService, SIGNAL(notebookEntriesDeleted(QList)), SLOT(filterNotes()));
        Q_ASSERT(ok);
    
        // Fill the data model with notes initially
        filterNotes();
    }
    //! [0]
    
    //! [1]
    void NoteBook::setCurrentNote(const QVariantList &indexPath)
    {
        // Extract the ID of the selected note from the model
        if (indexPath.isEmpty()) {
            m_currentNoteId = NotebookEntryId();
        } else {
            const QVariantMap entry = m_model->data(indexPath).toMap();
            m_currentNoteId = entry.value("noteId").value();
        }
    }
    //! [1]
    
    //! [2]
    void NoteBook::createNote()
    {
        // Prepare the note editor for creating a new note
        m_noteEditor->reset();
        m_noteEditor->setMode(NoteEditor::CreateMode);
    }
    //! [2]
    
    //! [3]
    void NoteBook::editNote()
    {
        // Prepare the note editor for editing the current note
        m_noteEditor->loadNote(m_currentNoteId);
        m_noteEditor->setMode(NoteEditor::EditMode);
    }
    //! [3]
    
    //! [4]
    void NoteBook::viewNote()
    {
        // Prepare the note viewer for displaying the current note
        m_noteViewer->setNoteId(m_currentNoteId);
    }
    //! [4]
    
    //! [5]
    void NoteBook::deleteNote()
    {
        m_notebookService->deleteNotebookEntry(m_currentNoteId);
    }
    //! [5]
    
    bb::cascades::GroupDataModel* NoteBook::model() const
    {
        return m_model;
    }
    
    QString NoteBook::filter() const
    {
        return m_filter;
    }
    
    //! [6]
    void NoteBook::setFilter(const QString &filter)
    {
        if (m_filter == filter)
            return;
    
        m_filter = filter;
        emit filterChanged();
    
        // Update the model now that the filter criterion has changed
        filterNotes();
    }
    //! [6]
    
    NoteViewer* NoteBook::noteViewer() const
    {
        return m_noteViewer;
    }
    
    NoteEditor* NoteBook::noteEditor() const
    {
        return m_noteEditor;
    }
    
    //! [7]
    void NoteBook::filterNotes()
    {
        NotebookEntryFilter filter;
    
        // Use the entered filter string as search string
        filter.setSearchString(m_filter);
    
        const QList notes = m_notebookService->notebookEntries(filter);
    
        // Clear the old note information from the model
        m_model->clear();
    
        // Iterate over the list of notes
        foreach (const NotebookEntry ¬e, notes) {
            // Copy the data into a model entry
            QVariantMap entry;
            entry["noteId"] = QVariant::fromValue(note.id());
            entry["title"] = note.title();
            entry["status"] = NoteViewer::statusToString(note.status());
    
            // Add the entry to the model
            m_model->insert(entry);
        }
    }
    //! [7]
    

    NoteBook.hpp

    /* Copyright (c) 2012, 2013  BlackBerry Limited.
    *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
    *
    * http://www.apache.org/licenses/LICENSE-2.0
    *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    */
    
    #ifndef NOTEBOOK_HPP
    #define NOTEBOOK_HPP
    
    #include 
    #include 
    #include 
    
    #include 
    
    class NoteEditor;
    class NoteViewer;
    
    /**
     * @short The controller class that makes access to notes available to the UI.
     */
    //! [0]
    class NoteBook : public QObject
    {
        Q_OBJECT
    
        // The model that provides the filtered list of notes
        Q_PROPERTY(bb::cascades::GroupDataModel *model READ model CONSTANT);
    
        // The pattern to filter the list of notes
        Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged);
    
        // The viewer object for the current note
        Q_PROPERTY(NoteViewer* noteViewer READ noteViewer CONSTANT);
    
        // The editor object for the current note
        Q_PROPERTY(NoteEditor* noteEditor READ noteEditor CONSTANT);
    
    public:
        NoteBook(QObject *parent = 0);
    
    public Q_SLOTS:
        /**
         * Marks the note with the given @p indexPath as current.
         */
        void setCurrentNote(const QVariantList &indexPath);
    
        /**
         * Prepares the note editor to create a new note.
         */
        void createNote();
    
        /**
         * Prepares the note editor to edit the current note.
         */
        void editNote();
    
        /**
         * Prepares the note viewer to display the current note.
         */
        void viewNote();
    
        /**
         * Deletes the current note.
         */
        void deleteNote();
    
    Q_SIGNALS:
        // The change notification signal for the property
        void filterChanged();
    
    private Q_SLOTS:
        // Filters the notes in the model according to the filter property
        void filterNotes();
    
    private:
        // The accessor methods of the properties
        bb::cascades::GroupDataModel* model() const;
        QString filter() const;
        void setFilter(const QString &filter);
        NoteViewer* noteViewer() const;
        NoteEditor* noteEditor() const;
    
        // The central object to access the notebook service
        bb::pim::notebook::NotebookService* m_notebookService;
    
        // The property values
        bb::cascades::GroupDataModel* m_model;
        QString m_filter;
    
        // The controller object for viewing a note
        NoteViewer* m_noteViewer;
    
        // The controller object for editing a note
        NoteEditor* m_noteEditor;
    
        // The ID of the current note
        bb::pim::notebook::NotebookEntryId m_currentNoteId;
    };
    //! [0]
    
    #endif
    

    If something you can help me with then this would be very useful - if you need to see more of code then let me know too!

    Thanks in advance

    Try to add in constructor (after a call to setGrouping):

    QStringList keys;
    key<>
    m_model-> setSortingKeys (keys);

    May require alterations, I have not tried this compilation.

  • Get the location of the device

    I had my application built with HTML5 for OS7, I build for BB10 and I decided to go with a feel more native and waterfalls. I must admit however, the old WebWorks documentation was much wasier and friendly, you had a small example of using each feature.

    I'm having a problem getting the location of the device, I went through the sample application "Diagnoses of the situation", but it's really complicated (he has 3 classes of objects with a ton of features to get the location).

    I'm just trying to find the location of the device, using cell towers, every two minutes. I want to create and the entire class for this? Also, how to trigger this function of the part of Cascades?

    I'd appreciate any help!

    Hello

    Here's a simplified example of code. These files are from the empty project template by default in the IDE of Momentix (file-> New-> project-> BlackBerry Project-> Application of stunts-> empty project Standard). They have been updated to include cellsite positioning updates every two minutes. The output will simply through cost.

    applicationui.h:

    // Default empty project template
    #ifndef ApplicationUI_HPP_
    #define ApplicationUI_HPP_
    
    #include 
    
    #include 
    
    using ::QtMobilitySubset::QGeoPositionInfo;     // so the SIGNAL()/SLOT() macros can have matching signatures.
    
    namespace bb { namespace cascades { class Application; }}
    
    /*!
     * @brief Application pane object
     *
     *Use this object to create and init app UI, to create context objects, to register the new meta types etc.
     */
    class ApplicationUI : public QObject
    {
        Q_OBJECT
    public:
        ApplicationUI(bb::cascades::Application *app);
        virtual ~ApplicationUI() {}
    
        void startCellSiteUpdates();
    
    public Q_SLOTS:
        void positionUpdated(const QGeoPositionInfo & pos);
        void positionUpdateTimeout();
    
    private:
        QtMobilitySubset::QGeoPositionInfoSource * _source;
    };
    
    #endif /* ApplicationUI_HPP_ */
    

    applicationui.cpp

    // Default empty project template
    #include "applicationui.hpp"
    
    #include 
    
    #include 
    #include 
    #include 
    
    #include 
    
    using namespace bb::cascades;
    
    ApplicationUI::ApplicationUI(bb::cascades::Application *app)
    : QObject(app)
    {
        // create scene document from main.qml asset
        // set parent to created document to ensure it exists for the whole application lifetime
        QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    
        // create root object for the UI
        AbstractPane *root = qml->createRootObject();
        // set created root object as a scene
        app->setScene(root);
    
        // Instantiate the default QGeoPositionInfoSource
        _source = QtMobilitySubset::QGeoPositionInfoSource::createDefaultSource(this);
        if ( _source ) {        // connect to the QGeoPositionInfoSource's signals, to get the position info and/or error status
            connect(_source, SIGNAL(positionUpdated(const QGeoPositionInfo &)), this, SLOT(positionUpdated(const QGeoPositionInfo &)));
            connect(_source, SIGNAL(updateTimeout()), this, SLOT(positionUpdateTimeout()));
        }
    }
    
    // call this method to start the position updates
    void ApplicationUI::startCellSiteUpdates()
    {
        if ( !_source ) {
    
            std::cout << "Error getting default position info source" << std::endl;
            return;
        }
    
        // QtLocation allows control over which provider(s) will be queried for position info. NonSatellitePositioningMethods
        // includes wifi and cellsite fix types.
        _source->setPreferredPositioningMethods( QtMobilitySubset::QGeoPositionInfoSource::NonSatellitePositioningMethods );
    
        // On BlackBerry the default QGeoPositionInfoSource allows finer control over the fix type. This extension, and others, take advantage of the Qt property system.
        // Here we are interested only in cellsite fixes.
        _source->setProperty("fixType", "cellsite");
    
        // set the update interval to a couple of minutes.
        _source->setUpdateInterval(120000);
    
        // start the updates, which we expect to receive in ApplicationUI::positionUpdated()
        _source->startUpdates();
    }
    // slot connected to the QGeoPositionInfoSource::positionUpdated() signal
    void ApplicationUI::positionUpdated(const QGeoPositionInfo & pos)
    {
        // print out the position in a convenient format:
        std::cout << pos.coordinate().toString().toLatin1().constData() << std::endl;
    
        // print out the accuracy as well, if available
        if ( pos.hasAttribute(QtMobilitySubset::QGeoPositionInfo::HorizontalAccuracy) ) {
            std::cout << "    horizontal accuracy = " << (double)pos.attribute(QtMobilitySubset::QGeoPositionInfo::HorizontalAccuracy) << std::endl;
        }
    
    }
    // slot connected to the QGeoPositionInfoSource::updateTimeout() signal
    void ApplicationUI::positionUpdateTimeout()
    {
        std::cout << "timeout occurred" << std::endl;
    
        // On BlackBerry more information as to why the device timed out may be available:
        bb::location::PositionErrorCode::Type errorCode = bb::location::PositionErrorCode::None;
    
        if ( _source->property("replyErrorCode").isValid()  ) {
            errorCode = _source->property("replyErrorCode").value();
            if ( errorCode != bb::location::PositionErrorCode::None ) {
                std::cout << "    " << _source->property("replyErrStr").toString().toLatin1().constData() << std::endl;
            }
        }
    }
    

    And main.cpp looks like this:

    // Default empty project template
    #include 
    
    #include 
    #include 
    #include "applicationui.hpp"
    
    // include JS Debugger / CS Profiler enabler
    // this feature is enabled by default in the debug build only
    #include 
    
    using namespace bb::cascades;
    
    Q_DECL_EXPORT int main(int argc, char **argv)
    {
        // this is where the server is started etc
        Application app(argc, argv);
    
        // localization support
        QTranslator translator;
        QString locale_string = QLocale().name();
        QString filename = QString( "SimpleLocation_%1" ).arg( locale_string );
        if (translator.load(filename, "app/native/qm")) {
            app.installTranslator( &translator );
        }
    
        ApplicationUI * appUI = new ApplicationUI(&app);
    
        appUI->startCellSiteUpdates();
    
        // we complete the transaction started in the app constructor and start the client event loop here
        return Application::exec();
        // when loop is exited the Application deletes the scene which deletes all its children (per qt rules for children)
    }
    

    Your file bar - descriptor.xml must contain this line to allow approval of the app for location-based services:

        access_location_services
    

    Also to ensure that location-based Services are enabled under settings on your device.

    Your .pro file should contain this line so that the QtLocationSubset library is linked:

    LIBS += -lQtLocationSubset
    

    I hope this helps!

    Jim

  • How to connect NotificationDialog finished() signal?

    Can't find a doc on how to correctly connect the signal over.

    I have this for the notificationdialog in my c folder

    Boolean success = QObject::connect (pNotification,
    SIGNAL (finished (bb:latform::NotificationResult:ButtonSelection *));
    This,
    SLOT (onSelected (bb:latform::NotificationResult::ButtonSelection*)));))

    sub myApp:nSelected (bb:latform::NotificationResult * button)
    {
    }

    I have this in my file:

    public Q_SLOTS:
    Sub onSelected (bb:latform::NotificationResult * button);

    What is the right way to connect it?  Thank you

    To give a clear answer:

    #include 
    using namespace bb::platform;
    
    NotificationDialog *pNotification = .....;
    
    [...]QObject::connect(pNotification, SIGNAL(finished(bb::platform::NotificationResult::Type)),
                         this, SLOT(onSelected(bb::platform::NotificationResult::Type));
    
    [...]
    
    void myApp::onSelected(bb::platform::NotificationResult::Type value){
    NotificationDialog *dialog = qobject_cast(sender()); // or reference a member variable directly
    if (dialog)
    {
      SystemUiButton *button = dialog->buttonSelection();
      ...
    }
    
  • Invocation. What did I miss?

    m_pInvocation = Invocation::create(
        InvokeQuery::create()
          .parent(this)
          .mimeType("text/txt"));
      QObject::connect(m_pInvocation, SIGNAL(armed()),
        this, SLOT(onArmed()));
      QObject::connect(m_pInvocation, SIGNAL(finished()),
        m_pInvocation, SLOT(deleteLater()));
    

    When I'm compiling, I got error:

    type incomplete "bb::cascades:InvokeQuery" used in the nested name specifier

     

    What did I miss?

       void share(QString string);
    
    public Q_SLOTS:
        void onArmed();
    
    private:
        bb::cascades::Invocation* m_pInvocation;
    

    #include ?

  • A return to the QML container onCreationComplete event Q_String

    Hello

    I'm trying to regain a QString funcition onCreationComplete a container.

    Here is the code I use.  When I debug the QML debugger jumps on the

    event and moves on to the next control.  I'm guessing that there is an error of some sort, but I don't know what it is.

    Thanks in advance.

    file .qml

    onCreationCompleted: {}
    If (ListItemData.channelName is {MSNApp.getSelectedChannel ()})
    Background = Color.create("#74D2F7")
    }
    }

    all files

    public:

    QString Q_INVOKABLE getSelectedChannel();

    private:

    QString selectedChannel;

    .cpp file

    selectedChannel = 'Home';  Download initialized in the constructor

    QString ApplicationUI::getSelectedChannel() {}

    Return selectedChannel;
    }

    Aparently there is a bug when it comes to properties of context and ListView.  I found this work around.

    Thanks for the suggestions.

    http://supportforums.BlackBerry.com/T5/Cascades-development/cannot-access-context-property-from-INSI...

    Best regards

    John

  • Stunts by the way of GroupDataModel of c ++ qml problem!

    Hello

    I'm trying to access the data of GroupDataModel of c ++ to qml!

    I tried,

    in PHP,.

    public Q_SLOTS:

    BB::Cascades:GroupDataModel load_datamodel (const QString & txprofile);

    in the PRC,

    BB::Cascades:GroupDataModel ApplicationUI::load_datamodel (const QString & txprofile)

    {

    Model GroupDataModel;

    .......

    model.insertList (()) list.value;

    return the template;

    }

    But it's not working! Please help me!

    I guess that you see no changes when the DataModel is updated?  I recommend to expose to as a Q_PROPERTY QML like this:

    Q_PROPERTY(bb::cascades::DataModel* model READ model NOTIFY dataModelChanged)
    
    public:
    
        YourClass(QObject *parent = 0);
    
    Q_SIGNALS:
    
        /*
         * This signal is emitted the data model is updated.
         */
        void dataModelChanged();
    
    private:
    
        bb::cascades::DataModel* model() const;
    
        bb::cascades::GroupDataModel* mDataModel;
    

    Side C++ you can then pull the signal of dataModelChanged after the model has been changed and you want to update your user interface.

  • Cannot access object C++ in QML

    I have a NavigationPane defined in QML. In my C++ class, I create the NavigationPane and use setContextProperty in order to access the C++ class. However, when I try to use the QML context in the onCreationCompleted signal, the console displays a "ReferenceError: can't find variable: splashSample" error.

    The code is as follows:

    QML:

    import bb.cascades 1.0
    
    NavigationPane
    {
        id: navigationPane
        Page
        {
            onCreationCompleted:
            {
                splashSample.splashScreenDone.connect(navigationPane.push(getSecondPage()))
            }
            Container
            {
                background: Color.Black
                layout: DockLayout
                {
                }
                ImageView
                {
                    horizontalAlignment: HorizontalAlignment.Center
                    verticalAlignment: VerticalAlignment.Center
                    imageSource: "asset:///images/splash.png"
                    onTouch:
                    {
                        // show detail page when the button is clicked
                        var page = getSecondPage();
                        console.debug("pushing detail " + page)
                        navigationPane.push(page);
                    }
                    property Page secondPage
                    function getSecondPage()
                    {
                        if (! secondPage)
                        {
                            secondPage = secondPageDefinition.createObject();
                        }
                        return secondPage;
                    }
                    attachedObjects:
                    [
                        ComponentDefinition
                        {
                            id: secondPageDefinition
                            source: "main.qml"
                        }
                    ]
                }
            }
        }
    }
    

    CPP file:

    SplashScreenSample::SplashScreenSample(bb::cascades::Application *app)
    : QObject(app)
    {
        QmlDocument *qml = QmlDocument::create("asset:///splash.qml").parent(this);
    
        AbstractPane *root = qml->createRootObject();
        qml->setContextProperty("splashSample", this);
    
        app->setScene(root);
    
    //  QTimer::singleShot(1000, this, SLOT(loadMainScreen()));
    }
    
    void SplashScreenSample::loadMainScreen()
    {
        emit splashScreenDone();
        qDebug("******************************************************************");
    }
    

    the HPP file:

    #ifndef SplashScreenSample_HPP_
    #define SplashScreenSample_HPP_
    
    #include 
    
    namespace bb { namespace cascades { class Application; }}
    
    class SplashScreenSample : public QObject
    {
        Q_OBJECT
    public:
        SplashScreenSample(bb::cascades::Application *app);
        virtual ~SplashScreenSample() {}
    
    public Q_SLOTS:
        void loadMainScreen();
    
        Q_SIGNALS:
            void splashScreenDone();
    
    };
    
    #endif /* SplashScreenSample_HPP_ */
    

    It seems that the alias 'splashSample' is not accessible in the onCreationCompleted signal. Is this the case? Is it possible to connect to a signal when the QML document is created?

    Thank you very much.

    You must call setContextProperty before calling createRootObject

  • Capture AbstractActionItem SIGNAL to slip into the menu drop-down

    Hello

    So I need to do anything when I press the ActionItem in slide it towards the bottom of the context menu on BB10.

    I created the shot on the menu drop-down

        Menu *menu = Menu::create();
        Image infoIcon = Image(QUrl("asset:///images/info"));
        menu->addAction(ActionItem::create().title("Info").image(infoIcon));
        menu->setObjectName("infoItem");
    

    Looked at the docs. AbstractActionItem

    https://developer.BlackBerry.com/Cascades/reference/bb__cascades__abstractactionitem.html the action point emits a triggered() Signal.

    Then ran info a bunch of question that did not help.

    • Looked QTDocs
    • Looked at the signals & Slots section of BB stunts Docs

    in my App.hpp file I added

    public:
       void debugText();
    

    I tried to connect the menu by using the following code:

    connect(menu->objectName(), SIGNAL(triggered()), this, SLOT(debugText()));
    

    It does not work, and I spent 2 hours trying to figure why not.
    How do you connect in fact these things?

    Thank you!

    Hello

    trigger signal is attached to ActionItem itself and not Menu object.

    And don't forget the Q_SLOT macro.

    class xxx : virtual QObject {
      Q_OBJECT
    
    public:
      Q_SLOT void debugText(void);
    };
    
    Menu *menu = Menu::create();
    Image infoIcon = Image(QUrl("asset:///images/info"));
    
    ActionItem *mItem = ActionItem::create().title("Info").image(infoIcon)
    
    menu->addAction(mItem);
    menu->setObjectName("infoItem");
    
    connect(mItem, SIGNAL(triggered()), this, SLOT(debugText()));
    

    Nicklas

Maybe you are looking for

  • How to connenct laptop from Vista to Windows XP PC to share internet?

    My wife recently bought a new laptop Toshiba A100 with Vista installed. My PC, connected to AOL Broadband uses XP as an operating system. I'm trying to set up a wireless link. AOL, said that XP and Vista are not compatible, and to put in place a link

  • Need help to RIP my music CD

    Original title: copy CDs in My Documents How to copy music from a CD to my documents

  • SNMP requests returns the number "36" PERC H700 battery. What it means?

    SNMP OID Text: iso.org.dod.internet.private.enterprises.dell.storage.software.storageManagement.physicalDevices.batteryTable.batteryEntry.batteryState.1 In the numeric form: 1.3.6.1.4.1.674.10893.1.20.130.15.1.4.1 Possible States: 0: Unknown 1: OK 2:

  • Support implementation of KMS host please?

    Have a server windows server 2003. Installed KMS Service 1.2 with support for windows 7. Key installed and activated using commany invites Configuration for which entries were made to the DNS server. Now.   On client computers, I type in the KMS key

  • I can't turn on "force way dragging" in Illustrator?

    First of all, let me say that I LOVE the most of the new enhancements in Illustrator 17.1. The corners live in particular will save a lot of time! I don't think that there's enough compliments on the forums, and I appreciate the work you did to make