2016-01-22 40 views
2

我在Qt應用程序中有一個選項卡窗口小部件,我用CSS爲自己設計了它。Qt:Hower效果與選定的選項卡重疊

這是它的樣子:

The selected tab, 2. the hovered hab, 3. the inactive (unselected) tab

1.所選擇的選項卡,2.懸停的選項卡,3.不活動的(未選擇的)選項卡

但是,當我懸停在已經選擇的選項卡上(在本例中爲「創建測驗」),它將被替換爲懸停效果(我忘記使用黑色字體顏色),我不希望用戶可以將鼠標懸停在選定的選項卡上。即使您將鼠標懸停在其上,「創建測驗」也應保持綠色。但我也不想扔掉懸停效果,因爲它很有用。

Hover effect is replacing the selected tab effect

CSS:

QTabBar::tab{ 
background-color: rgba(255, 255, 255, 94); 
border-top-left-radius: 4px; 
border-top-right-radius: 4px; 
min-width: 8px; 
padding: 10px; 
margin-left: 3px; 
margin-top: 4px; 
margin-bottom: 2px;} 


QTabBar::tab:selected { 
    color: rgb(255, 255, 255); 
    background-color: rgb(11, 154, 111); 
} 

QTabBar::tab:hover { 
    background-color: rgba(204, 204, 204, 178); 
} 

有什麼建議?

回答

2

只需增加一個部分:

QTabBar::tab:selected:hover { 
    color: rgb(255, 255, 255); 
    background-color: rgb(11, 154, 111); 
} 

然後selcted +懸停將有綠色的了。 (或者你可以自定義)

相關問題