天天看点

怎样通过QSS设置ICON

在网上找了许久,也测试了不少的方法,终于找到可以设置QPushButton ICON的方法。很完美的将图标设置到左边。

#CUserWidget #teacherPbt{

    qproperty-icon: url(data/images/userMangaer/teacher.png);

}

怎样通过QSS设置ICON

最终实现方式为:

#CUserWidget #teacherPbt{

    qproperty-icon: url(data/images/userMangaer/teacher.png) off, url(data/images/userMangaer/teacher-focus.png) on;

    qproperty-iconSize: 20px 20px;

}

可以实现图标的变换。

曾通过这种方法:

    image:url(data/images/userMangaer/teacher.png);

    image-position:0px left;

进行过修改,不过太麻烦了。

继续阅读