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. what is the best way to distinguish the a single QGraphicsItem Visually from other QGraphicsitems in the QGraphicsView

what is the best way to distinguish the a single QGraphicsItem Visually from other QGraphicsitems in the QGraphicsView

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 2 Posters 2.0k 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by Qt Enthusiast
    #1

    On continuation of this topic
    What is the best way to distinguish he a single QGraphicsItem from other QGraphicsitems in the QGraphicsView

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Asperamanca
      wrote on last edited by
      #2

      Depends on what you want to distinguish (e.g. just item type? or item identity?), and for what use case.

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        Qt Enthusiast
        wrote on last edited by
        #3

        A rectangle from rest of other rectangles ?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Asperamanca
          wrote on last edited by
          #4

          Ok, let's say you have 10 QGraphicsRectItem instances in your scene, and you want to remember one of them.
          If it's sufficient to remember it during the life time of the scene, the pointer works fine. It's unique, and it doesn't change as you change the position, color and other aspects of the rectangle.

          However, it really depends on what you want to do with it. For example, the pointers work fine if you want to save and restore item selection. Say, the user has selected 3 rectangles, and wants to save this selection for sometimes later. You can save the three pointers. In this case, you need to remember that an item might have been deleted, so you have to take care of that case without crashing your application.

          But that's just one example. If you describe in more detail what you try to achieve, we can discuss more specifically suited approaches.

          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            Qt Enthusiast
            wrote on last edited by
            #5

            I want to differentiate graphically and visually one rectangle from others , I cannot use colors and styles to differentiate

            A 1 Reply Last reply
            0
            • Q Qt Enthusiast

              I want to differentiate graphically and visually one rectangle from others , I cannot use colors and styles to differentiate

              A Offline
              A Offline
              Asperamanca
              wrote on last edited by
              #6

              @Qt-Enthusiast said in what is the best way to distinguish the a single QGraphicsItem Visually from other QGraphicsitems in the QGraphicsView:

              I want to differentiate graphically and visually one rectangle from others , I cannot use colors and styles to differentiate

              What output do you want? For example, do you just want to know "Rectangle A looks different than Rectangle B", or do you want detailed information on what is different? Or do you want to have a difference image showing how exactly the rectangles differ?
              And what do you mean by "I cannot use colors and styles to differentiate"?

              1 Reply Last reply
              0
              • Q Offline
                Q Offline
                Qt Enthusiast
                wrote on last edited by
                #7

                @Asperamanca said in what is the best way to distinguish the a single QGraphicsItem Visually from other QGraphicsitems in the QGraphicsView:

                What output do you want? For example, do you just want to know "Rectangle A looks different than Rectangle B", or do you want detailed information on what is different? Or do you want to have a difference image showing how exactly the rectangles differ?

                I have 10 rectangles out of which I want one rectangle to stand apart from others

                I cannot make one rectangles as color blue and rest as red . I cannot use styles to differentiate between the rectangles

                A 1 Reply Last reply
                0
                • Q Offline
                  Q Offline
                  Qt Enthusiast
                  wrote on last edited by
                  #8

                  how to use QGraphicsPixmapItem for this ?

                  1 Reply Last reply
                  0
                  • Q Qt Enthusiast

                    @Asperamanca said in what is the best way to distinguish the a single QGraphicsItem Visually from other QGraphicsitems in the QGraphicsView:

                    What output do you want? For example, do you just want to know "Rectangle A looks different than Rectangle B", or do you want detailed information on what is different? Or do you want to have a difference image showing how exactly the rectangles differ?

                    I have 10 rectangles out of which I want one rectangle to stand apart from others

                    I cannot make one rectangles as color blue and rest as red . I cannot use styles to differentiate between the rectangles

                    A Offline
                    A Offline
                    Asperamanca
                    wrote on last edited by
                    #9

                    @Qt-Enthusiast said in what is the best way to distinguish the a single QGraphicsItem Visually from other QGraphicsitems in the QGraphicsView:

                    @Asperamanca said in what is the best way to distinguish the a single QGraphicsItem Visually from other QGraphicsitems in the QGraphicsView:

                    What output do you want? For example, do you just want to know "Rectangle A looks different than Rectangle B", or do you want detailed information on what is different? Or do you want to have a difference image showing how exactly the rectangles differ?

                    I have 10 rectangles out of which I want one rectangle to stand apart from others

                    I cannot make one rectangles as color blue and rest as red . I cannot use styles to differentiate between the rectangles

                    I think I misunderstood your original intentions then. If you say, you want one rectangle to stand apart, that sound like you want to highlight certain items, for example like when you select a file in a file explorer.

                    One approach I use is to create a child element to the element I want to highlight, and remove it once I don't want the highlight anymore.
                    There are several possibilities on how to use it, depending on what visual effect you want:

                    • You could make the child item like a small marker in one corner of your rectangle
                    • You could make the child item semi-transparent and put it on top of the rectangle
                    • You could make the child item larger than the rectangle, and put it behind the rectangle in z order (you need to set the flag QGraphicsItem::ItemStacksBehindParent on the child item to achieve this effect)
                    1 Reply Last reply
                    0
                    • Q Offline
                      Q Offline
                      Qt Enthusiast
                      wrote on last edited by
                      #10

                      sample code will be helpful

                      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