V
V
Vitaly2014-04-02 21:56:38
Qt
Vitaly, 2014-04-02 21:56:38

How to draw a QGraphicsRectItem with a hole?

Hello, I have a little question: I
have a giant QGraphicsRectItem rectangle stretched to the width of a QGraphicsScene.
How can I subtract another rectangle from it so that a transparent window is obtained in a large one, something like this: It is
square_hole.png
possible to draw in parts, something like this:
square_hole_parts.png
but this is not optimal - we draw four shapes, and in the first case two, the second of which is subtractive.
But although there is another option to draw such a polynomial to create the feeling of a square with a hole, but then there will be one single figure:
square_hole_polynom.png
But also not optimal, there will be too many numbers to change the size and position of the hole window.
Is it possible to implement the first option by standard means? (Qt 4.8)
Although the third option is more or less suitable, but if you add a function for comfortable resizing.
Why do I need it?
I am creating a game level editor, the level map is divided into sections isolated from each other, but the game is designed so that all sections are placed in a single coordinate space.
I want to make it so that when the section switch changes, the window-hole moves and covers the section I need, simultaneously with changing the camera position on the coordinate plane. The camera position has already been implemented, but I can’t find a holey square anywhere yet.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
xseven, 2014-04-08
@Wohlstand

Yes you can qpolygon substract

X
xandox, 2014-04-03
@xandox

Draw the big one first, then the smaller one with a different color

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question