\n in ListView

hey im trying to put data serval in lines in a row og a listview but whan I put the "\n" it dosent shows mid anything in the app, so who can I do?

I think that the standard model for the ListItemComponant does not support multiline.

Try this...

            listItemComponents: [
                ListItemComponent {
                 Container {
                        Label {
                            text: ListItemData
                            multiline: true
                        }
                 }
            }
            ]

Tags: BlackBerry Developers

Similar Questions

  • Could not load the log for listview

    I can not load calllog to list view.

    Here is the code

    signals:
        void calllogLoaded(const QList &data);
    
    QList callHistoryResults = callHistoryService.callHistory(defaultAccount.id(), defaultFilter, callHistoryParams);emit calllogLoaded(callHistoryResults);
    

    and QML

    calllogDM.insertList(data)
    

    «I got this error "QMetaProperty::read: unable to manage"QList"non-registered data type for the property «QDeclarativeBoundSignalParameters::data»»»

    Have spent days for this, I have not found the solution. Could you help me on this? How can I insert calllog to listview?

    Thank you!

    You need to do the conversion yourself. You should always get the actual data, the CallEntry ( https://developer.blackberry.com/native/reference/cascades/bb__pim__phone__callentry.html ). The model is unable to handle this for you anyway.

  • Why my ListView items cannot display on a single line?

     ListView {
           preferredHeight: ui.du(20)
           id: keyItemList
           dataModel: _nao.keyItemList
    
           leftPadding: 20
           rightPadding: 20
        //
           layout: StackListLayout {
               orientation: LayoutOrientation.LeftToRight
               headerMode: ListHeaderMode.None
           }
    
           listItemComponents: [
    
               ListItemComponent {
                   type: 'item'
                   Container {
                       preferredHeight: ui.du(20)
                       preferredWidth: ui.du(20)
                       KeyItem {
                           name: ListItemData.name
                           nowPic: ListItemData.nowPic
                           dot: ListItemData.dot
                           rate: ListItemData.rate
                       }
                       topMargin: ui.du(1.0)
                       leftMargin: ui.du(1.0)
                       rightMargin: ui.du(1.0)
                       bottomMargin: ui.du(1.0)
                  }
              }
          ]
    
          verticalAlignment: VerticalAlignment.Center
          horizontalAlignment: HorizontalAlignment.Center
    }
    

    If I put prop of listview layout. Items being passed.

    If I didn't put any accessories page layout, the elements present, but vertically.

    It can be a little difficult to get the horizontal listviews to behave, dimensions should be set correctly if I remember correctly.

    See https://github.com/oniongarlic/bb10-hlv-example/blob/master/assets/main.qml for an example code.

  • String bounded to the listview

    I have a property string delimited in a qml which I want to display in the form of a simple list in qml.

    I tried arraydatamodel without success.

    Any help will be appreciated.

    Thank you

    Mukesh

    Looks like OP is having 2 numbers, or is not quite explain his problem. Since the original post, I thought the same thing as @radwon and believed that OP wanted to build a dataModel off delimited string. But her reply, I think he's trying to access this delimited string of its ListItemComponent, which cannot be done directly, but need to access from its ListView using ListItem.view

    Here is a screenshot of the official ListView docs indicating that

    Maybe the OP maybe specify exactly what he must do.

  • ListView.leadingVisual ignores horizontalAlignment

    It seems that the ListView.leadingVisual simply ignores the horizontalAlignment property.

    I try using horizontalAlignment: HorizontalAlignment.Fill but it will be not just extend:

    leadingVisual: container}

    horizontalAlignment: HorizontalAlignment.Fill

    }

    Even if ListView is expanded, the only solution is to put the preferedWidth. No idea if it is wanted ot a bug?

    It seems to work when you set the layoutProperties + spaceQuota.

    layoutProperties: {StackLayoutProperties}

    spaceQuota: 1

    }

    Looks like the container around the leadingVisual has a StackLayout

    Still not sure if this should be considered a bug or not

  • WebView ListView data Page

    I have a ListView that ItemData containing Web sites. When you select an item, it pushes a page from the data. I can view the data. Then I have an action button that pushes another page with a WebView. The problem I have is that the WebView never is completed and said that the web page is unavilable. I have a label that does not display the correct Web page and I can also get the Web page to display if I put the url directly to the page.

    Here is the code:

        actions:  [
            ActionItem {
                title: qsTr("View")
                imageSource: "asset:///icons/actions/view.png"
                onTriggered: {
                    var page = htmlPage.createObject();
                    page.url = "http://www.google.com";
                    console.log(page.url);
                    navPane.push(page);
                }
    
            }
        ]
    
    import bb.cascades 1.2
    
    Page {
    
        property string  url
    
        id: htmlPage
        Container {
            preferredWidth: Infinity
            preferredHeight: Infinity
            verticalAlignment: VerticalAlignment.Center
            horizontalAlignment: HorizontalAlignment.Center
            WebView {
                id: webView
                settings.background: Color.Black
                url: url
            }
           Label {
               text: url
               textStyle.fontSize: FontSize.XXSmall
            }
        }
    }
    

    I tried a lot of different things without success. Anyone have this type of process work?

    All of a sudden, it came to me.

        property alias url : webView.url
    
  • How to detect when ListView recycles an ImageView?

    I have a ListView with items ~ 600 in a 4-wide grid. Each element is a WebImageView (inherits from ImageView, slightly modified from code kindly provided here) over a label.

    Everything works spot - we (and performance is awesome) except for one glaring problem: when I sometimes momentarily the ImageView ListView displays scrolling scrolls the erroneous image of an item that was previously on. Sometimes it moves even between two prior images before displaying the right pair. These problems are happening because applications for network WebImageView queues upward because the visible element has been recycled once or even twice.

    What I need to solve this problem is to know when the WebImageView has been recycled by ListView in order to disconnect the network signals and erase the old image. I can't find how to do this.

    So I have a "fix" that is more than a workaround. In the WebImageView, I added a member variable:

    int m_iCurrentRequestIndex;

    Whenever WebImageView has applied for a network, I add m_iCurrentRequestIndex as an attribute of the QNetworkRequest and then increment.

    When I receive the response from the network, I check if the value of attraibute for example a_reply-> request (.attribute (...)) and throw the answer if it is not the last.

    Not a very good solution because it is always that which allows network support needless to proceed and just throw the results, but at least it works. But if anyone can answer the question in the original post, I who brand as the solution because it will allow for better efficiency. I want to know a signal or something available at WebImageView that is called when ListView is recycled as:

    WebImageView::onRecycled()
    {
        // close() and disconnect() current QNetworkRequest().
    }
    
  • ListView cannot see C++ object passed to QML via QmlDocument-> 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.

  • ListView will not display datamodel set of c ++

    I have a listview that retrieves a file from a web service json and it analyzes in a datamodel (tried GroupDataModel and QListDataModel). Thanks to some discussions that I found here, I managed to get the data in the data model and attach properly to the listview. which I checked through debugging.

    However; When I return to QML, I'm not able to get the data to display.

    My loots listview like that at the moment, but it's really just a lighter version of what I want, since I'm trying to make it work:

    ListView {
                                objectName: "list"
                                listItemComponents: [
                                    ListItemComponent {
                                        type: "item"
                                        Container {
                                            id: root
                                            WebImageView {
                                                url: ListItemData.image
                                            }
                                            Label {
                                                text: ListItemData.title
                                            }
                                        }
                                    }
                                ]
                            }
    

    Regarding my code, c ++, I use the Twitter example found here as my base:

    http://supportforums.BlackBerry.com/T5/Cascades-development/method-for-making-an-HTTP-style-request-...

    For reference, if I try to use QListDataModel, my cards will eventually look like this:

     QMap(("Description", QVariant(QString, "Description here") ) ( "image" ,  QVariant(QString, "https://image.com/image.jpg") ) ( "title" ,  QVariant(QString, "title") ) )
    

    As I said, I see the datamodel get associated with my list by list-> setDataModel (model); but it does not display anything. I'm sure it's something on the side QML that I'm hurting, but hopefully someone here can help.

    So, I realized my problem while working on another part of the application.

    Unlike the example of Twitter I've provided, I wasn't using a global variable for * root. I believe that when I started with this example, that part was giving me problems, so I used local variables. For this reason, my application created the root object in the initialization and the method of "GetTimeline".

    Once I did fixed it is global, the list filled.

    Thanks for your help on this everyone.

  • onTriggered retail Info (LISTVIEW)

    Hello

    Sorry to ask again

    I want to show the details of my promo

    It's my main QML

    NavigationPane {
               id : nav1
               onPopTransitionEnded: page.destroy()
            Page {
    
                Container {
                    Header{
                        title: "Promo"
                    } 
    
                    ListView {
                        id: listViewDemo
                        dataModel: GroupDataModel {
                            id : prm1
                            grouping: ItemGrouping.None
                        }
                        listItemComponents: [
                            ListItemComponent {
                                type: "promo"
                                Container {
                                    layout: StackLayout {
                                        orientation: LayoutOrientation.LeftToRight
                                    }
                                    WebView {
                                        preferredWidth: 150
                                        preferredHeight: 90
                                        verticalAlignment: VerticalAlignment.Top
                                        url : ListItemData["ImageLink"]
    
                                    }
                                    StandardListItem {
                                        title: ListItemData["promoID"] + "." + ListItemData["Title"]
                                        description: ListItemData["Description"]
                                        leftMargin: 30
                                        verticalAlignment: VerticalAlignment.Center  
    
                                        }
    
                                 }
                              }
                        ]  
    
                        function itemType(data, indexPath) {
                            return "promo";
                    }
    
                    onTriggered: {
                        if(indexPath!=0){
                            var promo = prm1.data(indexPath);
                            var promodetail = promocontent.createObject();
                            promodetail.promo = promo;
                            nav1.push(promocontent);
                        }
                    }
                    }
                    }
                 }
             }
    
                attachedObjects: [
                    DataSource {
                        id: serviceDataSource
                        source:                                  "http://www.rws.rajaspot.com/rs_promoclient.php"
                        type: DataSourceType.Json
                        onDataLoaded: {
                        listViewDemo.dataModel.insertList(data.promo_info)
                        }
                    },
                    ComponentDefinition {
                        id : promocontent
                        source : "PromoContent.qml"
                    }
                ]
    
                onCreationCompleted: {
                    serviceDataSource.load();
                }
    

    It's my promodetail

    Page {
        property variant promo;
        Container {
    
            id: container1
            verticalAlignment: VerticalAlignment.Center
            horizontalAlignment: HorizontalAlignment.Center
            topPadding: 50
            WebView {
    
                id : imageview
                horizontalAlignment: HorizontalAlignment.Center
                url: promo["ImageLink"]
                preferredWidth: 400
                preferredHeight: 400
            }
            Label {
    
                id:label1
                textStyle.base: SystemDefaults.TextStyles.BigText
                horizontalAlignment: HorizontalAlignment.Center
                text:promo["Title"]
            }
            Label {
                id:label2
                textStyle.base: SystemDefaults.TextStyles.SubtitleText
                horizontalAlignment: HorizontalAlignment.Center
                text:promo["Description"]
            }
        }
    }
    

    the following error message are

    url: promo["ImageLink"]
    
    text:promo["Title"]
    
    text:promo["Description"]
    

    He can't call my main.qml

    any suggestion?

    Thank you

    In some cases, your promo property can be "undefined" after you press page. Because it is not yet assigned. You can avoid this if you check the property on your page.
    For example:

    Page{
        property variant promo: null
    
        Container{
            layout: DockLayout{}
            leftPadding: 20
            rightPadding: 20
            topPadding: 20
    
            Label{
                id: label
                horizontalAligment: HorizontalAligment.Center
                /* In some cases will be the text empty. Because promo property is not yet assigned*/
                text: promo.Description
            }
        }
    }
    

    -------------------------------------------------
    See the simple example. You have two options to avoid ownership promo "undefined".
    1. replace the text property of the label with this
    text: promo? Promo. Description:
    2. signal property promo label definition
    onPromoChanged: if (promo) label.text = promo. Description

    My English is bad, so I hope you understand what I mean. Maybe someone who has good English can specify my 'answer '.

    EDIT:

    You can also find 'Data passing between the QML pages' for more information

  • QML ListView

    Hello people!

    I'm developing an application in which I use a ListView filled by an XML file (as for now), but I want to make entries bigger and maybe even a little cloroful. Found nothing about that.

    Any help?

    Wildcat

    ListView {
    
      listItemComponents: [
          ListItemComponent {
              type: "item"
    
              CustomListItem {
                  Label{
                      text: ListItemData.title
                  }
              }
          }
      ]
    }
    

    CustomListItem (or something like that), you should get what you want. Instead of the label, you can use container and put in as much as you want

  • ListView and the height of a CustomListItem

    I have created a ListView with a CustomListItem. The code looks like the following:

    ListView {
        dataModel: myDataModel
        listItemComponents: [
            ListItemComponent {
                type: "item"
                CustomListItem {
                     Container {
                        layout: StackLayout {}
                        TextArea {
                            text: ListItemData.data
                            multiline: true
                        }
                        TextArea {
                            text: ListItemData.data2
                            multiline: true
                        }
                    }
                }
            }
        ]
    }
    

    I came across this problem recently. I suggest to create a personalized yourself list item and do not use the CustomListItem class, I think it is buggy in that regard.

  • Mark the selected item in a listview

    Hello experts,

    So, I need to show a selected list item by placing a checkmark next to him (into the cell). What a cell can be selected. So does anyone have a solution that can be shared? Or some advise how this can be done properly. I would be very grateful.

    Hello everyone.

    I did the following. In onTriggered in a listview control, I've added these 2 lines:

    clearSelection();
    select(indexPath, true);
    

    That's all.

  • Strange behavior of ListView

    Hello
    I use following code:

     ListView {       id: listView listItemComponents: ListItemComponent {           Container {               id: listItemContainer               property string packageId: ListItemData.packageId               property variant packageDetailsPage               layout: AbsoluteLayout { }               WebImageView               {                   preferredHeight: 290                   preferredWidth: 751                   url: ListItemData.url;              }          }     }
    

    code for WebImageView:

    webimageview. HPP

    #ifndef WEBIMAGEVIEW_H_
    #define WEBIMAGEVIEW_H_
    
    #include 
    #include 
    #include 
    #include 
    using namespace bb::cascades;
    
    class WebImageView: public bb::cascades::ImageView {
        Q_OBJECT
        Q_PROPERTY (QUrl url READ url WRITE setUrl NOTIFY urlChanged)
        Q_PROPERTY (float loading READ loading NOTIFY loadingChanged)
    
    public:
        WebImageView();
        const QUrl& url() const;
        double loading() const;
    
        public Q_SLOTS:
        void setUrl(const QUrl& url);
        void clearCache();
    
        private Q_SLOTS:
        void imageLoaded();
        void dowloadProgressed(qint64,qint64);
    
        signals:
        void urlChanged();
        void loadingChanged();
    
    private:
        static QNetworkAccessManager * mNetManager;
        static QNetworkDiskCache * mNetworkDiskCache;
        QUrl mUrl;
        float mLoading;
    
        bool isARedirectedUrl(QNetworkReply *reply);
        void setURLToRedirectedUrl(QNetworkReply *reply);
    };
    
    #endif /* WEBIMAGEVIEW_H_ */
    

    webimageview.cpp

    #include "WebImageView.h"
    #include 
    #include 
    //#include 
    #include 
    
    using namespace bb::cascades;
    
    QNetworkAccessManager * WebImageView::mNetManager = new QNetworkAccessManager();
    //QNetworkDiskCache * WebImageView::mNetworkDiskCache = new QNetworkDiskCache();
    
    WebImageView::WebImageView() {
        // Initialize network cache
        //mNetworkDiskCache->setCacheDirectory(QDesktopServices::storageLocation(QDesktopServices::CacheLocation));
    
        // Set cache in manager
        //mNetManager->setCache(mNetworkDiskCache);
    
        // Set defaults
    
        mLoading = 0;
    }
    
    const QUrl& WebImageView::url() const {
        return mUrl;
    }
    
    void WebImageView::setUrl(const QUrl& url) {
        // Variables
    
            mUrl = url;
            mLoading = 0;
            qDebug()<<"url:: "<get(request);
    
            // Connect to signals
            QObject::connect(reply, SIGNAL(finished()), this, SLOT(imageLoaded()));
            QObject::connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(dowloadProgressed(qint64,qint64)));
    
            emit urlChanged();
    
    }
    
    double WebImageView::loading() const {
        return mLoading;
    }
    
    void WebImageView::imageLoaded() {
        // Get reply
        QNetworkReply * reply = qobject_cast(sender());
        QObject::disconnect(reply, SIGNAL(finished()), this, SLOT(imageLoaded()));
        QObject::disconnect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(dowloadProgressed(qint64,qint64)));
        if (reply->error() == QNetworkReply::NoError) {
            if (isARedirectedUrl(reply)) {
                setURLToRedirectedUrl(reply);
                return;
            } else {
                QByteArray imageData = reply->readAll();
                setImage(Image(imageData));
            }
        }
        // Memory management
        reply->deleteLater();
    }
    
    bool WebImageView::isARedirectedUrl(QNetworkReply *reply) {
        QUrl redirection = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
        return !redirection.isEmpty();
    }
    
    void WebImageView::setURLToRedirectedUrl(QNetworkReply *reply) {
        QUrl redirectionUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
        QUrl baseUrl = reply->url();
        QUrl resolvedUrl = baseUrl.resolved(redirectionUrl);
    
        setUrl(resolvedUrl.toString());
    }
    
    void WebImageView::clearCache() {
        //mNetworkDiskCache->clear();
    }
    
    void WebImageView::dowloadProgressed(qint64 bytes, qint64 total) {
        mLoading = double(bytes) / double(total);
    
        emit loadingChanged();
    }
    

    I use ListDataModel. and code above works fine and the loading of the images. But when there are more than 100 items in a list it shows the bad images in some WebImageView. When you scroll through random images change. I checked the url property of webImageView to the point where bad image is loaded, but there the right url.

    in this connection, blackberry says that view list follows MVC architecture, and QObject belonged to ListView objects are deleted when scrolling out of the area visible to the element to which they belong, or when the ListView itself is deleted. What is the cause of my problem? If not, this what's wrong with this code? Help, please...

    nik005 wrote:

    @ekke Yes. If I scroll slowly, it works fine.

    THX.

    Then, it's the same reason.

    as soon as I have a small reproducible application to create a problem, I'll add this thread and let you know

  • How to get the item to the index by the listview in qml programming

    Hi guys.

    I'm sorry my English not good level.

    At the point of selection Android listview to index easylly, I call ListView.selectionPosition (int index)

    But when you use ListView on cascades qml, I think point get in way to the index.

    Hope you help me.

    For a simple DataModel with a single level of items, you can access the item at a specific position with code of God:
    int position = 0
    var MonElement = myDataModel.data ([position])-requires one [of QVariantList]

  • ListView grid change to list dynamically

    Dear developers

    I have a listview that is represented by a grid. But I want a menuaction to change the schedule to the list and vice versa. But it seems more difficult, so I thought. My griditems are different then my listitems. For those who must change too.

    That's what I have so far but I'm stuck to be honest.

    import bb.cascades 1.0
    
    Container {
        property bool isGrid: true
    
        ListView {
            id: listView
            dataModel: channelListVM.otherDataModel
            horizontalAlignment: HorizontalAlignment.Fill
            layoutProperties: StackLayoutProperties {
                spaceQuota: 1.0
            }
            layout: isGrid ? gridLayout : stackLayout
            listItemComponents: [
                ListItemComponent {
                    type: "gridItem"
                    GridItem {
                        contextActions: ActionSet {
                            title: ListItemData.name
                            actions: [
                                ActionItem {
                                    title: qsTr("Favorite")
                                    imageSource: "asset:///img/bb_action_favorites.png"
                                    onTriggered: {
                                        ListItemData.favorite()
                                    }
                                }
                            ]
                        }
                    }
                },
                ListItemComponent {
                    type: "listItem"
                    MyListItem {
                        contextActions: ActionSet {
                            title: ListItemData.name
                            actions: [
                                ActionItem {
                                    title: qsTr("Favorite")
                                    imageSource: "asset:///img/bb_action_favorites.png"
                                    onTriggered: {
                                        ListItemData.favorite()
                                    }
                                }
                            ]
                        }
                    }
                }
            ]
    
            function itemType(data, indexPath) {
                if(isGrid) {
                    return "gridItem";
                }
    
                return "listItem";
            }
    
            attachedObjects: [
                StackListLayout {
                    id: stackLayout
                },
                GridListLayout {
                    id: gridLayout
                    columnCount: 3
                    horizontalCellSpacing: 10.0
                    verticalCellSpacing: 10.0
                    cellAspectRatio: 1
                }
            ]
        }
    }
    

    And when I change the isGrid true or false, it amends the provision but it seems that the UI is not updated. How can I fix without working with 2 ListViews and hide/show them about the property?

    Thanks in advance

    Since you're using the itemType function you do not require a change in your database. However, given that you match the layout of your choice of item type, you will need to notify the ListView that its cache is no longer valid. If ListView will not selection of the type of return until you load a new element in its cache.

    To do this, you just have your DataModel emit a signal after you change your property to isGrid. This is done via DataModel::itemsChanged. Since you want your entire list to rebuild, you want to give him the DataModelChangeType::Init.

    Code wise, you need to add this call:

    channelListVM.otherDataModel.itemsChanged(DataModelChangeType.Init)
    

Maybe you are looking for

  • PX1396E hangs after some time

    Hello I use a USB external PX1396E disk for Windows XP backup purposes. After a while, the reader goes down, meaning that it disappears from Windows Explorer and reappears only after that I have pass the power of training off and on again. I handed t

  • No access to bookmarks

    NONE of the statements in your files of information on access to the bookmarks will work for me... NONE of them and I've tried all. I want to go back to the previous version. How to do this. I appreciate your browser, but do not have the time to disa

  • How can I unlock an iPhone backup if I forgot the password

    How can I unlock an iPhone backup if I forgot the password encrypted

  • laptop on startup

    my laptop keeps rebooting at startup time and time again, I entered in safe mode and selected a date before the problem started, it was OK for a few days then it again alll above, please help

  • Entries calendar Outlook Z30 blackBerry will not synchronize to z30

    Why don't my Z30 takes all my Outlook events when I synchronize a way from computer to the device?