Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 3 Support (Qt 5) › 2.15.1 strange crash during ListModel.append

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #18578

    Marek

    Hi

    I have an app which worked fine and after last update it is crashing, tested on Mac, iOS Simulator, Linux

    I have narrowed the problem to ListModel which is updated in Component.onCompleted

    Code is below, it crashed when I change Page1 to Page2 and it is fine when I comment out hourModel.append(data)

    //Main.qml
    import Felgo 3.0
    import QtQuick 2.4
    
    App {
        // You get free licenseKeys from https://felgo.com/licenseKey
        // With a licenseKey you can:
        //  * Publish your games & apps for the app stores
        //  * Remove the Felgo Splash Screen or set a custom one (available with the Pro Licenses)
        //  * Add plugins to monetize, analyze & improve your apps (available with the Pro Licenses)
        //licenseKey: "<generate one from https://felgo.com/licenseKey>"
    
        Navigation {
            id:mainNavigation
            anchors.fill: parent
            visible: true
            navigationMode: navigationModeDrawer
    
            NavigationItem {
                id:homeNaviItem
                title: "Page1"
                icon: IconType.home
                NavigationStack {
                    id: progNaviStack
    
                    Page {
                        id: prog1Page
                        title: "page1"
    
                    }
                }
            }
            NavigationItem {
                id:sectionNaviItem
                title: "Page2"
                icon: IconType.home
                NavigationStack {
                    id: sectionNaviStack
    
                    Page {
                        id:page
                        Rectangle {
                            id:innerRect
                            height: parent.height*0.7
                            width:parent.width
                            anchors.horizontalCenter: parent.horizontalCenter
                            anchors.verticalCenter: parent.verticalCenter
    
                            ListModel {
                                id: hourModel
                            }
    
                            CustomTumbler {
                                id:hourTumbler
                                anchors.left: parent.left
                                anchors.top:parent.top
                                anchors.bottom: parent.bottom
                                model: hourModel
                                width:parent.width/2
                            }
                            Component.onCompleted: {
                                for(var i=0;i<24;i++) {
                                    var data = {'value': (i<10 ? "0"+i : ""+i)};
                                    hourModel.append(data);
                                }
                            }
                        }
                    }
                }
            }
    
        }
    }
    
    
    //CustomTumbler.qml
    import QtQuick 2.9
    import QtQuick.Controls 2.2
    import Felgo 3.0
    
    Tumbler {
        id: customTumbler
        implicitWidth: textItem.implicitWidth + leftPadding + rightPadding
        implicitHeight: dp(100)
    
        // hidden text for width calculation
        AppText {
            id: textItem
            visible: false
            text: processDelegateText ? processDelegateText(0) : 0
        }
    
        // styling
        delegate: AppText {
            text: processDelegateText ? processDelegateText(modelData) : modelData
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
            color: "white"// blendColor("red", "white", 1 - Math.abs(Tumbler.displacement) / (visibleItemCount / 3))
            opacity: 1.0 - Math.abs(Tumbler.displacement) / (visibleItemCount / 2)
    
            function blendColor(col1, col2, mix) {
                var r = col1.r * (mix) + col2.r * (1 - mix)
                var g = col1.g * (mix) + col2.g * (1 - mix)
                var b = col1.b * (mix) + col2.b * (1 - mix)
                return Qt.rgba(r, g, b, 1)
            }
        }
    }
    

    Best Regards

    Marek

    #18581

    Günther
    Felgo Team

    Hi Marek,

    yes, it seems there’s a problem with Qt ListModel + Tumbler in this use-case with append(). However, I found that an array-based model works just fine:

    Page {
                        id:page
                        Rectangle {
                            id:innerRect
                            height: parent.height*0.7
                            width:parent.width
                            anchors.horizontalCenter: parent.horizontalCenter
                            anchors.verticalCenter: parent.verticalCenter
    
                            property var hourModel: []
    
                            CustomTumbler {
                                id:hourTumbler
                                anchors.left: parent.left
                                anchors.top:parent.top
                                anchors.bottom: parent.bottom
                                model: parent.hourModel
                                width:parent.width/2
                            }
    
                            Component.onCompleted: {
                                for(var i=1;i<24;i++) {
                                  hourModel.push((i<10) ? "0"+1 : ""+i)
                                }
                                hourTumbler.modelChanged()
                            }
                        }
                    }

    Best,
    Günther

    #18582

    Marek

    Thanks it works for me.

    Best Regards

    Marek

Viewing 3 posts - 1 through 3 (of 3 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded