View Full Version : QwtWidgetOverlay resize
StrikeByte
23rd September 2015, 12:33
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?
Uwe
24th September 2015, 06:22
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
StrikeByte
24th September 2015, 11:09
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)
void QwtMovableMarker::resizeEvent(QResizeEvent *event)
{
setVisible( false );
setMask( maskHint() );
setVisible( true );
}
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
Uwe
25th September 2015, 07:29
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:
void QwtMovableMarker::resizeEvent(QResizeEvent *event)
{
....
QwtWidgetOverlay::resizeEvent( event );
}You could also have a look at the itemeditor example, that shows an implementation for QwtPlotShapeItem items.
Uwe
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.