我試圖在QT5中設計一個組合框。我正在使用QT Creator進行佈局,並在啓動時加載應用程序範圍的樣式表。QComboBox文本顏色不會隨樣式表變化
我已經與我的組合框的CSS如下:
QComboBox
{
color:white;
background-color: qlineargradient(x1:0, y1:0, x2:1,y2:1, stop: 1 rgba(228, 41, 81, 100), stop: 0 rgba(234, 107, 101, 100));
border-color: rgba(255,255,255,200);
border-width: 1px;
border-style: solid;
}
QComboBox QListView
{
border-style: none;
background-color: qlineargradient(x1:0, y1:0, x2:1,y2:0, stop: 1 rgba(228, 41, 81, 100), stop: 0 rgba(234, 107, 101, 100));
}
QComboBox::drop-down
{
width: 20px;
border: 1px;
border-color:white;
border-left-style:solid;
border-top-style: none;
border-bottom-style: none;
border-right-style: none;
}
QComboBox::down-arrow
{
image: url(:/ArrowImages/images/whitearrowdown16.png);
width: 16px;
height: 16px;
}
但在組合框中remainds作爲默認的(黑)顏色的文本顏色。下拉的顏色是白色的。邊框顏色和樣式都可以正常使用。組合框上的標籤是我需要單獨設計的某種子控件嗎?還是我錯過了別的?
謝謝。
編輯:
新增截圖清晰度
編輯2: 它看起來像這樣僅在組合框設置爲不可編輯(這是發生對我的程序來說是正確的行爲,所以並沒有真正幫助我。)當組合框設置爲可編輯時,它正確地服從樣式。我試過添加
QCombobox:!editable
{
color:white;
}
但它不能解決問題。
如果你從一個文件中加載樣式表,你可能會在你的應用程序中加載另一個樣式表來覆蓋該特定樣式?你可以嘗試使用'QComboBox#YOUR_SPECIFIC_COMBO_BOX_NAME {color:white; }' – TWE