How to set a QPalette::Window to a QGraphicsScene?



  • Hi guys,
    I'm trying to set this color rule QPalette::Window to be a background in a QGraphicsScene,
    but so far I dont be able to do it.
    I tried some the code bellow:

    QPalette p(palette());
        p.setBrush(Qt::Window);
        setPalette(p);
    /* --*/
    setPalette(QPalette(QPalette::Window));
    /*---*/
    QPalette p(palette());
        p.setColor(QPalette::Window,Qt::gray);
        scene()->setPalette(p);
    

    How i do this?


  • Moderators

    @Lays147
    i think setting it on the QGraphicsView would be more correct.
    Alternatively you can subclass QGraphicsView and reimplement QGraphicsView::drawBackground()



  • @Lays147

    If only you want changed background color for QGraphicsScene, then:

    scene()->setBackgroundBrush(palette().window());


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.