方法一:通过代码的形式。
例如:
/*定义一个button_style的字符串,共定义了三组:按键初始状态、鼠标停留状态、鼠标按下状态。*/
QString button_style ="QPushButton{background-color:rgb(80,180,200);
color:white;border-radius:12px;border:2px groove gray;border-style:outset;}"\
"QPushButton:hover{background-color:white;color:black;}"\
"QPushButton:pressed{background-color:rgb(85,170,255);border-style:inset;}";
/*通过该语句实现按钮的风格设置。*/
ui->login_button->setStyleSheet(button_style);
方法二:通过右击对象-----》changed stylesheet:
在这个对话框中选择内容,但是选择的时候需要添加前缀(如border-style:),不能会出现invalid style sheet错误。