Как сделать так, чтобы полоса прокрутки таблицы выглядела одинаково как в Windows, так и в Mac - PullRequest
0 голосов
/ 17 мая 2019

TableView в QML действительно странно, на мой взгляд, по крайней мере, на QtQuick.Controls 1.4

В Windows происходит следующее:

enter image description here

на mac:

enter image description here

Почему они такие разные? Я не понимаю Как я могу сделать их такими же.

Как мы видим в окнах, scrollBar начинается в верхней части таблицы, а в Mac - под заголовком.

Ниже приведен код таблицы:

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.

1 Ответ

1 голос
/ 18 мая 2019

Qt Quick Controls 1.x должны обеспечивать естественный вид вашего интерфейса.Я не знаю, как macOS отображает полосы прокрутки, но если она отличается от Windows, то это относится к Qt Quick Controls 1.x.

У вас есть два решения для этого:

  1. Рассмотрите возможность перехода на Qt Quick Controls 2.x, но они не обрабатывают собственные L & F.
  2. Настройте полосы прокрутки: https://doc.qt.io/qt-5/qtquick-controls-styles-qmlmodule.html
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...