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. How to set a QPalette::Window to a QGraphicsScene?
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
qgraphicssceneqpalette
3 Posts 3 Posters 1.5k Views
  • 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.
  • L Offline
    L Offline
    Lays147
    wrote on 20 Jan 2016, 21:53 last edited by
    #1

    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?

    Lays Rodrigues
    Newby on Qt - Learning always!
    Using QT 5.7
    ArchLinux

    R D 2 Replies Last reply 21 Jan 2016, 07:00
    0
    • L Lays147
      20 Jan 2016, 21:53

      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?

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 21 Jan 2016, 07:00 last edited by
      #2

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

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • L Lays147
        20 Jan 2016, 21:53

        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?

        D Offline
        D Offline
        Devopia53
        wrote on 21 Jan 2016, 07:46 last edited by
        #3

        @Lays147

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

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

        1 Reply Last reply
        0

        2/3

        21 Jan 2016, 07:00

        • Login

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