Quantcast
Channel: Active questions tagged qtquick2 - Stack Overflow
Viewing all articles
Browse latest Browse all 137

How to set background color of HorizontalHeaderView Qt QML Quick Controls 2 (Qt6.5)

$
0
0

How is the background color of a HorizontalHeaderView within a TableView to be set?

My goal is a table where the heading has a dark background, and a bright text color.

possible layout: image

I neither managed to get it via palette, nor via a background property.

The only way I've seen was with a stack of colored rects behind the delegates, while there the size never matched the table size.And if I simply put a rect behind the header delegates, the top bar never becomes solid because of the columnSpacing.

import QtQuick 2.15import QtQuick.Controls 2.15import Qt.labs.qmlmodels 1.0...    TableView {        id: myTable        anchors { fill: parent; topMargin: horizontalHeader.height }        columnSpacing: 4; rowSpacing: 4        implicitHeight: parent.height        implicitWidth: parent.width        model: SuperCarModel {}        ...    }        HorizontalHeaderView {        id: horizontalHeader        syncView: myTable        anchors.left: myTable.left        anchors.top: myTable.top        clip: true        delegate: Item {            implicitHeight: delegateLabel.implicitHeight            implicitWidth: delegateLabel.implicitWidth            Label {                id: delegateLabel                text: model.display                font.bold: true                color: palette.buttonText                padding: 4                leftPadding: 4            }            Rectangle {                anchors.left: delegateLabel.left                anchors.top: delegateLabel.top                anchors.bottom: delegateLabel.bottom                color: "#aaa"                z: delegateLabel.z - 1            }        }

Would expect a background property in the headerView or perhaps a palette entry like

palette.background: "black"

Viewing all articles
Browse latest Browse all 137

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>