Hello,

I have code that resizes the (currently empty) scene and view from within the window's resizeEvent(). To help me visualize the changes, I have included debug statements and a call to a helper function that draws a rectangle around the inside of the scene. Seems to work just fine, but I just wanted to make sure that I'm not making any faux pas, or that there isn't a better way to be doing it. Here's my code:

Qt Code:
  1. void MainWindow::resizeEvent(QResizeEvent *e)
  2. {
  3. QSize size(e->size());
  4. int w = size.width()-2; // -2: 1 pixel from each side
  5. int h = size.height()-2;
  6. qDebug() << w+2 << "," << h+2;
  7. scene->setSceneRect(0,0,w,h);
  8. scene->updateBorder();
  9. QMainWindow::resizeEvent(e);
  10. }
To copy to clipboard, switch view to plain text mode 

And in the scene class:
Qt Code:
  1. void MyScene::updateBorder()
  2. {
  3. clear();
  4. QRectF r = sceneRect();
  5. addRect(r.x(), r.y(), r.width()-1, r.height()-1);
  6. }
To copy to clipboard, switch view to plain text mode 

Thanks in advance for any suggestions.