【问题标题】:Is there way to make QPushButton background transparent, but adding icon?有没有办法让 QPushButton 背景透明,但添加图标?
【发布时间】:2021-05-18 17:20:55
【问题描述】:

是否可以让按钮的背景透明,但同时添加一个图标?

据我所知,我应该使用:

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

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

【问题讨论】:

    标签: qt user-interface qpushbutton qt6


    【解决方案1】:

    可以使用 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);
    

    【讨论】:

      猜你喜欢
      • 2018-05-31
      • 1970-01-01
      • 2011-01-28
      • 1970-01-01
      • 1970-01-01
      • 2014-10-10
      • 1970-01-01
      • 1970-01-01
      • 2014-11-25
      相关资源
      最近更新 更多