TableView
上,QML中的 QtQuick.Controls 1.4
确实很奇怪
在Windows中发生以下情况:
在Mac上:
它们为什么如此不同?我不明白我该如何使它们相同。
正如我们在Windows上看到的那样,scrollBar从表的顶部开始,但是在mac上,scrollBar从标题的下面开始。
下面我提供表格的代码:
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.3
import QtQuick.Controls.Styles 1.1
ApplicationWindow {
id: window
title: "Stack"
visible: true
width: 300
ListModel {
id: libraryModel
ListElement {
title: "A Masterpiece"
author: "Gabriel"
}
ListElement {
title: "Brilliance"
author: "Jens"
}
ListElement {
title: "Outstanding"
author: "Frederik"
}
ListElement {
title: "Outstanding"
author: "Frederik"
}
ListElement {
title: "Outstanding"
author: "Frederik"
}
ListElement {
title: "Outstanding"
author: "Frederik"
}
ListElement {
title: "Outstanding"
author: "Frederik"
}
ListElement {
title: "Outstanding"
author: "Frederik"
}
ListElement {
title: "Outstanding"
author: "Frederik"
}
ListElement {
title: "Outstanding"
author: "Frederik"
}
ListElement {
title: "Outstanding"
author: "Frederik"
}
ListElement {
title: "Outstanding"
author: "Frederik"
}
ListElement {
title: "Outstanding"
author: "Frederik"
}
}
Page {
id: page
anchors.fill: parent
TableView{
id:table
anchors{
//top:chooseColum.bottom
topMargin:10
left:parent.left
right:parent.right
bottom:parent.bottom
}
model: libraryModel
headerDelegate: Rectangle{
id:recHeader
width:styleData.width+20
height:30
color:"blue"
border.color: "black"
border.width: 1
Text {
anchors.fill:parent
//color:globals.text.textColor
text:styleData.value
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
}
itemDelegate: Rectangle {
border.color:"black"
border.width: 1
Text
{
text: styleData.value
elide: Text.ElideRight
}
}
TableViewColumn {
id: col1
role: "title"
title: "Title"
}
TableViewColumn {
role: "author"
title: "Authors of this tutorial"
}
}
}
}
目前,不能选择将QT更新到5.12。
答案 0 :(得分:0)
Qt Quick Controls 1.x应该为您的UI提供本机外观。我不知道macOS如何显示滚动条,但是如果它与Windows不同,那么Qt Quick Controls 1.x就是这种情况。
您有两种解决方案: