Results 1 to 4 of 4

Thread: QwtWidgetOverlay resize

  1. #1
    Join Date
    May 2012
    Posts
    136
    Thanks
    2
    Thanked 27 Times in 24 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default QwtWidgetOverlay resize

    At the moment im drawing a QwtPlotMarker in a QwtWidgetOverlay, but when the plot resizes it doesn't update the overlay.
    I tried to do an updateOverlay when the resize event gets triggered, but this ends up in a endless loop of resize events.
    For some reason the update also triggers a resize while being in a resize event, when I do a updateOverlay at some other moment the resize doesn't get triggered.

    Anyone know how to propery redraw the QwtWidgetOverlay when resizing the plot?

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

    Default Re: QwtWidgetOverlay resize

    QwtWidgetOverlay installs an event filter for its parent calling resize, whenever seeing a resize event for the parent ( a resize of the overlay automatically triggers an update ). So when the plot canvas is the parent of your overlay everything should work out of the box.

    If not I would start with debugging when the paintEvents/resizeEvents of the overlay are called.

    Uwe

  3. #3
    Join Date
    May 2012
    Posts
    136
    Thanks
    2
    Thanked 27 Times in 24 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QwtWidgetOverlay resize

    After some testing it looks like the mask of the widget doesn't get updated properly when doing a resize

    if I add this code to the resizeEvent it seems to end up in a endless loop (setVisible(true) triggers another resize)

    Qt Code:
    1. void QwtMovableMarker::resizeEvent(QResizeEvent *event)
    2. {
    3.  
    4. setVisible( false );
    5.  
    6. setMask( maskHint() );
    7.  
    8. setVisible( true );
    9.  
    10. }
    To copy to clipboard, switch view to plain text mode 

    In the source of qwt_widget_overlay.cpp it states that Qt does a total repaint when setting the mask while visible, I don't know if it is still the case
    when I remove the setVisible it works
    Last edited by StrikeByte; 24th September 2015 at 12:32.

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

    Default Re: QwtWidgetOverlay resize

    Your implementation of QwtMovableMarker::resizeEvent has one serious problem: it disables QwtWidgetOverlay::resizeEvent !
    If it was not done for debugging only it would explain missing updates, as it disables clearing of an internal cache.

    So first I would remove your resizeEvent and then have a look for the paintEvents. If you still need to overload resizeEvent it has to look like this:

    Qt Code:
    1. void QwtMovableMarker::resizeEvent(QResizeEvent *event)
    2. {
    3. ....
    4. QwtWidgetOverlay::resizeEvent( event );
    5. }
    To copy to clipboard, switch view to plain text mode 
    You could also have a look at the itemeditor example, that shows an implementation for QwtPlotShapeItem items.

    Uwe

Similar Threads

  1. Replies: 2
    Last Post: 13th June 2014, 14:19
  2. Replies: 2
    Last Post: 20th March 2014, 11:53
  3. Replies: 1
    Last Post: 29th December 2013, 19:06
  4. Replies: 3
    Last Post: 11th December 2011, 11:09
  5. Replies: 2
    Last Post: 22nd January 2008, 17:10

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.