Value of multi ArrayDataModel in QML

I have the ArrayDataModel:

 ArrayDataModel {
            id: arrayModel

        },

DataSource:

        DataSource {
            id: subListDataSource
            source: "data/xPlayer.db"
            query: "SELECT * FROM song_data WHERE album ='" + subListPage.keyWord + "'";

            onDataLoaded: {
                subListDataModel.clear();
                for (var i = 0; i < data.length; ++ i) {
                    arrayModel.append(data[i])
                }

            }

        }

and ListView:

  ListView {
            dataModel: subListDataModel

            listItemComponents: [
                ListItemComponent {
                    type: "item"
                    StandardListItem {
                        title: ListItemData.title
                        status: ListItemData.album

                    }

                }
            ]
      }

the xPlayer.db file is a table of song_data to store data that include the info of the song (album, artist, title)

I implement this code but list view do not seem to work properly, it show only the ownership of the album in the title of listview?

Can I have a multi property table data model?

Implement a routine listType() on the ListView, something like this:

                function itemType(data, indexPath) {
                    return 'item';
                }

Without this, it has no way of knowing that the type of the elements returned by the DataModel should match the type of 'item' you specified in the ListItemComponent.

You can also change the ListItemComponent to say just type: "" because it is essentially the default element type.

Tags: BlackBerry Developers

Similar Questions

  • How to get items of the multi ArrayDataModel element

    Hello

    When I add items to an ArrayDataModel like that

    // Main.qmlvar data = {"name": filename, "path": filepath}theDataModel.append(data);
    

    How can I get items once again? When I fill out a single item of the data model I can use the value() method

    theDataModel.value(i)
    

    This gives the value added to the i - th position. But now I have items at each position in the data model. How can I get each item? When I use again theDataModel.value (i) I get '[object Object]' as output.

    Your output [object Object] is ok as is JSON object. To access name or path you need this

    theDataModel.value(i).name //print name value
    theDataModel.value(i).path //print path value
    

    Use the method of data instead of the value of your

    https://developer.BlackBerry.com/native/reference/Cascades/bb__cascades__arraydatamodel.html#functio...

  • Retreive QvaraintMap values of Custom QObject in QML

    Hello

    I'm working on an application that has a general usecase of getting data from the server and show it on the client.

    Here is the code for a better understanding

    //NetworkCommunicator.hpp
    
    class NetworkCommunicator: public QObject {
        Q_OBJECT
        Q_PROPERTY(QString url READ url WRITE setUrl)
        Q_PROPERTY(Weather weather READ weather WRITE setWeather)
    public:
    ...................
        void setWeather(Weather weather);
        Weather weather();
    
        void setUrl(QString url);
        QString url();
    
        signals:
        void dataAvailable();
        void error();
    private:
        QNetworkAccessManager *vNetworkAccessManager;
        Weather vWeather;
        QString urlStr;
    ...........
    // NetworkCommunicator.cpp
    ...........................
    vWeather.setLocationMap(rootMap.value("yweather:location").value());
    vWeather.setUnitsMap(rootMap.value("yweather:units").value());   vWeather.setWindMap(rootMap.value("yweather:wind").value());
    
    //Weather.h
    .................
        Q_PROPERTY(QVariantMap unitsMap READ getUnitsMap WRITE setUnitsMap);
        Q_PROPERTY(QVariantMap windMap READ getWindMap WRITE setWindMap);
    
    //QML
            NetworkCommunicator {
                id: networkCommunicator
                url: "http://weather.yahooapis.com/forecastrss?w=2442047&u=c"
                onDataAvailable: {
                    console.log("got response " + networkCommunicator.url);
                    console.log("weather " + networkCommunicator.weather);
                    console.log("weather.unitsmap " + networkCommunicator.weather.getUnitsMap.value("distance"));
                    activityIndicator.stop();
                }
            }
    

    Here is the result

    has got the answer http://weather.yahooapis.com/forecastrss?w=2442047&u=c
    QVariant (Weather) weather
    ..................................... 3/native/Assets / / hand. QML:26: TypeError: result of expression 'networkCommunicator.weather.getUnitsMap' [undefined] is not an object.

    The issue could be included in the output.

    Netcommunicator request a data server and analyzes the data and affects weather analyzed data object receives the response.

    But after that I couldn't retrieve the string data to weather object that stores in the form of QvariantMap.

    Any help is very appreciated.

    As I could not achieve this is QML, I created the view in C++ and started using that. Thanks for you help guys.

  • Value to multi-column tree?

    I have a tree with two columns.

    How to add

    Label1/value1 to row0, col0;

    Label2/value2 to row0, col1;

    Label3/value3 ro row1, col0;

    Label4/value4 to row1, col1 and so on.

    By looking at the examples of the InsertTreeItem() tree, I am only able to add labels and values to col0 one after the other.

    Thank you!

    Hi ts_2012,

    Please note that InsertTreeItem sets the value of the item of the tree with the column. In CVI, columns cannot have attached values.

  • Retrieving values of multi select checkboxes delimeted by ': '.

    A set of checkboxes in a form Apex product "V1:V2:V3" in the target field, these are the fields key from a dynamic selection lists based on a table that contains the key fields / value. Does anyone have a sample SQL fragment that will produce a record for each of the values?

    FORM_TABLE
    -------------------
    ID (1)
    CB_TARGET (V1:V2:V4)

    LIST_TABLE
    -----------------
    KEY_F (V1), (V2), (V3), (V4), etc.
    VALUE_F (value 1), (value 2), (value 3), (value 4...)

    Even if there is a single line in this example in the "FORM_TABLE", how can it be transformed to:

    1, V1
    1, V2
    1, V4


    Concerning
    H

    Does anyone have a sample SQL fragment that will produce a record for each of the values?

    Must be SQL? The simplest approach is probably to PL/SQL, using the apex_util.string_to_table function.

    For a solution purely SQL, use of any technique of string-to-row is appropriate to your situation.

  • How to check the values in multi-record block. ?

    Hello

    I'm new to forms. I have the field titled "Comments" in the block of multi-record. I have a button called "reject". Reject button is in the control block. If I press the button reject, field comments must be entered in one of the record. Otherwise, he should tell message. How to check the multi-record block. ?

    Pl.Help.

    Thanks in advance.
    Mano

    Mano,

    Add NEXT_RECORD just before the END of the LOOP.

         GO_BLOCK('');
         FIRST_RECORD;
         LOOP
              IF NVL(:., ' ' ) = ' ' THEN
                   MESSAGE('');
                   RAISE FORMS_TRIGGER_FAILURE;
              END IF;
              EXIT WHEN :SYSTEM.LAST_RECORD = 'TRUE';
              NEXT_RECORD;
         END LOOP;
    

    Kind regards

    Manu.

    If my response or response from another person was helpful, please mark accordingly

  • Browsing through the values of multi-donnees block against certain values BEFORE UPDATE! (FORMS 10G)

    I have a form with 2 blocks: a tabular and a single.

    I need to check a condition before INSERT/update to each record.

    To insert, I do this in WHEN_VALIDATE_RECORD and its working perfectly fine.

    However, to insert, as only the updated records are validated if its does not work very well against all records.

    How to browse and check all records against a condition on the UPDATE.

    I tried go_block, loop, depending on type of logical record in pre_update and pre_commit, but they are limited to these triggers.

    How to solve this problem?

    Kind regards

    Misbah.

    What I mean is that you must take logic out-pre - COMMIT because you can't do a GO_BLOCK.  Instead, you need to transfer this logic in triggering the COMMIT BUTTON.  It is not limited, so he can make the GO_BLOCK, NEXT_RECORD, etc...

  • Reference ID of qml files

    I have 2 files qml. One containing a pane with tabs (tabbedMenu.qml) and the other (ContentContainer.qml) with a container with a label.

    I use ContentContainer.qml as a template for the pages of tabbedPane as follows:

    (ContentContainer.qml)
    Contains a label with the id headerLabel

    (tabbedMenu.qml)

    TabbedPane {}
    {Page}
    ID: connectTab
    paneProperties: {TabbedPaneProperties}
    Title: 'Tab '.
    }

    content: {ContentContainer}
    ID: connectContent
    {Label
    ID: testLabelID
    text: "text".
    }
    }
    }
    ...

    Is it possible to update the value of headerLabel to tabbedMenu.qml when a tab is changed?

    I thought about it. I just used a C++ class, it entered as property and class variables to the variables on the side QML.

    See https://bdsc.webapps.blackberry.com/cascades/documentation/ui/integrating_cpp_qml/index.html for an example

  • BPS to QML

    I use battery using bpsinformation, as shown in the code below, I can send it to QML, but as a QString, I want just the integer value for a condition in QML. I don't think I can use parseInt, based on this documentation. I think of methods Q_INVOKABLE or globalisation of the variable, but I'm still familiar with dev, so I don't know what would be the best method would be to waterfalls.

    StatusEventHandler.cpp

    void StatusEventHandler::event(bps_event_t *event) {
        if (bps_event_get_domain(event) == battery_get_domain()) {
        if (BATTERY_INFO == bps_event_get_code(event)) {
            battery_info_t *info = battery_event_get_info(event);
            int voltage = battery_info_get_battery_voltage(info);
    
            emit batteryUpdated(voltage);
            }
        }
    }
    

    applicationUI.cpp

    ApplicationUI::ApplicationUI(bb::cascades::Application *app)
    : QObject(app)
    {
        QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
        AbstractPane *root = qml->createRootObject();
        qml->setContextProperty("app", this);
        app->setScene(root);
    
        voltageLabel = root->findChild("voltageLabel");
    
        initUI();
    }
    
    void ApplicationUI::initUI() { voltageLabel->setText("Voltage: ?");
    
     statusEventHandler = new StatusEventHandler();
    
     connect(statusEventHandler, SIGNAL(batteryUpdated(int)), this, SLOT(onBatteryUpdated(int)));}
    
    void ApplicationUI::onBatteryUpdated(int voltage) { voltageLabel->setText("Voltage: " + QString::number(voltage) + " mV");}
    

    hand. QML

    Label {
        id: voltageLabel
        objectName: "voltageLabel"
    }
    

    Using Q_PROPERTY to store the int inside your StatusEventHandler class value and add a setContextProperty() for statusEventHandler object.
    http://Qt-project.org/doc/Qt-4.8/properties.html

  • How to filter values using variable presentation if it uses a multiselec

    Hi gurus,

    Could you pls suggest me here.
    I have a requirement like my version 10G OBIEE isn't filtering report values when we choose a value any in dash prompt.
    I tried to create a variable presentation in the prompt for filtering, but invites under control, he is given a MULTI SELECT.
    I need to filter the values today if select us any value from the command prompt, it does not choose any value.
    How to filter values using MULTI SELECT Here.Please suggest me here.

    Kind regards
    SK

    Functions applied on the columns must be the two places (in report and guest) and must affect is fast after the function applied in the report.

    In your case is prompt value before cast, it seems that it is the reason why it does not work.

    Mark correct/good so pls help.

  • How to manipulate the NCLOB values in oracle 10g?

    Hi Experts,
    I have a scenario where I have to show the output of the screen multi language. IM using plsql developer, my plsql block should show the report of multi language.
    Root table have multi language stirng stored in it with the NCLOB data type. In my block plsql, im in NCLOB variable(ex: var1) selection. When I insert as var1 in other tables of test with nclob column, it's showing the original text in multi language. But when I manipulate than with some other variables var1 (ex: var3: = var2 | var1), now if I insert additional tables var3 it inserts as var2? value. and even in the DBMS output as well.
    Please help me to get the original value of multi language. Or guide me to manipulate variables nclob.

    Have you tried DBMS_LOB. ADD?

  • Equium A110 - 252 (PSAB2E) - core that only one works

    Have an A110-252 Equim running Vista Home premium. Only a basic work. The value of multi-process active core BIOS.

    Version of the BIOS V5.20
    Any ideas?
    Concerning

    It seems that this model came with XP. Did you install Vista or upgrade to Vista?

    You need to maybe install or update the Intel Chipset driver or install the package of value added.

  • Save the color

    Hello guys I have this type of code in the following files do not know how to record the different colors, can someone help me?

    Setting.HPP

    #ifndef SETTINGS_HPP_
    #define SETTINGS_HPP_
    
    #include 
    
    class Settings: public QObject {
            Q_OBJECT
    
    public:
            Settings();
            virtual ~Settings();
    
            /**
             * This Invokable function gets a value from the QSettings,
             * if that value does not exist in the QSettings database, the default value is returned.
             *
             * @param objectName Index path to the item
             * @param defaultValue Used to create the data in the database when adding
             * @return If the objectName exists, the value of the QSettings object is returned.
             *         If the objectName doesn't exist, the default value is returned.
             */
            Q_INVOKABLE
            QString getValueFor(const QString &objectName, const QString &defaultValue);
    
            /**
             * This function sets a value in the QSettings database. This function should to be called
             * when a data value has been updated from QML
             *
             * @param objectName Index path to the item
             * @param inputValue new value to the QSettings database
             */
            Q_INVOKABLE
            void saveValueFor(const QString &objectName, const QString &inputValue);
    };
    

    Setting.cpp

    #include "Settings.hpp"
    
    #include 
    
    Settings::Settings() {
    }
    
    QString Settings::getValueFor(const QString &objectName, const QString &defaultValue) {
            QSettings settings;
    
            // If no value has been saved, return the default value.
            if (settings.value(objectName).isNull()) {
                    return defaultValue;
            }
    
            // Otherwise, return the value stored in the settings object.
            return settings.value(objectName).toString();
    }
    
    void Settings::saveValueFor(const QString &objectName, const QString &inputValue) {
            // A new value is saved to the application settings object.
            QSettings settings;
            settings.setValue(objectName, QVariant(inputValue));
    }
    
    Settings::~Settings() {
    }
    

    main.cpp

    #include "applicationui.hpp"
    
    #include 
    
    #include 
    #include 
    #include "Settings.hpp"
    #include 
    
    using namespace bb::cascades;
    
    QString getValue() {
        Settings settings;
        // use "theme" key for property showing what theme to use on application start
        return settings.getValueFor("theme", "primaryDropDown");
    }
    
    Q_DECL_EXPORT int main(int argc, char **argv)
    {
        // update env variable before an application instance created
        qputenv("CASCADES_THEME", getValue().toUtf8());
    
        Application app(argc, argv);
    
        // Create the Application UI object, this is where the main.qml file
        // is loaded and the application scene is set.
        ApplicationUI appui;
    
        // Enter the application main event loop.
        return Application::exec();
    }
    

    Applicationui.HPP

    #ifndef ApplicationUI_HPP_
    #define ApplicationUI_HPP_
    
    #include 
    
    namespace bb
    {
        namespace cascades
        {
            class LocaleHandler;
        }
    }
    
    class QTranslator;
    
    /*!
     * @brief Application UI object
     *
     * Use this object to create and init app UI, to create context objects, to register the new meta types etc.
     */
    class ApplicationUI : public QObject
    {
        Q_OBJECT
    public:
        ApplicationUI();
        virtual ~ApplicationUI() {}
    private slots:
        void onSystemLanguageChanged();
    private:
        QTranslator* m_pTranslator;
        bb::cascades::LocaleHandler* m_pLocaleHandler;
    };
    
    #endif /* ApplicationUI_HPP_ */
    

    Applicationui.cpp

    #include "applicationui.hpp"
    
    #include 
    #include 
    #include 
    #include 
    #include "timer.hpp"
    #include "Settings.hpp"
    
    using namespace bb::cascades;
    
    ApplicationUI::ApplicationUI() :
            QObject()
    {
        // prepare the localization
        m_pTranslator = new QTranslator(this);
        m_pLocaleHandler = new LocaleHandler(this);
        qmlRegisterType("CustomTimer", 1, 0, "Timer");
        bool res = QObject::connect(m_pLocaleHandler, SIGNAL(systemLanguageChanged()), this, SLOT(onSystemLanguageChanged()));
        // This is only available in Debug builds
        Q_ASSERT(res);
        // Since the variable is not used in the app, this is added to avoid a
        // compiler warning
        Q_UNUSED(res);
    
        // initial load
        onSystemLanguageChanged();
    
        // Create scene document from main.qml asset, the parent is set
        // to ensure the document gets destroyed properly at shut down.
        QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    
        // Create settings object and export it to qml
        Settings *settings = new Settings();
        qml->setContextProperty("Settings", settings);
    
        // Create root object for the UI
        AbstractPane *root = qml->createRootObject();
    
        // Set created root object as the application scene
        Application::instance()->setScene(root);
        // CustomTimer library
    
    }
    
    void ApplicationUI::onSystemLanguageChanged()
    {
        QCoreApplication::instance()->removeTranslator(m_pTranslator);
        // Initiate, load and install the application translation files.
        QString locale_string = QLocale().name();
        QString file_name = QString("Vk10_%1").arg(locale_string);
        if (m_pTranslator->load(file_name, "app/native/qm")) {
            QCoreApplication::instance()->installTranslator(m_pTranslator);
        }
    }
    
            DropDown {
            id: primaryDropDown
            title: qsTr("Primary color")
            translationY: 5.0
            Option { text: qsTr("Default"); value: 0 }
            Option { text: qsTr("Red"); value: Color.Red }
            Option { text: qsTr("Green"); value: Color.Green }
            Option { text: qsTr("Yellow"); value: Color.Yellow }
            Option { text: qsTr("Blue"); value: Color.Blue }
            Option { text: qsTr("Gray"); value: Color.Gray }
            onSelectedValueChanged: {
            Application.themeSupport.setPrimaryColor(primaryDropDown.selectedValue, primaryBaseDropDown.selectedValue)
            Settings.saveValueFor("primaryColor", primaryDropDown.selectedValue);
            }
            }
    

    I do but not work

  • change the visibility of the label of C++

    Hello.

    the main page of my application contains a container with a ListView that is filled with an ArrayDataModel defined as a Q_PROPERTY.

    There is also a label on the Page I want to be invisible when the ArrayDataModel is empty.

    All this would be in QML I found that it works. I set the ArrayDataModel in QML as follows:

    attached Objects: [
      id: theDataModel
    
      property bool empty: true
    
      onItemAdded: empty = isEmtpy()
      onItemRemoved: empty = isEmtpy()
      onItemUpdated: empty = isEmtpy()
      onItemsChanged: empty = isEmtpy()
    
    ]
    

    I can't use here because my ArrayDataModel is defined in C++.

    I think I should use signals and slots. But then I have to write all this is the signal (as when adding, deleting, changed the DataModel) and connect it to the label.

    Is it the way I have to go. Or is there a simpler way?

    You can set your DataModel in QML, but fill it in c++ (several of the tutorials do that elsewhere, see for example the example of quote).

    This way you can always control the visibility of your labels through QML

  • Q_PROPERTY

    I'm confused about Q_PROPERTY

    can any body tell what "Q_PROPERTY (QString text text READ WRITE setText NOTIFY textChanged)" means

    Hello

    Q_PROPERTY is a macro and a part of the system of Qt properties. Its purpose is to allow us to bind the properties that we use in our QML to C++ data by appropriate methods. Your example combines three things a QML property whose id is "text". Let's review each of them:

    Text READ: it means "to get a value for the text property, call a C++ method text()".

    WRITE setText: in other words, "if we change the value of the text property to QML by assigning a value, communicate to C++ by calling a method, setText (QString NewText).

    TextChanged NOTIFY: This means that "If the value of the data in my C++ object is modified by a non - QML action, notify me that it has changed so that I can update the value of the property in QML by transmitting the signal of Qt, whose name is «textChanged()»»

    There is still information on the QML and C++ integration in our documentation here:

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

    Here is an example of my own as well:

    Q_OBJECT
    
        // a Q_PROPERTY declaration is a binding between a property we can use in QML and underlying C++ methods and signals
    
    Q_PROPERTY(
            // the name of our property as used from QML
            QString my_property
            // a method that will be called to populate our QML property with a value from C++
            READ getMyProperty
            // a method that will be called when we want to change the value of our corresponding C++ variable
            WRITE setMyProperty
            // a signal that will be emitted if the underlying data value changes. This signal will be automatically connected to our QML property
            // so that anywhere our property has been used, it's value will be updated
            NOTIFY signalMyPropertyChanged)
    

    Figure 1 declaring a Q_PROPERTY

    And then we declare signals and the associated methods:

    public:
    
        // for my Q_PROPERTY
        QString getMyProperty();
        void setMyProperty(QString text);
    
        Q_INVOKABLE void resetMyProperty();
    
    signals:
        // signal that is emitted if my property value changes
        void signalMyPropertyChanged();
    

    Figure 2: declare the methods and signals used by the Q_PROPERTY

    private:
        QString _some_text;
    

    Figure 3: Our C++ data we bind to our property

    Note that I also used Q_INVOKABLE authorizing the call directly from the resetMyProperty() to the specified method of QML.

    QString ApplicationUI::getMyProperty() {
        qDebug() << "XXXX getMyProperty called";
        return _some_text;
    }
    
    void ApplicationUI::setMyProperty(QString some_text) {
        qDebug() << "XXXX setMyProperty called:" << some_text;
        _some_text = some_text;
        qDebug() << "XXXX setMyProperty emiting signalMyPropertyChanged";
        emit signalMyPropertyChanged();
    }
    
    void ApplicationUI::resetMyProperty() {
        qDebug() << "XXXX resetMyProperty called";
        setMyProperty("Hello I am a property");
    }
    

    Figure 4: implementation of C++ functions

        QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    
        // expose the property to QML
        qml->setContextProperty("my_prop", this);
    

    Figure 5 expose our C++ object to QML

    import bb.cascades 1.2
    
    Page {
        Container {
    
            TextField {
                id: tf
                objectName: "tf"
                // this causes the READ method bound to our property to be called
                text: my_prop.my_property
            }
            Button {
                text: "Change Property"
                onClicked: {
                    // this causes the WRITE method bound to our property to be called
                    my_prop.my_property = tf.text
                }
            }
            Button {
                text: "Reset"
                onClicked: {
                    // this calls a C++ method that was exposed using Q_INVOKABLE
                    my_prop.resetMyProperty();
                }
            }
        }
    }
    

    Figure 6 the QML

    When I run my application, I see that TextField tf is generated automatically and this is accomplished by the system calling the getMyProperty READING method. So, if I change the text and click the button of change of ownership, I see that the WRITE method is called. If I click on Reset, the Q_INVOKABLE method is called directly from QML and it my signal, so notify the QML bound property value has changed. This causes a call to the READ method and my text field in QML is updated.

    XXXX getMyProperty called
    XXXX setMyProperty called: "Hello"
    XXXX setMyProperty emiting signalMyPropertyChanged
    XXXX getMyProperty called
    XXXX resetMyProperty called
    XXXX setMyProperty called: "Hello I am a property"
    XXXX setMyProperty emiting signalMyPropertyChanged
    XXXX getMyProperty called
    

    Figure 7: out of the call display console

    Hope that helps

    Martin

Maybe you are looking for

  • Slimline Office 260-a020: install Windows 7 Home Premium on a new machine Windows 10?

    Just got a new HP 260 - A020, but I used Windows 10 library for 3 weeks in the meantime and have no use for the clumsy, stupid thing, overworked or otherwise for his reputation as a Big Brother. (also software security 3 deep at the top of the parano

  • Information from LabVIEW to TestStand using a notifier TestStand and the SetEx method

    Hi all I'm trying to use the parameter dataPropObj of the SetEx method to send information of LabVIEW TestStand during setting of the notifier. The works of declarant perfectly by itself when I wire variant empty constant by default entry dataPropObj

  • 15 J191nb: 10 Windows will identify the Samsung SSD

    Hello On my laptop, I did the upgrade of Windows 10 and now I want to put an SSD.I want to clone all my data cable USB to SATA.But when I'm in 'Samsung data migration' and my SSD is connected, there is the message that I should connect a Samsung SSD.

  • 5520 photosmart e-all-in-one-series

    I do not have wifi in my house, just an interest of connection by wire. So, I need to use a wired printer connection. However, my new printer is not equipped with a cable to connect it to my computer. When I tried to install the printer, it does not

  • IPSec VPN tunnel only to come

    Hello I am trying to configure an IPSec VPN tunnel between my company and a remote company for the use of FTP secure. I used the SDM to configure the tunnel on my router based on the information provided by the society that we are trying to connect t