【问题标题】:QML ListView : "complex" delegate causes crashQML ListView:“复杂”委托导致崩溃
【发布时间】:2014-01-14 09:43:12
【问题描述】:

我的应用程序出现问题我在网上搜索了一些(甚至是远程)类似的东西,发现了这个:Remove rows from QAbstractListModel (答案中提供的代码)-效果很好!但是当我将ListView 委托更改为更“复杂”的东西时,就像这样:

Component {
        id: commonDelegate
        Rectangle {
            width: view.width
            implicitHeight: editor.implicitHeight + 10
            color: "transparent"
            border.color: "red"
            border.width: 2
            radius: 5
            TextInput {
                id: editor
                anchors.margins: 1.5 * parent.border.width
                anchors.left: parent.left
                text: edit.name // "edit" role of the model, to break the binding loop
                onTextChanged: {
                    display.name = text;
                    model.display = display
                }
            }

            ComboBox {
                id: siema
                anchors.left: editor.right
                model: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "+"]
            }

            Button {
                id: bt
                text: "Guizk"
                anchors.left: siema.right
                anchors.right: parent.right
            }

        }
    }

然后应用程序在添加一些行(足以填满整个屏幕,因此其中一些不可见)并尝试滚动到那些不可见的行后崩溃。使用调试器运行时,报告的错误为EXC_BAD_ACCESS,并且在 Creator 中显示了函数 QCoreApplication::proccessEvents 的反汇编。

委托的“复杂程度”是否有限制?或者有没有更好(更有效)的方法来做到这一点,这样它就不会崩溃?

崩溃发生在 Windows 7 64bit、OsX 10.8.5 和 Android 4.1 上

如果您需要更多信息,请告诉我。

【问题讨论】:

  • 您能否显示完整的回溯并提供SSCCE

标签: qt qml


【解决方案1】:

我有同样的问题,经过反复试验,我发现 Combobox 对崩溃负责。

如果你可以没有它,尽量不要使用它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    • 2019-12-22
    • 2017-01-21
    • 2015-12-03
    相关资源
    最近更新 更多