ui->QTableView->verticalScrollBar()      // 竖轴
ui->QTableView->horizontalScrollBar()  // 横轴
"QScrollBar:vertical{"        //垂直方向
	 "background:#FFFFFF;"  //背景色 
	 "padding-top:20px;"    //上预留位置(放置向上箭头)  
	 "padding-bottom:20px;" //下预留位置(放置向下箭头)  
	 "padding-left:3px;"    //左预留位置(美观)  
	 "padding-right:3px;"   //右预留位置(美观)  
	 "border-left:1px solid #d7d7d7;}"//左分割线  
"QScrollBar::handle:vertical{"//滑块样式
     "background:#dbdbdb;"  //滑块颜色  
     "border-radius:6px;"   //边角圆润  
     "min-height:80px;}"    //滑块最小高度  
"QScrollBar::handle:vertical:hover{"//鼠标触及滑块样式  
	 "background:#d0d0d0;}" //滑块颜色  
"QScrollBar::add-line:vertical{"//向下箭头样式  
	 "background:url(:/images/down.png) center no-repeat;}" 
"QScrollBar::sub-line:vertical{"//向上箭头样式  
	 "background:url(:/images/up.png) center no-repeat;}"
"QScrollBar:horizontal{ }"  // 水平方向
"QScrollBar::handle:horizontal{}"  // 水平滑块样式
"QScrollBar::handle:horizontal:hover{}" 
// 和垂直方向一样,唯一就是将相应 vertical 替换为 horizontal

自定义QTabWidget TabBar样式(字体90度旋转)

#ifndef CUSTOMTAB_H
#define CUSTOMTAB_H
#include <QStyleOptionTab>
#include <QStylePainter>
#include <QTabBar>
#include <QProxyStyle>
#define STR_FONTFAMILY_CN "宋体"
#define STR_FONT_EXAMPEL_CN "路"
const QColor qcolorGray = QColor(247, 247, 247);
const QColor qcolorBlack = QColor(51, 51, 51);
const QColor qcolorDrakGray = QColor(102, 102, 102);
const int i_FONTSIZE = 30;
class CustomTab : public QProxyStyle //继承QProxyStyle
public:
    QSize sizeFromContents(ContentsType type, const QStyleOption *option,
        const QSize &size, const QWidget *widget) const
        QSize tabsize = QProxyStyle::sizeFromContents(type, option, size, widget);
        if (QStyle::CT_TabBarTab == type)
            tabsize.transpose();
            QFont font(STR_FONTFAMILY_CN, i_FONTSIZE);
            QFontMetrics fm(font);
            int ipixelsWide = fm.width(STR_FONT_EXAMPEL_CN);   // 计算“路”字的宽度
            int ipixelsHigh = fm.height();
            tabsize.rwidth() = ipixelsWide; // 设置每个tabBar中item的大小
            tabsize.rheight() = ipixelsHigh * 3;
        return tabsize;
    void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
        if (CE_TabBarTabLabel == element)
        	//如果元件是TabBarTabLabel
            if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option))
                QRect allRect = tab->rect;//获取tab矩形框
                if (tab->state & QStyle::State_Selected)
                    painter->save();
                    painter->setPen(Qt::white);//设置颜色
                    painter->setBrush(QBrush(qcolorGray));
                    painter->drawRect(allRect.adjusted(0,0,0,0));  //重绘tab的矩形边框
                    painter->restore();//恢复
                QTextOption option;//这里设置文本样式
                option.setAlignment(Qt::AlignCenter);//设置对其方式。居中对齐
                if (tab->state & QStyle::State_Selected)
                    painter->setPen(qcolorBlack);//设置颜色
                    painter->setPen(qcolorDrakGray);
                painter->drawText(allRect, tab->text, option);//绘制文本
                return;
        if (CE_TabBarTab == element)
            QProxyStyle::drawControl(element, option, painter, widget);
#endif // CUSTOMTAB_H

设置QTabWidget TabBar样式

"QTabBar::tab:selected{background-color:rgb(247,247,247);}"   // 按下状态
"QTabBar::tab{background-color:rgb(255,255,255);width: 50}"   // 普通状态

QPushButton样式

"QPushButton{image: url(********);"     								// 设置图片  
 "background-color: rgb(255, 255, 255);" 								// 设置背景色
 "border:none;"							 								// 设置边框
 "border-radius:10px;"
 "padding:2px 4px;}"
 "QPushButton:pressed{background-color: rgb(248, 248, 248);}"           // 按下状态设置
                    滚动条ui-&gt;QTableView-&gt;verticalScrollBar()      // 竖轴ui-&gt;QTableView-&gt;horizontalScrollBar()  // 横轴"QScrollBar:vertical{"        //垂直方向	 "background:#FFFFFF;"  //背景色 	 "padding-top:20px;"    //上预留位置(放置向上箭头)  	 "padding-bottom:20px;" //下预留位置(放置
QTableView QTableCornerButton::section {
/*  background: red;
border: 2px outset red;*/
color: red;
background-color: rgb(64, 64, 64);
border: 5px solid #f6f7fa;
border-radius:0px;
border-color: rgb(64, 64, 64);
QTableView {
color: whi
this->setStyleSheet(
        "QPushButton#btn_one,QPushButton#btn_two{
            background-color:yellow;//设置背景色
            font-family:SimSun;//设置字体
            color:black;//设...
				
1.设置QTabWidget 的Tab标签下面窗格的样式 QTabWidget#tabwidget_DevMang::pane { border-top: 3px solid black; border-left: 3px solid black; background-color: green; left:5px; right:5px;
Qt样式表是一个可以自定义部件外观的十分强大的机制﹐除了那些能够通过子类化QStyle更改的外观,其余的都可以使用Qt样式表来美化。Qt样式表的概念,术语和语法都受到了HTML的层叠样式表(Cascading Style Sheets, CSS)的启发,不过与CSS不同的是,Qt样式表应用于部件。 Qt样式表介绍 样式表可以使用QApplication: : setStyleSheet()函数将其设置到整个应用程序上,也可以使用QWidget::setStyleSheet()函数将其设置到一个指定的部件(还
1、Qt样式表 Qt样式表(style sheet)是用于定制用户界面的强有力的机制,其概念、术语是收到HTML中的级联样式表(Cascading Style Sheets,CCS)启发而来,只是Qt样式表是用用于窗体界面的 与HTML的CSS类似,Qt样式表是纯文本的格式定义,在应用程序运行时可以载入和解析这些样式定义。使用样式表可以定义各种界面组件(QWidget类及其子类)的样式,从而使应用程序的界面呈现不同的效果。很多软件具有换肤功能,使用Qt样式表就可以很容易的实现这样的功能 多多翻看Qt官方
QTableView { color: white; /*表格内文字颜色*/ gridline-color: black; /*表格内框颜色*/ background-color: rgb(1... this->setStyleSheet("QTabWidget::pane{border-width:1px;border-color:rgb(48, 104, 151);\ border-style: outset;background-color: rgb(132, 171, 208);\ background: transparent;} \ QTabW. 样式的规则1:样式规则由选择器和声明组成。选择器指定哪些小部件受规则影响;声明指定应该在小部件上设置哪些属性。 如:QPushButton { color : red }。 其中QPushButton就是选...
Qt 是一个跨平台的 C++ 库,用于开发图形用户界面 (GUI) 应用程序。它提供了一个通用的界面样式表,允许开发者在界面上使用相同的样式Qt 提供了多种内置的界面样式,包括 "Plastique"、"Windows" 和 "Fusion"。开发者可以使用 Qt 的 QStyle 类来设置应用程序的界面样式。例如,可以使用以下代码设置应用程序的界面样式为 "Windows": QApplication::setStyle("windows"); 此外,开发者还可以使用自定义的界面样式表Qt 提供了一种叫做 Qt Style Sheets 的机制,允许开发者使用类似于 CSS 的语法来定义界面元素的样式。例如,可以使用以下代码设置所有按钮的背景颜色为红色: QPushButton { background-color: red; Qt Style Sheets 可以用于设置界面元素的外观、布局、字体等属性,可以在不修改代码的情况下改变应用程序的外观。