Update QListDataModel of c + c++ / QML

I have a QVariantList and from there I'm creating a QListDataModel and its application in my ListView in QML.

My problem is that I do this, where my main page of QML is created in C++, and when I add to the list of the loose or change them that they are not updated.

I have read that I need to signals and what did not, and then make the changes directly in the model for them to be updated.

My question is how I updated the model of data outside of my function to create C++ main UI that I don't know how to access the data model in C++ for the specific listview or QML.

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
    qml->setContextProperty("app", this);
    app->setScene(root);

    QSettings settings;
    qList = settings.value("list").toList();

    ListView* myList = root->findChild("myListView");

    model = new QListDataModel;
    model->setParent(this);
    model->clear();

    for (int i  = 0; i  < qList.length(); ++ i ) {
        myListModel *myModel= new myListModel(i);
        model->insert(i,myModel);
    }

    myList->setDataModel(model);
    myList->setVisible(true);
    qmlRegisterType("com.example", 1,0, "myListModel");
}

void ApplicationUI::updateList(){

    //QListDataModel  *model = Application::instance()->scene()->findChild("myListModel");
}

For reference, all I had to do was keep the pointer to the global listview and instead of update of specific items, I recreate a new model with new data and apply the new model on this listview.

May be ineffective, but if I did that several items in my list of great works.

Tags: BlackBerry Developers

Similar Questions

  • Update of the progress in QML dialog box

    I have the progress dialog box and QTimer. I want to make my progress dialog was updated every second for 60 seconds, how?

    Sorry, I misread your original message.

    In your onTimeout QTimer slot, you should be able to do something like this:

    progressDialog.progress = ;
    progressDialog.update();
    

    ... except that it won't work because update() is not defined as Q_INVOKABLE. I don't know why it wouldn't because this seems to be a fairly common use case. You may be forced to do it all in C++, you can call update(), which to my knowledge is the only way to change the progress posted on SystemProgressIndicator. If you want to continue to do in QML you can extend SystemProgressIndicator with your own class, make visible update() to QML via Q_INVOKABLEand then expose your new class to QML with qmlRegisterType.

    lichienmine wrote:
    your code works well, but progressDialog and progressIndicator is different. I have no problem to update the value progressIndicator but how to update the progress of the progressDialog?

  • Dynamic active frame with the data from a file

    Hello

    I'm looking in creating a dynamic active setting (like the BBM active frame that has a title of the header and moves through updates).

    I will create a page that has a heading "interesting facts" and then labels different facts and I was wondering how I would go on the establishment in order to create a dynamic active frame that scroll the different labels?

    Thanks in advance

    Hello

    You can follow the example of code here.

    https://github.com/BlackBerry/Cascades-samples/tree/master/BFB-showcase

    The "activeFrameQML.cpp" has this feature

    {voidActiveFrameQML::update()}

    TODO: Replace with piloted by data update instead.

    If {(isActiveFrame)

    QTimer::singleShot (10000, this, SLOT (update ()));

    issue of updateChanged();

    }

    }

    And you can place your updated code in the 'AppCover.qml' to update your ActiveFrame

  • How to make your custom data type used in your QListDataModel to QML?

    I have QListDataModel filled with objects of a custom class carying data and defined with Q_DECLARE_METATYPE. So far, it works however I can't access the data in qml:

    e.g. text: ListItemData.Name
    

    I read that this can be solved by letting QML know your custom class/type, but how to do this?

    See

    https://developer.BlackBerry.com/native/documentation/Cascades/dev/integrating_cpp_qml/

    example:

    qmlRegisterType("com.isec7.materials", 1, 0, "Account");
    
  • Update QML component c++

    Hello

    I was following the situation. Let's say I have a main QML file that is called from C++ as follows:

    ShareTheMatch::ShareTheMatch(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();
    
        // Expose networking instance to QML so that from QML it is possible
        // to make queries to the network and the server
        NetworkManager *networkObject = new NetworkManager();
        qml->setContextProperty("networkObject", networkObject);
    
        // set created root object as a scene
        app->setScene(root);
    }
    

    Now, on the main.qml file, the user can do various activities, for example to navigate to a new .qml file.

    Now, imagine a user has clicked a button on the file main.qml which he redirected a qml file, called

    SecondDialog.qml. my problem is the following. Code C++ (see above), I want to be able to update

    a component that is located on the SecondDialog.qml - how is possible to do this?

    PS. I know not how I'd be able to do that if I were to update a component that was on the file main.qml (e.. g, using the findChild method), but I do not know how to proceed in the case of SecondDialog.qml (partially because she is recalled in another qml file). How to get there?

    Any help greately appreciated.

    set an object name

    Button{
    id: myButton
    objectName: "secondPageButton"
    }
    
    Button *newButton = bb::cascades::Application::instance()->findChild("secondPageButton");
    
  • update of a drop-down list of QML from C++ fails the first time

    Hey gang,

    I have a function in my C++ class that seeks a couple of drop downs by ObjectName and their Options adds.

    the feature works well - except that when the application first starts, the function cannot find the menu drop-down, then the drop-down list is empty.  At various times during the execution of the application, it refreshes the drop-down list and those all great works.  It is only on the first attempt when the application first starts it fails.

    Here's the function:

    void WorkManager::updateDropDown() {
    //  qWarning() << "WorkManager::updateDropDown(), running..";
    /*
     * this function updates the two drop down lists in the UI
     * it updates them dynamically with the taskName() ('label') of the job.
     * NOTE: for some reason, this doesn't find the dropdown's by name on first start.  however subsequent runs work fine.
     */
        int i = 0;
        QList  myObjects = m_model->toListOfObjects();
        DropDown * dpList = bb::cascades::Application::instance()->scene()->findChild("scriptListDropDown");
        DropDown * logDpList = bb::cascades::Application::instance()->scene()->findChild("logDropDown");
        if (dpList != 0 && logDpList !=0 ) {
            dpList->removeAll();
            logDpList->removeAll();
            for (i = 0; i < myObjects.size(); i++) {
                Task * myTask = static_cast (myObjects[i]);
                myTask->setParent(this);
                dpList->add(Option::create().text(myTask->taskLabel()).value(myTask->command()));
                logDpList->add(Option::create().text(myTask->taskLabel()).value(myTask->taskName() + ".log"));
            }
        } else  {
    //      qWarning() << "WorkManager::updateDropDown(), ---> dpList was 0, try again";
        }
    }
    

    so when the application starts, I get this message of qWarning() and dpList (and logDpList) are both 0.

    I tried the dissemination of calls to this function in various places at the same time the C++ class, so in onCreationCompleted() different signals in the QML IU - as for the homepage, TabbedPane, drop-down menus.

    No matter where and when I call, I can't get the drop-down list to provide information on the first try.

    is there a way to find a way to make this work?  It's (quite) a little annoying.  I wish that the onCreationCompleted() for the drop-down list would work, but alas, no joy.

    Help?

    Thank you!

    J

    Quite simply, if the object is not in the scene tree, you will get a result of findChild. It has not been created or added to the scene.

    You say that you did above in onCreationCompleted of a drop-down list, but this would only guarantee that one of your drop-down menus has been created and your conditional statement requires that both happening simultaneously be non-null. You must run the above, when the two objects are created.

    It seems that you can split the above function to manage separately, the dpList and logDpList after the onCreationCompleted of signals for each drop-down list.

    Note: If you run findChild on the user interface of your entire application, your application has a serious design flaw.

  • How to create timer thread and update the data in qml

    See once again that the user selects the time then I have to open a plus qml, them what that time that the user has selected he will start him it and display in the texview of this point of time until compled times what the user has selected.

    the textview should show how the change of second... That is to say all like look.

    Please guide me what the correct feature I have to used?

    I won't go to timer or wire?

    Please guide me

    Now please tell me that you are able to see the image or not?

    Plese now answer the solution?

  • SystemProgressDialog automatically in QML update

    I need help, I want to update my SystemProgressDialog progress every second for about 1 minutes. I try but the progress is not updated. Here is my code:

    Container {
        Button {
            text : "Start"
            onClicked : {
                myProgress.show()
                myTimer.start()
            }
        }
        attachedObject : [
            SystemProgressDialog {
                id : myProgress
                title: ""
                body: ""
                progress: 0
                emoticonsEnabled: true
                state : SystemUiProgressState.Active
            },
            QTimer {
                id: myTimer
                interval:  1000
                onTimeout: {
                    if (myProgress.progress < 100 ){
                        //I have try this one too myProgress.progress = myProgress.progres + (100/60)
                        myProgress.progressChanged(myProgress.progres + (100/60))
                        timer.start()
                    }
    
                }
            }
        ]
    }
    

    You start as a first Timer

    onClicked:{
        myTimer.start()
        myProgress.show()
    }
    

    And as Timer will repeat until you stop it. So call myTimer.start () onTimeout signal is bad...

    Try this:

    Page {
        Button {
            text : "Start"
            onClicked : {
                myTimer.start()
                myProgress.show()
    
            }
        }
        attachedObjects : [
            SystemProgressDialog {
                id : myProgress
                title: "Title"
                onFinished: {
                    if (result == SystemUiResult.ConfirmButtonSelection){
                        console.debug("OK clicked")
                        myTimer.stop()
                    }
                }
            },
            MyTimer {
                id: myTimer
                interval:  1000
                onTimeout: {
                    if (myProgress.progress == 100 ){                    myProgress.cancel()
                        stop()
                    }
                    myProgress.progress += 100/60
                    console.debug("CurrentProgress: ".concat(myProgress.progress))
                    myProgress.update()
                }
            }
        ]
    }
    

    If you use Cascades API 1.2, then you can try set autoUpdateEnabled to tru to use myProgress.update () instead

  • Display QList ListItemData &lt; QVariantMap &gt; with &lt; QVariantMap &gt; QListDataModel

    Hey,.

    I have a declared list like so:

    ListView {
                    id: PostsList
                    preferredWidth: 700
                    objectName: "PostsList"
                    layoutProperties: DockLayoutProperties {
                        horizontalAlignment: HorizontalAlignment.Center
                    }
    
                    // A single component because there's no list header.
                    listItemComponents: [
                        ListItemComponent {
                            type: "post"
                            PostItem {
                            }
                        }
                    ]
                                    //Tried this hoping items were being misparsed as headers.
                    function itemType(data, indexPath) {
                            return 'item';
                    }
                }
    

    Where is PostItem.qml

    Container {
        id: itemRoot
        layout: DockLayout {
            leftPadding: 30
            rightPadding: leftPadding
            topPadding: 30
        }
    
        Container {
            preferredHeight: 250
            layout: DockLayout {
            }
            Label {
                //text: ListItemData.data.title
                text: ListItemData.title
                layoutProperties: DockLayoutProperties {
                    verticalAlignment: VerticalAlignment.Center
                    horizontalAlignment: HorizontalAlignment.Center
                 }
            }        Label {            //text: ListItemData.data.title            text: ListItemData.description            layoutProperties: DockLayoutProperties {                verticalAlignment: VerticalAlignment.Center                horizontalAlignment: HorizontalAlignment.Center             }        } }
    
        // Signal handler for list item activation.
        ListItem.onActiveChanged: {
            setHighlight (ListItem.active);
        }
    
        // Signal handler for list item selection.
        ListItem.onSelectedChanged: {
            setHighlight (ListItem.selected);
        }
    }
    

    If you begin to feel that this code resembles stamp collector, you something...

    in any case, I stated as follows the data model for the list, copy the following code runs in a callback function SLOT QNetworkAccessManager...

    QList map;QVariantMap variant;foreach (post, posts)
    {
        variant.clear();
        variant.insert("id", post->id);
        variant.insert("title", post->title);
        variant.insert("author", post->author);
        map.insert(map.length(), variant);
    }
    
    ListView *PostsList = mNav->findChild("PostsList");
    
    QListDataModel *model = new QListDataModel;
    model->setParent(this);
    model->clear();
    
    QVariantMap v;
    int i = 0;
    foreach(v, map)
    {
        model->insert(i,v);
        i++;
    }
    
    PostsList->setDataModel(model);
    

    Here is what I expected to happen.

    I compile and debug the program. Some code I have send the network request. I analyze the JSON in a QList (which is my own type). From their I looked in a QList (map, called in the code above). Once I put my ListView data model as the variable according to the guidelines of this line:

    PostsList-> setDataModel (model);

    "PostsList" list updates in the application and displays the data from post-> title, as that inserted in the QVariant inserted in QVariantMap on this line:

    Variant. Insert ("title", post-> title);

    Instead, what is shown is the post-> data of the author, and the only reason I can possible design that is displayed (in reality the point post about 13 members, I removed most of length) is that it is the first in alphabetical order and seems to be the first member of the QVariantMap variable. The author of the message is the unique label presented, so declared both in the QML labels seem to be ignored.

    When I select a list item (by using the code is essentially identical to the example of stampcollector) and page through the QDeclarativeContext method all members of the QVariantMap are accessible and can be used to display items QML.

    Here is an example of how the stamp collector app that performs in the OnSelectionChanged handler:

    ListView* PostsList = dynamic_cast(sender());
    DataModel* Model = PostsList->dataModel();
    
    // Update the content view context property so that it corresponds to
    // the selected item and navigate to the page.
    QVariantMap map = Model->data(indexPath).toMap();
    mQmlContext->setContextProperty("_contentView", map);
    mNav->push(mContentPage);
    

    Can someone explain the behavior that I receive? Why can't I access the articles through the ListItemData.member method as described in the documentation?

    Note: some minor code changes have been made for length and clarity, the code has no compiler errors and like I said the DataModel code works at least to a certain extent all the data members that I expect to be accessible in ListItemData are available in _contentView.

    I haven't checked in depth, but the first thing I would try, is to change your function to return 'post' instead of "item", since you have a component for "post".   I will try an example.

    Stuart

  • HOWTO: Translation Live in C++ similar to re-translate in QML

    WARNING: To come long post!

    If you've built (or building) your apps BlackBerry 10 Aboriginal stunts with internationalization in mind, then you have probably dotted with QML qsTr() calls and macros tr() C++ code. When your application starts the text wrapped in qsTr() or tr() is replaced by the localized text for the local unit and the language (if defined, otherwise default text is used). This works fine unless you change the language setting on your device while your application is running. Unless you take measures to propagate the change to the language through your live webcam app, the text displayed in your application will not match the settting of language new device only when your application is restarted. QML provides this translation of 'direct' with the re-translation class, which can be used with qsTr() update of translations that soon the language setting of the device is changed:

    Page {   Container {      Label {         id: label01
    
             // ---This label's text will be live translated         text: qsTr("Label 1") + Retranslate.onLanguageChanged      }      Label {         id: label02
    
             // ---This label's text will be static translated         text: qsTr("Label 2")      }   }}
    

    In this example, label01 will be his attribute of translated text live as it is updated as soon as the device language is changed. However, label02 will have only his attribute of text translated when the software is first started and the language changes following while the application is running will not update to it.

    With the help of the re-translation with QML class makes direct translation as simple as the addition of a small amount of code just after each use of qsTr(), but C++ does provide no such convenience. To implement the translation directly in C++ code, it is necessary to call setXXX() for a string with the macro tr() attribute slot once to do the initial translation and then connect the setXXX() slot to an instance of LocaleHandler that emits a signal every time the language (or locale) changes. It's complicated by the fact that the LocaleHandler knows that the language has changed, but he doesn't know which key text to provide openings, it is attached to the then must fix the LocaleHandler signal to an intermediate location that knows what translation of key to use for this attribute, and then emits a different signal with the key as a parameter that must be connected to the slot machine control setXXX() . This means that, for every single control attribute you want live, translate you'll need a separate intermediate location set somewhere, a signal linked to this site and two calls QObject::connect(). For EACH attribute that we want to live translation. Of course, this becomes very ugly, very fast.

    I prefer to use C++ with QML little or not to expose my app pages so I was determined to find a solution that was easier to use than retranslating in QML (or almost) and after some trial and error I came up with a solution that I am very satisfied. The core of this technique is a C++ class called LiveTranslator. The syntax to use is a bit more complicated to use QML re-translation, but as re-translation you only need to add a line of code for each attribute that you want to translate live. Here is the header for LiveTranslator:

    #ifndef LIVETRANSLATOR_HPP_
    #define LIVETRANSLATOR_HPP_
    
    #include 
    
    using namespace bb::cascades;
    
    class LiveTranslator: public QObject {
        Q_OBJECT
    
        QString _key;
        QString _context;
    
        static LocaleHandler* _localeHandler;
    
    public:
        LiveTranslator( const QString& context, const QString& key, QObject* target, const char* slot );
        static void setLocaleHandler( LocaleHandler* localeHandler );
    
    private slots:
        void localeOrLanguageChangedHandler();
    
    signals:
        void translate( const QString& string );
    };
    
    #endif /* LIVETRANSLATOR_HPP_ */
    

    .. .and the body...

    #include "LiveTranslator.hpp"
    
    // ---Initialize the locale handler pointer on app startup so we can tell if it has been set properly later
    LocaleHandler* LiveTranslator::_localeHandler = 0;
    
    // ---Note that the target control is also used as the parent so the live translator dies when the control does
    LiveTranslator::LiveTranslator( const QString& context, const QString& key, QObject* target, const char* slot ) :
            QObject( target ) {
    
        bool success;
        Q_UNUSED( success );
    
        // ---Save the context and key string
        this->_key = key;
        this->_context = context;
    
        // ---Die (during debug) if the locale handler hasn't been set properly before use
        Q_ASSERT( LiveTranslator::_localeHandler );
    
        // ---Watch for locale or language changes
        success = QObject::connect( LiveTranslator::_localeHandler, SIGNAL( localeOrLanguageChanged() ), SLOT( localeOrLanguageChangedHandler() ) );
        Q_ASSERT( success );
    
        // ---Trigger specified slot when locale or language changes
        success = QObject::connect( this, SIGNAL( translate( const QString& ) ), target, slot );
        Q_ASSERT( success );
    }
    
    void LiveTranslator::localeOrLanguageChangedHandler() {
        // ---Use the specified slot on the target to update the appropriate string attribute with the translated key
        emit translate( QCoreApplication::translate( this->_context.toLocal8Bit().constData(), this->_key.toLocal8Bit().constData() ) );
    }
    
    // ---This function MUST be called once with a valid LocaleHandler before any LiveTranslator classes are instantiated
    void LiveTranslator::setLocaleHandler( LocaleHandler* localeHandler ) {
        LiveTranslator::_localeHandler = localeHandler;
    }
    

    LiveTranslator encapsulates all the ugly stuff, including remembering the key to the translation, the intermediate signal/slot, and all signal/slot connections necessary for direct translation. Use is as simple as creating an instance of LiveTranslator, passing the constructor the translation for the attribute key (and the context, but more on that later), the Visual control of the target and the location on the control that accepts the update of translation. Note that tr() only works with static keys chains...

    // ---This is valid
    QString str1 = tr("string one");
    
    // ---This is not!
    Qstring str1 = "string one";
    QString str2 = tr(str1);
    

    .. .so instead tr(), LiveTranslator must use QCoreApplication translate() internally.

    An example of use of LiveTranslator :

    MyClass::MyClass() {
        Label* label = Label::create().text( tr("Label one") );
        new LiveTranslator( "MyClass", "Label one", label, SLOT(setText(const QString&)));
    
        Option* option = Option::create().text( tr("Option one") ).description( tr("Option one description") );
        new LiveTranslator( "MyClass", "Option one", option, SLOT(setText(const QString&)));
        new LiveTranslator( "MyClass", "Option one description", option, SLOT(setDescription(const QString&)));
    
        ActionItem* actionItem = Option::create().title( tr("Action one") );
        new LiveTranslator( "MyClass", "Action one", actionItem, SLOT(setTitle(const QString&)));
    }
    

    Note that there is no need to save a reference to the new instance LiveTranslator since the constructor sets the 'target' as a parent control. When the control is destroyed by your app the LiveTranslator will go with him. The first parameter to the constructor LiveTranslator is the 'context' where the translation key. When you use the macro tr() (or function qsTr() QML) the code parser mentions of where he found the key and stores it in the translation file. This way you can use the same key for translation on different pages, and if the context is different, you could have them translated differently. The parser doesn't know anything about the LiveTranslator class but it must indicate the context explicitly. For C++, the context is always the name of the class containing the code that you are translating. In addition, in case it is not obvious, the "key" parameter must be the same value used with tr() on the input line.

    There is one thing that you must do before using LiveTranslator in your C++ code and that is to give it a LocaleHandler to work with. Rather than force you to spend a LocaleHandler for each instance of LiveTranslator, you tell LiveTranslator that one to use only once with a static function call. If you created your application from one of the Momentics models then you already have a Manager, you can use:

    ApplicationUI::ApplicationUI() : QObject() {
        // prepare the localization
        m_pTranslator = new QTranslator( this );
        m_pLocaleHandler = new LocaleHandler( this );
    
        // Use this locale handler for all the live translations too
        LiveTranslator::setLocaleHandler( m_pLocaleHandler );
    
        ...
        ...
        ...
    }
    

    I enclose the source for LiveTranslator so all you need to do to get the direct translation working in your BB10 native C++ code is extract the zip in your src directory, add a call to LiveTranslator::setLocaleHandler() in your main application class constructor, and then call new LiveTranslator (...) with the appropriate settings for each attribute of the control you want to be living translated. I hope that is useful to the native BlackBerry 10 development community wonderful (and long-suffering).

    IMPORTANT!

    The instructions posted above have been extended and improved to work with some additional user interface controls such as SystemDialog and SystemUiButton. It was published with a link to a sample application on GitHub as an guest article on the Blog of Dev of BlackBerry. Additional functionality has been added to the original code shown above, then the blog article and GitHub example now consider the definitive description of this technique.

    See you soon.

  • Using C++ in QML classes in app without head: refers to 'bb::device:VibrationController:staticMetaObject' the undefined

    Hi, I've been weeks of work on the BB and had a lot of problems. Some of them have been resolved, some were not without the support of the forum.

    Now I have a great difficulty that I can't find answer by Googling.

    I am grateful to some body can help.

    Here's a simple case that make the big problem for me:

    1. create an app without head with Momentics. 2 project will be generated HeadlessApp and HeadlessAppService.

    Without modification, this code works well.

    2. I'm link below to use VibrationController in HeadlessAppService: https://developer.blackberry.com/native/documentation/dev/integrating_cpp_qml/index.html#usingcclass...

    below the code has been added:

    -Add codes below to main.cpp HeadlessAppService

    #include 
    using namespace bb::device;
    

    then add qmlRegisterType as below

    Q_DECL_EXPORT int main(int argc, char **argv)
    {
    
       Application app(argc, argv);
    
       qmlRegisterType("bb.vibrationController", 1, 0, "VibrationController");
       ApplicationUI appui;
       return Application::exec();
    }
    

    3. to confirm the new code, I just right click on the project and select build project.

    Bang! I got several error I don't understand. (red lines are errors)

    08:44:30 **** Incremental Build of configuration Device-Debug for project headlessTest ****
    make -j4 Device-Debug
    make -C .//translations -f Makefile update
    make[1]: Entering directory 'D:/BB-dev/momentics-workspace/headlessTest/translations'
    C:/bbndk/host_10_3_1_12/win32/x86/usr/bin/lupdate headlessTest.pro
    Updating 'headlessTest.ts'...
        Found 2 source text(s) (0 new and 2 already existing)
    make[1]: Leaving directory 'D:/BB-dev/momentics-workspace/headlessTest/translations'
    make -C .//translations -f Makefile release
    make[1]: Entering directory 'D:/BB-dev/momentics-workspace/headlessTest/translations'
    C:/bbndk/host_10_3_1_12/win32/x86/usr/bin/lrelease headlessTest.pro
    Updating 'D:/BB-dev/momentics-workspace/headlessTest/translations/headlessTest.qm'...
        Generated 0 translation(s) (0 finished and 0 unfinished)
        Ignored 2 untranslated source text(s)
    make[1]: Leaving directory 'D:/BB-dev/momentics-workspace/headlessTest/translations'
    make -C ./arm -f Makefile debug
    make[1]: Entering directory 'D:/BB-dev/momentics-workspace/headlessTest/arm'
    make -f Makefile.Debug
    make[2]: Entering directory 'D:/BB-dev/momentics-workspace/headlessTest/arm'
    qcc -Vgcc_ntoarmv7le -lang-c++ -Wl,-rpath-link,C:/bbndk/target_10_3_1_995/qnx6/armle-v7/lib -Wl,-rpath-link,C:/bbndk/target_10_3_1_995/qnx6/armle-v7/usr/lib -Wl,-rpath-link,C:/bbndk/target_10_3_1_995/qnx6/armle-v7/usr/lib/qt4/lib -Wl,-rpath-link,C:/bbndk/target_10_3_1_995/qnx6/armle-v7/usr/lib/qt4/lib -o o.le-v7-g/headlessTest o.le-v7-g/.obj/applicationui.o o.le-v7-g/.obj/main.o o.le-v7-g/.obj/moc_applicationui.o    -LC:/bbndk/target_10_3_1_995/qnx6/armle-v7/usr/lib/bb1 -LC:/bbndk/target_10_3_1_995/qnx6/armle-v7/lib -LC:/bbndk/target_10_3_1_995/qnx6/armle-v7/usr/lib -LC:/bbndk/target_10_3_1_995/qnx6/armle-v7/usr/lib/qt4/lib -LC:/bbndk/target_10_3_1_995/qnx6//usr/lib/qt4/lib -lbb -lbbsystem -lbbcascades -lQtDeclarative -lQtScript -lQtSvg -lQtSql -lsqlite3 -lz -lQtXmlPatterns -lQtGui -lQtNetwork -lsocket -lQtCore -lm -lbps
    o.le-v7-g/.obj/main.o: In function `int qmlRegisterType(char const*, int, int, char const*)':
    c:/bbndk/target_10_3_1_995/qnx6/usr/include/qt4/QtDeclarative/qdeclarative.h:191: undefined reference to `bb::device::VibrationController::staticMetaObject'
    o.le-v7-g/.obj/main.o: In function `QDeclarativeElement':
    c:/bbndk/target_10_3_1_995/qnx6/usr/include/qt4/QtDeclarative/qdeclarativeprivate.h:87: undefined reference to `bb::device::VibrationController::VibrationController(QObject*)'
    o.le-v7-g/.obj/main.o:(.data.rel.ro._ZTVN19QDeclarativePrivate19QDeclarativeElementIN2bb6device19VibrationControllerEEE[_ZTVN19QDeclarativePrivate19QDeclarativeElementIN2bb6device19VibrationControllerEEE]+0x8): undefined reference to `bb::device::VibrationController::metaObject() const'
    o.le-v7-g/.obj/main.o:(.data.rel.ro._ZTVN19QDeclarativePrivate19QDeclarativeElementIN2bb6device19VibrationControllerEEE[_ZTVN19QDeclarativePrivate19QDeclarativeElementIN2bb6device19VibrationControllerEEE]+0xc): undefined reference to `bb::device::VibrationController::qt_metacast(char const*)'
    o.le-v7-g/.obj/main.o:(.data.rel.ro._ZTVN19QDeclarativePrivate19QDeclarativeElementIN2bb6device19VibrationControllerEEE[_ZTVN19QDeclarativePrivate19QDeclarativeElementIN2bb6device19VibrationControllerEEE]+0x10): undefined reference to `bb::device::VibrationController::qt_metacall(QMetaObject::Call, int, void**)'
    o.le-v7-g/.obj/main.o:(.data.rel.ro._ZTIN19QDeclarativePrivate19QDeclarativeElementIN2bb6device19VibrationControllerEEE[_ZTIN19QDeclarativePrivate19QDeclarativeElementIN2bb6device19VibrationControllerEEE]+0x8): undefined reference to `typeinfo for bb::device::VibrationController'
    o.le-v7-g/.obj/main.o: In function `~QDeclarativeElement':
    c:/bbndk/target_10_3_1_995/qnx6/usr/include/qt4/QtDeclarative/qdeclarativeprivate.h:91: undefined reference to `bb::device::VibrationController::~VibrationController()'
    c:/bbndk/target_10_3_1_995/qnx6/usr/include/qt4/QtDeclarative/qdeclarativeprivate.h:91: undefined reference to `bb::device::VibrationController::~VibrationController()'cc: C:/bbndk/host_10_3_1_12/win32/x86/usr/bin/ntoarm-ld caught signal 1
    Makefile.Debug:103: recipe for target 'o.le-v7-g/headlessTest' failed
    make[2]: *** [o.le-v7-g/headlessTest] Error 1make[2]: Leaving directory 'D:/BB-dev/momentics-workspace/headlessTest/arm'
    make[1]: *** [debug] Error 2
    Makefile:50: recipe for target 'debug' failed
    make: *** [Device-Debug] Error 2make[1]: Leaving directory 'D:/BB-dev/momentics-workspace/headlessTest/arm'
    mk/cs-base.mk:31: recipe for target 'Device-Debug' failed
    08:44:31 Build Finished (took 1s.47ms)
    

    I give up!

    Why adding simple code can be a problem? Please help me!

    Thank you very much!

    You must add this code into main.cpp to your HeadlessApp, not HeadlessAppService. Your spare part cannot run any UI stuff, trying to save an object any for QML is part of the things in the user interface.

    But anyway, reading your newspaper from the console, you seem to put in the right place anyway. Did you add this to your headlessTest.pro file:
    LIBS +=-lbbdevice

  • QML preview window does not

    I'm actually trying to get a snippet of my application in the windows but QML Previewer is does not work... I need to how to solve this problem see this Image and well know http://snag.gy/zp6Bc.jpg hate this for two days

    It would be the Nvidia 920 m, which should have the necessary support.  Try to update your video drivers to the latest from NVIDIA.

  • Custom in QML for waterfalls icon button

    Just thought I'd share this in case anyone is looking for a solution get a button that is customized by using Cascades.
    The idea is to have a button with an icon and label.

    I use 2 nine slices images as a background.

    In C++, I have a method called navClick(QString name), I can't tell which button was clicked by his label.

    IconButton.qml

    import bb.cascades 1.0
    
    Container {
        layout: DockLayout {
        }
        property alias image: img.imageSource
        property alias text: lbl.text
    
        leftMargin: 10
        rightMargin: 10
        preferredWidth: 400
    
        //
        onTouch: {
            if (event.isUp ()) {
                root.navClick (text);
                console.log (text);
            }
            //
            if (event.isDown () || event.isMove ()) {
                panel.imageSource = "asset:///panel_down";
            } else {
                panel.imageSource = "asset:///panel_up"
            }
        } 
    
       //    onTouchExit: {        panel.imageSource = "asset:///ui/panel_up"    }    //
        ImageView {
            id: "panel"
            imageSource: "asset:///panel_up"
            preferredWidth: 400
            minHeight: 178
            scalingMethod: ScalingMethod.Fill
        }
    
        //
        Container {
            layoutProperties: StackLayoutProperties {
                horizontalAlignment: HorizontalAlignment.Center
            }
            preferredWidth: 400
            Container {
            }
            //
            ImageView {
                layoutProperties: StackLayoutProperties {
                    horizontalAlignment: HorizontalAlignment.Center
                }
                id: img
                imageSource: "asset:///test.png"
                topMargin: 40
                preferredWidth: 51
                preferredHeight: 51
            }
    
            //
            Label {
                layoutProperties: StackLayoutProperties {
                    horizontalAlignment: HorizontalAlignment.Center
                }
    
                //
                textStyle {
                    color: Color.White
                }
    
                //
                id: lbl
                text: "label"
                topMargin: 26
            }
        }
    }
    

    To use in your page layout, just add a defined IconButtonand the image and the text.

    Example:

            Container {
                topMargin: 25
                bottomMargin: 25
    
                 //
                layout: StackLayout {
                    layoutDirection: LayoutDirection.LeftToRight
                }
    
                //
                layoutProperties: StackLayoutProperties {
                    horizontalAlignment: HorizontalAlignment.Center
                }
    
                //
                IconButton {
                    image: "asset:///icon_btn_one"
                    text: "Button 1"
                }
    
                //
                IconButton {
                    image: "asset:///icon_btn_two"
                    text: "Button 2"
                }
    
                 //
                IconButton {
                    image: "asset:///icon_btn_three"
                    text: "Button 3"
                }
            }
    

    If you have ideas to improve this or suggest a better approach, I'd love to hear it.

    Update: added onTouchExit then it resets the State if you move out of the control.

    If you are using the class Button of Cascades, unfortunately, the layout of the text & image cannot be changed and the image is adjusted to fit in the button automatically. You must build your own button as you suggested, varying the properties of components content and layout accordingly.

    Kind regards

    Martin

  • MapView problems after 2.0 update Momentics

    Hello, I am working on a prototype for an idea of the app I have and need to plan very much in the way that Foursquare manages the views of map locations. I've been led to believe that the native integration of cards required coding very little and nothing more than a few lines of code. I studied the demo mapview up and down for hours and I can't figure out what I did wrong. Here's the Basic code.

    import bb.cascades 1.2
    import bb.cascades.maps 1.0
    
    Page {
        Container {
            //Todo: fill me with QML
            Label {
                // Localized text with the dynamic translation and locale updates support
                text: qsTr("Hello World") + Retranslate.onLocaleOrLanguageChanged
                textStyle.base: SystemDefaults.TextStyles.BigText
            }
            MapView {
                id: mapview
                objectName: "mapView"
                altitude: 3000
                latitude: 43.449488
                longitude: -80.406777
                horizontalAlignment: HorizontalAlignment.Center
                preferredHeight: Infinity
                preferredWidth: Infinity
    
            }
        }
    }
    

    The problem is on the Viewer to waterfalls, that plan appears in RED saying "Missing: MapView ' when it is deployed on a device (Dev Alpha B), I get a black box, and no card, pinch and panoramic seem something in the console output log, but is also not very useful.

    Qml debugging is enabled. Only use this in a safe environment!
    unknown symbol: _ZN2bb8cascades4maps7MapView7setTiltEi
    unknown symbol: _ZN2bb8cascades4maps7MapView11setAltitudeEd
    unknown symbol: _ZN2bb8cascades4maps7MapView11setLatitudeEd
    unknown symbol: _ZN2bb8cascades4maps7MapViewC1EPNS0_9ContainerE
    unknown symbol: _ZN2bb8cascades4maps7MapView12setLongitudeEd
    unknown symbol: _ZN2bb8cascades4maps7MapView15setRenderEngineEPNS1_12RenderEngineE
    OrientationSupportPrivate::getSupportedDisplayOrientation:  auto
    OrientationSupportPrivate::initDirectionAndOrientation:
       isCardOrViewer:  false
       manifestDisplayOrientation: All
       displayOrientation: All
       uiOrientation: Portrait
       displayDirection: North
       nativeDisplayOrientation: Portrait
    CS Debugging enabled: false
    MapViewPrivate::removeRenderEngine
    using the following render engine:  bb::cascades::maps::BlankRenderEngine
    MapViewPrivate::removeRenderEngine
    removing the old render engine:  bb::cascades::maps::BlankRenderEngine
    RenderEngineManager::RenderEngineManager
    RenderEngineManager::scanForPlugins()
    render engine search: searching   QDir( "/apps/com.example.WoHoMu.testDev_mple_WoHoMued1f8138/native/mapview-renderengine" , nameFilters = { * },  QDir::SortFlags( Name | IgnoreCase ) , QDir::Filters( Dirs|Files|Drives|AllEntries ) )
    render engine search: searching   QDir( "/base/usr/lib/qt4/plugins/mapview-renderengine" , nameFilters = { * },  QDir::SortFlags( Name | IgnoreCase ) , QDir::Filters( Dirs|Files|Drives|AllEntries ) )
    render engine search: attempting to load  "/base/usr/lib/qt4/plugins/mapview-renderengine/libRenderEngine3d.so"
    RenderEngineManager::engine(    )
    using the following render engine:  bb::cascades::maps::BlankRenderEngine
    unknown symbol: _ZTIN2bb8platform3geo11GeoLocationE
    unknown symbol: _ZTIN2bb8platform3geo11GeoLocationE
    unknown symbol: _ZNK2bb8platform3geo11GeoLocation10metaObjectEv
    unknown symbol: _ZN2bb8platform3geo11GeoLocation11qt_metacastEPKc
    unknown symbol: _ZN2bb8platform3geo11GeoLocation11qt_metacallEN11QMetaObject4CallEiPPv
    unknown symbol: _ZNK2bb8platform3geo11GeoLocation11boundingBoxEv
    unknown symbol: _ZTIN2bb8cascades4maps12RenderEngineE
    unknown symbol: _ZN2bb8cascades4maps12RenderEngine16staticMetaObjectE
    unknown symbol: _ZTIN2bb8platform3geo11GeoPolylineE
    unknown symbol: _ZTIN2bb8platform3geo10GeoPolygonE
    unknown symbol: _ZTIN2bb8platform3geo10GeographicE
    unknown symbol: _ZN2bb8platform3geo17GeoDeviceLocation16staticMetaObjectE
    unknown symbol: _ZNK2bb8platform3geo8Polyline5countEv
    unknown symbol: _ZNK2bb8cascades4maps25RenderEngineConfiguration21foreignWindowWindowIdEv
    unknown symbol: _ZN2bb8platform3geo5StyleD1Ev
    

    I added the necessary permissions for the site and the internet in the bar-descriptor but also added the
    LIBS +=-lbbcascadesmaps line in the .pro project file. Can someone help me to know what is happening?

    I use these libs:

    -lQtLocationSubset - lbbcascadesmaps-lGLESv1_CM

  • WebView: Content is not being updated after changing the URL

    I wrote a code that updates the Blackberry main.qml WebView URL after that some process is running. QT/C++ code that updates WebView URL is given below

    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    qml->setContextProperty("app",this);
    AbstractPane *root = qml->createRootObject();
    responseWebPage = root->findChild("responseWebPage");
    responseWebPage->setUrl(QUrl(homePath + "/Appname/updatedhtml.html"));
    

    I even tried to signals and SLOTs and yet it did not work

    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    qml->setContextProperty("app",this);
    AbstractPane *root = qml->createRootObject();
    responseWebPage = root->findChild("responseWebPage");
    responseWebPage->setUrl(QUrl(homePath + "/Appname/updatedhtml.html"));
    bool response = QObject::connect(responseWebPage, SIGNAL(urlChanged(QUrl)), responseWebPage, SLOT(reload()));
    Q_UNUSED(response);
    Q_ASSERT(response);
    

    WebView main.qml article is

    WebView {
       id: responseWebPage
       objectName: "responseWebPage"
       accessibility.name: "responseWebPage"
       url: "local:///assets/initialcontent.html"
       onUrlChanged: {
          console.debug("URL is changed. New URL is " + responseWebPage.url);
       }
    }
    

    I am able to see the URL name updated in the newspapers printed by WebView debug console. I also checked that the file updatedhtml.html exists. (Checked through the system target file browser). Yet once the URL is set, I see no updatedhtml.html content displayed in device or Simulator. Is there any step I'm missing? Any help is greatly appreciated

    Ahh, I see what you're missing today.  You have created a new Page, it adds the WebView and set its URL, but you have actually posted this page.  What kind of navigation you are trying to use here?  If you want to display a new page and allow the user to return to the previous, look here: https://developer.blackberry.com/native/documentation/ui/navigation/multiple_screens_stack.html

    If you want to replace the current page with a new one, you must call setScene.  Alternatively, you can access the page currently displayed when it exists and update the WebView on it.

    Whatever approach you take, I recommend this reading for an overview on how the user of Cascades interface fit: https://developer.blackberry.com/native/documentation/dev/fundamentals/index.html

Maybe you are looking for