Results 1 to 11 of 11

Thread: how to draw a line over a frame?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2011
    Posts
    81
    Qt products
    Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default how to draw a line over a frame?

    in my progrm i am using 4frames(UI). I use show/hide frames using buttons. I have two draw a line in the 3rd frame. I have used the code
    Qt Code:
    1. void MainWindow::paintEvent(QPaintEvent *e)
    2. {
    3. QPainter painter(this);
    4. QPen linepen(Qt::red);
    5. linepen.setWidth(25);
    6. linepen.setCapStyle(Qt::RoundCap);
    7. painter.setRenderHint(QPainter::Antialiasing,true);
    8. painter.setPen(linepen);
    9. painter.drawLine(point,point2);
    10. }
    To copy to clipboard, switch view to plain text mode 



    since i have used the painter(this) the drawing is done on the main window so i cannot see the line on the frame. since frames(with background images) are placed over the main window.


    Now i try to use painter(ui->frame3)

    But it doesn't work. pls help me, thanks in advance
    Last edited by wysota; 17th August 2011 at 22:41. Reason: missing [code] tags

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanked 342 Times in 324 Posts

    Default Re: how to draw a line over a frame?

    Asked here already. What part of the sample code you don't understand ?

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: how to draw a line over a frame?

    The (default) painting of the child will happen after the painting of the parent. If you override the paint event of the parent then why do you expect that the painting behaviour of a child widget will be changed? You want to override the paint event of the child widget.
    "We can't solve problems by using the same kind of thinking we used when we created them." -- Einstein
    If you are posting code then please use [code] [/code] tags around it - makes addressing the problem easier.

Similar Threads

  1. To draw a circle on a frame when the key is pressed
    By soumya in forum Qt Programming
    Replies: 18
    Last Post: 9th February 2010, 10:21
  2. How to draw a widget directly on the frame buffer
    By kapoorsudhish in forum Qt Programming
    Replies: 8
    Last Post: 12th November 2009, 06:59
  3. how to draw a circle on a frame in Qt-4
    By grsandeep85 in forum Qt Programming
    Replies: 1
    Last Post: 16th September 2009, 08:05
  4. How do draw a frame in QListView?
    By someralex in forum Qt Programming
    Replies: 24
    Last Post: 21st December 2006, 11:56

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
  •  
Qt is a trademark of The Qt Company.