qt qss按钮边款颜色设定为什么上面的和下面的边没变色
1个回答
展开全部
用enterEvent和leaveEvent头文件:<pre t="code" l="cpp">#include <QPushButton>
class MyButton : public QPushButton
{
Q_OBJECT
public:
MyButton(QWidget *parent = 0);
~MyButton(){return;}
protected:
virtual void enterEvent(QEvent* e);
virtual void leaveEvent(QEvent* e);
};源文件:<pre t="code" l="cpp">
MyButton::MyButton(QWidget* parent)
: QPushButton(parent)
{
setText("I am a button");
setFixedSize(100, 100);
setStyleSheet("QPushButton{background: yellow;}");
}
void MyButton::enterEvent(QEvent* e)
{
setStyleSheet("QPushButton{background: red;}");
}
void MyButton::leaveEvent(QEvent* e)
{
setStyleSheet("QPushButton{background: yellow;}");
}
class MyButton : public QPushButton
{
Q_OBJECT
public:
MyButton(QWidget *parent = 0);
~MyButton(){return;}
protected:
virtual void enterEvent(QEvent* e);
virtual void leaveEvent(QEvent* e);
};源文件:<pre t="code" l="cpp">
MyButton::MyButton(QWidget* parent)
: QPushButton(parent)
{
setText("I am a button");
setFixedSize(100, 100);
setStyleSheet("QPushButton{background: yellow;}");
}
void MyButton::enterEvent(QEvent* e)
{
setStyleSheet("QPushButton{background: red;}");
}
void MyButton::leaveEvent(QEvent* e)
{
setStyleSheet("QPushButton{background: yellow;}");
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询