Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Bug?] QGraphicsWidget, transparent background, stylesheet
Qt 6.11 is out! See what's new in the release blog

[Bug?] QGraphicsWidget, transparent background, stylesheet

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 3.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wolfgang p.
    wrote on last edited by
    #1

    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);

    view.setScene(&scene;);
    QPushButton w("just a button");
    w.setGeometry(0, 0, 400, 100);
    a.setStyleSheet("QPushButton {background-color:rgba(0,0,0,127);border-radius:50px}");
    scene.addWidget(&w);
    
    view.show();
    
    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...

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved