Qt Designer中利用各个控件来setStyleSheet
2017-08-17 15:44
423 查看
1.QLabel
QLabel#label_sum_text{
font: 75 35pt "微软雅黑";/*字体*/
background-color: rgb(255, 255, 255);/*背景色*/
color: rgb(152, 156, 156);/*字体颜色*/
border-style:hidden;/*边框样式*/
padding: 1px 1px 8px 1px; /*四周边距*/
}
2.QToolButton、QPushButton
/*按钮正常显示*/
QToolButton#toolButton_7{
border-image: url(
:/keybord_cfm/images/keybord_cfm/u63.png);
}
/*按钮按下*/
QToolButton#toolButton_7::pressed{
border-image: url(
:/keybord_cfm/images/keybord_cfm/u63_mouseOver.png);
}
/*鼠标移到按钮上时*/
QToolButton#toolButton_7::hover{
border-image: url(
:/keybord_cfm/images/keybord_cfm/u63_mouseOver.png);
}
注意:border-image适用于所有控件
3.QFrame
QFrame#frame_right_top{
border-style:solid;/*边框样式*/
border-width:1px;/*边框宽度*/
border-radius: 6px;/*圆角边框*/
border-color: rgb(173, 176, 182);/*边框颜色*/
background-color: rgb(255, 255, 255);/*背景色*/
}
4.QTableView
/*设置行交替颜色*/
QTableView::item:alternate:!selected,
QTableWidget::item:alternate:!selected,
QListView::item:alternate:!selected
{ background: rgb(255, 255, 204); }
QTableView::item:!alternate:!selected,
QTableWidget::item:!alternate:!selected,
QListView::item:!alternate:!selected
{ background: rgb(248, 236, 212); }
QTableView{
font: 11pt "微软雅黑";
color: rgb(152, 152, 152);
selection-background-color: rgb(50, 151, 243);
}
QTableView::item:selected{
color: rgb(152, 152, 152);
background:rgb(248, 236, 212); /*选中行背景色*/
}
/*表头设置*/
QTableView QHeaderView
{
background-color: rgb(248, 248, 248);
font: 12pt "微软雅黑";
color: rgb(112, 112, 112);
}
/*水平表头*/
QHeaderView::section::horizontal {
padding: 0px;
border: none;
border-bottom: 1px solid rgb(214, 215, 218);
background-color: rgb(248, 248, 248);
}
/*垂直表头*/
QHeaderView::section::vertical {
padding: 5px;
border: none;
background-color: rgb(248, 248, 248);
alternate-background-color: rgb(255, 0, 0);
}
/*左上角按钮*/
QTableCornerButton::section {
padding: 0px;
border: none;
border-bottom: 1px solid rgb(214, 215, 218);
background-color: rgb(248, 248, 248);
}
5.QTableView属性设置
void setAttibutes(IN QTableView* pView,IN int nHeaderHeight,IN int nColumnHeight)
{
if ( pView == NULL )
{
QString strTemp = QStringLiteral("pView== NULL!设置表格属性失败!");
LOG_ALL_ERROR(strTemp);
QMessageBox::information(0,0,QStringLiteral("设置表格属性失败!"));
return;
}
}
pView->horizontalHeader()->setFixedHeight(nHeaderHeight);//设置表头的高度
pView->horizontalHeader()->setSectionsClickable(false);//设置表头不可点击(默认点击后进行排序)
//pView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); //列宽都一致
pView->horizontalHeader()->setStretchLastSection(true);//最后一列占满剩余空白
pView->setSelectionBehavior(QAbstractItemView::SelectRows);//设置选择行为时每次选择一行
pView->setEditTriggers(QAbstractItemView::NoEditTriggers);//使表视图只读
pView->verticalHeader()->setDefaultSectionSize(nColumnHeight);//设置行高
//pView->setAlternatingRowColors(true);//可以交替颜色显示
pView->setShowGrid(false);//设置不显示格子线
pView->setCornerButtonEnabled(false);//左上角的按钮不可用,此按钮功能,一点击,全选
//水平滚动条
pView->horizontalScrollBar()->setStyleSheet("QScrollBar{background:transparent; height:10px;}"
"QScrollBar::handle{background:lightgray; border:2px solid transparent; border-radius:5px;}"
"QScrollBar::handle:hover{background:gray;}"
"QScrollBar::sub-line{background:transparent;}"
"QScrollBar::add-line{background:transparent;}");
//垂直滚动条
pView->verticalScrollBar()->setStyleSheet("QScrollBar{background:transparent; width: 10px;}"
"QScrollBar::handle{background:lightgray; border:2px solid transparent; border-radius:5px;}"
"QScrollBar::handle:hover{background:gray;}"
"QScrollBar::sub-line{background:transparent;}"
"QScrollBar::add-line{background:transparent;}");
}
点击打开链接
QLabel#label_sum_text{
font: 75 35pt "微软雅黑";/*字体*/
background-color: rgb(255, 255, 255);/*背景色*/
color: rgb(152, 156, 156);/*字体颜色*/
border-style:hidden;/*边框样式*/
padding: 1px 1px 8px 1px; /*四周边距*/
}
2.QToolButton、QPushButton
/*按钮正常显示*/
QToolButton#toolButton_7{
border-image: url(
:/keybord_cfm/images/keybord_cfm/u63.png);
}
/*按钮按下*/
QToolButton#toolButton_7::pressed{
border-image: url(
:/keybord_cfm/images/keybord_cfm/u63_mouseOver.png);
}
/*鼠标移到按钮上时*/
QToolButton#toolButton_7::hover{
border-image: url(
:/keybord_cfm/images/keybord_cfm/u63_mouseOver.png);
}
注意:border-image适用于所有控件
3.QFrame
QFrame#frame_right_top{
border-style:solid;/*边框样式*/
border-width:1px;/*边框宽度*/
border-radius: 6px;/*圆角边框*/
border-color: rgb(173, 176, 182);/*边框颜色*/
background-color: rgb(255, 255, 255);/*背景色*/
}
4.QTableView
/*设置行交替颜色*/
QTableView::item:alternate:!selected,
QTableWidget::item:alternate:!selected,
QListView::item:alternate:!selected
{ background: rgb(255, 255, 204); }
QTableView::item:!alternate:!selected,
QTableWidget::item:!alternate:!selected,
QListView::item:!alternate:!selected
{ background: rgb(248, 236, 212); }
QTableView{
font: 11pt "微软雅黑";
color: rgb(152, 152, 152);
selection-background-color: rgb(50, 151, 243);
}
QTableView::item:selected{
color: rgb(152, 152, 152);
background:rgb(248, 236, 212); /*选中行背景色*/
}
/*表头设置*/
QTableView QHeaderView
{
background-color: rgb(248, 248, 248);
font: 12pt "微软雅黑";
color: rgb(112, 112, 112);
}
/*水平表头*/
QHeaderView::section::horizontal {
padding: 0px;
border: none;
border-bottom: 1px solid rgb(214, 215, 218);
background-color: rgb(248, 248, 248);
}
/*垂直表头*/
QHeaderView::section::vertical {
padding: 5px;
border: none;
background-color: rgb(248, 248, 248);
alternate-background-color: rgb(255, 0, 0);
}
/*左上角按钮*/
QTableCornerButton::section {
padding: 0px;
border: none;
border-bottom: 1px solid rgb(214, 215, 218);
background-color: rgb(248, 248, 248);
}
5.QTableView属性设置
void setAttibutes(IN QTableView* pView,IN int nHeaderHeight,IN int nColumnHeight)
{
if ( pView == NULL )
{
QString strTemp = QStringLiteral("pView== NULL!设置表格属性失败!");
LOG_ALL_ERROR(strTemp);
QMessageBox::information(0,0,QStringLiteral("设置表格属性失败!"));
return;
}
}
pView->horizontalHeader()->setFixedHeight(nHeaderHeight);//设置表头的高度
pView->horizontalHeader()->setSectionsClickable(false);//设置表头不可点击(默认点击后进行排序)
//pView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); //列宽都一致
pView->horizontalHeader()->setStretchLastSection(true);//最后一列占满剩余空白
pView->setSelectionBehavior(QAbstractItemView::SelectRows);//设置选择行为时每次选择一行
pView->setEditTriggers(QAbstractItemView::NoEditTriggers);//使表视图只读
pView->verticalHeader()->setDefaultSectionSize(nColumnHeight);//设置行高
//pView->setAlternatingRowColors(true);//可以交替颜色显示
pView->setShowGrid(false);//设置不显示格子线
pView->setCornerButtonEnabled(false);//左上角的按钮不可用,此按钮功能,一点击,全选
//水平滚动条
pView->horizontalScrollBar()->setStyleSheet("QScrollBar{background:transparent; height:10px;}"
"QScrollBar::handle{background:lightgray; border:2px solid transparent; border-radius:5px;}"
"QScrollBar::handle:hover{background:gray;}"
"QScrollBar::sub-line{background:transparent;}"
"QScrollBar::add-line{background:transparent;}");
//垂直滚动条
pView->verticalScrollBar()->setStyleSheet("QScrollBar{background:transparent; width: 10px;}"
"QScrollBar::handle{background:lightgray; border:2px solid transparent; border-radius:5px;}"
"QScrollBar::handle:hover{background:gray;}"
"QScrollBar::sub-line{background:transparent;}"
"QScrollBar::add-line{background:transparent;}");
}
点击打开链接
相关文章推荐
- Qt中各个控件利用Qt Designer来setStyleSheet
- 关于QT利用setStyleSheet为主控件添加背景图片,而不影响其子控件的背景设置
- Qt利用setstylesheet给控件设置背景图片不能显示
- Qt 利用palatte和setStyleSheet设置颜色
- Qt利用setStyleSheet设置样式
- QT QSS setStyleSheet 利用宏快速设置按钮的三态点击效果
- QT样式表,setstylesheet,控件使用图片
- Qt利用setStyleSheet设置样式
- Qt中使用setStyleSheet对QPushButton按钮进行外观设置
- qt的stylesheet中如何设置属性使背景图自动调整来适应控件的大小
- Qt 利用stylesheet 设置按钮五态图标
- Qt中使用setStyleSheet对QPushButton按钮进行外观设置
- Qt setStyleSheet 添加背景色/背景图片(取消背景色,读取本地文件作为背景色)
- Qt对基本控件进行美化 QStyle和QStyleSheet
- Qt中设置widget背景颜色/图片的注意事项(使用样式表 setStyleSheet())
- Qt控件样式 Style Sheet Demo
- Qt中绘制窗口的背景图片注意事项(常见的setStyleSheet和QPalette)
- Qt控件样式 Style Sheet Demo
- Qt—样式表(setStyleSheet())
- Qt 样式表 setStyleSheet