<?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[Finding the &quot;snap point&quot; for a splitter ?]]></title><description><![CDATA[<p dir="auto">I have a layout where I have 3 widgets left, center and right laid out in a horizontal splitter (so they're from left to right side-by-side).</p>
<p dir="auto">The problem is with the initial size of the splitter. The left side is initially way too large.</p>
<p dir="auto">The splitter has a "snap" point that seems to be some kind of minimum acceptable size if you drag it smaller it'll completely close.</p>
<p dir="auto">How to find this snap point and adjust the splitter so that  both the<br />
left and right sides are at the snap point and the center widget has maximum space?</p>
<p dir="auto">Thanks!</p>
]]></description><link>https://forum.qt.io/topic/155157/finding-the-snap-point-for-a-splitter</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Jul 2026 22:52:19 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/155157.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 07 Mar 2024 19:38:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Finding the &quot;snap point&quot; for a splitter ? on Wed, 13 Mar 2024 02:24:23 GMT]]></title><description><![CDATA[<p dir="auto">According to my experience, the "snap point" is indeed the minimum size, but not the value <code>minimumSize()</code> returned (unless you have set it), but  <code>minimumSizeHint()</code> if you have layout set on the widget.<br />
Are you sure <code>setStretchFactor()</code> is not working? I think it should if you set the center widget's strech to <code>1</code> and leave the other two untouched (0). (Or you can just set the center widget's <code>Horizontal Stretch</code> to <code>1</code> if you are using designer.)</p>
]]></description><link>https://forum.qt.io/post/793039</link><guid isPermaLink="true">https://forum.qt.io/post/793039</guid><dc:creator><![CDATA[Bonnie]]></dc:creator><pubDate>Wed, 13 Mar 2024 02:24:23 GMT</pubDate></item><item><title><![CDATA[Reply to Finding the &quot;snap point&quot; for a splitter ? on Thu, 04 Apr 2024 12:47:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/bonnie">@<bdi>Bonnie</bdi></a></p>
<p dir="auto">Thanks, the horizontal stretch factor seems to get me closest to what I want.</p>
]]></description><link>https://forum.qt.io/post/795695</link><guid isPermaLink="true">https://forum.qt.io/post/795695</guid><dc:creator><![CDATA[SamiV123]]></dc:creator><pubDate>Thu, 04 Apr 2024 12:47:25 GMT</pubDate></item><item><title><![CDATA[Reply to Finding the &quot;snap point&quot; for a splitter ? on Wed, 13 Mar 2024 09:40:36 GMT]]></title><description><![CDATA[<p dir="auto">I forgot, sorry,  you have to do the same with the following function:<br />
void QYourSplitterHandle::mouseMoveEvent(QMouseEvent* event)</p>
]]></description><link>https://forum.qt.io/post/793102</link><guid isPermaLink="true">https://forum.qt.io/post/793102</guid><dc:creator><![CDATA[Zbigniew-Sch]]></dc:creator><pubDate>Wed, 13 Mar 2024 09:40:36 GMT</pubDate></item><item><title><![CDATA[Reply to Finding the &quot;snap point&quot; for a splitter ? on Wed, 13 Mar 2024 09:27:42 GMT]]></title><description><![CDATA[<p dir="auto">Use the QSplitterHandle class.<br />
Integrate the object into the splitter and use "QSplitterHandle::mousePressEvent(QMouseEvent*<br />
eventPress)" to realize the “snap point”.</p>
<ol>
<li>Create your own class (QYourSplitterHandle) derived from "QSplitterHandle".</li>
<li>Implement:<br />
void QYourSplitterHandle::mousePressEvent(QMouseEvent* eventPress)</li>
<li>Create spliiter handle in your splitter class (virtual):<br />
virtual QSplitterHandle *createHandle();</li>
</ol>
<p dir="auto">Example:<br />
QYourSplitterHandle* QYourSplitter::createHandle()<br />
{<br />
return new QYourSplitterHandle(Qt::Orientation::Horizontal, this);<br />
}</p>
<p dir="auto">Calculate the widths of splitter widgets attached to the current splitter and for the "snap-point"<br />
<strong>do not call function from base class:</strong><br />
QSplitterHandle::mousePressEvent(eventPress);</p>
<p dir="auto">Determine splitter handle (using splitter object):<br />
QYourSplitterHandle* pcoSplitterHandle =<br />
qobject_cast&lt;QYourSplitterHandle*&gt;(pcoSplitter-&gt;handle(0));</p>
]]></description><link>https://forum.qt.io/post/793100</link><guid isPermaLink="true">https://forum.qt.io/post/793100</guid><dc:creator><![CDATA[Zbigniew-Sch]]></dc:creator><pubDate>Wed, 13 Mar 2024 09:27:42 GMT</pubDate></item><item><title><![CDATA[Reply to Finding the &quot;snap point&quot; for a splitter ? on Wed, 13 Mar 2024 02:24:23 GMT]]></title><description><![CDATA[<p dir="auto">According to my experience, the "snap point" is indeed the minimum size, but not the value <code>minimumSize()</code> returned (unless you have set it), but  <code>minimumSizeHint()</code> if you have layout set on the widget.<br />
Are you sure <code>setStretchFactor()</code> is not working? I think it should if you set the center widget's strech to <code>1</code> and leave the other two untouched (0). (Or you can just set the center widget's <code>Horizontal Stretch</code> to <code>1</code> if you are using designer.)</p>
]]></description><link>https://forum.qt.io/post/793039</link><guid isPermaLink="true">https://forum.qt.io/post/793039</guid><dc:creator><![CDATA[Bonnie]]></dc:creator><pubDate>Wed, 13 Mar 2024 02:24:23 GMT</pubDate></item><item><title><![CDATA[Reply to Finding the &quot;snap point&quot; for a splitter ? on Tue, 12 Mar 2024 20:17:24 GMT]]></title><description><![CDATA[<p dir="auto">So, no solution? :|</p>
]]></description><link>https://forum.qt.io/post/793032</link><guid isPermaLink="true">https://forum.qt.io/post/793032</guid><dc:creator><![CDATA[SamiV123]]></dc:creator><pubDate>Tue, 12 Mar 2024 20:17:24 GMT</pubDate></item><item><title><![CDATA[Reply to Finding the &quot;snap point&quot; for a splitter ? on Fri, 08 Mar 2024 22:42:01 GMT]]></title><description><![CDATA[<p dir="auto">I think you didn't understand the logic. You first have to determine the three widths of the widgets (when closing splitter).<br />
If you reduce the left and right widgets to 0 (via GUI splitter widgets changes), the middle widget will give the total width of splitter (1000), and the next time you start the program you can use splitter values.<br />
If you want to set the wide splitter widgets arbitrarily when initializing, then the following logic applies, example:</p>
<pre><code>splitter-&gt;setSizes({20, 200, 300}) - total width of the splitter
      corresponds to 520 units
    - the left widget: (20/520) * spliter-&gt;width() - wide
    - the middle widget : (200/520) * spliter-&gt;width() - wide
    - the right widget: (300/520) * spliter-&gt;width() - wide
</code></pre>
<p dir="auto">and if I set splitter-&gt;setSizes({0, 500, 0}) it doesn't matter what I pass 200, 500 or 1000, the left and right<br />
widgets have a width of 0 and the middle widget has the width of the entire splitter.</p>
<p dir="auto">I hope the logic is understandable now</p>
]]></description><link>https://forum.qt.io/post/792639</link><guid isPermaLink="true">https://forum.qt.io/post/792639</guid><dc:creator><![CDATA[Zbigniew-Sch]]></dc:creator><pubDate>Fri, 08 Mar 2024 22:42:01 GMT</pubDate></item><item><title><![CDATA[Reply to Finding the &quot;snap point&quot; for a splitter ? on Fri, 08 Mar 2024 21:31:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/zbigniew-sch">@<bdi>Zbigniew-Sch</bdi></a> said in <a href="/post/792629">Finding the "snap point" for a splitter ?</a>:</p>
<blockquote>
<p dir="auto">Each splitter part is connected to a widget (QLabel, QListWidget, QScrollArea ....)</p>
<p dir="auto">pcoSplitter-&gt;addWidget(pcoLeftWidget);<br />
int iLeftViewWidth = pcoLeftWidget-&gt;width();</p>
<p dir="auto">pcoSplitter-&gt;addWidget(pcoMiddleWidget);<br />
int iMiddleViewWidth = pcoMiddleWidget-&gt;width();</p>
<p dir="auto">pcoSplitter-&gt;addWidget(pcoRightWidget);<br />
int iRightViewWidth = pcoRightWidget-&gt;widht();</p>
</blockquote>
<p dir="auto">If you think about this for a second you should realize this is completely illogical.</p>
<p dir="auto">Let's say the parent widget that contains the splitter is 1000 units wide and has a splitter that has left pane 250, center 500 and right pane 250 units in width.</p>
<p dir="auto">What would be the result of setting the splitter "sizes" (QSplitter::setSizes) to 0, 500, 0?</p>
<p dir="auto">The space to be allotted between the three widgets is 1000. So the sizes would logically need to sum up to 1000.  0 + 500 + 0 sums to 500. Makes no sense.</p>
]]></description><link>https://forum.qt.io/post/792635</link><guid isPermaLink="true">https://forum.qt.io/post/792635</guid><dc:creator><![CDATA[SamiV123]]></dc:creator><pubDate>Fri, 08 Mar 2024 21:31:59 GMT</pubDate></item><item><title><![CDATA[Reply to Finding the &quot;snap point&quot; for a splitter ? on Fri, 08 Mar 2024 19:00:09 GMT]]></title><description><![CDATA[<p dir="auto">Each splitter part is connected to a widget (QLabel, QListWidget, QScrollArea ....)</p>
<p dir="auto">pcoSplitter-&gt;addWidget(pcoLeftWidget);<br />
int iLeftViewWidth = pcoLeftWidget-&gt;width();</p>
<p dir="auto">pcoSplitter-&gt;addWidget(pcoMiddleWidget);<br />
int iMiddleViewWidth = pcoMiddleWidget-&gt;width();</p>
<p dir="auto">pcoSplitter-&gt;addWidget(pcoRightWidget);<br />
int iRightViewWidth = pcoRightWidget-&gt;widht();</p>
]]></description><link>https://forum.qt.io/post/792629</link><guid isPermaLink="true">https://forum.qt.io/post/792629</guid><dc:creator><![CDATA[Zbigniew-Sch]]></dc:creator><pubDate>Fri, 08 Mar 2024 19:00:09 GMT</pubDate></item><item><title><![CDATA[Reply to Finding the &quot;snap point&quot; for a splitter ? on Fri, 08 Mar 2024 18:36:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/zbigniew-sch">@<bdi>Zbigniew-Sch</bdi></a></p>
<p dir="auto">And what are the sizes? Yeah.. that's basically the meat of the question.</p>
]]></description><link>https://forum.qt.io/post/792628</link><guid isPermaLink="true">https://forum.qt.io/post/792628</guid><dc:creator><![CDATA[SamiV123]]></dc:creator><pubDate>Fri, 08 Mar 2024 18:36:39 GMT</pubDate></item><item><title><![CDATA[Reply to Finding the &quot;snap point&quot; for a splitter ? on Fri, 08 Mar 2024 17:10:39 GMT]]></title><description><![CDATA[<p dir="auto">Use the following function:<br />
pcoSplitter-&gt;setSizes({ iLeftViewWidth , iMiddleViewWidth, iRightViewWidth });</p>
<p dir="auto">and  to your question:<br />
pcoSplitter-&gt;setSizes({ 0 , iMiddleViewWidth, 0 });</p>
]]></description><link>https://forum.qt.io/post/792626</link><guid isPermaLink="true">https://forum.qt.io/post/792626</guid><dc:creator><![CDATA[Zbigniew-Sch]]></dc:creator><pubDate>Fri, 08 Mar 2024 17:10:39 GMT</pubDate></item><item><title><![CDATA[Reply to Finding the &quot;snap point&quot; for a splitter ? on Fri, 08 Mar 2024 12:16:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> said in <a href="/post/792572">Finding the "snap point" for a splitter ?</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/samiv123">@<bdi>SamiV123</bdi></a> yes it can be. You can also set the minimum size to something suitable for you.</p>
</blockquote>
<p dir="auto">Well yes the minimum size of a widget can be 0 but in this case it doesn't make sense since the when the splitter is at the snap point the size (width) of the widget is non-zero. So the snap point can't be at a point where the widget's minimum size is zero.. Makes sense?</p>
<p dir="auto">Secondarily, using fixed minimum size rarely (if ever) works correctly across platforms and style  engines.  Using X units of width and it looks ok with Fusion or whatever?  Yeah, great then go and change the style engine to kvAntum or Adwaita and see how things are all kaput because the layout and widget sizes are completely different.</p>
]]></description><link>https://forum.qt.io/post/792600</link><guid isPermaLink="true">https://forum.qt.io/post/792600</guid><dc:creator><![CDATA[SamiV123]]></dc:creator><pubDate>Fri, 08 Mar 2024 12:16:16 GMT</pubDate></item><item><title><![CDATA[Reply to Finding the &quot;snap point&quot; for a splitter ? on Fri, 08 Mar 2024 06:49:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/samiv123">@<bdi>SamiV123</bdi></a> yes it can be. You can also set the minimum size to something suitable for you.</p>
]]></description><link>https://forum.qt.io/post/792572</link><guid isPermaLink="true">https://forum.qt.io/post/792572</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Fri, 08 Mar 2024 06:49:59 GMT</pubDate></item><item><title><![CDATA[Reply to Finding the &quot;snap point&quot; for a splitter ? on Thu, 07 Mar 2024 21:42:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> said in <a href="/post/792521">Finding the "snap point" for a splitter ?</a>:</p>
<blockquote>
<p dir="auto">Hi,</p>
<p dir="auto">Isn't it the minimal size of the widget ?</p>
<p dir="auto">That said, you can also use <a href="https://doc.qt.io/qt-6/qsplitter.html#setStretchFactor" target="_blank" rel="noopener noreferrer nofollow ugc">setStretchFactor</a> so you can make have them distributed in a more suitable fashion.</p>
</blockquote>
<p dir="auto">The minimum size is (width) is 0. So this can't be right.</p>
<p dir="auto">strech factor seems super obscure, doubt that will do anything other than make the situation worse.</p>
]]></description><link>https://forum.qt.io/post/792534</link><guid isPermaLink="true">https://forum.qt.io/post/792534</guid><dc:creator><![CDATA[SamiV123]]></dc:creator><pubDate>Thu, 07 Mar 2024 21:42:54 GMT</pubDate></item><item><title><![CDATA[Reply to Finding the &quot;snap point&quot; for a splitter ? on Thu, 07 Mar 2024 20:22:02 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Isn't it the minimal size of the widget ?</p>
<p dir="auto">That said, you can also use <a href="https://doc.qt.io/qt-6/qsplitter.html#setStretchFactor" target="_blank" rel="noopener noreferrer nofollow ugc">setStretchFactor</a> so you can make have them distributed in a more suitable fashion.</p>
]]></description><link>https://forum.qt.io/post/792521</link><guid isPermaLink="true">https://forum.qt.io/post/792521</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 07 Mar 2024 20:22:02 GMT</pubDate></item></channel></rss>