有没有办法使 QPushButton 背景透明,但添加图标?

Is there way to make QPushButton background transparent, but adding icon?

可不可以把按钮的背景做成透明的,同时加个图标?

据我所知,我应该使用:

button -> setStyleSheet("background-color: rgba(255, 255, 255, 0); ");

它工作正常,但我也想添加一个图标。我有一个漂亮的 window 背景,想通过我的按钮看到它,但按钮应该有图标 - 黑色箭头。

可以使用 Qt 6 C++。我找到了一种方法:

QPixmap buttonImage("/*path*/");
QIcon buttonIcon(buttonImage);
// make the button transparent
button->setStyleSheet("background-color: rgba(255, 255, 255, 0); ");
// add icon
button->setIcon(buttonIcon);