ResizeEvent is called indefintely when fitInView is called (QGraphicsScene)
Solved
General and Desktop
-
I have this weird problem.
I create my scene inside a QGraphicsView extended class like so:
scene = new QGraphicsScene(this); this->setScene(scene); this->setAlignment(Qt::AlignTop|Qt::AlignLeft); showRect.setCoords(0,0,sceneWidth,sceneHeight);
However. This same class has reimplemented the resizeEvent Method according to documentation:
void ConversationView::resizeEvent(QResizeEvent *e){ //Q_UNUSED(e); this->fitInView(showRect,Qt::KeepAspectRatioByExpanding); qWarning() << e->size(); }
Now I add a box the scene and nothing happens. But when I start resizing the window, there comes a point where I stop and the program hangs and I keep seing the sizing message, forever and ever with very very small variations on its size:
QSize(1342, 190) QSize(1356, 190) QSize(1342, 190) QSize(1356, 190)
Any ideas?
-
I figured out what the problem was. Instead of redefining the ConversationView's resize event (which extends from QGraphicsView), I redefined the containing Widget's resizeEvent (in this case a class based of a QDialog).
With the exact same parameters this made the problem go away.