2012-04-05 44 views
2

只有一個窗口小部件類QTableWidget的圖片表示對話框窗口。我的問題是,底部標題的邊框(紅色正方形,QHeaderView類)與左/右彩色邊框重疊!我想要的是讓紅色正方形部分正確地顯示爲綠色正方形。如何在標題中繪製正確的CSS邊框?

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

+0

看起來像一個Qt錯誤 – pnezis 2012-04-05 10:19:31

+0

@webclectic不,我在下面發佈解決方案。 Thnks! – mosg 2012-04-05 10:42:51

回答

6

我明白這東西是如何工作的!

解決方案

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

不管怎樣,謝謝大家!

+0

你好,你能接受你自己的答案嗎?這工作得很好,我認爲這對至少6人有幫助;-)。 – IAmInPLS 2017-11-10 13:14:11

+0

@IAmInPLS享受:) – mosg 2017-11-13 12:45:12