Cascade app

Hi all.

I'm writing an app with four pages...

I have two questions:

1 - is better a file.qml for each of the application pages or file .qml for all pages in the App?

2. in the second page I retrieve the users input a complex there. On page four, so that I can't bind the variable in two page view the result.

For example: page 2 - C = A + B

page4 - label = page2. C

What is the correct formula?

Sorry for my bad English...

It is better to have a QML file by page, this makes it easier to contol things as your application grows.

Regarding the scope of variables, I suspect that you must use the control id that you order data.

Examples of applications are a good example of organizing your data.

Graham

Tags: BlackBerry Developers

Similar Questions

  • App World notes and comments on doors and cascades apps

    Hello world

    OK, so maybe it's not the best place but being BB10 stunts I thought that this is the best place to ask...

    Anyone know if worn apps (like the playbook or other blackberry devices) who already have ratings and downloads... Will they HOLD these ratings and download numbers once BB10 goes live?

    I ask because when I look on App World (on the alpha device) all I see is litters apps at the top of the list. Now, some of them are major ports but most do not.

    So I wonder how this will work...

    1. Apps with event will keep their side and download numbers
    2. Do you think this helps or hurts native/cascades apps (since more likely apps do not have the same 'look and feel' as BB10 app)-more on BB10 is ideal for users and BlackBerry, but what new developers of cascades?
    3. How will this affect the Built for BlackBerry program (are transferred apps really build to BB10?)

    Just curious to know your opinion.

    Thank you

    This devblog ticket probably meets most of your questions on this subject: http://devblog.blackberry.com/2012/11/blackberry-app-world-success/ note this table and the places where it says "specific to each platform.

  • Display of text from BB10 Cascades App to the server

    How you POST code of your application of Cascades to the server? QHttp or CURL? Samples?

    (1) collect the text of the entry fields

    2) ?? code

    3) post to server

    The simplest implementation of what you are looking for:

    Creating a connection, ask the object with the addition of the parameters retrieved from textfields and then by calling the PostRequest method

    /*!
     * @params mRequestParams a QUrl object used to store the parameters used by MyNetwork object while making post request.
     * @params mEmailTxtFld a reference to TextField control used to store the email address entered by user.
     * @params mPassTxtFld a reference to TextField control used to store the password entered by user.
     */
    void App::requestNetwork(QUrl mRequestParams, TextField *mEmailTxtFld, TextField *mPassTxtFld)
    {
        if (mEmailTxtFld && mEmailTxtFld->text() != NULL
                && mEmailTxtFld->text().length() > 0)
        {
            qDebug() << "Email value " << mEmailTxtFld->text() << "  \n";
            mRequestParams.addQueryItem("username", mEmailTxtFld->text());
        }
        if (mPassTxtFld && mPassTxtFld->text() != NULL
                && mPassTxtFld->text().length() > 0)
        {
            qDebug() << "Pass value " << mPassTxtFld->text() << "  \n";
            mRequestParams.addQueryItem("password", mPassTxtFld->text());
        }
    
        try
        {
    
            /*!
             * @brief this object manages the whole network transaction(starting from request creation to response acceptance).
             */
            QNetworkAccessManager *networkManager = new QNetworkAccessManager(this);
            /*!
             * @brief this QUrl object is used as parameter to QNetworkRequest
             */
            QUrl requestUrl("Your Server Url That Is Accepting Two Parameters");
            /*!
             * @brief this QNetworkRequest object acts as a parameter to the post() method for making request to server.
             */
            QNetworkRequest request(requestUrl);
            request.setHeader(QNetworkRequest::ContentTypeHeader,
                    "application/x-www-form-urlencoded");
    
            if (networkManager)
            {
                /*!
                 * @brief this connect() method connects finished() Signal of QNetworkAccessManager object with the requestFinished() slot in this app context.
                 */
                bool resFromServer = connect(networkManager,
                        SIGNAL(finished(QNetworkReply*)), this,
                        SLOT(requestFinished(QNetworkReply*)));
                qDebug() << "Connection is success : ? : " << resFromServer;
                Q_ASSERT(resFromServer);
                Q_UNUSED(resFromServer);
    
                /*!
                 * @brief this object accepts the reply from server once request is made.
                 */
                QNetworkReply *reply = networkManager->post(request,
                        mRequestParams.encodedQuery());
                if (reply)
                {
                    qDebug() << "Reply from server is " << reply;
                }
            }
        }
        catch (bad_alloc& e)
        {
            qDebug() << "Exception : " << e.what() << "\n";
        }
        catch (bad_exception& e)
        {
            qDebug() << "Exception : " << e.what() << "\n";
        }
        catch (...)
        {
            qDebug() << "Unknown Exception Occurred \n";
        }
    
    }
    

    Collection of server response in a slot and handling method

     

    /*!
    * this SLOT method collects the reply from  server and handles it
    */
    void MyNetwork::requestFinished(QNetworkReply *reply)
    {
        /*!
         * @brief QString object to be used to store server response
         */
        QString response;
    
        if (reply)
        {
            if (reply->error() == QNetworkReply::NoError)
            {
                int available = reply->bytesAvailable();
                if (available > 0)
                {
                    QByteArray buffer(reply->readAll());
                    response = QString(buffer);
                }
                else
                    response = "Zero bytes in response";
    
            }
            else
            {
                int httpStatus = reply->attribute(
                        QNetworkRequest::HttpStatusCodeAttribute).toInt();
                response =
                        "Error and the code is "
                                + reply->attribute(
                                        QNetworkRequest::HttpStatusCodeAttribute).toString()
                                + "  And the Error string is :: "
                                + reply->errorString() + "\n";
            }
            reply->deleteLater();
        }
        else
        {
            response = "Response comes out to be null";
        }
    
        if ((response.trimmed().isEmpty()))
        {
            response = "Empty Response";
        }
        qDebug() << "Response String is :: " << response << " \n";
    
        if (!response.isNull())
        {
            // You got response . Do whatever you want to do with it.
        }
    
    }
    

    It will be useful.

     

  • Be confused with Cascades app Development

    Hello Guyz, I'm new to this development platform please clarify my confusion,
    Today, I tested a sample application named 'Notification' that is directly imported via IDE and its work fine the Dialogbox, sound, onClicked function, everything works fine, but whenver I create cool project from IDE who gave us "Hello World" promgramme in QmL, now request I copy the main.qml notification sample application source code for my custom project "s main.qml". , it does not work as an example of application, app run but the dialog box button or any other button doesn't work at all, what is the reason for this please specify

    I didn't look at the example of Notification for a long time, but there are probably C++ features to the project that supports the QML code. The QML will not work without the C++ stuff.

  • Make mistake while building/running bbutil with cascades app

    Hi, I am trying to build an opengl are 2.0 app and have pretty much used the tutorial for a cube with waterfalls using a foreignwindow, but the code used opengl 1.0. Since then I tried to use the code from a basic tutorial but I had difficulties to get the bbutil to work. Here is the log:

    13:30:23 * incremental Build of the unit for Project X debug configuration *.
    make - j8 device-Debug
    do .//translations - C f Makefile update
    CD arm & C:, bbndk, host_10_2_0_15, win32 / x 86/usr/bin/qmake-blackberry-armv7le-QCC of spec... X.Pro CONFIG += debug_and_release CONFIG += device
    make [1]: Entering directory "C: / users/X/momentics-space X/work/translation"
    C:, bbndk, host_10_2_0_15, win32 / x 86/usr/bin/lupdate X.pro
    Update 'X.ts '...
    Found 0 text (s) source (0 new and 0 already existing)
    make [1]: leaving directory ' C: / users/X/momentics-space work/X/translations.
    do .//translations f - C release of Makefile
    make [1]: Entering directory "C: / users/X/momentics-space X/work/translation"
    C:, bbndk, host_10_2_0_15, win32 / x 86/usr/bin/lrelease X.pro
    Update 'C:/Users/X/momentics-workspace/X/translations/X.qm '...
    Generated translation (s) 0 (0 finished and unfinished 0)
    make [1]: leaving directory ' C: / users/X/momentics-space work/X/translations.
    make - c / arm f Makefile debugging
    make [1]: Entering directory "" C: / users/X/momentics-space work/X/arm ' "
    do f Makefile.Debug
    make [2]: Entering directory "" C: / users/X/momentics-space work/X/arm ' "
    CQS-Vgcc_ntoarmv7le - c-Wc,-comprennent-Wc,o.le-v7-g/.obj/X - Wno-psabi - fstack-protector - fstack-protector-all - mcpu = cortex-a9 - g - Wno-psabi-wall-W-D_REENTRANT-DQT_NO_IMPORT_QT47_QML-DQ_OS_BLACKBERRY-DQT_DECLARATIVE_DEBUG-DQT_DECLARATIVE_LIB-DQT_CORE_LIB-DQT_SHARED - Ic: / bbndk/target_10_2_0_1155/qnx6/usr/share/qt4/mkspecs/blackberry-armv7le-CQS -... /... / X Ic: / bbndk/target_10_2_0_1155/qnx6/usr/include/qt4/QtCore - Ic: / bbndk/target_10_2_0_1155/qnx6/usr/include/qt4/QtDeclarative - Ic: / bbndk/target_10_2_0_1155/qnx6/usr/include/qt4 - I...-Io.le-v7-g/.moc/SRC - Ic: / bbndk/target_10_2_0_1155/qnx6/usr/include - Ic: / bbndk/target_10_2_0_1155/qnx6/usr/include/freetype2 - i. o o.le-v7-g/.obj/bbutil.o... /SRC/bbutil.c
    Cc1: error: one or more files PCH used have been found, but they were not valid
    make [2]: leaving directory ' C: / users/X/momentics-space work/X/arm.
    make [1]: leaving directory ' C: / users/X/momentics-space work/X/arm.
    Cc1: error: use - Winvalid-pch for more information
    Cc1: fatal error: o.le-v7-g/.obj/X: no such file or directory
    compilation is complete.
    CC: C:/bbndk/host_10_2_0_15/win32/x86/usr/lib/gcc/arm-unknown-nto-qnx8.0.0eabi/4.6.3/cc1 caught signal 1
    make [2]: * [o.le-v7-g/.obj/bbutil.o] error 1
    make [1]: * [debug] error 2
    make: * [Device-Debug] error 2

    13:30:24 completed Build (a 674ms)

    Any help is appreciated.

    OK, I managed to correct errors using the wonderful people IRC. Will post a source that uses opengl are 2.0 with the example of stunts to use when he's ready...

  • Native of filebrowse using and the cascading Save dialog box

    In my application I need to open file and file save dialog box when a specific button is clicked. I looked at the docs of stunts, but I found that the native options. Tried the native alert dialog, change of filebrowse dialog type. It displays well on Simulator, but could not get any output file that will be used in the Qt code.

    I pass these parameters

    int * num = NULL;

    char * folder [1024];
    dialog_update (alert_dialog);

    to dialog_event_get_filebrowse_filepaths(event,file,num), but it always returns BPS_FAILURE.

    In addition, access_shared is present in the bar-descriptor

    Here is my code:

    //slot function
    void App::fileOpen(){
        //===========================
            dialog_instance_t alert_dialog = 0;
    
            bps_initialize();
    
            dialog_request_events(0);    //0 indicates that all events are requested
    
            if (dialog_create_filebrowse(&alert_dialog) != BPS_SUCCESS) {
                        fprintf(stderr, "Failed to create alert dialog.");
                        return ;
                }
                const char* extensions[] = {"*.*","*.jpg","*.jpeg","*.mp3","*.wav","*.mp4","*.txt","*.doc","*.pdf"};
                int items = 9;
                if(dialog_set_filebrowse_filter(alert_dialog, extensions,items) != BPS_SUCCESS){
                    fprintf(stderr, "Failed to set alert dialog message text.");
                            dialog_destroy(alert_dialog);
                           alert_dialog = 0;
                           return ;
                }
               if( dialog_set_filebrowse_multiselect(alert_dialog,FALSE)!=BPS_SUCCESS){
                   fprintf(stderr, "Failed to set alert dialog message text.");
                                dialog_destroy(alert_dialog);
                               alert_dialog = 0;
                               return ;
               }
    
            if (dialog_show(alert_dialog) != BPS_SUCCESS) {
                fprintf(stderr, "Failed to show alert dialog.");
                dialog_destroy(alert_dialog);
                alert_dialog = 0;
                return ;
            }
    
            int shutdown =0;
            while (!shutdown) {
                bps_event_t *event = NULL;
                bps_get_event(&event, -1);    // -1 means that the function waits
                                              // for an event before returning
    
                if (event) {
                    if (bps_event_get_domain(event) == dialog_get_domain()) {
    
                        int selectedIndex =
                            dialog_event_get_selected_index(event);
                        const char* label =
                            dialog_event_get_selected_label(event);
                        const char* context =
                            dialog_event_get_selected_context(event);
    
                        char **fileArray[]={};
                        int *numFiles = NULL;
                       //
                              if(selectedIndex == 0){
           shutdown = 1;//user press the cancel button on dialog; close the dialog
       }
       else if(selectedIndex == 1){
           if(dialog_event_get_filebrowse_filepaths(event,file,num)!=BPS_SUCCESS){
           fprintf(stderr,"File open fail");
       }
       else{
    
    //debug purposes
           fprintf(stderr,"File array: %d/n",sizeof(file)*1024);
               fprintf(stderr,"Num files: %n",num);
               //fprintf(stderr,"Files int: %d",files);
       }
    
       }
                    }
                }
            }
    
            if (alert_dialog) {
                dialog_destroy(alert_dialog);
            }
            //===========================
    }
    

    Native Subforums have no useful information on this subject. Any help is greatly appreciated

    Hello again, here's the example as promised.

    To use the native filebrowse dialog box, the native code must run in its own thread to prevent the user interface in the Cascades to block. This is achieved by encapsulating all the dialog box code in a class derived from QThread.  The class I wrote is called FileBrowseDialog

    FileBrowseDialog.hpp

    #ifndef FILEBROWSEDIALOG_HPP_
    #define FILEBROWSEDIALOG_HPP_
    
    #include 
    #include 
    #include 
    
    /*
     * The file browse dialog displays a dialog to browse and select
     * files from shared folders on the system.
     */
    class FileBrowseDialog : public QThread
    {
        Q_OBJECT
    
        /*
         * QML property to allow multiple selection
         */
        Q_PROPERTY(bool multiselect READ getMultiSelect WRITE setMultiSelect)
    
        /*
         * QML property to read the selected filenames
         */
        Q_PROPERTY(QVariant filepaths READ getFilePaths)
    
        /*
         * QML property to set or get the file filters. This is an
         * list array variant.
         */
        Q_PROPERTY(QVariant filters READ getFilters WRITE setFilters)
    public:
        /*
         * Ctor and Dtor
         */
        FileBrowseDialog(QObject* parent = 0);
        virtual ~FileBrowseDialog();
    
        /*
         * Exposed to QML to start the run loop which creates and displays the dialog.
         * The dialog is shown until a button is clicked.
         */
        Q_INVOKABLE void show();
    
    public:
        /*
         * Getter for the selected filenames QML property
         */
        QVariant getFilePaths() const;
    
        /*
         * Setter and Getter for the filters QML property
         */
        QVariant getFilters() const;
        void setFilters(QVariant const& value);
    
        /*
         * Getter and Setter for the multiselect QML property
         */
        bool getMultiSelect() const;
        void setMultiSelect(bool value);
    
    signals:
        /*
         * Signal emitted when the OK button has been clicked on the browse dialog
         * The OK button is not enabled unless a file is selected
         */
        void selectionCompleted();
    
        /*
         * Signal emitted when the cancel button has been clicked on the browse dialog
         */
        void selectionCancelled();
    
    protected:
        /*
         * Implements the run loop. Dialog stays open until a button is clicked.
         */
        virtual void run();
    
    protected:
        dialog_instance_t m_dialog;
        bool m_multiSelect;
        QVariantList m_filePaths;
        QVariantList m_filters;
    };
    
    #endif /* FILEBROWSEDIALOG_HPP_ */
    

    FileBrowseDialog.cpp

    #include "FileBrowseDialog.hpp"
    #include 
    #include 
    
    FileBrowseDialog::FileBrowseDialog(QObject* parent)
        : QThread(parent)
        , m_multiSelect(false)
    {
        m_filters.push_back(QString("*.*"));
    }
    
    FileBrowseDialog::~FileBrowseDialog()
    {
    }
    
    void FileBrowseDialog::show()
    {
        if (!isRunning())
        {
            m_filePaths.clear();
            start();
        }
    }
    
    QVariant FileBrowseDialog::getFilePaths() const
    {
        return m_filePaths;
    }
    
    bool FileBrowseDialog::getMultiSelect() const
    {
        return m_multiSelect;
    }
    
    void FileBrowseDialog::setMultiSelect(bool value)
    {
        m_multiSelect = value;
    }
    
    QVariant FileBrowseDialog::getFilters() const
    {
        return m_filters;
    }
    
    void FileBrowseDialog::setFilters(QVariant const& value)
    {
        m_filters = value.toList();
        qDebug() << "filter count: " << m_filters.count();
    }
    
    void FileBrowseDialog::run()
    {
        bps_initialize();
    
        //request all dialog events
        dialog_request_events(0);
        if (dialog_create_filebrowse(&m_dialog) != BPS_SUCCESS)
        {
            qDebug() << "Failed to create file browse dialog.";
            emit selectionCancelled();
            return;
        }
    
        //set the selection filters
        if (m_filters.count() > 0)
        {
            char** ext = (char**)new char[m_filters.count()*sizeof(char*)];
            int i = 0;
            for (QVariantList::iterator it = m_filters.begin(); it != m_filters.end(); ++it, ++i)
            {
                QString filter = it->toString();
                if (!filter.trimmed().isEmpty())
                {
                    int length = (filter.length() + 1) * sizeof(char);
                    ext[i] = new char[length];
                    strncpy(ext[i], filter.toAscii(), length);
                }
            }
            if (dialog_set_filebrowse_filter(m_dialog, (const char**)ext, m_filters.count()) != BPS_SUCCESS)
            {
                qDebug() << "unable to set file browse dialog extensions";
            }
            for (i = 0; i < m_filters.count(); i++)
            {
                delete ext[i];
            }
            delete ext;
        }
    
        if (dialog_show(m_dialog) != BPS_SUCCESS)
        {
            qDebug() << "Failed to show file browse dialog.";
            dialog_destroy(m_dialog);
            m_dialog = 0;
            emit selectionCancelled();
            return;
        }
    
        bool shutdown = false;
        while (!shutdown)
        {
            bps_event_t* event = NULL;
            bps_get_event(&event, -1);    // -1 means that the function waits
            // for an event before returning
    
            if (event)
            {
                if (bps_event_get_domain(event) == dialog_get_domain())
                {
                    //0=ok, 1=cancel
                    int selectedIndex = dialog_event_get_selected_index(event);
    
                    if (selectedIndex == 1)
                    {
                        int count;
                        char** filepaths;
                        if (BPS_SUCCESS == dialog_event_get_filebrowse_filepaths(event, &filepaths, &count))
                        {
                            for (int i = 0; i < count; i++)
                            {
                                qDebug() << "selected file: " << filepaths[i];
                                m_filePaths.push_back(QString(filepaths[i]));
                            }
                            bps_free(filepaths);
                        }
                        emit selectionCompleted();
                    }
                    else
                    {
                        emit selectionCancelled();
                    }
    
                    qDebug() << "Got file browse dialog click";
                    shutdown = true;
                }
            }
        }
    
        if (m_dialog)
        {
            dialog_destroy(m_dialog);
        }
    }
    

    This class derives from QObject (by QThread) which means that it can be used by QML when it exposes properties and signals. The FileBrowseDialog class has 3 properties

    -multiple selection: a Boolean flag indicating if single or multiple selection is allowed

    -filepaths: a read only value that returns the list of files selected

    -Filters: a read/write value is where you can specify one or more filters to file (for example, ".doc", "*.jpg") etc.

    The next part is how you call the FileBrowseDialog through the QML. To do this, we must inform the QML of the FileBrowseDialog page. This is done in the App class via the qmlregistertype code.

    App.cpp

    #include 
    #include 
    #include 
    
    #include "app.hpp"
    #include "FileBrowseDialog.hpp"
    
    using namespace bb::cascades;
    
    App::App()
    {
        qmlRegisterType("Dialog.FileBrowse", 1, 0, "FileBrowseDialog");
        QmlDocument *qml = QmlDocument::create("main.qml");
        qml->setContextProperty("cs", this);
    
        AbstractPane *root = qml->createRootNode();
        Application::setScene(root);
    }
    

    The QML is now ready to be able to use the FileBrowseDialog. The example below is a page complete qml which has a button and a label. When we click on the FileBrowseDialog button is open, and all selected files will appear in the label.

    Main.QML

    import bb.cascades 1.0
    import Dialog.FileBrowse 1.0
    
    Page {
        content: Container {
            Label { id: filebrowseDialogLabel }
            Button {
                text : "File Browse Dialog"
                onClicked: {
                    filebrowseDialog.show();
                }
            }
            attachedObjects: [
                FileBrowseDialog {
                    id: filebrowseDialog
                    multiselect : true
                    filters : ["*.doc","*.jpg","*.txt"]
                    onSelectionCompleted: {
                        if(filebrowseDialog.filepaths.length>0)
                            filebrowseDialogLabel.text = filebrowseDialog.filepaths[0];
                        else
                            filebrowseDialogLabel.text = "no file selected";
                    }
                    onSelectionCancelled: {
                        filebrowseDialogLabel.text = "file browse dialog was cancelled";
                    }
                }
            ]
        }
    }
    

    And it's pretty much just invoke the native dialog file navigation in stunts. Please note save the file would follow a similar model, but I found that this dialog box was not particularly useful because it displays only a simple dialogbox with a text file name entry.

    See you soon

    Swann

  • Basic application and application of the cascade

    Hello

    I need to make a basic application that use Cascade app to display some independence UI (like webview, video, download data,...).

    I know cascade app and core app are separate, so I need to know is possible?

    If possible, can someone give me some suggestions or referrences?

    Thanks for reading and I hope an answer. ^_^

    Welcome on the support forums.

    Each of waterfalls is also a native application. Cascades is an infrastructure of UI (more or less) for the natives.
    This means that they are not really separate. Simply create a new application of Cascades to start. There are also a lot of samples available.

  • glReadPixels break when it is used from an application of Cascades?

    I'm trying to use Cascades of glReadPixels() of the OpenGL ES 2.0 active app.  Unfortunately, it crashes.

    If I use glReadPixels() from within the native SDK model OpenGL ES 2.0 than the QDE creates (no Cascades/natives only), it works.

    But, if I use an OpenGL ES 2.0 active Cascades app, it fails.

    I use it since in a ForeignWindowControl.  I use a version modified the example of GoodCitizenCascades (which I modified to work with Beta 3 for BlackBerry 10 - the original only works with Beta 2) found here: https://github.com/blackberry/Cascades-Community-Samples.  OpenGL rendering occurs in a separate thread.

    My code looks like this (Yes, it's not optimal, but it works for the tests):

    unsigned char * Byte = (unsigned char *): malloc (500 * 1000 * 3);
    : glPixelStorei (GL_PACK_ALIGNMENT, 1);
    : glReadPixels (0, 0, 500, 1000, GL_RGB, GL_UNSIGNED_BYTE, Byte);
    : free (pImage);

    The debugger shows the app crashing into one of the subroutines that call glReadPixels().  Unfortunately, there is no further details go, not to mention that.

    I don't think that it's the width/height because they are below what the screen width/height is set to.

    The code is called immediately after the other objects are drawn on the screen, and before the exchange of buffers is called.  So it's called go the same thread and at the same time as the other OpenGL stampings.

    I compared the Initialise OpenGL for Cascades vs sample how how the native model OpenGL ES2.0 initialize OpenGL, and they are basically the same.

    If there is a place to download sets of projects / complete code, I'd be happy to do so.

    Thank you

    Mark

    I pasted the code (but removed the::'s) in the last GoodCitizen.cpp class and the application has not crashed.)  I'm running it with a recent release so it may have been due to a bug in the former application code, or a bug in the operating system you're using now.  I present the latest version for review later this week and it should be posted next week.  You must also pass in the latest beta of BlackBerry 10 when it is released.

  • Method to apply a style HTTP in Cascades/QML?

    Something like AJAX. What is the equivalent in Cascades/QML? What classes should I Explorer in the API?

    Advice would be greatly appreciated.

    Applications vary.

    http://someservice.com/v1/do/blah

    http://someservice.com/v1/do/meh

    The output of the service is JSON.

    I'll take the exit and probably put it in a list (much like the sample application of stamp collector)

    Help me get started at all help or sample code would be really useful. I imagine that it would be useful for developers who integrate their stunts BB10 app API or data of third parties.

    Thank you!

    Hello

    I wrote a simple example application to show how to create an application that consumes a twitter feed and display JSON content crawled in a standard list view.

    First create a new project named 'Twitter', by selecting file-> New-> BlackBerry Cascades C++ Project, and then choose the option "Empty project" Standard.

    We will start by creating a class called TwitterRequest responsible for the download and let us know through the slots and signals that the twitter JSON data is available. This class must be placed in your src/folder of the project

    TwitterRequest.hpp

    /*
     * Copyright (c) 2011-2012 Research In Motion 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 TWITTERREQUEST_HPP_
    #define TWITTERREQUEST_HPP_
    
    #include 
    
    /*
     * This class is responsible for making a REST call to the twitter api
     * to retrieve the latest feed for a twitter screen name. It emits the complete()
     * signal when the request has completed.
     */
    class TwitterRequest : public QObject
    {
        Q_OBJECT
    public:
        TwitterRequest();
        virtual ~TwitterRequest();
    
        /*
         * Makes a network call to retrieve the twitter feed for the specified screenname
         * @param screenname - the screen name of the feed to extract
         * @see onTimelineReply
         */
        void getTimeline(QString screenname);
    
    public slots:
        /*
         * Callback handler for QNetworkReply finished() signal
         */
        void onTimelineReply();
    
    signals:
        /*
         * This signal is emitted when the twitter request is received
         * @param info - on success, this is the json reply from the request
         *               on failure, it is an error string
         * @param success - true if twitter request succeed, false if not
         */
        void complete(QString info, bool success);
    };
    
    #endif /* TWITTERREQUEST_HPP_ */
    

    TwitterRequest.cpp

    /*
     * Copyright (c) 2011-2012 Research In Motion 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.
     */
    
    #include "TwitterRequest.hpp"
    #include 
    #include 
    #include 
    #include 
    #include 
    
    TwitterRequest::TwitterRequest()
    {
    }
    
    TwitterRequest::~TwitterRequest()
    {
    }
    
    void TwitterRequest::getTimeline(QString screenname)
    {
        QNetworkAccessManager* netManager = new QNetworkAccessManager();
        if (!netManager)
        {
            qDebug() << "Unable to create QNetworkAccessManager!";
            emit complete("Unable to create QNetworkAccessManager!", false);
            return;
        }
    
        QString queryUri = "http://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_n...";
        queryUri += screenname;
        QUrl url(queryUri);
        QNetworkRequest req(url);
    
        QNetworkReply* ipReply = netManager->get(req);
        connect(ipReply, SIGNAL(finished()), this, SLOT(onTimelineReply()));
    }
    
    void TwitterRequest::onTimelineReply()
    {
        QNetworkReply* reply = qobject_cast(sender());
        QString response;
        bool success = false;
        if (reply)
        {
            if (reply->error() == QNetworkReply::NoError)
            {
                int available = reply->bytesAvailable();
                if (available > 0)
                {
                    int bufSize = sizeof(char) * available + sizeof(char);
                    QByteArray buffer(bufSize, 0);
                    int read = reply->read(buffer.data(), available);
                    response = QString(buffer);
                    success = true;
                }
            }
            else
            {
                response =  QString("Error: ") + reply->errorString() + QString(" status:") + reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toString();
                qDebug() << response;
            }
            reply->deleteLater();
        }
        if (response.trimmed().isEmpty())
        {
            response = "Twitter request failed. Check internet connection";
            qDebug() << response;
        }
        emit complete(response, success);
    }
    

    Then, replace the main.qml with the following content.

    import bb.cascades 1.0
    
    Page {
        content: Container {
            background : Color.DarkRed
            layout : DockLayout {
            }
            ListView {
                layoutProperties : DockLayoutProperties {
                    verticalAlignment : VerticalAlignment.Center
                }
                objectName : "basicTimelineView"
                id : basicTimelineView
                listItemComponents: [
                    ListItemComponent {
                        type: "item"
                        StandardListItem {
                            statusText: {
                                ListItemData.created_at
                            }
                            descriptionText: {
                                ListItemData.text
                                }
                        }
                    }
                ]
            }
        }
        onCreationCompleted: {
            cs.getTimeline("ladygaga");
        }
    }
    

    This is a simple page with a ListView with standard components, indicating the date and the content of the tweet. As you can see, immediately after that page is created a call is made in the c++ code by using the context property 'cs' set in the constructor for the App to retrieve the latest tweets of the usernamed "ladygaga". To learn more about the call c ++ QML here https://bdsc.webapps.blackberry.com/cascades/documentation/ui/integrating_cpp_qml/index.html

    Finally, this linking is the App class. It uses slot machines to handle the "full" signal generated by the class TwitterRequest when data are available, analyzes the data in a model of GroupData and fills the ListView with the recovered data.

    App.HPP

    #ifndef APP_H
    #define APP_H
    
    #include 
    #include 
    
    class App : public QObject
    {
        Q_OBJECT
    
    public:
        App();
    
        /*
         * Called by the QML to get a twitter feed for the screen nane
         */
        Q_INVOKABLE void getTimeline(QString screenName);
    
    public slots:
        /*
         * Handles the complete signal from TwitterRequest when
         * the request is complete
         * @see TwitterRequest::complete()
         */
        void onTwitterTimeline(QString info, bool success);
    
    protected:
        bb::cascades::AbstractPane* m_root;
    };
    
    #endif // ifndef APP_H
    

    App.cpp

    #include 
    #include 
    #include 
    #include 
    #include 
    
    #include "App.hpp"
    #include "TwitterRequest.hpp"
    
    using namespace bb::cascades;
    
    App::App()
    {
        QmlDocument *qml = QmlDocument::create("main.qml");
        qml->setContextProperty("cs", this);
    
        m_root = qml->createRootNode();
        Application::setScene(m_root);
    }
    
    void App::getTimeline(QString screenName)
    {
        //sanitize screenname
        QStringList list = screenName.split(QRegExp("\\s+"), QString::SkipEmptyParts);
        if (list.count() <= 0)
        {
            qDebug() << "please enter a valid screen name";
            return;
        }
        QString twitterid = list[0];
    
        TwitterRequest* tr = new TwitterRequest();
        tr->getTimeline(twitterid);
        connect(tr, SIGNAL(complete(QString, bool)), this, SLOT(onTwitterTimeline(QString, bool)));
    }
    
    void App::onTwitterTimeline(QString info, bool success)
    {
        if (!success)
        {
            qDebug() << "Error retrieving twitter fee: " << info;
            return;
        }
    
        ListView* list = m_root->findChild("basicTimelineView");
        if (!list || list->dataModel() != NULL)
        {
            qDebug() << "basic list already populated";
            return; //if basic timeline list not found or already populated do nothing
        }
    
        // Create a group data model with id as the sorting key
        GroupDataModel* dm = new GroupDataModel(QStringList() << "id_str");
        dm->setGrouping(ItemGrouping::None);
    
        // parse the json response with JsonDataAccess
        bb::data::JsonDataAccess ja;
        QVariant jsonva = ja.loadFromBuffer(info);
    
        // the qvariant is an array of tweets which is extracted as a list
        QVariantList feed = jsonva.toList();
    
        // for each object in the array, push the variantmap in its raw form
        // into the ListView
        for (QList::iterator it = feed.begin(); it != feed.end(); it++)
        {
            QVariantMap tweet = it->toMap();
            dm->insert(tweet);
        }
    
        // set the data model to display
        list->setDataModel(dm);
        list->setVisible(true);
    }
    

    I hope that's enough to help you get started. There are many improvements that can be made, for example using multiple pages, load the ajax style tweets, even having a page where the twitter user name can be changed, and so on of error handling. Good luck!

    See you soon

    Swann

  • Existing purchases in the sandbox?

    I'm currently testing digital purchases. We have a 30 day subscription and a mode (consumables) added to the project "1 year license.

    I can buy the two without problem, but searching for purchase fails.

    According to the documentation

    You can retrieve past purchases only for the current test session. Digital goods that are purchased in a draft status are not written to the transaction database, so when you end the test session the cache is cleared.
    

    For now I just have a few buttons, "purchase subscription", "buy license" and "check for purchases", I use one after the other (buy things!), but the answer of requestExistingPurchases() is always errorcode 3 item not found (PS1300eHW).

    As for the subscription, I buy it with success, but always the answer-> isActive returns false.

    Could someone explain the session 'test' ends in fact? Or how can I test my code without the publication of the application and the purchase of the subscription "for real" first?

    You will only be able to recover existing if you use local mode by setting the mode of connection Test or purchases local (depending on who is using Cascade app or C API).

    If you do not use the Test mode and you use a sandbox user, recovery of existing purchases won't work, because the purchase transaction is not recorded on the BlackBerry World.

    If subscriptions can only be tested in test/local mode, unless you use real money.

    It refers to the review session would be running the application in local/test mode.  Once you close, all data in the local mode disappeared.

  • NFC political "Allow transfer of work using NFC data" opens too many doors

    There are two strategies for BB10 on BES 12.3 for applications using NFC:

    a generic NFC

    and also

    "Allow transfer of work data using NFC"
    

    UseCase:

    Enterprise application runs the Cascades APP in the scope of work to register participants for events using the NFC

    APP is the reading of the ID of the NFC with C chip

    For this NFC card specific my Enterprise customer use, I had to put the two policies to allow reading of the ID cards.

    If there are employees more then a sweep of the participant - maps, in the end, we should collect all scanned and upload to the server (probably later because wifi is bad in many hotels)

    I have to transfer the collection ID of one peripheral BB10 to another creates a folder SNEP. (also using (C)

    SNEP transfers text/plain and secure data I encrypt the data and then encode Base64 for this exchange of data can be done between devices running the same app 'know' encrypt/decrypt.

    Here the problem:

    definition of the policy "allow the transfer...". "This opens for applications: you can mark the text and share it using NFC to other devices running all apps supporting NMIs private or work scope of NFC.

    transfer of files using the part of the NFC can be disabled policy, but for example set the text of email from work and transfer as text outside the scope of work is a possible leak.

    So it would be great, not only to have a comprehensive policy "allow the transfer...". "to the BES12, but also a specific authorization for BB10 apps.

    Maybe there is already something like this? (I know there are some additional permissions that are not included in the boxes of bar descriptor.xml editor)

    If not, where to place a request for security feature because it targets BES and waterfalls.

    It is really important for my client to the company (from Finance Services that run many devices BB10)

    THX help

    GOD

    I have it.  I don't think that there is a way to do it without opening the holes that you mention.  Climbing the functionality through their account manager would be the best way to go.

  • Why development is better in the platform of application waterfalls at the original place.

    Hello

    Please suggest why development is better in the waterfalls of platform application instead of native...

    mainly because you have a ready user interface to use and don't have to write it yourself.

    There are (other) infrastructure of user interface available for native, as QtQuick, but they do not have the same look & feel and users will quickly get used to the behavior of the cascades apps.
    (or html5 apps, which reproduce it)

    unless you want to have a completely custom user interface (or not?), I see little reason not go to waterfalls.

  • Error message when the export for immediate release

    Hello

    Yes, it was just that one.

    The problem seems to be the .pro file. I started this project some time ago and I noticed that recent examples have a different format for the .pro (and the ways for QT Mobility).

    I've updated to match the current location diagnoses cascades app and it relies. There were other problems caused by the switch - I actually had to revert to a previous without some mobility features while I have a glance.

    It is strange. How can I have a pro successfully file generates signed with a token of debugging, and breaks the packer of liberation?

  • Frame image error

    Hi guys!

    I try to create an Image in C++ object, but it is impossible for me. Take this piece of real waterfalls project code:

    #include 
    #include 
    #include 
    #include 
    
    #include "app.hpp"
    
    using namespace bb::cascades;
    
    App::App()
    {
        QmlDocument *qml = QmlDocument::create("main.qml");
        qml->setContextProperty("cs", this);
    
        AbstractPane *root = qml->createRootNode();
        Application::setScene(root);
        Image resImg = Image(QUrl("asset:///images/beach-scene"));
    }
    

    When launched, this error message appears in the Momentic Console:

    Context: Failed to find target node with id %d 27
    

    The same result if I put the file extension:

    Image resImg = Image(QUrl("asset:///images/beach-scene.png"));
    

    And even if I put this line in a class method:

    void App::createImage()
    {
        Image resImg = Image(QUrl("asset:///images/beach-scene"));
    }
    

    Bug?

    I get the warning that you indicate in the first beta by using the name of png, using assets: / / / or relative path.  Seems to create the Image he makes, not the definition of the image.  But the code seems to work in all cases.

    Will try again with the current beta.

    Stuart

  • problems of centering (vertically) a button on the screen

    Hello.

    I have a blackberry 10 cascades app with the code below.

    How could I get the button to fill the entire screen? I would have thought the following would do the trick, but it doesn't. The button expands horizontally to fill the width of the parent, but vertically the buttn just at the top of the screen the same as if I had not called setVerticalAlignment() at all.

    Any ideas? Maybe it's a bug?

    Thank you very much in advance.

    //-----------------------------------------

    Page * Pg = new Page();

    Button * butt = new Button();
    Welding end to end-> setText ("well");
    Welding end-to-end-> setHorizontalAlignment (HorizontalAlignment::Fill);
    Welding end-to-end-> setVerticalAlignment (VerticalAlignment::Fill);

    PG-> setContent (Butt);

    Application::instance()-> setScene (Pg);

    I really expect that this works only inside a container with a DockLayout. I don't know what pages in terms of layout, but I'm going to guess that they do nothing, which would mean that their single 'content' component would not adjusted at all position and sat at 0,0 or the upper left corner.

    It looks like you to experiment a little... in practice, I don't think that someone never put a single item non-conteneur on a Page, but generally always a container of other stuff in it. The default value for a container is StackLayout, so you will need to change to DockLayout and default alignment for stuff is Left and Top, so it should work with your Center for vertical alignment.

Maybe you are looking for