Qt之介面實現技巧

2021-08-06 04:57:51 字數 2783 閱讀 6215

qstring strqss = 「qprogressbar \

qprogressbar:horizontal \

qprogressbar::chunk:horizontal 」;

等待還原的時候使用。

三、qss樣式

1.qcombobox

combobox->setstylesheet(「qcombobox」

「qcombobox qabstractitemview::item」

「qcombobox::down-arrow」

「qcombobox::drop-down」);

combobox->setview(new qlistview());

包括設定下拉箭頭、下拉選項高度等。

2.qspinbox

pspinbox->setstylesheet(「qspinbox」

「qspinbox::up-button」

「qspinbox::down-button」);

3.qmenu

qmenu

qmenu::item

qmenu::item:selected:enabled

qmenu::item:selected:!enabled

qmenu::separator

4.qslider

qslider::groove:horizontal

qslider::sub-page:horizontal

qslider::add-page:horizontal

qslider::handle:horizontal

5.qcheckbox

qcheckbox

qcheckbox::indicator

qcheckbox::indicator:unchecked

qcheckbox::indicator:unchecked:hover

qcheckbox::indicator:unchecked:pressed

6.qscrollbar

水平滾動條

qscrollbar:horizontal

qscrollbar::handle:horizontal

qscrollbar::handle:horizontal:hover

qscrollbar::sub-line:horizontal

qscrollbar::add-line:horizontal

qscrollbar::sub-line:horizontal:hover

qscrollbar::add-line:horizontal:hover

qscrollbar::add-page:horizontal,qscrollbar::sub-page:horizontal

垂直滾動條

qscrollbar:vertical

qscrollbar::handle:vertical

qscrollbar::handle:vertical:hover

qscrollbar::sub-line:vertical

qscrollbar::add-line:vertical

qscrollbar::sub-line:vertical:hover

qscrollbar::add-line:vertical:hover

qscrollbar::add-page:vertical,qscrollbar::sub-page:vertical

qcheckbox::indicator:checked

qcheckbox::indicator:checked:hover

qcheckbox::indicator:checked:pressed

7.qstatusbar

qstatusbar::item

//不存在分隔線

8.qcombobox

qcombobox

qcombobox:hover

qcombobox:pressed

qcombobox::down-arrow

qcombobox::drop-down

qcombobox qabstractitemview

qcombobox qabstractitemview::item

qcombobox qabstractitemview::item:selected

一般也可以使用qpalette

qpalette palette;

palette.setbrush(qpalette::windowtext, qbrush(qt::white));

pcheckbox->setpalette(palette);

pcheckbox->setstylesheet(「color:white」);

調色盤類qpalette提供了顏色(color roles) 的概念,指當前介面中顏色的職責,通過列舉變數qpalette::colorrole來定義,比較常用的角色有:

qpalette::window 通常指視窗部件背景色

qpalette::windowtext 通常指視窗部件的前景色

qpalette::base 指文字的背景色(qtextedit、qlineedit等)

qpalette::text 與qpalette::base一塊使用,指文字輸入視窗部件前景色

qpalette::button 指按鈕視窗部件的背景色

qpalette::buttontext 指按鈕視窗部件的前景色

文章引用:

Qt之介面實現技巧

qstring strqss qprogressbar qprogressbar horizontal qprogressbar chunk horizontal 等待還原的時候使用。三 qss樣式 1.qcombobox combobox setstylesheet qcombobox qcomb...

Qt之介面換膚

首先,新建兩個 按需新增 字尾名為qss的檔案,例如 black.qss white.qss,將它們加入資源檔案 qrc 中。分別在 black.qss white.qss 檔案中編寫自己的樣式 例如 black.qss 提示 qtooltip white.qss 提示 qtooltip qss 請...

QT常用實用的介面設計技巧

qstring strqss qprogressbar qprogressbar horizontal qprogressbar chunk horizontal 等待還原的時候使用。三 qss樣式 1.qcombobox combobox setstylesheet qcombobox qcomb...