Results 1 to 2 of 2

Thread: How to draw a QPainter rectangle over Widgets

  1. #1

    Lightbulb How to draw a QPainter rectangle over Widgets

    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.
    Attached Images Attached Images

  2. #2
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to draw a QPainter rectangle over Widgets

    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.

  3. The following user says thank you to Spitfire for this useful post:

    shoyeb (9th December 2011)

Similar Threads

  1. right click QPainter rectangle?
    By mattyev87 in forum Newbie
    Replies: 6
    Last Post: 27th January 2011, 13:22
  2. How to draw rectangle with moveable edge
    By sagirahmed in forum Qt Programming
    Replies: 4
    Last Post: 2nd July 2010, 06:21
  3. How to draw fast rectangle/triangle/circle
    By nileshsince1980 in forum Qt Programming
    Replies: 1
    Last Post: 11th November 2008, 11:40
  4. how to draw columns in QPainter's rectangle
    By jyoti in forum Qt Programming
    Replies: 1
    Last Post: 24th August 2007, 10:50
  5. Draw a rectangle alternating two colors with qPainter
    By SkripT in forum Qt Programming
    Replies: 12
    Last Post: 24th January 2006, 23:12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.