Change QPushButton Icon on hover and pressed

后端 未结 5 1538
攒了一身酷
攒了一身酷 2021-02-10 02:34

I\'m trying to change the Icon of a QpushButton on hover and pressed, I\'m using QtDesigner with stylesheets. I tried this

QpushButton{
       qproperty-icon:ur         


        
5条回答
  •  春和景丽
    2021-02-10 03:17

    I maked it in designer, from ui_...h file:

    QIcon icon;
    icon.addFile(QStringLiteral(":/unpressed.png"), QSize(), QIcon::Normal, QIcon::Off);
    icon.addFile(QStringLiteral(":/pressed.png"), QSize(), QIcon::Normal, QIcon::On);
    pushButton->setIcon(icon);
    

提交回复
热议问题