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

Tags: BlackBerry Developers

Similar Questions

  • Request close does not correctly after the addition of SceneCover (QML)

    Just added a SceneCover exposed to QML, wanted to change my implementation of shit,

    Page {
    
        onCreationCompleted: {        Application.setCover(sceneCover)    }
    
      attachedObjects: [
    
          // An Active Frame is a Scene Cover      SceneCover {          id: sceneCover          content: Container {              background: Color.create("Black")          }
    
          },
    
    
    #include "applicationui.hpp"
    //#include "ActiveFrameQML.h"
    
    #include 
    #include 
    #include 
    #include 
    #include 
    //#include "OrientationSensor.hpp"
    using namespace bb::cascades;
    
    ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
            QObject(app) {
        displayInformation = new si::blackberrydev::DisplayInformation;
        qmlRegisterType("bb.cascades", 1, 2, "SceneCover");
        qmlRegisterUncreatableType("bb.cascades", 1, 2, "AbstractCover", "");
        // 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 root object for the UI
        qml->setContextProperty("display", displayInformation);
        AbstractPane *root = qml->createRootObject();
        // Set created root object as the application scene
        Application::instance()->setScene(root);
    }
    

    Now, whenever the application closes, it does and does not correctly close until terminated manually:

    It does not show this on the console but I'm not a clue what he is to me: "0x85ab510 error: must be attached to a control, no bb::cascades:QmlPage (0x85269a8).

    Any Suggestions?

    10.2 minimum API level targeting

    I noticed that, while this works, attaching class SceneCover application directly gives an error of bps to the exit event.

    To avoid this error, set the class of SceneCover via ComponentDefinition and attach it to the Application class.

    I have attached a code snippet below:

    onCreationCompleted: {
        Application.setCover(sceneCoverDef.createObject())
    }
    attachedObjects: [
        ComponentDefinition {
            id: sceneCoverDef
            SceneCover {
                content: Container {
                    background: Color.create("#000000")
                    Label {
                        text: "hello"
                    }
                }
            }
        }
    ]
    

    Try and see if the error persists.

  • Mode of mirroring of the FS7500 Force without UPS/BPS

    I have a pair of Dell FS7500 I have just install and performance is terrible. I connected them to a Dell equallogic SAN P6110E and all is well except for the fact that I don't have the device BPS (UPS) in use because I have redundant UPS systems that are the best bit the 7500 rack mounted UPS system used throughout the building. I don't want to use these UPS units, but if I disconnect them the FS7500 logging mode and is slower than it should be at least 50%.

    I can force mirroring mode on without connecting a UPS/BPS? I tried the ssh command line with the file set normal option system. It does not help. This seems to be a feature controlled internally to the system.

    Thank you

    Hello

    I'm sorry but no, there is no way to disable this feature.  It was designed in the 7500.

    Kind regards

    Don

  • Connection signal of C++ with slot QML

    Before ask you, I searched for answers to this question, but I have not found a satisfactory example.

    I have set up a service network in C++ that performs queries to REST against a backend. An example query would be to download a given element, the id of the item.

    Once the item is extracted, I emit a signal such as:

    itemReceived(QString& itemId, QString& item);
    

    My question is how can I wire this signal to the slot in a QML page so that the status of the answer? I tried to connect the signal on the Qml in C++ slot, as follows:

    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    QObject::connect(this->networkingService,
                         SIGNAL(itemReceived(QString&, QString&)),
                         qml, SLOT(onItemReceived(QString&, QString&));
    

    With a correspondent QML "slot" like this:

        function onItemReceived(x, y) {
            console.log("*********************");
            console.log("Item Received!");
            console.log("*********************");
        }
    

    But it does not work. I also tried using the element of connection of the QtQuick lib, but this also fails.

    Any help would be greatly appreciated. Even if he were to propose a better architecture for the "path of the cascades. Thank you!

    In C++:
    QmlDocument * qml = QmlDocument::create("asset:///main.qml").parent(this);
    QML-> setContextProperty ("_app", this);

    In QML:
    {Page}
    onCreationCompleted: {}
    _APP.itemReceived.connect (onItemReceived)
    }

    function onItemReceived (x, y) {}
    Console.log("***");
    Console.log ("point received!");
    Console.log("***");
    }

    // ...
    }

  • Get the height a label in QML?

    Can I get the height of a label in QML?

    Or the coordinates of a container (up/down)?

    BR, René

        Container {
            attachedObjects: [
                LayoutUpdateHandler {
                    id: containerLuh
                    onLayoutFrameChanged: {
                        console.log(layoutFrame.x)
                        console.log(layoutFrame.y)
                        console.log(layoutFrame.height)
                        console.log(layoutFrame.width)
                    }
                }
            ]
    
            Label {
                text: "Label height: " + labelLuh.layoutFrame.height
                attachedObjects: [ LayoutUpdateHandler { id: labelLuh } ]
            }
    
            Label {
                text: "Container height: " + containerLuh.layoutFrame.height
            }
        }
    
  • 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.

  • QML Cascades and to 'SCREEN_IDLE_MODE_KEEP_AWAKE' to work

    I have a QML driven application works very well, but after the usual delay, the display shuts off.  I need a way to keep it.

    I tried adding a "ForeignWindow" to my QML and then use FindChild to find the window, tie it to a ForeignWindow pointer and use it.  I have no errors, but the screen stays off.

    So, if someone got everything a QML Cascades driven UI app actually keep the screen on, please share your secret.

    Thank you

    Bryan

    Well, I'm this marking as closed in what I found a method to keep the screen awake (until it is actually completely supported in Cascades.

    The method was built with the participation of two people and a lot of research.  Here is the result

    (1) create a new thread

    (2) in the thread create a screen context

    (3) events ask for screen and navigator

    (4) when you get a message from idle screen, inject a key event in the queue of the screen

    Works very well.  Thank you all for your help

  • The Devs creating their active Frame for a separate QML file covers? I'm stuck

    Bit in trouble, I do my best to bring my Apps support 10.2.1 10.2.2 I practically everything by working the * beep * covers Active, I did do a check and create the file QML according to less than 10.3 or greater

     ComponentDefinition {
                id: creator;
                source: ""
                function createQMLObject(sourceUrl){source=sourceUrl; creator.createObject()}
            }
    

    Feel free to use that btw ^.

    if(olderFirmware===true)  Application.setCover(creator.createQMLObject("CoverOlderFirmware.qml"))
            else{Application.setCover(creator.createQMLObject("Cover.qml"))}
    

    Now for some reason, they do not work, they seem to be created, but do not want to show, normally I would create it from my main.qml but the passport and its lid Multi forced me to separate the covers in their own QML files

    Begins like (not included UI code)

    import bb.cascades 1.2
    
        SceneCover {
            id: large
    
            content: Container {
                background: Color.create("#000000")
                layout: DockLayout {}
    }
    }
    

    Place in a container gives me a weird error on not able to create a list in an object, probably referring to MultiCover and SceneCover as a child of the container.

    Any suggestions?

    I use active selector to do this, find in this application example:
    https://github.com/RodgerLeblanc/AssetSelector

    This method can support 10.2.1 users and below, don't forget to add the lines of c ++ this blog:
    https://bb10code.WordPress.com/2014/12/10/active-frame-made-easy/

    Check your email, I also sent you something on your last post on the forum.

  • 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?

  • solution: bps netstatus_interface_list_t as QVariantList

    I was looking for an easy way to know the name of the interface for WIFI, cell PHONE...

    These names are different for Z10, Z30, Q10,... you can't find names

    First aid, I found was Cascades Sample App "MyDevice".

    Congratulations to Martin Woolley @mdwrim providing this app to wander on Github

    Now I could get the names of WIFI connections, but lacked a way to get the names for cell PHONES

    discussed with @mdwrim on twitter and got to come an interface more names for cell PHONES, but this could be broken easy to new devices.

    next congratulations to @dkonigs who joined the discussion on twitter mentioning Netstatus API to inspect the Interface Types

    OK - I wanted to use the netstatus and discovered that I have a loop through a list of interfaces netstatus and tried this code.

    thought it would be easy because I already used Netstatus events to know if the user is on WIFI, cell PHONE etc.

    But I have to give up - as a former Developer Java and C++ now / Qt developer such things bps C does not for me.

    next Bravo to strobejb help with the code in this thread here. Based on his code I solved it and now it's easy to know all the Netstatus Interfaces.

    Here is a method that you give bps bps netstatus_interface_list_t as QVariantList, so you can use for data models, storing as JSON or almost.

    QVariantList YourClass::netStatusInterfaceList() {
        QVariantList interfaceList;
        netstatus_interface_list_t iflist;
        netstatus_get_interfaces(&iflist);
    
        for (int i = 0; i < iflist.num_interfaces; i++) {
            netstatus_interface_details_t *details = 0;
            netstatus_get_interface_details(iflist.interfaces[i], &details);
            if (details) {
                QVariantMap interfaceDetailsMap;
                const char *name = netstatus_interface_get_name(details);
                qDebug() << "DETAILS FOR Interface: " << name;
                interfaceDetailsMap.insert("name", name);
                netstatus_interface_type_t type = netstatus_interface_get_type(
                        details);
                bool connected = netstatus_interface_is_connected(details);
                interfaceDetailsMap.insert("connected", connected);
                bool up = netstatus_interface_is_up(details);
                interfaceDetailsMap.insert("up", up);
                interfaceDetailsMap.insert("hasType", type ? "true" : "false");
                if (type) {
                    interfaceDetailsMap.insert("type", type);
                    switch (type) {
                    case NETSTATUS_INTERFACE_TYPE_WIRED:
                        interfaceDetailsMap.insert("typeName", "WIRED");
                        break;
                    case NETSTATUS_INTERFACE_TYPE_WIFI:
                        interfaceDetailsMap.insert("typeName", "WIFI");
                        break;
                    case NETSTATUS_INTERFACE_TYPE_VPN:
                        interfaceDetailsMap.insert("typeName", "VPN");
                        break;
                    case NETSTATUS_INTERFACE_TYPE_BB:
                        interfaceDetailsMap.insert("typeName", "BB");
                        break;
                    case NETSTATUS_INTERFACE_TYPE_UNKNOWN:
                        interfaceDetailsMap.insert("typeName", "UNKNOWN");
                        break;
                    case NETSTATUS_INTERFACE_TYPE_USB:;
                        interfaceDetailsMap.insert("typeName", "USB");
                        break;
                    case NETSTATUS_INTERFACE_TYPE_BLUETOOTH_DUN:
                        interfaceDetailsMap.insert("typeName", "BLUETOOTH_DUN");
                        break;
                    case NETSTATUS_INTERFACE_TYPE_CELLULAR:
                        interfaceDetailsMap.insert("typeName", "CELLULAR");
                        break;
                    case NETSTATUS_INTERFACE_TYPE_P2P:
                        interfaceDetailsMap.insert("typeName", "P2P");
                        break;
                    default:
                        interfaceDetailsMap.insert("typeName", "????");
                        break;
                    }
                }
                if (connected) {
                    // enumerate the ip addresses for this interface
                    int numip = netstatus_interface_get_num_ip_addresses(details);
                    QVariantList ipAddressList;
                    for (int j = 0; j < numip; j++) {
                        QVariantMap ipAddressMap;
                        const char *ip = netstatus_interface_get_ip_address(details,
                                j);
                        const char *nm = netstatus_interface_get_ip_address_netmask(
                                details, j);
                        ipAddressMap.insert("ipAddress", ip);
                        ipAddressMap.insert("netmask", nm);
                        ipAddressList.append(ipAddressMap);
                    }
                    interfaceDetailsMap.insert("ipAddresses", ipAddressList);
                    // enumerate gateways for this interface
                    int numgw = netstatus_interface_get_num_ip_gateways(details);
                    QVariantList ipGatewayList;
                    for (int j = 0; j < numgw; j++) {
                        QVariantMap ipGatewayMap;
                        const char *ip = netstatus_interface_get_ip_gateway(details,
                                j);
                        ipGatewayMap.insert("gatewayIp",ip);
                        ipGatewayList.append(ipGatewayMap);
                    }
                    interfaceDetailsMap.insert("ipGateways",ipGatewayList);
                }
                interfaceList.append(interfaceDetailsMap);
            } // end if details
              // FREE Memory
            netstatus_free_interface_details(&details);
        }
        // FREE Memory
        netstatus_free_interfaces(&iflist);
        qDebug() << "List of Netstatus Interfaces: " << interfaceList.size();
        return interfaceList;
    }
    

    Thanks again to all the forum here and twitter. It's really nice to work with this great community

    XXXX

    and here is what you will get if the QVariantList was saved from the JsonDataAccess on a Z30:

    [
       {
          "connected" : false,
          "hasType" : "false",
          "name" : "pflog0",
          "up" : false
       },
       {
          "connected" : false,
          "hasType" : "false",
          "name" : "lo0",
          "up" : true
       },
       {
          "connected" : false,
          "hasType" : "false",
          "name" : "rndis0",
          "up" : false
       },
       {
          "connected" : false,
          "hasType" : "false",
          "name" : "ecm0",
          "up" : false
       },
       {
          "connected" : false,
          "hasType" : "false",
          "name" : "bb0",
          "up" : false
       },
       {
          "connected" : false,
          "hasType" : "false",
          "name" : "ppp0",
          "up" : false
       },
       {
          "connected" : false,
          "hasType" : "false",
          "name" : "pan0",
          "up" : false
       },
       {
          "connected" : false,
          "hasType" : "false",
          "name" : "nap0",
          "up" : false
       },
       {
          "connected" : false,
          "hasType" : "true",
          "name" : "msm4",
          "type" : 7,
          "typeName" : "CELLULAR",
          "up" : false
       },
       {
          "connected" : false,
          "hasType" : "true",
          "name" : "msm3",
          "type" : 7,
          "typeName" : "CELLULAR",
          "up" : false
       },
       {
          "connected" : false,
          "hasType" : "true",
          "name" : "msm2",
          "type" : 7,
          "typeName" : "CELLULAR",
          "up" : false
       },
       {
          "connected" : true,
          "hasType" : "false",
          "ipAddresses" : [
             {
                "ipAddress" : "10.21.34.184",
                "netmask" : "255.255.255.252"
             },
             {
                "ipAddress" : "fe80::4242:24ff:4242:94d7%msm1",
                "netmask" : "ffff:ffff:ffff:ffff::"
             }
          ],
          "ipGateways" : [
             {
                "gatewayIp" : "10.21.34.184"
             }
          ],
          "name" : "msm1",
          "up" : true
       },
       {
          "connected" : true,
          "hasType" : "true",
          "ipAddresses" : [
             {
                "ipAddress" : "10.51.149.71",
                "netmask" : "255.255.255.240"
             },
             {
                "ipAddress" : "fe80::4242:24ff:4242:94d7%msm0",
                "netmask" : "ffff:ffff:ffff:ffff::"
             }
          ],
          "ipGateways" : [
             {
                "gatewayIp" : "10.51.149.71"
             }
          ],
          "name" : "msm0",
          "type" : 7,
          "typeName" : "CELLULAR",
          "up" : true
       },
       {
          "connected" : false,
          "hasType" : "true",
          "name" : "bcm1",
          "type" : 2,
          "typeName" : "WIFI",
          "up" : false
       },
       {
          "connected" : true,
          "hasType" : "true",
          "ipAddresses" : [
             {
                "ipAddress" : "192.168.42.42",
                "netmask" : "255.255.255.0"
             },
             {
                "ipAddress" : "fe80::4242:24ff:4242:94d7%bcm0",
                "netmask" : "ffff:ffff:ffff:ffff::"
             }
          ],
          "ipGateways" : [
             {
                "gatewayIp" : "192.168.42.1"
             }
          ],
          "name" : "bcm0",
          "type" : 2,
          "typeName" : "WIFI",
          "up" : true
       },
       {
          "connected" : false,
          "hasType" : "false",
          "name" : "smsc0",
          "up" : false
       },
       {
          "connected" : false,
          "hasType" : "false",
          "name" : "asix0",
          "up" : false
       },
       {
          "connected" : false,
          "hasType" : "false",
          "name" : "vlan0",
          "up" : false
       },
       {
          "connected" : false,
          "hasType" : "false",
          "name" : "vpn0",
          "up" : false
       },
       {
          "connected" : false,
          "hasType" : "false",
          "name" : "openvpn0",
          "up" : false
       },
       {
          "connected" : false,
          "hasType" : "false",
          "name" : "ipsec1",
          "up" : false
       },
       {
          "connected" : false,
          "hasType" : "false",
          "name" : "ipsec0",
          "up" : false
       },
       {
          "connected" : false,
          "hasType" : "false",
          "name" : "lo2",
          "up" : false
       },
       {
          "connected" : false,
          "hasType" : "true",
          "name" : "msm5",
          "type" : 7,
          "typeName" : "CELLULAR",
          "up" : false
       },
       {
          "connected" : false,
          "hasType" : "true",
          "name" : "msm6",
          "type" : 7,
          "typeName" : "CELLULAR",
          "up" : false
       },
       {
          "connected" : false,
          "hasType" : "true",
          "name" : "msm7",
          "type" : 7,
          "typeName" : "CELLULAR",
          "up" : false
       },
       {
          "connected" : true,
          "hasType" : "true",
          "ipAddresses" : [
             {
                "ipAddress" : "fd38:4242:4242:67b5:dacc:4242:f17e:6af7%59",
                "netmask" : "ff00::"
             },
             {
                "ipAddress" : "fe80::4242:24ff:4242:94d7%bptp0",
                "netmask" : "ffff:ffff:ffff:ffff::"
             }
          ],
          "ipGateways" : [],
          "name" : "bptp0",
          "type" : 8,
          "typeName" : "P2P",
          "up" : true
       }
    ]
    

    the same linking Z10, Q10,... will report the names of different interfaces.

    Martin Woolley also updates the sample MyDevice for use netstatus interface list with QNetworkInterface

  • ListView cannot see C++ object passed to QML via QmlDocument-&gt; setContextProperty()

    I can access a C++ object using the QmlDocument function-> setContextProperty() in JavaScript inside most of the QML elements (such as containers, ImageButton, control etc.) happened, but can't access it from the JavaScript inside ListView. I get "ReferenceError: can't find variable: app. Why is this?

    Why is it a "problem"? It's probably just the way things work and should work. ListItemComponents are not really part of the scene graph/context since they exist only to be used during execution. Wait so the scope of the listItemcomponent unlike the rest of the document.

    The way around it, as described in the thread linked above is to create a function inside your listview that refers to the context property that you want to use. Then, your listitemcomponent has access to this feature of the listview.

  • Does everything with JSON of QML

    Hello

    Just trying to decide what type of template to use for the list, I wanted to do.

    It's true that I can't fully implement JSON in its entirety in QML? that is sort of the key (and everything else 100%) in QML, no C++ at all. (I have a JSON file I created)

    In the examples I see, to do a minimum implementation in C++ and more QML.

    Otherwise, I can use XML purely in QML but will not get the features of sort etc..

    Is everything is OK?

    I just noticed tonight that the 'global' Javascript object, in the environment of waterfalls QML, has a JSON object in it.

    This seems to be the JSON object standard ECMAscript 5 which is documented here: https://developer.mozilla.org/en-US/docs/Using_native_JSON

    By using it, you could make JSON.parse (somestring) and retrieve the result of the analysis of the JSON.  Similar to eval(), but probably better...

    Also a JSON.stringify () has to go the other way.

    These things were probably obvious to many who read this... was good news for me.

  • QML QVariantList QString Converter?

    Hey all

    I'm relatively new to programming of BB. I have some experience in Android and Windows Phone, but I think that BB10 will kick a lof of * beep *!

    I did a bit of programming for my application and I use a Web service to download the json from the server data. Now, I have programmed a view master / detail with qml, when clicking on an item in the list, I get the details of this item.

    But the article also has QVariantLists because it is a data table. For example, in my json file, I have the language of property: ['Dutch', 'English', 'French'].

    Now, I want to show these multiple languages in my detailpage. Is it possible to write a converter or something like that? Or should I do the treatment before you add data to my datamodel?

    Thanks in advance!

    QVariant-s work just like the javascript in QML tables.
    If you know how to access this QML QVariantList, you can also iterate through it the addition of all the members of a chain.

    var s = "";
    for (var i = 0; i < myList.length; i++) {
     console.log(myList[i]);
    
     if (i != 0)
       s += ", ";
     s += myList[i];
    }
    
  • Using C++ in QML classes: need for Clarification

    I have read the document using classes in QML C++ and understood that we must call qmlRegisterType before using C++ in QML classes.

    But I found that some (or all?) of the classes can be used in QML without call qmlRegisterType in advance.

    Example of

    import bb.device 1.0
    
    Page {
      attachedObjects: [VibrationController {id: qmlvib}]
      Container{
           Button {
                        text: "Test vibrate"
                        horizontalAlignment: HorizontalAlignment.Center
                        onClicked: qmlvib.start(100,100)
                       }
        }
    }
    

    I also found the SensorDemo project using many classes of QML sensor final qmlRegisterType<>(). But it does not call qmlRegisterType<>for VibrationController (?).

    I wish I had a few questions:

    1. How will I know which classes can be used in QML without qmlRegisterType<>()? Is there a list or the rule to help me know?

    2. what should I look at to decide using C++ class in QML directly (without qmlRegisterType<>(()) or with qmlRegisterType<>(): as the performance, memory management,...?

    3. If you can choose to use the C++ in QML class directly (without qmlRegisterType<>(()), BB shoud put it in the paper?

    Sorry for the many questions. I'm just a beginner on BB.

    Thank you very much!

    (1) I think that some classes are pre-registered. If it works without adding it yourself: looks like it was a.
    (2) I don't think that there is a performance issue with the help of registerType
    (3) No, there is not, just of the classes that are recorded automatically by the system.

  • 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

Maybe you are looking for