Results 1 to 3 of 3

Thread: Problem with CanvasPicker and WA_PaintOutsidePaintEvent

  1. #1
    Join Date
    Apr 2008
    Posts
    53
    Thanks
    10

    Default Problem with CanvasPicker and WA_PaintOutsidePaintEvent

    Hi,

    Currently my application repeatedly plots points to the canvas, and I need to be able to select one of the points while new points are still being plotted. This is fine when WA_PaintOutsidePaintEvent is set to false. However, when I set it to true:

    canvas()->setAttribute(WA_PaintOutsidePaintEvent, true);

    The QEvent::MouseButtonPress inside of the EventFilter in CanvasPicker does not get activated until the points stop plotting. Furthermore, the QEvent::MouseMove event still gets triggered even when the points are still plotting. Here is the EventFilter function:

    Qt Code:
    1. bool CanvasPicker::eventFilter(QObject *object, QEvent *e)
    2. {
    3.  
    4. if ( object != (QObject *)plot()->canvas() )
    5. return false;
    6.  
    7. switch(e->type())
    8. {
    9. case QEvent::FocusIn:
    10. showCursor(true);
    11. case QEvent::FocusOut:
    12. showCursor(false);
    13.  
    14. case QEvent::Paint:
    15. {
    16. QApplication::postEvent(this, new QEvent(QEvent::User));
    17. break;
    18. }
    19. case QEvent::MouseButtonPress:
    20. {
    21. // Only capture left click
    22. if (((QMouseEvent *)e)->button() == (Qt::LeftButton))
    23. {
    24. select(((QMouseEvent *)e)->pos(), ((QMouseEvent *)e)->globalPos());
    25. return true;
    26. }
    27. }
    28. // Gets called each time mouse is moved on canvas
    29. case QEvent::MouseMove:
    30. {
    31. return true;
    32. }
    33.  
    34. default:
    35. break;
    36. }
    37. return QObject::eventFilter(object, e);
    38. }
    To copy to clipboard, switch view to plain text mode 

    Can somebody please tell me how to get around this problem? (So I want to set WA_PaintOutsidePaintEvent true and have QEvent::MouseButtonPress get triggered while points are continuously plotting on the graph) Thank you.

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem with CanvasPicker and WA_PaintOutsidePaintEvent

    With WA_PaintOutsidePaintEvent QwtPlotCurve::draw() really paints the points - without the flag it only posts a dummy paint event. That's why you won't return to the main event loop until all points are painted.

    This could explain why you don't get any MouseButtonPress events until all points are done. If true you could split your points into smaller chunks and call QApplication::processEvents manually in between.

    But you also wouldn't get any MouseMove events - so my guess might be wrong.

    Uwe

    PS: WA_PaintOutsidePaintEvent is platform specific attribute. So be careful if you want to use it on platforms beside X11.

  3. #3
    Join Date
    Apr 2008
    Posts
    53
    Thanks
    10

    Default Re: Problem with CanvasPicker and WA_PaintOutsidePaintEvent

    Thanks for responding Uwe,

    Yeah I'm still not sure what the problem is. It might be because I'm using the plot panner with left mouse button, so that's getting captured but this mouseevent is not.

    Anyways I decided to work around this issue by using MouseMove to pop-up a small dialog window when the mouse is hovering over a point. Then I added a pushbutton on the hover dialog window.

    Thanks

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.