Use QML ImageView in C++

Hello

I can see how to use one ImageView, or any other QML declared, stated purpose in QML the constructor method that creates the scene using the QML document, and then sets the AbstractPane root. But how to access an ImageView to anywhere else in the same class? I will keep a reference to the root or document QML?

You can call Application: instance()-> scene() and cast your object type to top level, something like this:

Page * appPage = (Page *) Application::instance()-> scene();
Camera * camera = appPage->findChild ("myCamera");
etc.

Or let the appPage pointer or other controls in member variables. In this way, the code will be cleaner.

Tags: BlackBerry Developers

Similar Questions

  • How to parse RSS feeds using QML (waterfalls)?

    Hallo native devs! I am a beginner in native development and I want to know how to parse RSS feeds using QML cascading?

    I see the example like this:

    Page {
        content: Container {
            background: Color.White
            ListView {
                rootIndexpath: [1]
                dataModel: XmlDataModel { source: "model.xml" }
            }
        }
    }
    

    but, can I to ' source: ' use 'http://example.com/rss.xml'?

    If Yes, how can I analyze?

    Thanks for the help!

    The QML in your message assumes that the XML file is local, if you use a remote XML file then you will need to firstly using a few backend Qt C++ network code, download, then you can use QML.

    I would recommend from the Cascades sample quotes to get an idea of how XmlDataModel analysis work can start to look into the network access code and the file.

  • The creation of follow-up to the page dynamically using QML?

    Hi I want to create a dynamic page with QML follow-up

    How to do this?

    Examples or links that explain this?

    Thank you

    Of course, you can dynamically create an ActionItem.

    Page {
        id: page
    
        Container {
            Button {
                text: "Create Action"
                onClicked: {
                    var item = actionTemplate.createObject();
                    item.title = "New Action";
                    page.addAction(item, ActionBarPlacement.OnBar);
                }
            }
        }
    
        attachedObjects: [
            ComponentDefinition {
                id: actionTemplate
                ActionItem {
                    title: 'default'
                    onTriggered: {
                        print('dynamic action item created');
                    }
                }
            }
        ]
    }
    
  • Using qml ranging from base for a key card type / value

    I have given in my application in the form of a set of json key / value accessible through the data source build in qml. I would like to put this in a variant of the property, which is accessible from a number of different UI objects (labels, lists, text fields, etc.). Here's what I have...

    Page {
        property variant item
        Container {
             Label {
               id: testLabel
         }
    .
    .
    .
    

    And this is the json with data file

    {
        "message":"Request Successful",
        "data":{
        "id":52,
        },
        "date":"2012-12-17 12:47:28"},
        "status":"success"
    }
    

    However, if I leave with something like the following, I get the text appears in the label

           DataSource{
                   id: dataSource
                   source: "models/test.json"
               onDataLoaded: {
                     testLabel.text = data.message
              }
           }
    

    According to this page a qml Variant should have no problem holding a set of key-value pairs. Anyone know why this is happening? Am I missing something obvious?

    Too bad I had to declare the variant of the property within the section of NavigationPane not the section of the Page * facepalm *.

  • permutation of cameras using QML?

    Hey gang,

    trying to swap the rear camera to the front camera.

    I'm just trying to call:

    Camera1.close ();

    Camera1.open (CameraUnit.front);

    I do this on an ActionItem button...

    ActionItem {
                    title: "Switch Camera"
                    ActionBar.placement: ActionBarPlacement.OnBar
                    onTriggered: {
                    // what do you do to reverse the camera??
                    console.log("  ->App: camera unit: " + camera1.cameraUnit);
                    switch (camera1.cameraUnit)  {
                        case 0:
                            //
                            break;
                        case 1:
                            // front camera is open, open the front
                            camera1.close();
                            camera1.open(CameraUnit.Rear);
                            break;
                        case 2:
                            // rear is opoen, open the rear
                            camera1.close()
                            camera1.open(CameraUnit.Front);
                            break;
                    }  // end of switch
                  }
             }
    

    but does not work... I have to reopen the viewfinder too?  something escapes me?

    THX,

    J

    Maybe call you open/close too close together for the cameras, you must first

    1. stop the viewfinder
    2. close the camera
    3. Start the camera
    4. start the viewfinder

    in your case, you can set some variables to keep track of things

    property bool switchCamsproperty int currentCamera
    

    then listen to

    onViewFinderStopped: {
          if (!switchCams) {
              console.log("Viewfinder stopped Don't switch cameras")
          } else {
              camera.close()
          }
    }
    
    onCameraClosed: {
        if (!switchCams){
           console.log("Camera Closed Don't switch cameras")
        } else {        if (currentCamera == 0){             //Open a Camera             currentCamera = 1        } else if (currentCamera == 1){            // Open a Camera            currentCamera = 0        }
        }
    
    }
    

    best practice if you have used this method would be to put any device you initially open as 0 for currentCamera and then the camera that gets switched to should be 1

  • display image in ImageView of C++ QImage

    Hello

    I'm strunglling to view an image in QML ImageView of QImage in C++. I did a lot of gogling and reading posts in the forum but without success.

    I have the code in c ++

    bb::ImageData fromQImage(const QImage &qImage)
    {
        qDebug() << QString::number(qImage.format());
        bb::ImageData imageData(bb::PixelFormat::RGBA_Premultiplied, qImage.width(), qImage.height());
    
        unsigned char *dstLine = imageData.pixels();
        for (int y = 0; y < imageData.height(); y++) {
            unsigned char * dst = dstLine;
            for (int x = 0; x < imageData.width(); x++) {
                QRgb srcPixel = qImage.pixel(x, y);
                *dst++ = qRed(srcPixel);
                *dst++ = qGreen(srcPixel);
                *dst++ = qBlue(srcPixel);
                *dst++ = qAlpha(srcPixel);
            }
            dstLine += imageData.bytesPerLine();
        }
    
        return imageData;
    }
    
    Image ApplicationUI::getImage() const {
    
        QString appFolder(QDir::homePath());
        appFolder.chop(4);
        QString src=appFolder + "app/native/assets/images/Help.PNG";
        QImage img(src);
    
        bb::ImageData cstmImg = fromQImage( img );
        return cstmImg;
    }
    

    and then in QML I use it like this

                ImageView {
                    id: test
                    horizontalAlignment: HorizontalAlignment.Center
                    verticalAlignment: VerticalAlignment.Center
                    attachedObjects: [
                        ImageTracker {
                            id: imgTracker
                            imageSource: ""
                            onStateChanged: {
                                if (state == ResourceState.Loaded)
                                {
                                    test.image = _app.getImage()
                                }
                            }
                        }
                    ]
                }
    

    but I have nothing on the screen.

    What I am doing wrong?

    Thank you

    Well, I found a solution to display the image. Maybe this can help someone.

    I don't know if it's the right way to do it but it worked for me.

    In the constructor of the Application, I used this code

    ImageView * setImg = root->findChild("testImg1");
    setImg->setImage(getImage());
    

    and in main.qml, I put these lines

    ImageView {
                    id: test
                    objectName: "testImg1"
                    horizontalAlignment: HorizontalAlignment.Center
                    verticalAlignment: VerticalAlignment.Center
                }
    

    It will not work for any custom or pushed qml qmls.

  • Unable to restore the ImageView ListComponent - image of the data folder

    I downloaded an image in the folder data and want to show it in the listView.

    In Listcomponent, I use an ImageView

    "If I put its imagesource:".. /.. /.. "/ data/files/images/123.png".

    The image appears correctly.

    But if I try to put the same path of C++ code in the GroupDataModel, the image doesn't make.

    Hi friends,

    I found the solution. I hope that is useful you.

    . HPP

     

    #include 
    #include 
    #include 
    
    using namespace bb::cascades;
    
    class App: public QObject {
    Q_OBJECT
    
    public:
        App();
    
    public slots:
        void onSelectionChanged(const QVariantList indexPath, bool selected);
    
    private:
        ListView *listView;
    
    };
    

    . CPP

    #include "app.hpp"
    
    #include 
    #include 
    
    #include 
    
    #include 
    #include 
    #include 
    #include 
    #include 
    
    using namespace bb::cascades;
    
    App::App() {
        QmlDocument *qml = QmlDocument::create("main.qml");
        AbstractPane *root = qml->createRootNode();
    
        GroupDataModel *model = new GroupDataModel(
                QStringList() << "firstname" << "surname" << "imagepath");
        model->setGrouping(ItemGrouping::ByFirstChar);
    
        listView = root->findChild("listView");
    
        QVariantMap person;
        person["firstname"] = "John";
        person["surname"] = "Mark";
        person["imagepath"] = "I will set on click.";
        model->insert(person);
        person["firstname"] = "Mark";
        person["surname"] = "Russie";
        person["imagepath"] = "asset:///icon.png";
        model->insert(person);
    
        listView->setDataModel(model);
    
        QObject::connect(listView,
                SIGNAL(selectionChanged(const QVariantList, bool)), this,
                SLOT(onSelectionChanged(const QVariantList, bool)));
    
        Application::setScene(root);
    }
    
    void App::onSelectionChanged(const QVariantList indexPath, bool selected) {    if (selected) {        if (sender()) {            GroupDataModel *stampModel =                    (GroupDataModel *) listView->dataModel();            QVariantMap map = stampModel->data(indexPath).toMap();            //map["imagepath"] = "asset:///icon.png";            map["imagepath"] = "../../../data/icon.png";            stampModel->updateItem(indexPath, map);            fprintf(stderr, "\nSelection Called");        }    }}
    

    . QML

     

    import bb.cascades 1.0
    
    Page {
        content: Container {
            ListView {
                objectName: "listView"
                listItemComponents: [
                    ListItemComponent {
                        type: "header"
                        HeaderListItem {
                            title: ListItemData
                        }
                    },
                    ListItemComponent {
                        type: "item"
                        StandardListItem {
                            id: root
                            title: ListItemData.firstname
                            description: ListItemData.surname
                            imageSource: ListItemData.imagepath
                        }
                    }
                ]
            }
        }
    }
    

    Currently, I put a static image and a rest black. It will have the value during the click on list black image (dynamically).

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

  • HOWTO simply refer to a QML item and then work with it?

    Salvation a simple question:

    I have a QML layout and now want to access via c ++ to the Button, TextField oder Label e.g.

    I have the following code:

    HelloCascadesApp::HelloCascadesApp()
    {
        QmlDocument *qml = QmlDocument::create("hellocascades.qml");
        qml->setContextProperty("cs", this);
    
        AbstractPane *root = qml->createRootNode();
        Application::setScene(root);
    }
    

    is there something like in Android devleopment findViewById?

    If it was all the app was going to do, then you wouldn't be even not bother with C++ without doubt, given that it could be done entirely in the QML with Javascript. I'll assume that you already knew and that is just one example of what could be a greater application.

    Although it is technically possible to do what you describe, I don't think that's how we're supposed to use QML.  You would rather the button to emit a Signal when it has been activated and, after you link to a location in C++ code, you would do the calculations, then probably update a property in the C++ class.  Label text would have been bound to the property at startup, then it would update automatically after you change the value of the property.

    See the examples and background here http://qt-project.org/doc/qt-4.8/qtbinding.html and here http://qt-project.org/doc/qt-4.8/properties.html .

  • QML Api Documentation

    Could someone give me the link please, all I could find was the C/C++ Docs...

    Thankssssssssss

    If you mean the Cascades documentation for what you can use QML, it is integrated into the same documentation that you have found for C++. Look at the example of code to, for example, the button element: https://developer.blackberry.com/cascades/reference/bb__cascades__button.html and you will see the QML in there.

    If you mean docs for syntax QML itself, you will find here http://qt-project.org/doc/qt-4.8/qtquick.html but you will need to ensure that you understand which parts are autodescriptifs QML (syntax etc.) and are self-describing QtQuick which is a particular implementation, if you build on top of QML the waterfalls in a way even.

  • standard QML Rectangle

    Hello!

    Can I use standard qml of elements (such as Rectangle) in my application of cascades?

    You can use QML Qt instead of stunts if it is appropriate for your project.

    You waive the deep integration with the operating system and experience Blackberry signature provided through waterfalls.

    Stuart

  • C++ or integration of QML calendar event creation

    Hello

    I am currently trying to add calendar event creation integration in my application.

    I started using QML create here

    actions: [
            ActionItem {
                title: qsTr("Add To Calendar")
                imageSource: "asset:///IMG/ic_add_entry.png"
                ActionBar.placement: ActionBarPlacement.OnBar
    
                onTriggered: {
                    invokeCalendar.trigger("bb.action.CREATE")
                }
            }
        ]
        attachedObjects: [
            Invocation {
                id: invokeCalendar
                query {
                    //According to BlackBerry, this doesn't work so I need to find a workaround
                    mimeType: "text/calendar"
                    invokeActionId: "bb.action.CREATE"
                    invokeTargetId: "sys.pim.calendar.viewer.eventcreate"
                }
            }
        ]
    

    After the application of the above code, I discovered that nothing happened when the actionitem was activated; so, I asked him it with BlackBerry and it turns out that they couldn't make it work either.

    So, last week I tried various methods on how to integrate calendar functionality in my application. I tried the examples here and here , but could not get either to work due to several errors.

    Ideally, I would like to be able to define the: subject, body and the hour of beginning, all QML, but after searching the calendar I don't think I can.

    import bb.cascades 1.0
    
    Page {
        property alias fixtureInfo: fixtureText.text
        property alias dateInfo: dateText.text
        property alias timeInfo: timeText.text
        property alias timeZone: timeZoneText.text
        property alias stadiumInfo: stadiumText.text
        titleBar: TitleBar {
            // Localized text with the dynamic translation and locale updates support
            title: qsTr("Fixture") + Retranslate.onLocaleOrLanguageChanged
            scrollBehavior: TitleBarScrollBehavior.Sticky
        }
        ScrollView {
            id: scrollView
            scrollViewProperties {
                scrollMode: ScrollMode.Vertical
                pinchToZoomEnabled: true
            }
            Container {
                id: mainContainer
                Header {
                    title: qsTr("Teams Playing")
                }
                Container {
                    leftPadding: 20
                    rightPadding: 20
                    Label {
                        id: fixtureText
                        multiline: true
                        textStyle.base: bodyStyle.style
                    }
                }
                Divider {
                }
                Header {
                    title: qsTr("Date")
                }
                Container {
                    leftPadding: 20
                    rightPadding: 20
                    Label {
                        id: dateText
                        multiline: true
                        textStyle.base: bodyStyle.style
                    }
                }
                Divider {
                }
                Header {
                    title: qsTr("Time (GMT - 3)")
                }
                Container {
                    leftPadding: 20
                    rightPadding: 20
                    Label {
                        id: timeText
                        multiline: true
                        textStyle.base: bodyStyle.style
                    }
                }
                Divider {
                }
                Header {
                    title: qsTr("Time (My Timezone)")
                }
                Container {
                    leftPadding: 20
                    rightPadding: 20
                    Label {
                        id: timeZoneText
                        multiline: true
                        textStyle.base: bodyStyle.style
                    }
                }
                Divider {
                }
                Header {
                    title: qsTr("Stadium")
                }
                Container {
                    leftPadding: 20
                    rightPadding: 20
                    Label {
                        id: stadiumText
                        multiline: true
                        textStyle.base: bodyStyle.style
                    }
                }
                Divider {
                }
                attachedObjects: [
                    TextStyleDefinition {
                        id: bodyStyle
                        base: SystemDefaults.TextStyles.BodyText
                    }
                ]
            }
        }
        actions: [
            ActionItem {
                title: qsTr("Add To Calendar")
                imageSource: "asset:///IMG/ic_add_entry.png"
                ActionBar.placement: ActionBarPlacement.OnBar
    
                onTriggered: {
                    invokeCalendar.trigger("bb.action.CREATE")
                }
            },
            ActionItem {
                title: qsTr("Share")
                imageSource: "asset:///IMG/ic_share.png"
                ActionBar.placement: ActionBarPlacement.OnBar
    
                onTriggered: {
                    shareAction.trigger("bb.action.SHARE")
                }
            },
            ActionItem {
                title: qsTr("Search For Live Score")
                imageSource: "asset:///IMG/ic_search.png"
                ActionBar.placement: ActionBarPlacement.InOverflow
    
                onTriggered: {
                    var searchpage = goToSearch.createObject();
                    navigationPane1.push(searchpage);
                    searchpage.searchText("live score for " + fixtureText.text)
                }
            }
        ]
        attachedObjects: [
            ComponentDefinition {
                id: goToSearch
                source: "webView.qml"
            },
            Invocation {
                id: invokeCalendar
                query {
                    mimeType: "text/calendar"
                    invokeActionId: "bb.action.CREATE"
                    invokeTargetId: "sys.pim.calendar.viewer.eventcreate"
                }
            },
            Invocation {
                id: shareAction
                query.mimeType: "text/plain"
                query.invokeActionId: "bb.action.SHARE"
                query.data: fixtureText.text + qsTr(" at ") + timeText.text + qsTr(", ") + timeZoneText.text + qsTr(" in my time zone,") + qsTr(" on ") + dateText.text + qsTr(" in the ") + stadiumText.text + " via @TundraCore #WorldCup2014"
                query.onQueryChanged: {
                    query.updateQuery()
                }
            }
        ]
    }
    

    As you can see I'm using aliases, in the above code and so I want to put the following text:

    -Set the title of the event: "World Cup 2014:"+ fixtureText.text ".
    -Define the body as: fixtureText.text + 'to' + timeZoneText.text + 'on' + dateText.text + "in the" + stadiumText.text
    -Set the release date: dateText.text
    -Set as start time: timeZoneText.text

    Therefore, I was wondering if someone would be able to show me how to do this in QML or C++?

    Thanks in advance

    With the help of two other developers, I managed to get this working through QML my hpp file settings

  • Object to QML C++ signal/slot mechanism transfer

    Hello!

    I have a simple class:

    // myclass.hh
    
    class MyClass : public QObject {
    
        Q_OBJECT
    
        Q_PROPERTY(QString title READ title)
    
    public:
        MyClass(QObject* parent = nullptr)
            : QObject(parent)
        {}
    
        ~MyClass() {}
    
        MyClass(const MyClass&, QObject* parent = nullptr)
            : QObject(parent)
        {}
    
        QString title() const
        {
            return title_;
        }
    
    private:
        QString title_;
    };
    
    Q_DECLARE_METATYPE(MyClass);
    

    and in the main function, I save my metatype system class

    // main.cc
    
    ...
    qRegisterMetaType("MyClass");
    
    MainClass mainclass;qml->setContextProperty("mainclass", mainclass);
    ...
    

    and in another place, I try to convey the purpose of the MyClass class via the signal:

    // mainclass.hhclass MainClass : public QObject {    Q_OBJECT
    ...
    signals:
        void my_signal(MyClass);
    ...
    };
    // mainclass.cc
    ...
        MyClass mc;
        emit my_signal(mc);
    ...
    

    and try to catch this object in qml slot:

    // .qml
    
    Container {
        onCreationCompleted: {
            mainclass.my_signal.connect(signalHandler)
        }
    
        function signalHandler(myClassObj) {
            console.log('we here') // output 'we here'
            console.log(myClassObj.title) // output 'undefined'
            console.log(myClassObj.title()) // empty output
        }
    }
    

    Macro Q_INVOCABLE added before the declaration of MyClass::title() has the same effect.

    What is wrong with my code?

    This is the signal for all

    Q_SIGNALS:
    
        void addedToAllOrder(Order* order);
    

    Order is registered:

    qmlRegisterType("org.ekkescorner.data", 1, 0, "Order");
    

    Import in qml:

    import org.ekkescorner.data 1.0
    

    Qml connection:

    onCreationCompleted: {
            dataManager.addedToAllOrder.connect(onAddedToAllOrder)
        }
    

    Important! set a property in qml:

    Page {
        id: orderPage
        .....
        property Order anotherOrder
    

    then everything works well in qml function (SLOT)

        function onAddedToAllOrder(theOrder) {
            anotherOrder = theOrder
            console.debug("Order added: " + anotherOrder.nr)
        }
    

    This is how I have face this kind of stuff

    using a pointer ensures that there'e really a single object used in memory and you can use QML.

    the cool thing: he is glad assist in qml: type anotherOrder. ... gives all properties to select and you deal directly with your C++ object. don't forget that your C++ class is the owner (parent) of your object

    hope that gives you some ideas to try

  • The QML App charts

    Hi all!!!

    I am creating a QML app to view some data (using a rest service).

    Is there any loan (C++) library or plugin for this?

    Can I use a javascript plugin in my page QML?

    No there is no integrated graphics API.

    There are some 2D graphics libraries...

    http://developer.BlackBerry.com/native/documentation/core/library_support_at_a_glance.html

    And for the simple bar charts you can use QML containers with different color background.

    Also do a search on cards will also come up with a number other suggestions in the same direction...

    http://supportforums.BlackBerry.com/T5/forums/SearchPage/tab/message?filter=labels%2Clocation&Locati...

  • ImageView or webview

    I want to get an image in a listview. the image is from a url. should I use component imageview or webview.

    who can tell me the difference

    THX

    Just to add to the response of @pyth, since it's on the web, you must use asynchronous loading with...

    A few resources to help you...

    http://developer.BlackBerry.com/native/documentation/Cascades/UI/lists/asynch_data.html

    http://BlackBerry.github.IO/Cascades-samples/ImageLoader.html

Maybe you are looking for