setStyleSheet 設置的一些集合,一部分源碼和截圖來自
http://blog.sina.com.cn/s/articlelist_2801495241_0_1.html
1. 設置QLabel字體顏色
version_title->setStyleSheet("color:white;");
2.設置button透明
medal_button->setStyleSheet("background:transparent;");
3.設置QSplitter背景
main_splitter->setStyleSheet("QSplitter::handle{background:lightgray;}");
4.設置button圓弧大小,背景顏色,字體顏色,鼠標放到按鍵上的背景顏色。
power_button->setStyleSheet("QPushButton{border-radius:20px; background:rgb(110, 190, 10); color:white;}"
"QPushButton:hover{background:rgb(140, 220, 35);}");
按鍵設置http://blog.csdn.net/xj626852095/article/details/10430653
5.設置button的背景圖片
login_button->setStyleSheet("QPushButton{color:green; border-image:url(:/contentWidget/login);}"
"QPushButton:hover{color:rgb(110, 190, 10);}");
6.顏色設置 和 透明設置
register_button->setStyleSheet("color:rgb(0, 120, 230); background:transparent;");
7.設置QToolButton背景透明,鼠標指到時顯現背景,圓角5px,邊界線1px
recovery_button = new QToolButton();
recovery_button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
QPixmap recovery_pixmap(":/contentWidget/recovery");
recovery_button->setIcon(recovery_pixmap);
recovery_button->setIconSize(recovery_pixmap.size());
recovery_button->setFixedSize(recovery_pixmap.width()+50, recovery_pixmap.height()+35);
recovery_button->setStyleSheet("QToolButton{background:transparent;}"
"QToolButton:hover{border-radius:5px; border:1px solid rgb(210, 225, 230);}");
8.QTabWidget 設置
tab_widget->setStyleSheet("QTabWidget::pane{border: 1px;}"
"QTabWidget::tab-bar{alignment:center;}"
"QTabBar::tab{background:transparent;color:white; min-width:10ex; min-height:5ex; }"
"QTabBar::tab:hover{background:rgb(255, 255, 255, 100);}"
"QTabBar::tab:selected{border-color: white;background:white;color:green;}");
9.QLineEdit 輸入框的的設置
this->setStyleSheet("QLineEdit{border-width: 1px; border-radius: 4px; font-size:12px; color: black; border:1px solid gray;}"
"QLineEdit:hover{border-width: 1px; border-radius: 4px; font-size:12px; color: black; border:1px solid rgb(70, 200, 50);}");