<?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 set ResizetoContent for a single column in TableWidget?]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">I am new to Qt and I am using PyQt 5.8.</p>
<p dir="auto">I had my columns set to resizeColumnsToContents() but when setting setStretchLastSection(True), the table is always resizing to fit the content, even though I am manually setting the setStretchLastSection(True)  once more.</p>
<p dir="auto">Is there anything I can do to prevent it from doing so? I thought about setting 6 of my 7 columns to resizetoContent, so the  StretchLastSection won't be overwritten, but I can't seem to find a way to do so.</p>
<p dir="auto">(setStretchLastSection(True) is also set to true through Qt-Designer)</p>
<p dir="auto">my table is called table_1. my current code is below:</p>
<pre><code>        self.table_1.resizeRowsToContents()
        self.table_1.resizeColumnsToContents()
        self.table_1.verticalHeader().setStretchLastSection(True)
</code></pre>
<p dir="auto">thanks, I am open for constructive critics.</p>
]]></description><link>https://forum.qt.io/topic/77936/how-to-set-resizetocontent-for-a-single-column-in-tablewidget</link><generator>RSS for Node</generator><lastBuildDate>Fri, 14 Aug 2026 21:37:49 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/77936.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 04 Apr 2017 16:33:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to set ResizetoContent for a single column in TableWidget? on Tue, 04 Apr 2017 16:51:44 GMT]]></title><description><![CDATA[<p dir="auto"><a href="http://doc.qt.io/qt-5/qheaderview.html#setSectionResizeMode-1" target="_blank" rel="noopener noreferrer nofollow ugc">http://doc.qt.io/qt-5/qheaderview.html#setSectionResizeMode-1</a> lets you set the resize mode for each column</p>
<p dir="auto">P.S.</p>
<blockquote>
<p dir="auto">my columns set to resizeColumnsToContents() but when setting setStretchLastSection(True)</p>
</blockquote>
<blockquote>
<p dir="auto">self.table_1.verticalHeader().setStretchLastSection(True)</p>
</blockquote>
<p dir="auto">verticalHeader is for the rows, horizontalHeader is for the columns</p>
]]></description><link>https://forum.qt.io/post/386135</link><guid isPermaLink="true">https://forum.qt.io/post/386135</guid><dc:creator><![CDATA[VRonin]]></dc:creator><pubDate>Tue, 04 Apr 2017 16:51:44 GMT</pubDate></item><item><title><![CDATA[Reply to How to set ResizetoContent for a single column in TableWidget? on Tue, 04 Apr 2017 16:49:43 GMT]]></title><description><![CDATA[<p dir="auto">Oups, Qt 5.8</p>
]]></description><link>https://forum.qt.io/post/386134</link><guid isPermaLink="true">https://forum.qt.io/post/386134</guid><dc:creator><![CDATA[sysla1]]></dc:creator><pubDate>Tue, 04 Apr 2017 16:49:43 GMT</pubDate></item><item><title><![CDATA[Reply to How to set ResizetoContent for a single column in TableWidget? on Tue, 04 Apr 2017 16:43:22 GMT]]></title><description><![CDATA[<p dir="auto">What Qt version are you using?</p>
]]></description><link>https://forum.qt.io/post/386130</link><guid isPermaLink="true">https://forum.qt.io/post/386130</guid><dc:creator><![CDATA[VRonin]]></dc:creator><pubDate>Tue, 04 Apr 2017 16:43:22 GMT</pubDate></item></channel></rss>