<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[QGraphicsScene does not fit QGraphicsView full size]]></title><description><![CDATA[<p dir="auto">Hello,<br />
here is a test code.</p>
<p dir="auto"><em>CMakeLists.txt</em></p>
<pre><code>cmake_minimum_required(VERSION 3.5)

project(test LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Qt5 COMPONENTS REQUIRED Core Widgets)

set(SOURCE_FILES
  main.cpp
  test.cpp)

add_executable(test ${SOURCE_FILES})

target_link_libraries(test PRIVATE
  Qt5::Core
  Qt5::Widgets)
</code></pre>
<p dir="auto"><em>main.cpp</em></p>
<pre><code>// Qt headers
#include &lt;QApplication&gt;

#include "test.h"

int main(int argc, char *argv[])
{
     QApplication application(argc, argv);

    Test *applicationWindow = new Test();
    applicationWindow-&gt;setMinimumWidth(1200);
    applicationWindow-&gt;setMinimumHeight(900);
    applicationWindow-&gt;show();

    return application.exec();
}
</code></pre>
<p dir="auto"><em>test.h</em></p>
<pre><code>#ifndef TEST_H
#define TEST_H

#include &lt;QMainWindow&gt;
#include &lt;QGraphicsView&gt;

class Test : public QMainWindow
{
    Q_OBJECT
public:
    explicit Test(QWidget* parent = nullptr);
    ~Test() override;

public slots:

private:
    QGraphicsView *m_view;
};

#endif // TEST_H
</code></pre>
<p dir="auto">test.cpp</p>
<pre><code>// Qt headers
#include &lt;QGraphicsView&gt;
#include &lt;QGraphicsScene&gt;
#include &lt;QPixmap&gt;
#include &lt;QGraphicsPixmapItem&gt;
#include &lt;QGraphicsRectItem&gt;
#include &lt;QPainter&gt;
#include &lt;QPen&gt;

// Other headers
#include "test.h"

Test::Test(QWidget* parent /*=nullptr*/):
    QMainWindow(parent)
{
    m_view = new QGraphicsView();
    // draw borders of the QGraphicsView
    m_view-&gt;setStyleSheet("border: 5px solid red");

    //define the QGraphicsScene
    QGraphicsScene *scene = new QGraphicsScene();
    m_view-&gt;setRenderHint(QPainter::Antialiasing, true);
    m_view-&gt;setScene(scene);

    //define a QPixmap
    QPixmap img("tmp.svg");
    QGraphicsPixmapItem *item = scene-&gt;addPixmap(img);

    // image should fit all the QGraphicsScene/QGraphicsView
    m_view-&gt;fitInView(item, Qt::IgnoreAspectRatio);

    // draw borders of the QGraphicsScene
    QGraphicsRectItem *rect_item = scene-&gt;addRect(scene-&gt;sceneRect());
    rect_item-&gt;setParentItem(item);
    QPen pen = QPen(Qt::black);
    pen.setWidth(10);
    rect_item-&gt;setPen(pen);

    m_view-&gt;show();

    // set the QGraphicsView as the central widget
    setCentralWidget(m_view);
}

// destructor
Test::~Test()
{
}
</code></pre>
<p dir="auto">If you want to reproduce please add an image file in the directory in which you run the test program and name it tmp.svg.</p>
<p dir="auto">Here is what I get when I run the test program<br />
<img src="https://ddgobkiprc33d.cloudfront.net/cdc7c542-2500-4b15-aeef-59585abcdd20.png" alt="Capture d’écran du 2022-06-21 12-47-45.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">So it seems my image fits the full scene size (in black) but I do not understand my scene can fit the full QGraphicsView size (in red).</p>
]]></description><link>https://forum.qt.io/topic/137374/qgraphicsscene-does-not-fit-qgraphicsview-full-size</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Jul 2026 10:24:02 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/137374.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 21 Jun 2022 10:52:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QGraphicsScene does not fit QGraphicsView full size on Wed, 22 Jun 2022 12:49:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/odelaune">@<bdi>odelaune</bdi></a> said in <a href="/post/718622">QGraphicsScene does not fit QGraphicsView full size</a>:</p>
<blockquote>
<p dir="auto">What was missing was the implementation of showEvent(). This is now done and it fits well, even when not resizing.</p>
</blockquote>
<p dir="auto">Yes,  For widgets it is <code>showEvent()</code> which is first called when it is shown.  For anything "size" that is better than in constructor.</p>
]]></description><link>https://forum.qt.io/post/718623</link><guid isPermaLink="true">https://forum.qt.io/post/718623</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Wed, 22 Jun 2022 12:49:19 GMT</pubDate></item><item><title><![CDATA[Reply to QGraphicsScene does not fit QGraphicsView full size on Wed, 22 Jun 2022 12:43:50 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> said in <a href="/post/718614">QGraphicsScene does not fit QGraphicsView full size</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/odelaune">@<bdi>odelaune</bdi></a><br />
But nonetheless you still say it <em>does</em> work when you do the <code>fitInView()</code> in the <code>resizeEvent()</code>, but not in the constructor, right??</p>
</blockquote>
<p dir="auto">Yes, it <strong>does</strong> work in <code>resizeEvent()</code>.</p>
<blockquote>
<p dir="auto">Then I would basically read it as: <code>fitInView()</code> does not work "at all" in constructor before the view/scene is really shown, and that's just how it is.</p>
</blockquote>
<p dir="auto">It makes sense.</p>
<blockquote>
<p dir="auto">Assuming it's good in <code>resizeEvent()</code> you have your solution now anyway?  (If it's still not right very first time when shown but no <code>resizeEvent()</code> is called, you can do it initially in <code>showEvent()</code> too?)</p>
</blockquote>
<p dir="auto">What was missing was the implementation of <code>showEvent()</code>. This is now done and it fits well, even when not resizing.</p>
<p dir="auto">Here is the working example code</p>
<p dir="auto"><em>test.cpp</em></p>
<pre><code>// Qt headers
#include &lt;QPixmap&gt;
#include &lt;QGraphicsPixmapItem&gt;
#include &lt;QGraphicsRectItem&gt;
#include &lt;QPainter&gt;
#include &lt;QPen&gt;
#include &lt;QDebug&gt;
#include &lt;QResizeEvent&gt;

// Other headers
#include "test.h"

Test::Test(QWidget* parent /*=nullptr*/):
    QMainWindow(parent)
{
    m_view = new QGraphicsView(this);

    // draw border of the QGraphicsView
    m_view-&gt;setStyleSheet("border: 5px solid red");

    m_scene = new QGraphicsScene(m_view);

    m_view-&gt;setRenderHint(QPainter::Antialiasing, true);
    m_view-&gt;setScene(m_scene);
    m_view-&gt;setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    m_view-&gt;setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

    QPixmap img("tmp.svg");
    QGraphicsPixmapItem *item = m_scene-&gt;addPixmap(img);

    // draw border of the QGraphicsScene
    QGraphicsRectItem *rect_item = m_scene-&gt;addRect(m_scene-&gt;sceneRect());
    rect_item-&gt;setParentItem(item);
    QPen pen = QPen(Qt::black);
    pen.setWidth(10);
    rect_item-&gt;setPen(pen);

    // set the mapView as the central widget
    setCentralWidget(m_view);

    m_view-&gt;show();
}

// destructor
Test::~Test()
{
}


void Test::resizeEvent(QResizeEvent* event)
{
    if(!m_scene)
        return;
    QRectF bounds = m_scene-&gt;itemsBoundingRect();
    m_view-&gt;fitInView(bounds, Qt::IgnoreAspectRatio);
}


void Test::showEvent(QShowEvent* event)
{
    if(!m_scene)
        return;
    QRectF bounds = m_scene-&gt;itemsBoundingRect();
    m_view-&gt;fitInView(bounds, Qt::IgnoreAspectRatio);
}

</code></pre>
<p dir="auto">Thank you very much for your support.</p>
]]></description><link>https://forum.qt.io/post/718622</link><guid isPermaLink="true">https://forum.qt.io/post/718622</guid><dc:creator><![CDATA[odelaune]]></dc:creator><pubDate>Wed, 22 Jun 2022 12:43:50 GMT</pubDate></item><item><title><![CDATA[Reply to QGraphicsScene does not fit QGraphicsView full size on Wed, 22 Jun 2022 12:14:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/odelaune">@<bdi>odelaune</bdi></a><br />
But nonetheless you still say it <em>does</em> work when you do the <code>fitInView()</code> in the <code>resizeEvent()</code>, but not in the constructor, right??</p>
<p dir="auto">Then I would basically read it as: <code>fitInView()</code> does not work "at all" in constructor before the view/scene is really shown, and that's just how it is.  Assuming it's good in <code>resizeEvent()</code> you have your solution now anyway?  (If it's still not right very first time when shown but no <code>resizeEvent()</code> is called, you can do it initially in <code>showEvent()</code> too?)</p>
]]></description><link>https://forum.qt.io/post/718614</link><guid isPermaLink="true">https://forum.qt.io/post/718614</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Wed, 22 Jun 2022 12:14:58 GMT</pubDate></item><item><title><![CDATA[Reply to QGraphicsScene does not fit QGraphicsView full size on Wed, 22 Jun 2022 11:53:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> said in <a href="/post/718559">QGraphicsScene does not fit QGraphicsView full size</a>:</p>
<blockquote>
<p dir="auto">For example, debug out what is returned from m_scene-&gt;itemsBoundingRect() for that line where you call it in the constructor, my guess is it's not the size it will end up being?</p>
</blockquote>
<p dir="auto">Actually, they are the same (QRectF(-5,-5 472x349)) both in the constructor and in the resizeEvent function. The value doesn't change either when I resize the window (still QRectF(-5,-5 472x349)). The same with sceneRect().</p>
]]></description><link>https://forum.qt.io/post/718609</link><guid isPermaLink="true">https://forum.qt.io/post/718609</guid><dc:creator><![CDATA[odelaune]]></dc:creator><pubDate>Wed, 22 Jun 2022 11:53:10 GMT</pubDate></item><item><title><![CDATA[Reply to QGraphicsScene does not fit QGraphicsView full size on Wed, 22 Jun 2022 08:53:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/odelaune">@<bdi>odelaune</bdi></a><br />
Sizes are not always set/right in constructors in Qt.  For example, debug out what is returned from <code>m_scene-&gt;itemsBoundingRect()</code> for that line where you call it in the constructor, my guess is it's <em>not</em> the size it will end up being?</p>
<p dir="auto">Size is only "correct" when the object has been <em>shown</em>, since that is when Qt can calculate/set it.  So it would not be surprising if you have to redo this line in every <code>resizeEvent</code>....</p>
]]></description><link>https://forum.qt.io/post/718559</link><guid isPermaLink="true">https://forum.qt.io/post/718559</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Wed, 22 Jun 2022 08:53:33 GMT</pubDate></item><item><title><![CDATA[Reply to QGraphicsScene does not fit QGraphicsView full size on Wed, 22 Jun 2022 08:44:23 GMT]]></title><description><![CDATA[<p dir="auto">Hmmm, here is my code now</p>
<p dir="auto"><em>main.cpp</em></p>
<pre><code>// Qt headers
#include &lt;QApplication&gt;

#include "test.h"

int main(int argc, char *argv[])
{
    QApplication application(argc, argv);

    Test *applicationWindow = new Test();
    applicationWindow-&gt;setMinimumWidth(400);
    applicationWindow-&gt;setMinimumHeight(400);
    applicationWindow-&gt;show();

    return application.exec();
}
</code></pre>
<p dir="auto">test.cpp</p>
<pre><code>// Qt headers
#include &lt;QPixmap&gt;
#include &lt;QGraphicsPixmapItem&gt;
#include &lt;QGraphicsRectItem&gt;
#include &lt;QPainter&gt;
#include &lt;QPen&gt;
#include &lt;QResizeEvent&gt;

// Other headers
#include "test.h"

Test::Test(QWidget* parent /*=nullptr*/):
    QMainWindow(parent)
{
    m_view = new QGraphicsView(this);

    // draw border of the QGraphicsView
    m_view-&gt;setStyleSheet("border: 5px solid red");

    m_scene = new QGraphicsScene(m_view);

    m_view-&gt;setRenderHint(QPainter::Antialiasing, true);
    m_view-&gt;setScene(m_scene);
    m_view-&gt;setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    m_view-&gt;setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

    QPixmap img("tmp.svg");
    QGraphicsPixmapItem *item = m_scene-&gt;addPixmap(img);

    // draw border of the QGraphicsScene
    QGraphicsRectItem *rect_item = m_scene-&gt;addRect(m_scene-&gt;sceneRect());
    rect_item-&gt;setParentItem(item);
    QPen pen = QPen(Qt::black);
    pen.setWidth(10);
    rect_item-&gt;setPen(pen);

    // set the mapView as the central widget
    setCentralWidget(m_view);

    m_view-&gt;show();

    m_view-&gt;fitInView (m_scene-&gt;itemsBoundingRect(),Qt::IgnoreAspectRatio); // useless here

}

// destructor
Test::~Test()
{
}


void Test::resizeEvent(QResizeEvent* event)
{
    if(!m_scene)
        return;
    QRectF bounds = m_scene-&gt;itemsBoundingRect();
    m_view-&gt;fitInView(bounds, Qt::IgnoreAspectRatio);
}
</code></pre>
<p dir="auto"><em>test.h</em></p>
<pre><code>#ifndef TEST_H
#define TEST_H

#include &lt;QMainWindow&gt;
#include &lt;QGraphicsView&gt;
#include &lt;QGraphicsScene&gt;

class Test : public QMainWindow
{
    Q_OBJECT
public:
    explicit Test(QWidget* parent = nullptr);
    ~Test() override;
    void resizeEvent(QResizeEvent* event) override;

public slots:

private:
    QGraphicsView *m_view;
    QGraphicsScene *m_scene;
};

#endif // TEST_H
</code></pre>
<p dir="auto">And here is what I get when I start the application:<br />
<img src="https://ddgobkiprc33d.cloudfront.net/fee4685b-c484-47b8-9b52-617b4c569fa9.png" alt="Capture d’écran du 2022-06-22 10-27-39.png" class=" img-fluid img-markdown" /><br />
So clearly not what I am expecting.</p>
<p dir="auto">However, I get what I want when I resize the window:<br />
<img src="https://ddgobkiprc33d.cloudfront.net/792bab58-558e-450b-8877-3f74517f6ead.png" alt="Capture d’écran du 2022-06-22 10-27-49.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">The trick is done via the resizeEvent method. But I do not understand how can I do the same in the same in the constructor. Indeed</p>
<pre><code>m_view-&gt;fitInView (m_scene-&gt;itemsBoundingRect(),Qt::IgnoreAspectRatio)
</code></pre>
<p dir="auto">does not do the job when it is placed at the end of the constructor but works fine in resizeEvent.</p>
<p dir="auto">Any idea?</p>
]]></description><link>https://forum.qt.io/post/718549</link><guid isPermaLink="true">https://forum.qt.io/post/718549</guid><dc:creator><![CDATA[odelaune]]></dc:creator><pubDate>Wed, 22 Jun 2022 08:44:23 GMT</pubDate></item><item><title><![CDATA[Reply to QGraphicsScene does not fit QGraphicsView full size on Tue, 21 Jun 2022 15:03:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/odelaune">@<bdi>odelaune</bdi></a> said in <a href="/post/718462">QGraphicsScene does not fit QGraphicsView full size</a>:</p>
<blockquote>
<p dir="auto">m_view = new QGraphicsView();</p>
</blockquote>
<p dir="auto">m_view = new QGraphicsView( this );</p>
<p dir="auto">QGraphicsScene *scene = new QGraphicsScene( m_view or this  );<br />
m_view-&gt;setRenderHint(QPainter::Antialiasing, true);<br />
m_view-&gt;setScene(scene); ///The view does not take ownership of scene with this call.</p>
<p dir="auto">Try to change resize policy of scene</p>
<p dir="auto">check this example: <a href="https://code.qt.io/cgit/qt/qtbase.git/tree/examples/widgets/graphicsview/elasticnodes?h=6.3" target="_blank" rel="noopener noreferrer nofollow ugc">https://code.qt.io/cgit/qt/qtbase.git/tree/examples/widgets/graphicsview/elasticnodes?h=6.3</a></p>
]]></description><link>https://forum.qt.io/post/718490</link><guid isPermaLink="true">https://forum.qt.io/post/718490</guid><dc:creator><![CDATA[JoeCFD]]></dc:creator><pubDate>Tue, 21 Jun 2022 15:03:13 GMT</pubDate></item><item><title><![CDATA[Reply to QGraphicsScene does not fit QGraphicsView full size on Tue, 21 Jun 2022 13:45:19 GMT]]></title><description><![CDATA[<p dir="auto">Actually this code is a sample of my whole code where the QGraphicsView is inside a widget, so I experience the same issue either with QMainWindow or with QWidget.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> said in <a href="/post/718480">QGraphicsScene does not fit QGraphicsView full size</a>:</p>
<blockquote>
<ul>
<li>Maybe your scene is already the full size of the view (or vice versa).  Maybe you actually need to <em>enlarge</em> the scene/view to fill the whole window.</li>
</ul>
</blockquote>
<p dir="auto">Why not but I am not sure to know how to do it.</p>
]]></description><link>https://forum.qt.io/post/718487</link><guid isPermaLink="true">https://forum.qt.io/post/718487</guid><dc:creator><![CDATA[odelaune]]></dc:creator><pubDate>Tue, 21 Jun 2022 13:45:19 GMT</pubDate></item><item><title><![CDATA[Reply to QGraphicsScene does not fit QGraphicsView full size on Tue, 21 Jun 2022 13:15:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/odelaune">@<bdi>odelaune</bdi></a></p>
<ul>
<li>I would try with a <code>QWidget</code> instead of a <code>QMainWindow</code>.</li>
<li>Maybe your scene is already the full size of the view (or vice versa).  Maybe you actually need to <em>enlarge</em> the scene/view to fill the whole window.</li>
</ul>
<p dir="auto">That's all i know.</p>
]]></description><link>https://forum.qt.io/post/718480</link><guid isPermaLink="true">https://forum.qt.io/post/718480</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Tue, 21 Jun 2022 13:15:31 GMT</pubDate></item><item><title><![CDATA[Reply to QGraphicsScene does not fit QGraphicsView full size on Tue, 21 Jun 2022 12:12:32 GMT]]></title><description><![CDATA[<p dir="auto">The red square is drawn using "m_view-&gt;setStyleSheet("border: 5px solid red");" so technically this is the border of the QGraphicsView object and indeed this object is defined as the central widget. So it is still not clear to me why the QGraphicsScene does not fit the QGraphicsView.<br />
Since I have no toolbars, no dock, etc. (I have only one widget in my mainwindow, defined as the central widget). So everything should scale the full size of the mainwindow, but it is not.</p>
<p dir="auto">How would you rewrite my code to get what I look for?</p>
]]></description><link>https://forum.qt.io/post/718476</link><guid isPermaLink="true">https://forum.qt.io/post/718476</guid><dc:creator><![CDATA[odelaune]]></dc:creator><pubDate>Tue, 21 Jun 2022 12:12:32 GMT</pubDate></item><item><title><![CDATA[Reply to QGraphicsScene does not fit QGraphicsView full size on Tue, 21 Jun 2022 12:05:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/odelaune">@<bdi>odelaune</bdi></a><br />
The red square is the whole <code>QMainWindow</code>, right?  Why would you expect the <code>QGraphicsView</code> to occupy the whole of that, when it's only the <code>centralWidget</code>?  See the picture at <a href="https://doc.qt.io/qt-6/qmainwindow.html#qt-main-window-framework" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-6/qmainwindow.html#qt-main-window-framework</a>.  I wouldn't use a <code>QMainWindow</code> if I wanted one widget to occupy the whole window.</p>
]]></description><link>https://forum.qt.io/post/718474</link><guid isPermaLink="true">https://forum.qt.io/post/718474</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Tue, 21 Jun 2022 12:05:40 GMT</pubDate></item><item><title><![CDATA[Reply to QGraphicsScene does not fit QGraphicsView full size on Tue, 21 Jun 2022 11:51:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a><br />
I agree that my scene is smaller than my view but I do not understand why QGraphicsView::fitInView does not do the job.<br />
In <em>test.cpp</em>, using "m_view-&gt;fitInView (scene-&gt;sceneRect(),Qt::IgnoreAspectRatio);" instead of "m_view-&gt;fitInView(item, Qt::IgnoreAspectRatio);" gives me exactly the same result, i.e. the screenshot I have given in my first post.</p>
]]></description><link>https://forum.qt.io/post/718469</link><guid isPermaLink="true">https://forum.qt.io/post/718469</guid><dc:creator><![CDATA[odelaune]]></dc:creator><pubDate>Tue, 21 Jun 2022 11:51:11 GMT</pubDate></item><item><title><![CDATA[Reply to QGraphicsScene does not fit QGraphicsView full size on Tue, 21 Jun 2022 11:01:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/odelaune">@<bdi>odelaune</bdi></a><br />
That means your scene is smaller than the view.  I think you want <a href="https://doc.qt.io/qt-6/qgraphicsview.html#fitInView-2" target="_blank" rel="noopener noreferrer nofollow ugc">void QGraphicsView::fitInView(const QGraphicsItem *item, Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio)</a> ?</p>
<p dir="auto">Ah, actually for the whole <code>scene</code>: <a href="https://doc.qt.io/qt-6/qgraphicsview.html#fitInView" target="_blank" rel="noopener noreferrer nofollow ugc">void QGraphicsView::fitInView(const QRectF &amp;rect, Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio)</a></p>
<pre><code>ui-&gt;view-&gt;fitInView( scene-&gt;sceneRect(),Qt::KeepAspectRatio);
</code></pre>
<p dir="auto">?</p>
]]></description><link>https://forum.qt.io/post/718463</link><guid isPermaLink="true">https://forum.qt.io/post/718463</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Tue, 21 Jun 2022 11:01:46 GMT</pubDate></item></channel></rss>