如何使用样式表绘制正确的标题视图边框

问题描述 投票:0回答:1

在图片表示的对话框窗口中只有一个小部件类

QTableWidget
。我的问题是标题的bottom边框(红色方块,
QHeaderView
类)与左/右彩色边框重叠!我想要的是使红色方块部分正确显示为绿色方块。

enter image description here

放大图片:

enter image description here

这是我正在使用的 Qt Designer 的 QSS 代码:

QTableView#tableWidget QHeaderView::section:horizontal
{
    height: 24px;

    border-style: none;

    border-left: 1px solid #ecedef;
    border-top: 1px solid #161618;
    border-right: 1px solid #b1b1b5;
    border-bottom: 1px solid #161618;

    background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #f4f4f6, stop:1 #ceced6);
 }

/*
QTableView#tableWidget QHeaderView::section:horizontal:first,
QTableView#tableWidget QHeaderView::section:horizontal:last
{
    border-left-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #f4f4f6, stop:1 #ceced6);
}
*/
qt qtableview qtstylesheets qtwidgets qheaderview
1个回答
9
投票
QTableView#tableWidget QHeaderView
{
    /* draw the hole hor top & bottom line for the header */
    height: 24px;

    border-top: 1px solid #161618;
    border-bottom: 1px solid #161618;
}

QTableView#tableWidget QHeaderView::section:horizontal:first
{
    border-left-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #f4f4f6, stop:1 #ceced6);
}

QTableView#tableWidget QHeaderView::section:horizontal:last
{
    border-right-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #f4f4f6, stop:1 #ceced6);
}

QTableView#tableWidget QHeaderView::section:horizontal
{
    /* for each section draw ONLY left & right lines */
    height: 24px;

    border-style: none;

    border-left: 1px solid #ecedef;
    border-right: 1px solid #b1b1b5;

    background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #f4f4f6, stop:1 #ceced6);
}

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.