Important: Please read the Qt Code of Conduct -

ResizeEvent is called indefintely when fitInView is called (QGraphicsScene)

  • I have this weird problem.

    I create my scene inside a QGraphicsView extended class like so:

    scene = new QGraphicsScene(this);

    However. This same class has reimplemented the resizeEvent Method according to documentation:

    void ConversationView::resizeEvent(QResizeEvent *e){
        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.

Log in to reply