Results 1 to 8 of 8

Thread: Dymamic Painting outside paintEvent on mouse movement in QT4

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2009
    Posts
    5
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Dymamic Painting outside paintEvent on mouse movement in QT4

    Hi Every body ,

    I am porting my application fron QT3.3 to QT4.5. In my application all the paintings are done on viewport widget of QScrollView(Q3ScrollView in support class). In this application virtual function paintEvent is not implemented. I am trying to port this code to QT4.5 which require all the paintings done in paintEvent function. For the time being i don't want to change my code much so i am using : Qt::WA_PaintOutsidePaintEvent flag. I running my application on Linux but some how this flag is showing expected effect.

    Following is pseudo code :

    Qt Code:
    1. QucsView::QucsView(QWidget *parent) : Q3ScrollView(parent) // Constructor
    2. {
    3. setVScrollBarMode(Q3ScrollView::AlwaysOn);
    4. setHScrollBarMode(Q3ScrollView::AlwaysOn);
    5. viewport()->setPaletteBackgroundColor(QucsSettings.BGColor);
    6. viewport()->setMouseTracking(true);
    7. viewport()->setAttribute(Qt::WA_PaintOutsidePaintEvent, true);
    8. }
    9.  
    10. void QucsView::MMoveWire2(QMouseEvent *Event) // Called on movement of mouse
    11. // Basically drawing a line on mouse movement
    12. {
    13. setAttribute(Qt::WA_PaintOutsidePaintEvent, true);
    14. QPainter painter(viewport());
    15. painter.setPen(Qt::DotLine);
    16. painter.setCompositionMode(QPainter::RasterOp_NotSource);
    17. painter.drawLine(----);
    18. }
    To copy to clipboard, switch view to plain text mode 
    When i run this it give warning like
    QPainter::setPen: Painter not active and it don't draw as expected....

    This code is working completely fine with QT3.3 except PaintOutsidePaintEvent flag.

    Any ideas what might be wrong here. I will be thankful for ur help

    thx
    shivam
    Last edited by wysota; 7th June 2009 at 00:59. Reason: missing [code] tags

Similar Threads

  1. Mouse movement problem in QGraphicsView
    By zgulser in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2009, 07:01
  2. painting a widget outside a paintEvent
    By jayw710 in forum Qt Programming
    Replies: 1
    Last Post: 25th June 2007, 23:18
  3. Game mouse movement
    By chaosgeorge in forum Qt Programming
    Replies: 1
    Last Post: 2nd December 2006, 23:41
  4. setCanvas blocks mouse movement on QtCanvasView
    By YuriyRusinov in forum Qt Programming
    Replies: 8
    Last Post: 20th April 2006, 07:38

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.