Qt工作笔记-QSS中关于QCombox的设置
生活随笔
收集整理的這篇文章主要介紹了
Qt工作笔记-QSS中关于QCombox的设置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
QSS源碼如下:
QComboBox { border: 1px solid rgb(0, 0, 0); border-radius: 3px; padding: 1px 18px 1px 3px; min-width: 6px; background-color: rgb(0, 195, 255); color: rgb(255, 255, 255); font: 14pt "華文琥珀"; }運行截圖如下:
注意:這里font的大小會影響padding的屬性(在QSS里面,很多屬性會互相影響,這是要注意的)
?
修改向下的那個箭頭,和修改箭頭旁邊領域中的樣式:
QComboBox::drop-down { subcontrol-origin: padding; subcontrol-position: top right; width: 16px; border-left-width: 1px; border-left-color: darkgray; border-left-style: solid; border-top-right-radius: 3px; border-bottom-right-radius: 3px; }QComboBox::down-arrow { image: url(:/img/arrows_down.png); }程序運行截圖如下:
?
設置下拉選項框里面。選項框里面的屬性,源碼如下:
QComboBox QAbstractItemView { border: 1px solid rgb(161,161,161); }QComboBox QAbstractItemView::item { height: 24px; color: rgb(255, 255, 255); background-color: rgb(0, 195, 255); }QComboBox QAbstractItemView::item:selected { background-color:rgb(22, 37, 124); }
運行截圖如下:
這里要注意:
QComboBox并沒有專門設置內部Item的QSS,要使用這樣的代碼:
QStyledItemDelegate* itemDelegate = new QStyledItemDelegate();ui->comboBox->setItemDelegate(itemDelegate);今晚將會對QStyledItemDelegate進行補充
總結
以上是生活随笔為你收集整理的Qt工作笔记-QSS中关于QCombox的设置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C++ STL vector的容量
- 下一篇: Qt文档阅读笔记-Q_ASSERT的另外