<?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[How do I get this QGraphicsView to fit gfx item contents in view so that scroll bars possibly disappear?]]></title><description><![CDATA[<p dir="auto"><a href="https://youtu.be/JOosQtUv5kk" target="_blank" rel="noopener noreferrer nofollow ugc">https://youtu.be/JOosQtUv5kk</a></p>
<p dir="auto">There is a video showing what's up.  In the Logical Rule Widget there is a vertical layout of ListingWidgets, each containing various QGraphicsViews that point to an existing scene somewhere in a tab in a main window of the app.</p>
<p dir="auto">The listing is not scaling to fit the QGraphicsItem contents.</p>
<p dir="auto">Here is my relevant code:</p>
<pre><code>def fit_contents_in_view(self):
        rect = self.scene().itemsBoundingRect()
     if rect != QRectF():
         self.setSceneRect(rect)
</code></pre>
<p dir="auto">which is in my gfx.language_gfx_view.LanguageGfxView class.     Any idea how best to fit the scene's complete content into a QGraphicView viewing area?</p>
<p dir="auto">The complete code:<br />
<a href="https://github.com/enjoysmath/abstract-spacecraft" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/enjoysmath/abstract-spacecraft</a></p>
<p dir="auto">Also tried:</p>
<pre><code>def fit_contents_in_view(self):
        self.fitInView(self.scene().itemsBoundingRect(), Qt.IgnoreAspectRatio)
</code></pre>
]]></description><link>https://forum.qt.io/topic/139409/how-do-i-get-this-qgraphicsview-to-fit-gfx-item-contents-in-view-so-that-scroll-bars-possibly-disappear</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 01:15:02 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/139409.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 19 Sep 2022 01:07:02 GMT</pubDate><ttl>60</ttl></channel></rss>