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

Tags: BlackBerry Developers

Similar Questions

  • issue of cameraView show

    I'm trying to get the cameraView show, but when I open the map it shows just the underlying page.  What funny, however, is that the camera takes pictures when I touch.

    This is the code for my camera QML:

    I call this QML leave of a spreadsheet, don't know if that makes a difference.  Not there at - it no code standard QML to get the base cameraview (as in the camera application) without having to rely on the camera?  I want to reference the pictures stored in my application.

    import bb.cascades 1.0
    import bb.cascades.multimedia 1.0
    import bb.multimedia 1.0
    
    Sheet {
        id: cameraSheet
    
    Page {
        id: photoPage
        titleBar: TitleBar {
            title: qsTr("Take a picture") + Retranslate.onLanguageChanged
            dismissAction: ActionItem {
                title: qsTr("Cancel") + Retranslate.onLanguageChanged
                onTriggered: {
                    // Hide the Sheet.
                    cameraSheet.close()
                    }
            }
        }
    
        // A Container is used to gather visual items together.
        Container {
            layout: DockLayout {
            }
            Container {
                horizontalAlignment: HorizontalAlignment.Fill
                verticalAlignment: VerticalAlignment.Fill
    
                // This is the camera control that is defined in the cascades multimedia library.
                Camera {
                    id: camera
                    onTouch: {
                        if (event.isDown()) {
                            // Take photo
                            capturePhoto();
                        }
                    }
    
                    // When the camera is opened we want to start the viewfinder
                    onCameraOpened: {
                        // Using helper function to set resolution
    
                        // Additional camera settings, setting focus mode and stabilization
                        getSettings(cameraSettings)
                        cameraSettings.focusMode = CameraFocusMode.ContinuousAuto
                        cameraSettings.shootingMode = CameraShootingMode.Stabilization
                        applySettings(cameraSettings)
    //                    camera.startViewfinder();
                    }
    
                    // There are loads of messages we could listen to here.
                    // onPhotoSaved and onShutterFired are taken care of in the C++ code.
                    onCameraOpenFailed: {
                        console.log("onCameraOpenFailed signal received with error " + error);
                    }
                    onViewfinderStartFailed: {
                        console.log("viewfinderStartFailed signal received with error " + error);
                    }
                    onViewfinderStopFailed: {
                        console.log("viewfinderStopFailed signal received with error " + error);
                    }
                    onPhotoCaptureFailed: {
                        console.log("photoCaptureFailed signal received with error " + error);
                    }
                    onPhotoSaveFailed: {
                        console.log("photoSaveFailed signal received with error " + error);
                    }
                    onPhotoSaved: {
                        setting.lastFileName = fileName;
                        // Makes the ImageButton visible when a photo is captured.
                        setting.visible = true;
                    }
                    onShutterFired: {
                        // A cool trick here to play a sound. There are legal requirements in many countries to have a shutter-sound when
                        // taking pictures. So we need this shutter sound if you are planning to submit you're app to app world.
                        // So we play the shutter-fire sound when the onShutterFired event occurs.
                        cameraSound.play();
                    }
                    onCameraResourceAvailable: {
                        // This signal handler is triggered when the Camera resource becomes available to app
                        // after being lost by for example putting the phone to sleep, once it has been received
                        // it is possible to start the viewfinder again.
                        camera.startViewfinder()
                    }
    
                    onCreationCompleted: {
                        // Open the front facing camera.
                        camera.open(CameraUnit.Rear);
                    }
    
                    attachedObjects: [
                        CameraSettings {
                            id: cameraSettings
                        },
                        SystemSound {
                            id: cameraSound
                            sound: SystemSound.CameraShutterEvent
                        }
                    ]
                }
            }
    
        } // content Container
    }// Page
    }
    

    Thanks to davnce.  Any help will be loved and solutions will be marked.

    see you soon,

    Nevermind, I found a way to be much easier to do this simply by invoking the camera using C++

    bb::system::InvokeManager manager;
    bb::system::InvokeRequest request;
    request.setTarget("sys.camera.card");
    request.setAction("bb.action.CAPTURE ");
    InvokeTargetReply *targetReply = manager.invoke(request);
    
  • The color changes when translucent white

    I'm trying to overlap several translucent color objects, and I need to have a white object behind them so I can overlap other objects in the background. Anyway, when I decrease the opacity on the colors, they change colour. Any way I can avoid this? See the example in the image:

    Capture.JPG

    It is a standard white rectangle with default white fill and black stroke and a red top, square with an opacity to 30%. The Red should look like the rose outside the overlap region, why it changes color over a white object?

    Try it with preview enabled overprinting. This will give you a true vision of the final output.

  • Qml gridlayout rectangle icons

    I'm reproducing the rectangle icons on the homescreen of BB10 in a grid format. Right now I have a two-dimensional image of gird with my icons (no distinguishable area) and would like to see the box while that on top of my background color. How does qml cascading. Thank you

    You can use use ListView with the presentation of the grid.  Then using components customized to list items.  You should be able to define a background color of each element (transparent grey), have an ImageView and etiquette in addition to this.  Finally, have a background (anything of your choice) for the entire Page... this piece would be independent of the ListView.

  • How to create a rectangle of standard height without Add-ons like 'height of 100% MuseThemes.

    On my website www.rostany.com I am creating the grid black metal going up and down. I managed to do this as a background page in vertical mosaic image. However, now I need to add image slideshow as background and place the above grid on it (as before) to constitute the 'page' where text and graphical information is laid out.

    That's what I want this grid to look like (from top to bottom)

    was.png

    This is what it looks like the ugly burnts appearing at the top when the content is filled in.

    is.png

    I think you already understand the solution I can verify with your Web site.

    Thank you

    Sanjit

  • How to define a rectangle by program to use as a RIO

    Hello

    I'm analyzing a video and the ability to set either a RIO by clicking and dragging on the window of the video or using a default region. I managed to make the click and drag, but I cannot set the rectangle to the to the corner of the video. Video resolutions change between files, so I need to use the information in the width and height to set the coordinates. These values must then be passed to the IMAQ convert rectangle to RIO. The problem is that I can't write the function in the rectangle data type. I tried a standard cluster of the 5 elements that are in the rectangle data type, but it does not work. How can I do this? The photo shows the code I have.

    Thank you

    Stephen

    This example allows you to solve your problem

  • The Acer M3641 will have a standard ATX power supply? My power supply is dead.

    My M3641 does not start and it seems to be dead while it is turned off.  It was plugged and it started sparking and make loud pop.  I see no signs of a short circuit or damage the inside of the case, but I did not remove or open the power supply.  I think to replace, but I can't find all the information on the sites of Acer which would specify if a standard ATX PSU would work or if there are installation instructions I need.  Does anyone out there know about this?  Thank you.

    OK, no answer here yet, so I had to make a decision.  I bought a ThermalTake TR2 430W ATX PSU (also shown on their Web site as W0070) and I replaced the power supply in my M3641.  It cost me $25 (after discount) at a local TigerDirect store (CompUSA was.)  I was shocked (no pun intended) the degree of simplicity to install.  I was also shocked that he seems to have worked immediately.

    First I disconnected the power of the unit and press and hold the power on button on the front of the PC (according to the instructions of Acer) to release any remaining electrical load (or so they claim).  I removed the 4 screws of the old PSU and slid the box out of the chassis Assembly while retaining all connected cables.  I found the best direction for the new PSU (fan stood in the same place, so the new power supply heat can be evacuated in the chassis, but the chassis is open enough and if the fan is drawing inside the PSU the air comes from the back of the unit (reasonably fresh air.)  It's the only way it would fit the attachment power cord located on the side of the draw.  The old power supply had the fan and the power cord on the same side attachment to the rear of the chassis).  Note that it is possible that the fan is fan in the power supply and the back.  I do not know.  In any case, I had no choice about the direction.

    I unplugged the old PSU connector and replaced it by plugging the connector corresponding since the new power supply.  I did step by step, a connector at the same time, check first to make sure I knew exactly where the connector has been set and what was the orientation.  In each case, I checked to make sure that the paired wire color coding.  In some cases, there was an extra wire on the new connector, but all the others were corresponding to the color and orientation.  I had a square connection 4 pins which does not correspond to the form of any connector again, but the new PSU was a rectangle connector 8 this divide into two 4 pin and I joined an of these.  The main connector has been 24 pins and the new PSU gave me an option of 20 or 24 pins.  Once again, no problem.  I noticed that one of the connections of the old PSU was actually two connections separated on a single cable, so I simply repeated with the new power supply, which included two cables multiconnector just for this purpose.  I used one of those for the two connections (hard disk, I think) and the other for a single connection, probably for the optical drive.

    The old power supply was now completely detached.

    After checking that all the screws and connectors have been secured, screw the plate chassis and to make sure the PC is properly delivered together, I plugged it in the end of the power cable supplied with the new power supply with the power off PC switch.  Then I plugged the other end of the power cable on my PS backup APC no explosion yet, so I went the new PC button power on / off to we.  Still no spark, so I pressed the button on the front of the PC and voila, it lights up and started.  Everything seems fine.  It seems to work normally.  If I encounter problems such as overheating, I will update this post.

  • user accounts suddenly denied access to games standard

    OS is Vista Home Premium. I created two centuries ago user accounts. I am the administrator and have no problem. My husband is defined in Standard and until Friday 4th has been able to play an installed game he plays online. Suddenly, he is unable to play because he gets the message:
    "Windows cannot access the specified device, path or file. May not permissions to access you the item.
    Also, the icon of the shortcut to the game and read icon via start it > programs method changed to the type of icon where see you installed updates to windows. a rectangle with a small green square. Please note that nothing seen via my user account.
    If you set my husband to user account to be an administrator, or if you try to run the game "as an administrator", you still get the same message as above.
    If you view the permissions for the game that he has "full control". View permissions for the game through my user account says 'Special permissions' and I can easily play the game.
    I would like to know what has happened to cause this and also how to fix it.
    Thank you very much

    Thanks a lot for your suggestions.
    In response, I created a new standard user account and had the same problem on all standard user accounts. Then removed them.

    The problem occurred after a recent update of Windows, that somehow changed the permissions on some downloaded files. The UAC was responsible in some way. I guess I could undo each in turn to find out who we caused the problem, but decided to do so only if no other method could be found.

    You can easily see which applications have been affected because the Apps icon has been changed into an icon of the window - a rectangle with a small green square in it.

    In my case, my husband took ownership of a game and a control total seen on the Admin account, but it was ignored. If you are looking for the game in the list of the found program via the Start button and right click on the game and select Properties... this method does not work... or can run you as admin.

    However, I decided to try the following and have had a result.

    • I opened his account (note that whenever you are prompted to enter the Admin password to continue).
    • I clicked on the "Start" button and find the game in question under the "Programs" list
    • I then click right on this game and selected for "open file location".
    • Then, I selected the Application file (exe), right click and select "Properties".
    • Then choose the security"" tab.
    • My Admin user was in the list, but my husband's name was not if I chose to 'Edit' then 'Add' his name and user account.
    • Applied and could I stand it and the icon for the game immediately changed to show the correct and original icon with a windows shield attached.
    • I then click on the game again and selected to create a shortcut that I placed on the desktop.

    The game now runs from his account.
    Solved :)

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

  • How Textfield text on another page qml property access

    Hello

    I started 10 BB development recently and need help. I searched this forum but could not find some information exactly related to my problem (unlike only), or I missed something from basically. My main.qml, I want to access the text property of the textfield of the InputControl.qml to be used as a parameter in my SQLQuery (attached object). I tried to use the fieldname method alias property, but it does not work. I can't feature outside. Here is my code:

    hand. QML

    import bb.cascades 1.4
    import bb.cascades.datamanager 1.2
    import bb.system 1.0
    import bb.data 1.0
    
    Page {
    
        id: root 
    
        titleBar: UIControls {
        }
    
        //! [0]
       content: Container {
    
            leftPadding: ui.du(2)
            rightPadding: ui.du(2)
            topPadding: ui.du(2)
            bottomPadding: ui.du(2)
    
            InputControl {
            }
    
            // The ListView that's used to display the artist data
            //! [1]
            ListView {
                id: myListView
    
                //property variant dq: defaultDataQuery
                // Associate the list view with the data model that's defined in the
                // attachedObjects list
                layout: StackListLayout {
                    headerMode: ListHeaderMode.Sticky
                }
                layoutProperties: StackLayoutProperties {
                    spaceQuota: 1.0
                }
                horizontalAlignment: HorizontalAlignment.Fill
                verticalAlignment: VerticalAlignment.Fill
    
                listItemComponents: [
    
                    ListItemComponent {
                        type:  "item"
    
                        Container {
                            Label {
                                text: ListItemData.Japanisch
                                layoutProperties: StackLayoutProperties {
    
                                }
                                topMargin: 5.0
                                textStyle {
                                    base: SystemDefaults.TextStyles.TitleText
                                    fontWeight: FontWeight.Bold
                                    color: Color.create("#7a184a")
                                }
    
                            }
                            Label {
                                text: ListItemData.Lesung
                                textFit.maxFontSizeValue: 9.0
                                textStyle {
                                    base: SystemDefaults.TextStyles.TitleText
                                    fontWeight: FontWeight.Normal
                                    color: Color.create("#ff1818e9")
                                }
    
                            }
                            Label {
                                text: ListItemData.Deutsch
                                textStyle {
                                    base: SystemDefaults.TextStyles.TitleText
                                    fontWeight: FontWeight.Normal
                                }
    
                                multiline: true
                                textFit.maxFontSizeValue: 8.0
                            }
                            Divider {}
                        }// Container
                    }
                    // Use a standard list item to display the data in the model
                ]    
    
            } // end of ListView
    
        }//![1]
    
        attachedObjects: [
            //! [2]
            // One of the default provided DataModel's
    
            GroupDataModel {
                id: dataModel
                grouping: ItemGrouping.None
            },
            DataSource {
                id: dataSource
    
                // Load the data from an SQL database, based on a specific query
                source: "WadokuJT.db"
                //query: "select Japanisch, Deutsch, Lesung from WadokuJT where Deutsch like '%Wasser%'"
                query: "select Japanisch, Deutsch, Lesung from WadokuJT where Deutsch like '%" + stext + "%'";
    
                onDataLoaded: {
                    // After the data is loaded, insert it into the data model
                    dataModel.insertList(data);
    
                }
                type: DataSourceType.Sql
            } // end of DataSource      
    
        ]//! [2]  
    
        actions: [
            //! [8]
            ActionItem {
                title: qsTr("Search")
                imageSource: "asset:///images/ic_search.png"
                ActionBar.placement: ActionBarPlacement.Signature
                onTriggered: {
                    myListView.dataModel = null
                    dataSource.load()
                    //myListView.dq = defaultDataQuery
                    myListView.dataModel = dataModel 
    
                }
            },
    
            ActionItem {
                title: qsTr("Settings")
                imageSource: "asset:///images/ic_settings.png"
                onTriggered: {
    
                }
            },
    
            ActionItem {
                title: qsTr("Help")
                imageSource: "asset:///images/ic_help.png"
                onTriggered: {
    
                }
            }                           
    
        ]//![8]
    
    } // end of Page
    

    And here is my InputControl.qml

    import bb.cascades 1.4
    
     Container {
         property alias stext: txtSearchText.text
    
        Label {
            id: lblSearchText
            text: "Searchtext\r\n"
    
        }
    
        TextField {
            id: txtSearchText
            layoutProperties: FlowListLayoutProperties {
    
            }
            hintText: "Enter Searchtext"
        }
    }
    

    Any help is greatly appreciated. Thank you.

    Give InputControl an id (in main.qml), for example someId.

    Access the variable an alias like someId.stext

  • On the available library that can be used in QML

    I found the following reference in QML

    text: Qt.formatDate(ListItemData, "ddd, MMM d, yyyy")

    Can someone be able to summarize the other libraries like Qt, which can be used directly beside QML?

    Thank you

    You can use most of the global JavaScript stuff (Math, number, String) which is not dependent on a browser environment.

    You can use the global object of Qt this formatDate() routine where, although many of these functions are not useful (for example color ones) cascading: http://doc.qt.digia.com/stable/qml-qt.html#qmlglobalqtobject

    I don't know if there is an exhaustive list. I took notes once after exploring:

    * eval() parseInt(), parseFloat(), isNaN(), isFinite()
    * escape(), unescape(), decodeURI(), decodeURIComponent(), encodeURI(), encodeURIComponent()
    * print(), gc()?
    * Object, function, array, Boolean, String, number, Date, RegExp
    Error, EvalError, RangeError, ReferenceError, SyntaxError,
    TypeError, URIError
    * console.log () and console.debug () (difference?)
    * qsTranslate(), qsTr() and friends

    Some people are standard JavaScript. Some come from Qt. It is also an object Application, probably from stunts himself but maybe Qt.

  • QML perfomance

    Hello. I have a problem with qt on playbook. I managed to create a simple player for PB, using qml technology, but when I scroll through the text, I have annoying lags. I took a video of it: http://youtu.be/FW0JkUR4rQA

    The elemnt, who is trolling, is faster with rectangles personalized inside. There is a code:

        Flickable {
            property int myBottomMargin: 0
                id: flick
                anchors.rightMargin: 0
                anchors.bottomMargin: myBottomMargin
                anchors.leftMargin: 250
                anchors.topMargin: 48
                z: 1
                flickableDirection: Flickable.VerticalFlick
                contentWidth: 517
                contentHeight: 0
                interactive: true
                clip: true
                anchors.fill: parent
        }
    

    The objects that are in use this class:

    import QtQuick 1.1
    
    Rectangle {
        id: story
        property alias storyText : joke.text
        property alias idText : id.text
        property alias dateText : date.text
        property alias ratioText : ratio.text
        //transformOrigin: Item.TopLeft
        width: topLine.width
        height: topLine.height + border_image1.height
    
        Image {
            id: topLine
            x: 0
            y: 0
            source: "../quite_top.png"
    
            Image {
                id: image1
                x: 20
                y: 4
                width: 21
                height: 18
                source: "../up.png"
            }
    
            BorderImage {
                id: border_image1
                x: 0
                y: topLine.height + topLine.y
                width: topLine.width
                height: joke.paintedHeight
                border.top: 0
                border.right: 633
                border.left: 633
                z: -1
                source: "../quite_middle.png"
            }
    
            Text {
                id: joke
                x: 20
                y: topLine.height + topLine.y
                //+topLine.width*0.05
                width: border_image1.width-40
                height: 200
                font.family: "Times New Roman"
                //text: qsTr("good joke")
                wrapMode: Text.WrapAtWordBoundaryOrAnywhere
                font.pixelSize: 18
            }
    
            Image {
                id: bottomLine
                x: 0
                y: joke.paintedHeight + joke.y
                source: "../quite_bottom.png"
            }
    
            Text {
                id: id
                x: 497
                y: 6
                width: 116
                height: 14
                text: qsTr("")
                verticalAlignment: Text.AlignVCenter
                horizontalAlignment: Text.AlignRight
                font.pixelSize: 12
            }
    
            Text {
                id: date
                x: 327
                y: 6
                text: qsTr("")
                verticalAlignment: Text.AlignVCenter
                font.pixelSize: 12
            }
    
            Text {
                id: ratio
                x: 49
                y: 6
                text: qsTr("")
                verticalAlignment: Text.AlignVCenter
                horizontalAlignment: Text.AlignLeft
                font.pixelSize: 12
            }
    
        }
    }
    

    And how I have the complete list:

    function addObjects() {
        console.log("Add objects")
        console.log(data[0][0])
    
        setStatusBarText();
    
        isLoading = false
    
        count = data[0].length
    
        var component = Qt.createComponent("Story.qml")
        var height_flick = y_offset
    
        //console.log(data[0][0]);
        for (var i=0;i
    

    I use Qt 4.8.3 with settings by default if it is. Thank you

    Hello

    Faster is not optimized for the display of several elements.

    It is best to use a ListView with delegate & dataModel. ListView creates only items that are currently on the screen and should work very quickly.

  • Standard icons in BB10

    Some of the sample apps and various BB10 screenshots seem to make all white standard icons for things like:

    -Share

    -Edit

    -Remove

    -Add

    -etc.

    These icons are used it tabs, action items, menus, etc.

    Is there a place where these are documented and made available, and we have allowed / expects to use these same icons in our applications?

    Currently, there is no way to access a set of default icons. For (a little) more information, you might want to look at this thread: http://supportforums.blackberry.com/t5/Cascades-Development/Couple-of-questions-coming-from-pure-QML...

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

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

    Advice would be greatly appreciated.

    Applications vary.

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

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

    The output of the service is JSON.

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

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

    Thank you!

    Hello

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

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

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

    TwitterRequest.hpp

    /*
     * Copyright (c) 2011-2012 Research In Motion Limited.
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
    
    #ifndef TWITTERREQUEST_HPP_
    #define TWITTERREQUEST_HPP_
    
    #include 
    
    /*
     * This class is responsible for making a REST call to the twitter api
     * to retrieve the latest feed for a twitter screen name. It emits the complete()
     * signal when the request has completed.
     */
    class TwitterRequest : public QObject
    {
        Q_OBJECT
    public:
        TwitterRequest();
        virtual ~TwitterRequest();
    
        /*
         * Makes a network call to retrieve the twitter feed for the specified screenname
         * @param screenname - the screen name of the feed to extract
         * @see onTimelineReply
         */
        void getTimeline(QString screenname);
    
    public slots:
        /*
         * Callback handler for QNetworkReply finished() signal
         */
        void onTimelineReply();
    
    signals:
        /*
         * This signal is emitted when the twitter request is received
         * @param info - on success, this is the json reply from the request
         *               on failure, it is an error string
         * @param success - true if twitter request succeed, false if not
         */
        void complete(QString info, bool success);
    };
    
    #endif /* TWITTERREQUEST_HPP_ */
    

    TwitterRequest.cpp

    /*
     * Copyright (c) 2011-2012 Research In Motion Limited.
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
    
    #include "TwitterRequest.hpp"
    #include 
    #include 
    #include 
    #include 
    #include 
    
    TwitterRequest::TwitterRequest()
    {
    }
    
    TwitterRequest::~TwitterRequest()
    {
    }
    
    void TwitterRequest::getTimeline(QString screenname)
    {
        QNetworkAccessManager* netManager = new QNetworkAccessManager();
        if (!netManager)
        {
            qDebug() << "Unable to create QNetworkAccessManager!";
            emit complete("Unable to create QNetworkAccessManager!", false);
            return;
        }
    
        QString queryUri = "http://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_n...";
        queryUri += screenname;
        QUrl url(queryUri);
        QNetworkRequest req(url);
    
        QNetworkReply* ipReply = netManager->get(req);
        connect(ipReply, SIGNAL(finished()), this, SLOT(onTimelineReply()));
    }
    
    void TwitterRequest::onTimelineReply()
    {
        QNetworkReply* reply = qobject_cast(sender());
        QString response;
        bool success = false;
        if (reply)
        {
            if (reply->error() == QNetworkReply::NoError)
            {
                int available = reply->bytesAvailable();
                if (available > 0)
                {
                    int bufSize = sizeof(char) * available + sizeof(char);
                    QByteArray buffer(bufSize, 0);
                    int read = reply->read(buffer.data(), available);
                    response = QString(buffer);
                    success = true;
                }
            }
            else
            {
                response =  QString("Error: ") + reply->errorString() + QString(" status:") + reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toString();
                qDebug() << response;
            }
            reply->deleteLater();
        }
        if (response.trimmed().isEmpty())
        {
            response = "Twitter request failed. Check internet connection";
            qDebug() << response;
        }
        emit complete(response, success);
    }
    

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

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

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

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

    App.HPP

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

    App.cpp

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

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

    See you soon

    Swann

  • Format SQLite DateTime in QML

    Hi all

    I'm sorry if this is an easy/stupid question. But I can't get the updated date retrieved from an SQLite database object shaped properly.

    I found the TwitterTimeline example, but they released only this. I want to format as exact in my ListView.

    I thought I could standard Javascript like this:

    StandardListItem {
      reserveImageSpace: false
      title: {
        ListItemData.sys+" : "+ListItemData.dia
      }
      status:{ (new Date(ListItemData.measure_date)).getFullYear(); }
    }
    

    and toString() methods and so on, but I only retrieve the outputs "nan".

    Then I tried without the 'new Date()' conversion, maybe b/c it is already converted to a new date, but get no results.

    Can someone help me on this? I'm quite new to BB 10/stunts, but he really likes to use it.

    Thank you very much!

    So it seems to me that the part in the QML is not Javascript, at least, it seems that the Date functions do not work.

    So I took a different path and made my custom objects, filling a SQL GroupDataModel inside and these custom objects custom objects I make the date formatting.

    Maybe it helps someone else, too.

Maybe you are looking for

  • My garageband suddenly started fading out

    So I recorded three different tracks.  The track of a guitar and two vocal tracks.  I worked a bit on it and everything seemed fine.  Then I started to mess with some settings, because I wanted to put some effects on the guitar.  And then I found mys

  • The Web site will not play its asf

    By visiting the web site, sognoromance.com/ladyinred.htm, pages do not play sound in ASF or WMA format.They do it with IE.I installed the plugin, tested and turned off everything to nothing does not. Is there a way to be able to hear the sound? Thank

  • How to remove a scratch on the screen

    Is it possible to remove a scratch from the screen?

  • Satellite A50-109: after RAM upgrade-&gt; blue screen

    Hi all I bought a new patriot 1 GB ram sodimm pc 2700 as an upgrade to my satellite a50-109. After installation of the equipment on the back of the laptop, I had some problems with windows xp bsod (blue screen of death). Errors 0x000000e8. After reco

  • Photosmart HP 7520: ip address for web services is not on the printer properties

    Printer is a HP Photosmart 7520, I have this printer is installed on computers laptops HP two and two are running Windows 7 Pro.  On one of the laptops (mine), when I click on devices and printers, and then right-click on my default printer that is t