Qt界面美化常用到样式表,用好样式表能达到不一样的效果。

  • 样式表用法

常用控件样式表用法如下:

/**********子界面背景**********/
QWidget#customWidget {background: rgb(68, 69, 73);
}/**********子界面中央背景**********/
QWidget#centerWidget {background: rgb(50, 50, 50);
}/**********主界面样式**********/
QWidget#mainWindow {border: 1px solid rgb(50, 50, 50);background: rgb(50, 50, 50);
}QWidget#messageWidget {background: rgba(68, 69, 73, 50%);
}QWidget#loadingWidget {border: none;border-radius: 5px;background: rgb(50, 50, 50);
}QWidget#remoteWidget {border-top-right-radius: 10px;border-bottom-right-radius: 10px;border: 1px solid rgb(45, 45, 45);background: rgb(50, 50, 50);
}StyledWidget {qproperty-normalColor: white;qproperty-disableColor: gray;qproperty-highlightColor: rgb(0, 160, 230);qproperty-errorColor: red;
}QProgressIndicator {qproperty-color: rgb(175, 175, 175);
}/**********提示**********/
QToolTip{border: 1px solid rgb(45, 45, 45);background: white;color: black;
}/**********菜单栏**********/
QMenuBar {background: rgb(57, 58, 60);border: none;
}
QMenuBar::item {padding: 5px 10px 5px 10px;background: transparent;
}
QMenuBar::item:enabled {color: rgb(227, 234, 242);
}
QMenuBar::item:!enabled {color: rgb(155, 155, 155);
}
QMenuBar::item:enabled:selected {background: rgba(255, 255, 255, 40);
}/**********菜单**********/
QMenu {border: 1px solid rgb(100, 100, 100);background: rgb(68, 69, 73);
}
QMenu::item {height: 22px;padding: 0px 25px 0px 20px;
}
QMenu::item:enabled {color: rgb(225, 225, 225);
}
QMenu::item:!enabled {color: rgb(155, 155, 155);
}
QMenu::item:enabled:selected {color: rgb(230, 230, 230);background: rgba(255, 255, 255, 40);
}
QMenu::separator {height: 1px;background: rgb(100, 100, 100);
}
QMenu::indicator {width: 13px;height: 13px;
}
QMenu::icon {padding-left: 2px;padding-right: 2px;
}/**********状态栏**********/
QStatusBar {background: rgb(57, 58, 60);
}
QStatusBar::item {border: none;border-right: 1px solid rgb(100, 100, 100);
}/**********分组框**********/
QGroupBox {font-size: 15px;border: 1px solid rgb(80, 80, 80);border-radius: 4px;margin-top: 10px;
}
QGroupBox::title {color: rgb(175, 175, 175);top: -12px;left: 10px;
}/**********页签项**********/
QTabWidget::pane {border: none;border-top: 3px solid rgb(0, 160, 230);background: rgb(57, 58, 60);
}
QTabWidget::tab-bar {border: none;
}
QTabBar::tab {border: none;border-top-left-radius: 4px;border-top-right-radius: 4px;color: rgb(175, 175, 175);background: rgb(255, 255, 255, 30);height: 28px;min-width: 85px;margin-right: 5px;padding-left: 5px;padding-right: 5px;
}
QTabBar::tab:hover {background: rgb(255, 255, 255, 40);
}
QTabBar::tab:selected {color: white;background: rgb(0, 160, 230);
}QTabWidget#tabWidget::pane {border: 1px solid rgb(45, 45, 45);background: rgb(57, 58, 60);margin-top: -1px;
}QTabBar#tabBar::tab {border: 1px solid rgb(45, 45, 45);border-bottom: none;background: transparent;
}
QTabBar#tabBar::tab:hover {color: white;
}
QTabBar#tabBar::tab:selected {color: white;background: rgb(57, 58, 60);
}/**********表头**********/
QHeaderView{border: none;border-bottom: 3px solid rgb(0, 160, 230);background: rgb(57, 58, 60);min-height: 30px;
}
QHeaderView::section:horizontal {border: none;color: white;background: transparent;padding-left: 5px;
}
QHeaderView::section:horizontal:hover {background: rgb(0, 160, 230);
}
QHeaderView::section:horizontal:pressed {background: rgb(0, 180, 255);
}
QHeaderView::up-arrow {width: 13px;height: 11px;padding-right: 5px;image: url(:/Black/topArrow);subcontrol-position: center right;
}
QHeaderView::up-arrow:hover, QHeaderView::up-arrow:pressed {image: url(:/Black/topArrowHover);
}
QHeaderView::down-arrow {width: 13px;height: 11px;padding-right: 5px;image: url(:/Black/bottomArrow);subcontrol-position: center right;
}
QHeaderView::down-arrow:hover, QHeaderView::down-arrow:pressed {image: url(:/Black/bottomArrowHover);
}/**********表格**********/
QTableView {border: 1px solid rgb(45, 45, 45);background: rgb(57, 58, 60);gridline-color: rgb(60, 60, 60);
}
QTableView::item {padding-left: 5px;padding-right: 5px;border: none;background: rgb(72, 72, 74);border-right: 1px solid rgb(45, 45, 45);border-bottom: 1px solid rgb(45, 45, 45);
}
QTableView::item:selected {background: rgba(255, 255, 255, 40);
}
QTableView::item:selected:!active {color: white;
}
QTableView::indicator {width: 20px;height: 20px;
}
QTableView::indicator:enabled:unchecked {image: url(:/Black/checkBox);
}
QTableView::indicator:enabled:unchecked:hover {image: url(:/Black/checkBoxHover);
}
QTableView::indicator:enabled:unchecked:pressed {image: url(:/Black/checkBoxPressed);
}
QTableView::indicator:enabled:checked {image: url(:/Black/checkBoxChecked);
}
QTableView::indicator:enabled:checked:hover {image: url(:/Black/checkBoxCheckedHover);
}
QTableView::indicator:enabled:checked:pressed {image: url(:/Black/checkBoxCheckedPressed);
}
QTableView::indicator:enabled:indeterminate {image: url(:/Black/checkBoxIndeterminate);
}
QTableView::indicator:enabled:indeterminate:hover {image: url(:/Black/checkBoxIndeterminateHover);
}
QTableView::indicator:enabled:indeterminate:pressed {image: url(:/Black/checkBoxIndeterminatePressed);
}/**********滚动条-水平**********/
QScrollBar:horizontal {height: 20px;background: transparent;margin-top: 3px;margin-bottom: 3px;
}
QScrollBar::handle:horizontal {height: 20px;min-width: 30px;background: rgb(68, 69, 73);margin-left: 15px;margin-right: 15px;
}
QScrollBar::handle:horizontal:hover {background: rgb(80, 80, 80);
}
QScrollBar::sub-line:horizontal {width: 15px;background: transparent;image: url(:/Black/arrowLeft);subcontrol-position: left;
}
QScrollBar::add-line:horizontal {width: 15px;background: transparent;image: url(:/Black/arrowRight);subcontrol-position: right;
}
QScrollBar::sub-line:horizontal:hover {background: rgb(68, 69, 73);
}
QScrollBar::add-line:horizontal:hover {background: rgb(68, 69, 73);
}
QScrollBar::add-page:horizontal,QScrollBar::sub-page:horizontal {background: transparent;
}/**********滚动条-垂直**********/
QScrollBar:vertical {width: 20px;background: transparent;margin-left: 3px;margin-right: 3px;
}
QScrollBar::handle:vertical {width: 20px;min-height: 30px;background: rgb(68, 69, 73);margin-top: 15px;margin-bottom: 15px;
}
QScrollBar::handle:vertical:hover {background: rgb(80, 80, 80);
}
QScrollBar::sub-line:vertical {height: 15px;background: transparent;image: url(:/Black/arrowTop);subcontrol-position: top;
}
QScrollBar::add-line:vertical {height: 15px;background: transparent;image: url(:/Black/arrowBottom);subcontrol-position: bottom;
}
QScrollBar::sub-line:vertical:hover {background: rgb(68, 69, 73);
}
QScrollBar::add-line:vertical:hover {background: rgb(68, 69, 73);
}
QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {background: transparent;
}QScrollBar#verticalScrollBar:vertical {margin-top: 30px;
}/**********下拉列表**********/
QComboBox {height: 25px;border-radius: 4px;border: 1px solid rgb(100, 100, 100);background: rgb(72, 72, 73);
}
QComboBox:enabled {color: rgb(175, 175, 175);
}
QComboBox:!enabled {color: rgb(155, 155, 155);
}
QComboBox:enabled:hover, QComboBox:enabled:focus {color: rgb(230, 230, 230);background: rgb(68, 69, 73);
}
QComboBox::drop-down {width: 20px;border: none;background: transparent;
}
QComboBox::drop-down:hover {background: rgba(255, 255, 255, 30);
}
QComboBox::down-arrow {image: url(:/Black/arrowBottom);
}
QComboBox::down-arrow:on {/**top: 1px;**/
}
QComboBox QAbstractItemView {border: 1px solid rgb(100, 100, 100);background: rgb(68, 69, 73);outline: none;
}
QComboBox QAbstractItemView::item {height: 25px;color: rgb(175, 175, 175);
}
QComboBox QAbstractItemView::item:selected {background: rgba(255, 255, 255, 40);color: rgb(230, 230, 230);
}/**********进度条**********/
QProgressBar{border: none;text-align: center;color: white;background: rgb(48, 50, 51);
}
QProgressBar::chunk {background: rgb(0, 160, 230);
}QProgressBar#progressBar {border: none;text-align: center;color: white;background-color: transparent;background-image: url(":/Black/progressBar");background-repeat: repeat-x;
}
QProgressBar#progressBar::chunk {border: none;background-color: transparent;background-image: url(":/Black/progressBarChunk");background-repeat: repeat-x;
}/**********复选框**********/
QCheckBox{spacing: 5px;
}
QCheckBox:enabled{color: rgb(175, 175, 175);
}
QCheckBox:enabled:hover{color: rgb(200, 200, 200);
}
QCheckBox:!enabled{color: rgb(155, 155, 155);
}
QCheckBox::indicator {width: 20px;height: 20px;
}
QCheckBox::indicator:unchecked {image: url(:/Black/checkBox);
}
QCheckBox::indicator:unchecked:hover {image: url(:/Black/checkBoxHover);
}
QCheckBox::indicator:unchecked:pressed {image: url(:/Black/checkBoxPressed);
}
QCheckBox::indicator:checked {image: url(:/Black/checkBoxChecked);
}
QCheckBox::indicator:checked:hover {image: url(:/Black/checkBoxCheckedHover);
}
QCheckBox::indicator:checked:pressed {image: url(:/Black/checkBoxCheckedPressed);
}
QCheckBox::indicator:indeterminate {image: url(:/Black/checkBoxIndeterminate);
}
QCheckBox::indicator:indeterminate:hover {image: url(:/Black/checkBoxIndeterminateHover);
}
QCheckBox::indicator:indeterminate:pressed {image: url(:/Black/checkBoxIndeterminatePressed);
}/**********单选框**********/
QRadioButton{spacing: 5px;
}
QRadioButton:enabled{color: rgb(175, 175, 175);
}
QRadioButton:enabled:hover{color: rgb(200, 200, 200);
}
QRadioButton:!enabled{color: rgb(155, 155, 155);
}
QRadioButton::indicator {width: 20px;height: 20px;
}
QRadioButton::indicator:unchecked {image: url(:/Black/radioButton);
}
QRadioButton::indicator:unchecked:hover {image: url(:/Black/radioButtonHover);
}
QRadioButton::indicator:unchecked:pressed {image: url(:/Black/radioButtonPressed);
}
QRadioButton::indicator:checked {image: url(:/Black/radioButtonChecked);
}
QRadioButton::indicator:checked:hover {image: url(:/Black/radioButtonCheckedHover);
}
QRadioButton::indicator:checked:pressed {image: url(:/Black/radioButtonCheckedPressed);
}/**********输入框**********/
QLineEdit {border-radius: 4px;height: 25px;border: 1px solid rgb(100, 100, 100);background: rgb(72, 72, 73);
}
QLineEdit:enabled {color: rgb(175, 175, 175);
}
QLineEdit:enabled:hover, QLineEdit:enabled:focus {color: rgb(230, 230, 230);
}
QLineEdit:!enabled {color: rgb(155, 155, 155);
}/**********文本编辑框**********/
QTextEdit {border: 1px solid rgb(45, 45, 45);color: rgb(175, 175, 175);background: rgb(57, 58, 60);
}/**********滚动区域**********/
QScrollArea {border: 1px solid rgb(45, 45, 45);background: rgb(57, 58, 60);
}/**********滚动区域**********/
QWidget#transparentWidget {background: transparent;
}/**********微调器**********/
QSpinBox {border-radius: 4px;height: 24px;min-width: 40px;border: 1px solid rgb(100, 100, 100);background: rgb(68, 69, 73);
}
QSpinBox:enabled {color: rgb(220, 220, 220);
}
QSpinBox:enabled:hover, QLineEdit:enabled:focus {color: rgb(230, 230, 230);
}
QSpinBox:!enabled {color: rgb(65, 65, 65);background: transparent;
}
QSpinBox::up-button {width: 18px;height: 12px;border-top-right-radius: 4px;border-left: 1px solid rgb(100, 100, 100);image: url(:/Black/upButton);background: rgb(50, 50, 50);
}
QSpinBox::up-button:!enabled {border-left: 1px solid gray;background: transparent;
}
QSpinBox::up-button:enabled:hover {background: rgb(255, 255, 255, 30);
}
QSpinBox::down-button {width: 18px;height: 12px;border-bottom-right-radius: 4px;border-left: 1px solid rgb(100, 100, 100);image: url(:/Black/downButton);background: rgb(50, 50, 50);
}
QSpinBox::down-button:!enabled {border-left: 1px solid gray;background: transparent;
}
QSpinBox::down-button:enabled:hover {background: rgb(255, 255, 255, 30);
}/**********标签**********/
QLabel#grayLabel {color: rgb(175, 175, 175);
}QLabel#highlightLabel {color: rgb(175, 175, 175);
}QLabel#redLabel {color: red;
}QLabel#grayYaHeiLabel {color: rgb(175, 175, 175);font-size: 16px;
}QLabel#blueLabel {color: rgb(0, 160, 230);
}QLabel#listLabel {color: rgb(0, 160, 230);
}QLabel#lineBlueLabel {background: rgb(0, 160, 230);
}QLabel#graySeperateLabel {background: rgb(45, 45, 45);
}QLabel#seperateLabel {background: rgb(80, 80, 80);
}QLabel#radiusBlueLabel {border-radius: 15px;color: white;font-size: 16px;background: rgb(0, 160, 230);
}QLabel#skinLabel[colorProperty="normal"] {color: rgb(175, 175, 175);
}
QLabel#skinLabel[colorProperty="highlight"] {color: rgb(0, 160, 230);
}QLabel#informationLabel {qproperty-pixmap: url(:/Black/information);
}QLabel#errorLabel {qproperty-pixmap: url(:/Black/error);
}QLabel#successLabel {qproperty-pixmap: url(:/Black/success);
}QLabel#questionLabel {qproperty-pixmap: url(:/Black/question);
}QLabel#warningLabel {qproperty-pixmap: url(:/Black/warning);
}QLabel#groupLabel {color: rgb(0, 160, 230);border: 1px solid rgb(0, 160, 230);font-size: 15px;border-top-color: transparent;border-right-color: transparent;border-left-color: transparent;
}/**********按钮**********/
QToolButton#nsccButton{border: none;color: rgb(175, 175, 175);background: transparent;padding: 10px;qproperty-icon: url(:/Black/nscc);qproperty-iconSize: 32px 32px;qproperty-toolButtonStyle: ToolButtonTextUnderIcon;
}
QToolButton#nsccButton:hover{color: rgb(217, 218, 218);background: rgb(255, 255, 255, 20);
}QToolButton#transferButton{border: none;color: rgb(175, 175, 175);background: transparent;padding: 10px;qproperty-icon: url(:/Black/transfer);qproperty-iconSize: 32px 32px;qproperty-toolButtonStyle: ToolButtonTextUnderIcon;
}
QToolButton#transferButton:hover{color: rgb(217, 218, 218);background: rgb(255, 255, 255, 20);
}/**********按钮**********/
QPushButton{border-radius: 4px;border: none;width: 75px;height: 25px;
}
QPushButton:enabled {background: rgb(68, 69, 73);color: white;
}
QPushButton:!enabled {background: rgb(100, 100, 100);color: rgb(200, 200, 200);
}
QPushButton:enabled:hover{background: rgb(85, 85, 85);
}
QPushButton:enabled:pressed{background: rgb(80, 80, 80);
}QPushButton#blueButton {color: white;
}
QPushButton#blueButton:enabled {background: rgb(0, 165, 235);color: white;
}
QPushButton#blueButton:!enabled {background: gray;color: rgb(200, 200, 200);
}
QPushButton#blueButton:enabled:hover {background: rgb(0, 180, 255);
}
QPushButton#blueButton:enabled:pressed {background: rgb(0, 140, 215);
}QPushButton#selectButton {border: none;border-radius: none;border-left: 1px solid rgb(100, 100, 100);image: url(:/Black/scan);background: transparent;color: white;
}
QPushButton#selectButton:enabled:hover{background: rgb(85, 85, 85);
}
QPushButton#selectButton:enabled:pressed{background: rgb(80, 80, 80);
}QPushButton#linkButton {background: transparent;color: rgb(0, 160, 230);text-align:left;
}
QPushButton#linkButton:hover {color: rgb(20, 185, 255);text-decoration: underline;
}
QPushButton#linkButton:pressed {color: rgb(0, 160, 230);
}QPushButton#transparentButton {background: transparent;
}/*****************标题栏按钮*******************/
QPushButton#minimizeButton {border-radius: none;border-bottom-left-radius: 4px;border-bottom-right-radius: 4px;background: rgb(50, 50, 50);image: url(:/Black/minimize);
}
QPushButton#minimizeButton:hover {background: rgb(60, 60, 60);image: url(:/Black/minimizeHover);
}
QPushButton#minimizeButton:pressed {background: rgb(55, 55, 55);image: url(:/Black/minimizePressed);
}QPushButton#maximizeButton[maximizeProperty="maximize"] {border-radius: none;border-bottom-left-radius: 4px;border-bottom-right-radius: 4px;background: rgb(50, 50, 50);image: url(:/Black/maximize);
}
QPushButton#maximizeButton[maximizeProperty="maximize"]:hover {background: rgb(60, 60, 60);image: url(:/Black/maximizeHover);
}
QPushButton#maximizeButton[maximizeProperty="maximize"]:pressed {background: rgb(55, 55, 55);image: url(:/Black/maximizePressed);
}QPushButton#maximizeButton[maximizeProperty="restore"] {border-radius: none;border-bottom-left-radius: 4px;border-bottom-right-radius: 4px;background: rgb(50, 50, 50);image: url(:/Black/restore);
}
QPushButton#maximizeButton[maximizeProperty="restore"]:hover {background: rgb(60, 60, 60);image: url(:/Black/restoreHover);
}
QPushButton#maximizeButton[maximizeProperty="restore"]:pressed {background: rgb(55, 55, 55);image: url(:/Black/restorePressed);
}QPushButton#closeButton {border-radius: none;border-bottom-left-radius: 4px;border-bottom-right-radius: 4px;background: rgb(50, 50, 50);image: url(:/Black/close);
}
QPushButton#closeButton:hover {background: rgb(60, 60, 60);image: url(:/Black/closeHover);
}
QPushButton#closeButton:pressed {background: rgb(55, 55, 55);image: url(:/Black/closePressed);
}QPushButton#skinButton {border-radius: none;border-bottom-left-radius: 4px;border-bottom-right-radius: 4px;background: rgb(50, 50, 50);image: url(:/Black/skin);
}
QPushButton#skinButton:hover {background: rgb(60, 60, 60);image: url(:/Black/skinHover);
}
QPushButton#skinButton:pressed {background: rgb(55, 55, 55);image: url(:/Black/skinPressed);
}QPushButton#feedbackButton {border-radius: none;border-bottom-left-radius: 4px;border-bottom-right-radius: 4px;background: rgb(50, 50, 50);image: url(:/Black/feedback);
}
QPushButton#feedbackButton:hover {background: rgb(60, 60, 60);image: url(:/Black/feedbackHover);
}
QPushButton#feedbackButton:pressed {background: rgb(55, 55, 55);image: url(:/Black/feedbackPressed);
}QPushButton#closeTipButton {border-radius: none;border-image: url(:/Black/close);background: transparent;
}
QPushButton#closeTipButton:hover {border-image: url(:/Black/closeHover);
}
QPushButton#closeTipButton:pressed {border-image: url(:/Black/closePressed);
}QPushButton#changeSkinButton{border-radius: 4px;border: 2px solid rgb(41, 41, 41);background: rgb(51, 51, 51);
}
QPushButton#changeSkinButton:hover{border-color: rgb(45, 45, 45);
}
QPushButton#changeSkinButton:pressed, QPushButton#changeSkinButton:checked{border-color: rgb(0, 160, 230);
}QPushButton#transferButton {padding-left: 5px;padding-right: 5px;color: white;background: rgb(0, 165, 235);
}
QPushButton#transferButton:hover {background: rgb(0, 180, 255);
}
QPushButton#transferButton:pressed {background: rgb(0, 140, 215);
}
QPushButton#transferButton[iconProperty="left"] {qproperty-icon: url(:/Black/left);
}
QPushButton#transferButton[iconProperty="right"] {qproperty-icon: url(:/Black/right);
}QPushButton#openButton {border-radius: none;image: url(:/Black/open);background: transparent;
}
QPushButton#openButton:hover {image: url(:/Black/openHover);
}
QPushButton#openButton:pressed {image: url(:/Black/openPressed);
}QPushButton#deleteButton {border-radius: none;image: url(:/Black/delete);background: transparent;
}
QPushButton#deleteButton:hover {image: url(:/Black/deleteHover);
}
QPushButton#deleteButton:pressed {image: url(:/Black/deletePressed);
}QPushButton#menuButton {text-align: left center;padding-left: 3px;color: rgb(175, 175, 175);border: 1px solid rgb(100, 100, 100);background: rgb(72, 72, 73);
}
QPushButton#menuButton::menu-indicator{subcontrol-position: right center;subcontrol-origin: padding;image: url(:/Black/arrowBottom);padding-right: 3px;
}
  • 遇到的问题

1、设置widget背景图片失败。

在Qt中设置widget背景颜色或者图片方法很多种:重写paintEvent() , 调色板QPalette , 样式表setStyleSheet等等。用setStyleSheet()这个函数时要注意以下几个问题:

①:该函数只能用于设置有父窗口的子窗口的背景!如果一个窗口没有子窗口,则无法使用该函数来设置背景颜色或图  片!!

          ②:同时:对于一个父窗口而言:如果我们用setStyleShette设置了其样式,而对于其子窗口:如果没有用同样的函数来设置的话, 则其子窗口的样式和其父窗口完全一致,亦即:其集成了自己父窗口的样式!

③:延伸:对顶层窗口(没有父窗口),其有若干个子窗口,则当我们用setStyleShette来设置这个顶层窗口的样式后,依据①可知:该父窗口本身没有任何变化,亦即设置没有生效;而其子窗口:只要子窗口本身没有用setStyleShette来设置自己的样式表,则其就是用的自己父窗口的样式表!!

但如果要QWidget的子类窗口如要正常显示背景色或图片,需要setAttribute(Qt::WA_StyledBackground)。

调色板QPalette用法如下。

this->setAutoFillBackground(true); // 这句要加上, 否则可能显示不出背景图.
QPalette palette = this->palette();
palette.setBrush(QPalette::Window,QBrush(QPixmap(":/res/backgroud.png").scaled(// 缩放背景图.this->size(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation)));             // 使用平滑的缩放方式
this->setPalette(palette);                           // 给widget加上背景图

2、QT样式表QComboBox设置下拉列表行距无效的原因

QComboBox的下拉列表默认情况下行距等于字高,显示效果看起来非常拥挤,对于显示相关的问题,一般都能用样式表解决,但是QComboBox的下拉列表的行高就比较另类了

用样式表设置行高的qss语句如下:

QComboBox QAbstractItemView
{border: 2px solid darkgray;/*下拉列表的边线的粗细、实虚*/selection-background-color: lightgray;/*下拉列表选中的行的背景色*/
}
QComboBox QAbstractItemView::item
{height:20px;/*下拉列表的行高,也可以看做行距*/
}

但是这样却无法修改成功,查找Qt帮助手册Customizing QComboBox例子:style sheet -> Qt Style Sheets Examples -> Customizing QComboBox。并参考下面的例子。

参考的链接如下:http://www.qtcentre.org/threads/13496-CSS-QCombobox-setting-min-height-for-drop-down-list

除了设置好样式表以外,还要为每一个QComboBox对象执行:

ui->comboBox->setView(new QListView());

当你有很多QComboBox时,你可以封装QComboBox。

Qt 常用控件样式表及遇到的问题相关推荐

  1. Qt常用控件介绍(一)

    Qt常用控件介绍 Qt Creator 的使用技巧 Qt Creator的常用快捷键 按钮 QPushButton QToolButton QRadioButton QCheckBox QComman ...

  2. 【QT】QT从零入门教程(八):QT常用控件 [QLabel、QPushButton、QLineEdit、QTextEdit]

      本节介绍一些常用的控件,是在"图像处理自编软件"中用到的几种,包括QLabel.QPushButton.QLineEdit.QTextEdit.QSlider.QSpinBox ...

  3. 【QT】QT从零入门教程(九):QT常用控件 [QSlider、QSpinBox、QComboBox、QRadioButton]

    QSlider 滑动条与QSpinBox微调框 (这里只贴出控件的基本用法,需要时再查阅资料.) QSlider *slider = new QSlider(Qt::Horizontal); // 创 ...

  4. QT常用控件(三)——QTreeWidget(树控件),QTableWidget控件

    QTreeWidget树控件 实例: #include "layout.h" #pragma execution_character_set("utf-8") ...

  5. QT常用控件——QComboBox控件

    操作系统: 统信UOSv20 Qt版本: 5.11.3 一,简单介绍 QComboBox提供了一种以占用最小屏幕空间的方式向用户呈现选项列表的方法.组合框是显示当前项目的选择小部件,可以弹出可选择项目 ...

  6. qt开关控件设计(手把手从零开始)

    从零开始手把手教你设计自己的qt控件 1 说明 1.1 显示效果 1.2 控件特性 1.3 设计方法 2 控件需求分析 2.1 必要需求 2.1 顺带需求(锦上添花) 3 功能设计 3.1 设计思路( ...

  7. Qt控件样式之QSS

    QSS常用于Qt的控件样式美化,合理地使用Qss可以完成在不改动代码的情况下改变Qt界面的样式. 官方提供的例子: http://qt-project.org/doc/qt-4.8/styleshee ...

  8. 【Qt】桌面应用开发教程——布局|按钮组|容器|常用控件|消息事件机制

    文章目录 3.布局 3.1 系统提供的布局控件 3.2 利用widget做布局 3.3 利用表单做布局 4.按钮组 5.项目构建组 6.容器 7.常用控件 7.1 QLabel控件使用 7.1.1 显 ...

  9. 【QT开发笔记-基础篇】| 第二章 常用控件 | 2.12 表格控件 QTableWidget

    本节对应的视频讲解:B_站_链_接 QTableWidget 是 Qt 中的表格控件,可以行列的形式来展示数据 1. 属性和方法 QTableWidget 有很多属性和方法,完整的可查看帮助文档. 在 ...

最新文章

  1. ajax与axios使用哪个好,ajax、axios、fetch之间的详细区别以及优缺点
  2. CV之路 —— Opencv学习
  3. C++成员对象和封闭类
  4. Paper:《Multimodal Machine Learning: A Survey and Taxonomy,多模态机器学习:综述与分类》翻译与解读
  5. 安装或卸载英特尔快速存储技术时,提示“此程序有一个挂起的重新启动”
  6. 图Graph--寻找二度好友(BFS应用)
  7. 跳过php学thinkphp,PHP学习-ThinkPHP《从入门到放弃》(六)
  8. 买下千万美元豪宅的库克 在周日获得了价值3600万美元股票
  9. 天池实验室-Task03-Python入门(下)
  10. 【IT领导力】IT 使命、愿景和价值观声明:成功的基础
  11. 某同学:1年经验和1本软考证书,很迷茫~
  12. 【PS填充背景色和前景色】
  13. linux下载百度网盘
  14. 城市精细化治理过程中的智能图像识别如何更精准、更智能?
  15. shp文件转换到CAD dwg,dxf
  16. linux7 etc下的grub2,Centos7安装 grub2 配置技巧:改变启动顺序
  17. Oracle Executable Binary Mismatch Detected
  18. 立法白噪声的时间序列检验Matlab
  19. (转)《一定要争气》
  20. STM32开发笔记48:STM32F4+DP83848以太网通信指南系列(二):系统时钟

热门文章

  1. 一场技术人的年终盛典:9个老兵对2016年总结与思考
  2. layui 如何取得select下拉框选中的值
  3. java如何比较字符asc_Java中的Asc码与字符互相转化
  4. 伺服电机编码器为什么要调零或校正
  5. python实现屏幕视频录制_Python实现屏幕录制功能的代码
  6. dede 修改首页默认访问路径/dede修改安装目录
  7. git clone报错:could not read Username for ‘http://xxx.com‘: Device not configured
  8. 拨号盘拨号数字间距太小 调大 修改通讯录里面收藏和所有联系人字体颜色
  9. 前端全栈工程师进阶学习笔记
  10. H5: 关于底部导航使用“fixed”会遮住网页最下面内容的解决办法!