[Bug?] QGraphicsWidget, transparent background, stylesheet

  • What I want is a half-transparent QGraphicsWidget with rounded borders.
    I'm trying to achieve this by setting background-color and border-radius in the widgets stylesheet.

    But what happens is that the background is drawn TWICE, once inside the rounded borders and once all over the boundingRect of the corresponding graphics-proxy-item.

    Here is a simple example (tested with Qt 4.7.3 on win7-32bit):
    #include <QtGui/QApplication>
    #include <QGraphicsView>
    #include <QGraphicsScene>
    #include <QPushButton>

    int main(int argc, char *argv[])
    QApplication a(argc, argv);
    QGraphicsView view;
    QGraphicsScene scene(0, 0, 400, 100);

    QPushButton w("just a button");
    w.setGeometry(0, 0, 400, 100);
    a.setStyleSheet("QPushButton {background-color:rgba(0,0,0,127);border-radius:50px}");
    return a.exec&#40;&#41;;


    I searched around and tried a lot of things (e.g. manipulating the widgets palette), but nothing worked.
    I would really like to know if this is a problem with Qt, or if I'm just doing something wrong...

Log in to reply