PDA

View Full Version : How to draw a QPainter rectangle over Widgets



sureshdharmadurai
24th November 2011, 07:04
I am creating a custom widget using Qlabels. In this widget I have Qlabels created one over the other like a stack. I need to draw a vertical rectangle on top of the Labels. I used QPainter drawRect() function for drawing this rectangle. But the rectangle is coming in the background of the labels and not on the top of it.
Please see the attachment for details.

In this image the red lines are labels and each labels perform some operation as per code ,and the two vertical lines in the middle are rectangles drawn using QPainter which is coming in the background of the labels. I want the rectangles to draw on top of the labels.

Spitfire
24th November 2011, 10:17
Where you're drawing the rectangle?
I'm guessing that in the parent paintEvent?
Then what you'll draw will always be behind the labels (in the background) as children are drawn after the parent.