QT Quick TableView rowDelegate崩溃android

时间:2017-03-09 20:28:41

标签: android qt tableview qt-creator

我在这里是因为我有一个非常奇怪的错误,我正在使用QT,我正在尝试构建一个桌面和移动应用程序,现在用于Linux和Android Kitkat最低限度。

好吧,一切顺利,直到我将“rowDelegate”添加到我的TableView,在Linux上,完美的工作,在启动时与SIGSEV的Android崩溃。

可能我做错了什么,但我找不到我的错误。

这是“TableView”示例的一个版本,如果你为Android构建它,即使在模拟器中,应用程序也会在启动时崩溃。

cygwin

QT Creator在“应用程序输出”视图中显示的输出是

import QtQuick 2.2
import QtQuick.Layouts 1.1
import QtQuick.Controls 1.2
import org.qtproject.example 1.0

ApplicationWindow {
    id: window
    visible: true
    title: "Table View Example"

    toolBar: ToolBar {
        TextField {
            id: searchBox

            placeholderText: "Search..."
            inputMethodHints: Qt.ImhNoPredictiveText

            width: window.width / 5 * 2
            anchors.right: parent.right
            anchors.verticalCenter: parent.verticalCenter
        }
    }

    TableView {
        id: tableView

        frameVisible: false
        sortIndicatorVisible: true

        anchors.fill: parent

        Layout.minimumWidth: 400
        Layout.minimumHeight: 240
        Layout.preferredWidth: 600
        Layout.preferredHeight: 400

        rowDelegate: Rectangle{
            color: "blue"
        }

        TableViewColumn {
            id: titleColumn
            title: "Title"
            role: "title"
            movable: false
            resizable: false
            width: tableView.viewport.width - authorColumn.width
        }

        TableViewColumn {
            id: authorColumn
            title: "Author"
            role: "author"
            movable: false
            resizable: false
            width: tableView.viewport.width / 3
        }

        model: SortFilterProxyModel {
            id: proxyModel
            source: sourceModel.count > 0 ? sourceModel : null

            sortOrder: tableView.sortIndicatorOrder
            sortCaseSensitivity: Qt.CaseInsensitive
            sortRole: sourceModel.count > 0 ? tableView.getColumn(tableView.sortIndicatorColumn).role : ""

            filterString: "*" + searchBox.text + "*"
            filterSyntax: SortFilterProxyModel.Wildcard
            filterCaseSensitivity: Qt.CaseInsensitive
        }

        ListModel {
            id: sourceModel

            ListElement {
                title: "Test"
                author: "<div><b><table><tr><th>1</th><th>2</th><th>3</th><th>4</th><th bgcolor='#00ff00'>5</th><th>6</th><th>7</th></tr></table></b></div>"
            }
            ListElement {
                title: "Moby-Dick"
                author: "Herman Melville"
            }
            ListElement {
                title: "The Adventures of Tom Sawyer"
                author: "Mark Twain"
            }
            ListElement {
                title: "Cat’s Cradle"
                author: "Kurt Vonnegut"
            }
            ListElement {
                title: "Farenheit 451"
                author: "Ray Bradbury"
            }
            ListElement {
                title: "It"
                author: "Stephen King"
            }
            ListElement {
                title: "On the Road"
                author: "Jack Kerouac"
            }
            ListElement {
                title: "Of Mice and Men"
                author: "John Steinbeck"
            }
            ListElement {
                title: "Do Androids Dream of Electric Sheep?"
                author: "Philip K. Dick"
            }
            ListElement {
                title: "Uncle Tom’s Cabin"
                author: "Harriet Beecher Stowe"
            }
            ListElement {
                title: "The Call of the Wild"
                author: "Jack London"
            }
            ListElement {
                title: "The Old Man and the Sea"
                author: "Ernest Hemingway"
            }
            ListElement {
                title: "A Streetcar Named Desire"
                author: "Tennessee Williams"
            }
            ListElement {
                title: "Catch-22"
                author: "Joseph Heller"
            }
            ListElement {
                title: "One Flew Over the Cuckoo’s Nest"
                author: "Ken Kesey"
            }
            ListElement {
                title: "The Murders in the Rue Morgue"
                author: "Edgar Allan Poe"
            }
            ListElement {
                title: "Breakfast at Tiffany’s"
                author: "Truman Capote"
            }
            ListElement {
                title: "Death of a Salesman"
                author: "Arthur Miller"
            }
            ListElement {
                title: "Post Office"
                author: "Charles Bukowski"
            }
            ListElement {
                title: "Herbert West—Reanimator"
                author: "H. P. Lovecraft"
            }
        }
    }
}

拜托,我真的需要帮助。 先感谢您 最好的祝福 Trungus

1 个答案:

答案 0 :(得分:0)

我遇到了完全相同的问题。尽管你的帖子已经有一段时间了,但我在这里看不到解决方案。我使用qt5.7并导入QtQuick 2.4并导入QtQuick.Controls 1.4。我发现为崩溃周围的委托组件添加了一个显式高度。一定是个臭虫!

rowDelegate: 
    Rectangle {
        height: 30
        color: "blue" 
    }