Qt中各个控件利用Qt Designer来setStyleSheet
2015-06-23 08:53
1061 查看
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学习 第一章:基本对话框
- 使用Shiboken为C++和Qt库创建Python绑定
- Qt定时器和随机数详解
- Qt实现图片移动实例(图文教程)
- Qt for Android开发实例教程
- QModelIndex/Role/Model介紹<二>
- 基于PyQt5的快速开发框架QFramer
- ok6410开发板移植DirectFB手记
- 【笔记】给Qt内嵌一个Chrome吧
- 【算法】最短路径之A*搜索
- qt入门必备
- 在 Qt4 中使用 C++11
- Hello Word ~ v0.2.2 背单词软件发布 -- By WHYPRO
- ubuntu下opencv和qt的安装配置
- linux下opengl的安装(with qt)
- qt 学习小节
- QT的命名风格
- QT 中的sleep
- QT 串口的监控
- 在VS2010下配置QT和ITK+VTK