Skip to content

Commit

Permalink
scene: Resize background when resizing scene
Browse files Browse the repository at this point in the history
  • Loading branch information
Tectu committed May 11, 2024
1 parent ddb2ef5 commit dd6387a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions qschematic/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ Scene::Scene(QObject* parent) :
setupBackground();
connect(this, &QGraphicsScene::sceneRectChanged, [this](const QRectF rect){
if (_background) {
// Adjust scene rect (make it smaller) because otherwise the scene resizes automatically to a larger size to accomodate
// the background rect and we end up in an infinite loop.
// ToDo
//_background->setRect(rect.adjusted(10, 10, -10, -10));
// Note: We adjust the scene rect (make it smaller) before we set it as the background rect because the scene automatically resizes
// to accommodate all items. If we were not ot do this, the scene would resize (get larger) after setting the background rect
// triggering this slot again and we'd end up in an infinite loop.
_background->setRect(rect.adjusted(1, 1, -1, -1));
}
});
}
Expand Down

0 comments on commit dd6387a

Please sign in to comment.