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. Make QGraphicsItem cover items under it
QtWS25 Last Chance

Make QGraphicsItem cover items under it

Scheduled Pinned Locked Moved Solved General and Desktop
graphicsviewqgraphicsitemqgraphicsscenebackground
6 Posts 2 Posters 1.2k 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.
  • M Offline
    M Offline
    mbise1993
    wrote on 18 Feb 2019, 05:03 last edited by mbise1993
    #1

    I'm working with the graphics view framework on a project and I've run into a problem where I'm adding a QGraphicsRectItem to a scene and setting its brush, but the item under it is still visible. I've tried setting the Z value, but the items aren't exactly siblings so it has no effect. The hierarchy is:

    Measure
        - Line
        - Beat
            - Note
    

    I'm trying to make the note cover the line that it is on. As you can see in the screenshot, the line is still visible over the red background of the note. Anyone have any ideas?
    0_1550466061464_Screen Shot 2019-02-17 at 11.53.44 PM.png

    J 1 Reply Last reply 18 Feb 2019, 05:31
    0
    • M mbise1993
      18 Feb 2019, 05:03

      I'm working with the graphics view framework on a project and I've run into a problem where I'm adding a QGraphicsRectItem to a scene and setting its brush, but the item under it is still visible. I've tried setting the Z value, but the items aren't exactly siblings so it has no effect. The hierarchy is:

      Measure
          - Line
          - Beat
              - Note
      

      I'm trying to make the note cover the line that it is on. As you can see in the screenshot, the line is still visible over the red background of the note. Anyone have any ideas?
      0_1550466061464_Screen Shot 2019-02-17 at 11.53.44 PM.png

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 18 Feb 2019, 05:31 last edited by
      #2

      @mbise1993 Did you try to set opacity https://doc.qt.io/qt-5/qgraphicsitem.html#setOpacity ?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply 18 Feb 2019, 05:51
      0
      • J jsulm
        18 Feb 2019, 05:31

        @mbise1993 Did you try to set opacity https://doc.qt.io/qt-5/qgraphicsitem.html#setOpacity ?

        M Offline
        M Offline
        mbise1993
        wrote on 18 Feb 2019, 05:51 last edited by
        #3

        @jsulm I just tried setting the opacity on the note item to 1.0, but it didn't help.

        J 1 Reply Last reply 18 Feb 2019, 05:54
        0
        • M mbise1993
          18 Feb 2019, 05:51

          @jsulm I just tried setting the opacity on the note item to 1.0, but it didn't help.

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 18 Feb 2019, 05:54 last edited by
          #4

          @mbise1993 Try to set ItemIgnoresParentOpacity via https://doc.qt.io/qt-5/qgraphicsitem.html#setFlags

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          M 1 Reply Last reply 18 Feb 2019, 07:29
          0
          • J jsulm
            18 Feb 2019, 05:54

            @mbise1993 Try to set ItemIgnoresParentOpacity via https://doc.qt.io/qt-5/qgraphicsitem.html#setFlags

            M Offline
            M Offline
            mbise1993
            wrote on 18 Feb 2019, 07:29 last edited by
            #5

            @jsulm Unfortunately, that wasn't it either.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mbise1993
              wrote on 18 Feb 2019, 17:41 last edited by
              #6

              I found the problem. I was drawing the beats before the lines, so the lines took precedent over the beats since they are siblings. The solution was to either draw the beats last or set the Z value on the beat, not the note.

              1 Reply Last reply
              1

              4/6

              18 Feb 2019, 05:54

              • Login

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