Forcing QGraphicsWidget::setGeometry to execute....?
-
Hi all,
I'm trying to figure out how to force
QGraphicsWidget::setGeometryto fully execute - even when I'm passing in a geometry that is exactly the same as the current geometry for that widget.In my code I have a section that calls
QGraphicsWidget::resize(width, height);
Which then internally callsQGraphicsWidget::setGeometry(width, height)
Sometimes users come across a corner case where large parts of the GUI has changed and been redrawn, but this specific part has the same geometry, thus internally theQGraphicsWidget::setGeometrycall early outs, based on the following code from qgraphicswidget.cpp Ln. 344if (newGeom == d->geom) return;However the rest of my code depends on signals that are emitted from within the setGeometry function,
and in this edge case, parts of my GUI don't get drawn in correctly.So my question is:
Is there a easy / cheap way to force the internal setGeometry function to fully execute?
I've tried the followingmGraphicsWidget->layout()->setInstantInvalidatePropagation(true); mGraphicsWidget->layout()->invalidate();But it doesn't do what I need.
Doing a...mGraphicsWidget->resize(0, 0);Prior to the resize, DOES work, but it seems like an unnecessary duplication of work?
Is there a faster, more effective way of modifying the internal state of the QGraphicsWidget,
( ie. theQGraphicsLayoutItemPrivate d->geomthat will allow the actual setGeometry to fully execute?)Cheers,
James -
I've also discovered that
~mGraphicsWidget->adjustSize();
has the desired effect, But i see that internally this is just doing a setGeometry() with the preferred size for this object - so we are still doing a 2 setGeometry() calls :( -
Hi all,
I'm trying to figure out how to force
QGraphicsWidget::setGeometryto fully execute - even when I'm passing in a geometry that is exactly the same as the current geometry for that widget.In my code I have a section that calls
QGraphicsWidget::resize(width, height);
Which then internally callsQGraphicsWidget::setGeometry(width, height)
Sometimes users come across a corner case where large parts of the GUI has changed and been redrawn, but this specific part has the same geometry, thus internally theQGraphicsWidget::setGeometrycall early outs, based on the following code from qgraphicswidget.cpp Ln. 344if (newGeom == d->geom) return;However the rest of my code depends on signals that are emitted from within the setGeometry function,
and in this edge case, parts of my GUI don't get drawn in correctly.So my question is:
Is there a easy / cheap way to force the internal setGeometry function to fully execute?
I've tried the followingmGraphicsWidget->layout()->setInstantInvalidatePropagation(true); mGraphicsWidget->layout()->invalidate();But it doesn't do what I need.
Doing a...mGraphicsWidget->resize(0, 0);Prior to the resize, DOES work, but it seems like an unnecessary duplication of work?
Is there a faster, more effective way of modifying the internal state of the QGraphicsWidget,
( ie. theQGraphicsLayoutItemPrivate d->geomthat will allow the actual setGeometry to fully execute?)Cheers,
James@Jammin44fm said in Forcing QGraphicsWidget::setGeometry to execute....?:
if (newGeom == d->geom)
return;Given this I assume you need to have a changed geometry. Use an
adjustSize()or temporarily set its geometry to 1 more or less than it should be and set it back. Or change whatever in your code so that it does not need asetGeometrysignal where it has not actually changed. -
Hi all,
I'm trying to figure out how to force
QGraphicsWidget::setGeometryto fully execute - even when I'm passing in a geometry that is exactly the same as the current geometry for that widget.In my code I have a section that calls
QGraphicsWidget::resize(width, height);
Which then internally callsQGraphicsWidget::setGeometry(width, height)
Sometimes users come across a corner case where large parts of the GUI has changed and been redrawn, but this specific part has the same geometry, thus internally theQGraphicsWidget::setGeometrycall early outs, based on the following code from qgraphicswidget.cpp Ln. 344if (newGeom == d->geom) return;However the rest of my code depends on signals that are emitted from within the setGeometry function,
and in this edge case, parts of my GUI don't get drawn in correctly.So my question is:
Is there a easy / cheap way to force the internal setGeometry function to fully execute?
I've tried the followingmGraphicsWidget->layout()->setInstantInvalidatePropagation(true); mGraphicsWidget->layout()->invalidate();But it doesn't do what I need.
Doing a...mGraphicsWidget->resize(0, 0);Prior to the resize, DOES work, but it seems like an unnecessary duplication of work?
Is there a faster, more effective way of modifying the internal state of the QGraphicsWidget,
( ie. theQGraphicsLayoutItemPrivate d->geomthat will allow the actual setGeometry to fully execute?)Cheers,
James@Jammin44fm said in Forcing QGraphicsWidget::setGeometry to execute....?:
Is there a easy / cheap way to force the internal setGeometry function to fully execute?
Forcing a complete re-draw with new geometry is never "cheap" or efficient. That would also require
prepareGeometryChange()to be called, so the view/scene knows what is going to happen next.
MostQGraphicsItemsinvalidate their boundingRect in this case and re-create it on nextpaint()with updated geometry and matching content.