QT,我在自定义一个按钮的时候出现了一个问题,就是我想创建一个设计师界面类,继承与Qpushbutton,类名叫btn
btn::btn(QWidget *parent) :
QPushButton(parent),
ui(new Ui::btn)
{
ui->setupUi(this);
ui->pushButton->setStyleSheet("QPushButton{background-color: rgb(225, 225, 225);border:2px groove gray;border-radius:10px;padding:2px 4px;border-style: outset;}"
"QPushButton:hover{background-color:rgb(229, 241, 251); color: black;}"
"QPushButton:pressed{background-color:rgb(204, 228, 247);border-style: inset;}");
}
ui->pushButton是我在设计师界面拖的一个控件,然后我在主窗口,拖了一个按钮,然后提升为btn,但是我发现我的这个btn并没有改变样式,但是如果在btn的cpp中的ui->pushbutton,改成this->pushbutton,主界面的按钮就改变样式了,请问这两者写法有什么区别吗?