×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    11

    Huge lag with QAbstractListModel and QML ListView with Symbian components

    Hello!

    I'm getting huge lag when scrolling the ListView element, which uses a QAbstractListModel as it's model and a delegate, which is based on the ListItem Symbian Qt Quick component.

    Everything works fine in the simulator, no noticeable lag there. The model I'm using is based on this article here.

    The lag appears every time a new item in the list is scrolled to the screen (when an item is loaded?) when I use the application on my phone (N8).

    Is there any way to fix this? It's weird that such a simple case causes this much trouble, the app is basically unusable in it's current state. The documentation has been of no help.

    -Vesa

    Here's the QML code for the delegate:

    Code:
    import QtQuick 1.0
    import com.nokia.symbian 1.0
    
    ListItem {
        id: listItem
        subItemIndicator: true
    
        Column {
            id: column
            anchors.fill: listItem.padding
            ListItemText {
                id: titleText
                mode: listItem.mode
                role: "Title"
                text: task
            }
            ListItemText {
                id: subtitleText
                mode: listItem.mode
                role: "SubTitle"
                text: date
            }
        }
    
        onClicked: dialog.open()
        onPressAndHold: dialog_delete.open()
        QueryDialog {
            id: dialog
            titleText: "Task: " + task
            message: "Completed in <b>" + time + "</b> minutes<br>Date: <b>" + date + "</b>"
            acceptButtonText: "Ok"
        }
    
        QueryDialog {
            id: dialog_delete
            titleText: "Remove task?"
            message: "Do you want to remove the task <b>" + task + "</b> from the log?"
            acceptButtonText: "Yes"
            rejectButtonText: "No"
            onAccepted: logBook.removeRow(index)
        }
    }

  2. #2
    Registered User
    Join Date
    Oct 2011
    Posts
    11

    Re: Huge lag with QAbstractListModel and QML ListView with Symbian components

    Ok so the bottleneck really seems to be located somewhere between the QAbstractListModel and the ListView: apparently the model is slow on providing items to the view and the whole GUI freezes when an item is being loaded. I created a ListView and populated it with 60 items in the QML file (ListModel filled with 60 ListElements) and it works really well, ~60FPS on my N8.

    Now the question is probably this: is there a way to preload the items in the QAbstractListModel into the ListView?

  3. #3
    Regular Contributor
    Join Date
    Oct 2008
    Location
    Oslo, Norway
    Posts
    329

    Re: Huge lag with QAbstractListModel and QML ListView with Symbian components

    Check the performance tips on http://doc.qt.nokia.com/4.7-snapshot...view-delegates

    Do you have lag even when you remove the click/clickAndHold functionality from the delegate?

    You can also try to play with ListView's cacheBuffer property, see if that helps.

  4. #4
    Registered User
    Join Date
    Oct 2011
    Posts
    11

    Re: Huge lag with QAbstractListModel and QML ListView with Symbian components

    Quote Originally Posted by treinio View Post
    Check the performance tips on http://doc.qt.nokia.com/4.7-snapshot...view-delegates

    Do you have lag even when you remove the click/clickAndHold functionality from the delegate?

    You can also try to play with ListView's cacheBuffer property, see if that helps.
    I've checked the perfomance tips, but that's the weird thing. I don't think my code is in any way bloated (the QML is in the first message) and should be fast, it works great on the simulator.

    There's no lag whatsoever when clicking/clickAndHolding or if I scroll back and forward so that no new items appear on the screen (so if there's 9 items on the screen, the same 9 stay on the screen, only the highest and lowest items go a bit out of view but never completely out of sight). The lag appears only when new items are loaded.

    I haven't found the cacheBuffer too helpful, as the only thing it did made the application throw an "out of memory" error on my phone.

    What I'm going to try next is probably this:
    * I create a ListModel QML item
    * I fill it with items from the QAbstractListModel with some kind of javascript (listModel.append(abstractListModel.get(i) or something similiar, I have to look into it)

    As the ListView with a purely QML ListModel worked really great, I believe that this should work well. The only problem is the javascript part, I hope that theres support for this type of operations.

    I'll check back again if I get this thing to work!

    Thanks,
    - Vesa

  5. #5
    Registered User
    Join Date
    Oct 2011
    Posts
    11

    Re: Huge lag with QAbstractListModel and QML ListView with Symbian components

    Ok so my QML delegate was too bloated afteral!

    I tried to make a QML ListModel and fill it with the content from the QAbstractListModel, but it was as slow as before. Atleast I learned that it was possible.

    So this is how my ListView looks like now:
    Code:
                ListView {
                    id: taskList
    
                    highlightFollowsCurrentItem: false
                    clip: true
                    anchors {
                        top: graphImage.bottom
                        topMargin: 5
                        left: parent.left
                        right: parent.right
                        bottom: parent.bottom
                        bottomMargin: 15
                    }
    
                    model: logBook
                    delegate: LogDelegate{}
    
                    Connections {
                        target: taskList.currentItem
                        onPressAndHold: {
                            dialog_delete.open();
                        }
                        onClicked: {
                            dialog_info.open();
                        }
                    }
    
                    QueryDialog {
                        id: dialog_info
                        titleText: "Task: " + taskList.currentItem.itemTask
                        message: "Completed in <b>" + taskList.currentItem.itemTime + "</b> minutes<br>Date: <b>" + taskList.currentItem.itemDate + "</b>"
                        acceptButtonText: "Ok"
                    }
    
                    QueryDialog {
                        id: dialog_delete
                        titleText: "Remove task?"
                        message: "Do you want to remove the task <b>" + taskList.currentItem.itemTask + "</b> from the log?"
                        acceptButtonText: "Yes"
                        rejectButtonText: "No"
                        onAccepted: logBook.removeLogData(taskList.currentIndex)
                    }
                }
            }
    And my delegate:
    Code:
    import QtQuick 1.0
    import com.nokia.symbian 1.0
    
    ListItem {
        id: listItem
        subItemIndicator: true
    
        property string itemTask: task
        property string itemDate: date
        property int    itemTime: time
        Column {
            id: column
            anchors.fill: listItem.padding
            ListItemText {
                id: titleText
                mode: listItem.mode
                role: "Title"
                text: itemTask
            }
            ListItemText {
                id: subtitleText
                mode: listItem.mode
                role: "SubTitle"
                text: itemDate
            }
        }
    }
    So what I did was move the QueryDialog out from the delegate and connect the items' signals with a Connections element.

    A lesson learned! I have been strugling with this for hours and hours, nice to get the thing working!
    Last edited by weeezes; 2011-11-06 at 11:09. Reason: Additional info of what I did

  6. #6
    Regular Contributor
    Join Date
    Oct 2008
    Location
    Oslo, Norway
    Posts
    329

    Re: Huge lag with QAbstractListModel and QML ListView with Symbian components

    Quote Originally Posted by weeezes View Post
    So what I did was move the QueryDialog out from the delegate and connect the items' signals with a Connections element.
    Yes, that's what I meant by 'removing functionality', i.e. remove the dialogs from the delegate - sorry about being so obscure. Your solution with the Connections element in the ListView looks OK.

  7. #7
    Registered User
    Join Date
    Oct 2011
    Posts
    11

    Re: Huge lag with QAbstractListModel and QML ListView with Symbian components

    Yes, your comment lead me to check the thing once more . Thank you for your help!

    It seems like the just released 1.1 components in the 1.1.4 SDK makes the ListView even faster according to this blog post, so that's very nice!

    My application is finally ready, looking forward to getting it into Nokia Store soon (free, of course) .

    PS. is there a way to mark a thread solved?

Similar Threads

  1. ListView inside ListView
    By hassan kassem in forum [Archived] Qt Quick
    Replies: 2
    Last Post: 2011-10-20, 10:53
  2. Symbian: Qt Components 1.1
    By pixsta in forum [Archived] Qt Quick
    Replies: 1
    Last Post: 2011-10-08, 18:54
  3. Replies: 0
    Last Post: 2011-07-07, 11:13
  4. How to use QAbstractListModel in pathview element of qml
    By sk.panda in forum [Archived] Qt Quick
    Replies: 1
    Last Post: 2011-05-30, 06:52
  5. Replies: 3
    Last Post: 2010-04-22, 12:33

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •