最近在測試Qt5樣式的使用方法。
用QApplication_setStyleSheet設(shè)置想要的樣式(我也只會簡單的)
procedure TForm1.Button2Click(Sender: TObject); var s:PWideString; begin new(s); s^:='QPushButton { background-color: blue; color: white; } '+ 'QProgressBar::chunk {background-color: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 #FF0000, stop:1 #00FF00); }'+ 'QLineEdit { background: gray; color: white; } '+ 'QMainWindow { background-color: gray; color: white; } '; QApplication_setStyleSheet(QApplicationH(self),s); Dispose(s); end;
LCL控件與Qt5名稱對比表:
| LCL 控件 | Qt5 控件類型 (QSS 選擇器) | 說明/示例樣式 |
|---|---|---|
TButton |
QPushButton |
標(biāo)準(zhǔn)按鈕 |
TCheckBox |
QCheckBox |
復(fù)選框 |
TRadioButton |
QRadioButton |
單選按鈕 |
TEdit |
QLineEdit |
單行文本框 |
TMemo |
QTextEdit |
多行文本框 |
TComboBox |
QComboBox |
下拉框 |
TListBox |
QListWidget |
列表框 |
TTreeView |
QTreeView |
樹形視圖 |
TProgressBar |
QProgressBar |
進度條 |
TTrackBar |
QSlider |
滑塊控件 |
TScrollBar |
QScrollBar |
滾動條 |
TLabel |
QLabel |
標(biāo)簽文本 |
TPanel |
QFrame |
面板容器 |
TGroupBox |
QGroupBox |
分組框 |
TTabControl |
QTabWidget |
標(biāo)簽頁控件 |
TPageControl |
QTabWidget |
分頁控件 |
TStatusBar |
QStatusBar |
狀態(tài)欄 |
TToolBar |
QToolBar |
工具欄 |
TMenu |
QMenu |
菜單 |
TMainMenu |
QMenuBar |
主菜單欄 |

使用自定義樣式:


浙公網(wǎng)安備 33010602011771號