Using the following code as the event filter:
qDebug()<<"Object:"<< o <<"Event: "<<e->type();
//process resize event of needed widget
if (o
== calendarview
&& e
->type
() == QEvent::Resize) { qDebug()<<"Should fire fitInView...";
//rescale the scene to fit the view
calendarscene->views().first()->fitInView(calendarscene->sceneRect(),Qt::KeepAspectRatio);
return true;
}
}
bool DialogScene::eventFilter(QObject *o, QEvent *e) {
qDebug()<<"Object:"<< o <<"Event: "<<e->type();
//process resize event of needed widget
if (o == calendarview && e->type() == QEvent::Resize) {
qDebug()<<"Should fire fitInView...";
//rescale the scene to fit the view
calendarscene->views().first()->fitInView(calendarscene->sceneRect(),Qt::KeepAspectRatio);
return true;
}
return QMainWindow::eventFilter(o, e);
}
To copy to clipboard, switch view to plain text mode
I get the following results:
When I drag the window larger in any of the ways that will make the scene resize, the event firing sequence is as follows:
Should fire fitInView...
Object
: QGraphicsView(0xe42f10, name
= "calendarview") Event
: 43 //fitInView happens hereShould fire fitInView...
Object
: QGraphicsView(0xe42f10, name
= "calendarview") Event
: 43 //fitInView happens here
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 14
Should fire fitInView...
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 12
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 43 //fitInView happens here
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 43
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 43
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 43
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 43
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 43
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 14
Should fire fitInView...
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 12
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 43 //fitInView happens here
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 43
To copy to clipboard, switch view to plain text mode
QEvent::Resize -> QEvent::Paint -> QEvent::MetaCall -> QEvent::MetaCall ...
The meta call happens over and over as I drag the boundries of the window. Commenting out the fitInView command causes the QEvent::MetaCall to not fire, so I assume QEvent::MetaCall is analogous to the fitInView command happening.
When the glitch happens as seen in the picture, dragging the window boundaries produces the following events:
Should fire fitInView...
Should fire fitInView...
Should fire fitInView...
Should fire fitInView...
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 14
Should fire fitInView...
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 12
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 14
Should fire fitInView...
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 12
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 14
Should fire fitInView...
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 12
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 14
Should fire fitInView...
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 12
To copy to clipboard, switch view to plain text mode
QEvent::Resize > QEvent::Paint > QEvent::Resize > QEvent::Paint... (over and over as I drag)
however as soon as I drag the window small enough to where the glitched area hits the edge of the view, then I get the following event sequence:
Should fire fitInView...
Object
: QGraphicsView(0xe42f10, name
= "calendarview") Event
: 43 //fitInView happens hereShould fire fitInView...
Object
: QGraphicsView(0xe42f10, name
= "calendarview") Event
: 43 //fitInView happens here
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 14
Should fire fitInView...
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 12
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 76
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 43 //fitInView happens here
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 43
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 43
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 43
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 12
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 14
Should fire fitInView...
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 12
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 43 //fitInView happens here
Object: QGraphicsView(0xe42f10, name = "calendarview") Event: 43
To copy to clipboard, switch view to plain text mode
QEvent::LayoutRequest > QEvent::Resize -> QEvent::Paint -> QEvent::MetaCall ...
so it seems that if I drag the window too far, then the QEvent::MetaCall AKA fitInView stops working, but as soon as it gets smaller and the QEvent::LayoutRequest fires, then everything returns to its proper operation.
It is also strange that the fitInView will not fire after its resized both vertical and horizontal at the same time, because the events show that the QEvent::Resize is triggering, and that the object that triggered it was "calendarview" so, there should be no reason why the if() statement does not evaluate to true and allow the fitInView command to work.
Bookmarks