Set the button status, default status, move the mouse over the status, click the status, use three pictures to indicate different statuses
ui->close->setStyleSheet("QPushButton{border-image: url(:/image/close.png);}" "QPushButton:hover{border-image: url(:/image/close2.png);}" "QPushButton:pressed{border-image: url(:/image/close2.png);}");
I am not very familiar with qss. I will record some of my favorite results first.
This is an effect of others' 360 interfaces. If you think it is good, write it down.
Tab style sheet
tab_widget->setStyleSheet("QTabWidget::pane{border: 0px;}""QTabWidget::tab-bar{alignment:center;}""QTabBar::tab{background:transparent; color:white; min-width:30ex; min-height:10ex;}""QTabBar::tab:hover{background:rgb(255, 255, 255, 100);}""QTabBar::tab:selected{border-color: white;background:white;color:green;}");
Button style sheet
ok_button->setStyleSheet("QPushButton{border:1px solid lightgray; background:rgb(230,230,230);}""QPushButton:hover{border-color:green; background:transparent;}");cancel_button->setStyleSheet("QPushButton{border:1px solid lightgray; background:rgb(230,230,230);}""QPushButton:hover{border-color:green; background:transparent;}");
The style of the "view 360 user privacy protection commitment" button above. The background is transparent and the font color is set.
look_privacy_button->setCursor(Qt::PointingHandCursor);look_privacy_button->setStyleSheet("color:rgb(0, 120, 230); background:transparent;");
Qgroupbox Style
tab1_group_box->setStyleSheet("QGroupBox::title{color:green;}");
This is a style of hovering the mouse over a button.
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);}");
Today, I wrote a qscrollbar style like QQ. Of course it's not as good as QQ.
edit->setStyleSheet("QScrollBar::vertical{background:transparent; width:8px; padding-top:3px; padding-bottom:3px; margin:0px 0px 0px 0px; border-radius:4px;}" "QScrollBar::vertical:hover{background:rgb(221, 220, 220);}" "QScrollBar::handle:vertical {background: rgb(197, 196, 196); width:8px; min-height:30px; margin: 2px 0px 2px 0px; border-radius:4px; border:none;}" "QScrollBar::handle:hover{background:rgb(110, 110, 110);}" "QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical{background:none;}" "QScrollBar::sub-line:vertical{background: url(:/down.png);}" "QScrollBar::add-line:vertical{background: url(:/up.png);}");
When adding an image to a button, there may be a border, and the effect is not good, you can set it like this
setStyleSheet("\ QToolButton{border:0px;}\ QToolButton::menu-button {image: url(none);}");
Then
pBtn->setIcon(objPixmap.copy((nPixWidth/4)*(state-1),0,nPixWidth/4,nPixHeight));