I think the best example is the Qt Demo application.
Take a look at this:
{
this->resetMatrix();
this->scale(event->size().width() / 800.0, event->size().height() / 600.0);
DemoItem::setMatrix(this->matrix());
if (this->trolltechLogo){
const QRectF r
= this
->scene
->sceneRect
();
QRectF ttb
= this
->trolltechLogo
->boundingRect
();
this->trolltechLogo->setPos(int((r.width() - ttb.width()) / 2), 595 - ttb.height());
QRectF qtb
= this
->qtLogo
->boundingRect
();
this->qtLogo->setPos(802 - qtb.width(), 0);
}
// Changing size will almost always
// hurt FPS during the changing. So
// ignore it.
this->fpsHistory.clear();
}
void MainWindow::resizeEvent(QResizeEvent *event)
{
this->resetMatrix();
this->scale(event->size().width() / 800.0, event->size().height() / 600.0);
QGraphicsView::resizeEvent(event);
DemoItem::setMatrix(this->matrix());
if (this->trolltechLogo){
const QRectF r = this->scene->sceneRect();
QRectF ttb = this->trolltechLogo->boundingRect();
this->trolltechLogo->setPos(int((r.width() - ttb.width()) / 2), 595 - ttb.height());
QRectF qtb = this->qtLogo->boundingRect();
this->qtLogo->setPos(802 - qtb.width(), 0);
}
// Changing size will almost always
// hurt FPS during the changing. So
// ignore it.
this->fpsHistory.clear();
}
To copy to clipboard, switch view to plain text mode
This is the resize event of the main window, which is also a QGraphicsView.
The first 3 lines are the most relevant.
Regards
Bookmarks