<?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 to stop QLabel and QPushbutton from expanding????]]></title><description><![CDATA[<p dir="auto">This is driving me crazy. I just want a QLabel and a QPushButton, each initialized with plain text, to sit together on the left side of one row inside an enclosing widget with a QVBoxLayout; together they are much narrower than the enclosing widget. No matter what I have tried they expand in one way or another. As the QPushButton text is either "+" or "-", I could call setMaximumSize(16) and that works for it; my class doesn't know the width of the label text. But there must be a better way. No attempt using QSizePolicy has worked for me.</p>
<p dir="auto">How can I get them to look like this at the left side of the enclosing widget:<br />
Label Text [+]<br />
(here the QPushButton is mimicked by [].)</p>
]]></description><link>https://forum.qt.io/topic/31414/how-to-stop-qlabel-and-qpushbutton-from-expanding</link><generator>RSS for Node</generator><lastBuildDate>Wed, 08 Apr 2026 14:59:09 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/31414.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 30 Aug 2013 22:31:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to stop QLabel and QPushbutton from expanding???? on Sat, 31 Aug 2013 02:22:28 GMT]]></title><description><![CDATA[<p dir="auto">If I attempted to use fixed geometry in the parent, I would have to carefully keep track of the pixel position of every widget in it; there are a lot of them. That's a LOT of work, and would be quite fragile; the whole point of using layouts is to avoid that sort of thing. Moreover, I don't know how much space to allocate for each.</p>
<p dir="auto">Why is it so hard in Qt to place widgets side-by-side without expanding? Or am I missing something rather obvious? After all, in HTML that's just natural. As it happens, I am translating dialog boxes from HTML to Qt (long, sad, story).</p>
<p dir="auto">I guess I'm looking for the analog to Java's FlowLayout....</p>
]]></description><link>https://forum.qt.io/post/193510</link><guid isPermaLink="true">https://forum.qt.io/post/193510</guid><dc:creator><![CDATA[tjrob]]></dc:creator><pubDate>Sat, 31 Aug 2013 02:22:28 GMT</pubDate></item><item><title><![CDATA[Reply to How to stop QLabel and QPushbutton from expanding???? on Fri, 30 Aug 2013 23:33:38 GMT]]></title><description><![CDATA[<p dir="auto">So you have a button of known size, and a label of unknown size that are contained in a widget and you want their placement to be fixed.</p>
<hr />
<p dir="auto"></p><div class="plugin-markdown"><input type="checkbox" checked="true" />|  &lt;-- this representing the widget, text,and button</div><br />
|_________|<br />
Do you have to place them within the QVBoxLayout? Why not tie them directly to the parent and use setGeometry to fix their placement within the parent?<p></p>
]]></description><link>https://forum.qt.io/post/193505</link><guid isPermaLink="true">https://forum.qt.io/post/193505</guid><dc:creator><![CDATA[Buckets]]></dc:creator><pubDate>Fri, 30 Aug 2013 23:33:38 GMT</pubDate></item></channel></rss>