1

I have a QGraphicsScene with many QGraphicsItem like circle, rectangle, polylines, arc etc.
Every QGraphicsItem has a name. And I have a Search feature which highlights searched items using that name. When scene contains fewer items, highlighted items are seen properly. But when scene contains many items ( 100 + ) then identifying the highlighted item becomes difficult. For that I need to scroll up - down or left - right to check where is that highlighted item is.

So I want my highlighted item to be easily recognizable.

For that I was suggested, some approach like

  • Take searched item in front
    Or
  • Add some marker

But I do not know, how to implement it , which Qt class should I use etc.

tushar
  • 313
  • 4
  • 10

1 Answers1

0

QGraphicsScene displays items depending on their stacking, i.e., when you call .items(), the first item in the QList is the topmost item on the scene.

The ordering of the items is depending on their respective Z-values which you can set for the QGraphicsItem by calling .setZValue()

You can read more about this on the following link: https://doc.qt.io/qt-5/qgraphicsitem.html#sorting

As for your question on how to put them in front. If you implemented your own children classes of QGraphicsItem, you can add a method or a slot to toggle them "on-top". E.g., all of the items usually have a Z-order of 0, so your method could just set it to 1 when the item is highlighted and revert it to 0 when it's not.

stribor14
  • 340
  • 2
  • 9