css - 如何在标题中绘制正确的 CSS 边框?

标签 css qt qt-designer

在图片上表示的对话框窗口只有一个小部件类 QTableWidget。我的问题是页眉的底部 边框(红色方 block ,QHeaderView 类)与左/右彩色边框重叠!我想要的是使红色方 block 部分正确显示为绿色方 block 。

enter image description here

这是我正在使用的来自 Qt Designer 的 CSS 代码:

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);
}
*/

谢谢!


更新:这是放大的图片,以防万一......

enter image description here

最佳答案

我已经了解了这些东西是如何工作的!

解决方案:

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

谢谢大家!

关于css - 如何在标题中绘制正确的 CSS 边框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10024525/

相关文章:

CSS 选择器性能

c++ - 将打开的窗口实例作为参数传递给第二个窗口

qt - QtDesigner 中的重叠小部件

python - 为什么 lineEdit 显示这样?

jquery - bootstrap 旋转木马 100% 宽度

javascript - 让二级子菜单与主导航齐平

html - html 源中的 CSS-sprites 替代方案

mysql - 使用 Windows XP、Qt Creator 4.5.2(windows 32 位)的 QT MySql 连接

Qt :How to make hyperlink to exe file

c++ - Qt 自定义小部件插件 Q_Property With Enum