<?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 hide the unnessary column of the qwidgetitem ?]]></title><description><![CDATA[<p dir="auto">When i used the qwidgetitem of the qt ui objects ,it comes out that an unnessary column on the last of the column.<br />
Esspesially when I scrolled to the maximum window,the last column of the qtablewidget became the longest column,so ugly.Idont know what to do or search information from the forum.<br />
Here's the code below.</p>
<pre><code>setSelectionBehavior(QAbstractItemView::SelectRows);  
    setSelectionMode(QAbstractItemView::SingleSelection); 
    setContextMenuPolicy(Qt::CustomContextMenu);// and how to add a menu trigger with this widgetitem?
    setAlternatingRowColors(true);
    verticalHeader()-&gt;setHidden(true); 

//the code created the widgetitems of the qtablewidget
 for(int rowid = 0;rowid&lt; rowCount;rowid++){
        UiBaseComponentTableWidgetItem * edititem = new UiBaseComponentTableWidgetItem();
        edititem-&gt;onCreateAllChild();
        int itemCount = colCount &gt;= edititem-&gt;getContentCount() ? edititem-&gt;getContentCount() : colCount ;
       //***when the itemCount equals number 5,there would be 6 columns in the widget *** 
        for(int itemId = 0;itemId &lt; itemCount;itemId++){
            QTableWidgetItem * tmpptr =(QTableWidgetItem *)edititem-&gt;getTableItem().at(itemId);
            setItem(rowid,itemId,tmpptr);
        }
        mTableItem.push_back(edititem);
    }

</code></pre>
]]></description><link>https://forum.qt.io/topic/139483/how-to-hide-the-unnessary-column-of-the-qwidgetitem</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 04:19:16 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/139483.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 22 Sep 2022 05:07:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to hide the unnessary column of the qwidgetitem ? on Fri, 23 Sep 2022 08:13:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/nicker-player">@<bdi>nicker-player</bdi></a> said in <a href="/post/729894">How to hide the unnessary column of the qwidgetitem ?</a>:</p>
<blockquote>
<p dir="auto">I bind the headerview signal sectionResized to the method to control the width but failed</p>
</blockquote>
<p dir="auto">Please provide more details and show the code. Why do you do that at all?</p>
]]></description><link>https://forum.qt.io/post/729895</link><guid isPermaLink="true">https://forum.qt.io/post/729895</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Fri, 23 Sep 2022 08:13:48 GMT</pubDate></item><item><title><![CDATA[Reply to How to hide the unnessary column of the qwidgetitem ? on Fri, 23 Sep 2022 08:11:18 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a><br />
In fact its not.Because when i resize one of the columns to the maximum width, then the headview horizonal scollbar appears for a short time .only if i double click the headerview ,then the scrollbar disappeared and the width becomes normally.<br />
So how to prevent this happened.I bind the headerview signal sectionResized to the method to control the width but failed.</p>
]]></description><link>https://forum.qt.io/post/729894</link><guid isPermaLink="true">https://forum.qt.io/post/729894</guid><dc:creator><![CDATA[nicker player]]></dc:creator><pubDate>Fri, 23 Sep 2022 08:11:18 GMT</pubDate></item><item><title><![CDATA[Reply to How to hide the unnessary column of the qwidgetitem ? on Fri, 23 Sep 2022 08:02:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/nicker-player">@<bdi>nicker-player</bdi></a> said in <a href="/post/729754">How to hide the unnessary column of the qwidgetitem ?</a>:</p>
<blockquote>
<p dir="auto">that the user could modified the width of the headerview columns</p>
</blockquote>
<p dir="auto">That should work by default</p>
]]></description><link>https://forum.qt.io/post/729893</link><guid isPermaLink="true">https://forum.qt.io/post/729893</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Fri, 23 Sep 2022 08:02:11 GMT</pubDate></item><item><title><![CDATA[Reply to How to hide the unnessary column of the qwidgetitem ? on Fri, 23 Sep 2022 07:57:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a><br />
Could u help me ? it is very hard for me to find an easy way to fix the problem.</p>
]]></description><link>https://forum.qt.io/post/729892</link><guid isPermaLink="true">https://forum.qt.io/post/729892</guid><dc:creator><![CDATA[nicker player]]></dc:creator><pubDate>Fri, 23 Sep 2022 07:57:57 GMT</pubDate></item><item><title><![CDATA[Reply to How to hide the unnessary column of the qwidgetitem ? on Fri, 23 Sep 2022 01:21:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a><br />
Yeah ,thanks a lot.<br />
But it would be not what I want.<br />
all the columns have the same width  what looks like.<br />
I just wondered if there is a mode that do not have the empty space and user could modified the column width.</p>
<p dir="auto">Now I use the code like this</p>
<pre><code>QHeaderView * header = horizontalHeader();
    header-&gt;setSectionResizeMode(QHeaderView::Interactive);
    header-&gt;setCascadingSectionResizes(true);
    header-&gt;setMinimumSectionSize(60);
    header-&gt;setStretchLastSection(true);
</code></pre>
<p dir="auto">I just want to acommplish a function that the user could modified the width of the headerview columns<br />
by themself .<br />
But in fact once one of the columns was modified,the others after the one modified would disappear from the view area if I resize the column the max width.<br />
How could i do to prevent the user maximum the column not to be the max width or maybe this is what i want:<br />
when the user modified the column width there wouldnt appear the horizontal scorllbar of the headerview and all of the columns would be in the view area.<br />
Its very hard to describe the actions.</p>
]]></description><link>https://forum.qt.io/post/729754</link><guid isPermaLink="true">https://forum.qt.io/post/729754</guid><dc:creator><![CDATA[nicker player]]></dc:creator><pubDate>Fri, 23 Sep 2022 01:21:26 GMT</pubDate></item><item><title><![CDATA[Reply to How to hide the unnessary column of the qwidgetitem ? on Thu, 22 Sep 2022 07:17:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/nicker-player">@<bdi>nicker-player</bdi></a> said in <a href="/post/729714">How to hide the unnessary column of the qwidgetitem ?</a>:</p>
<blockquote>
<p dir="auto">there would be an extra column</p>
</blockquote>
<p dir="auto">It's not an extra column, it's simply empty space.<br />
Take a look at <a href="https://stackoverflow.com/questions/17411634/resizing-qtablewidget-columns-and-rows-to-fill-table" target="_blank" rel="noopener noreferrer nofollow ugc">https://stackoverflow.com/questions/17411634/resizing-qtablewidget-columns-and-rows-to-fill-table</a></p>
]]></description><link>https://forum.qt.io/post/729717</link><guid isPermaLink="true">https://forum.qt.io/post/729717</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Thu, 22 Sep 2022 07:17:44 GMT</pubDate></item><item><title><![CDATA[Reply to How to hide the unnessary column of the qwidgetitem ? on Thu, 22 Sep 2022 07:14:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a><br />
In fact ,i dont think its the usage of the problem.I think its that maybe was the layout or something.<br />
When minimum the qtablewidget there would be the right columns,<br />
but once maximum the qtablewidget,there would be an extra column seemed in fact was not the column.Cause the last column has diffrent styles with the others before.<br />
I ve marked the area with the red <a href="http://pen.So" target="_blank" rel="noopener noreferrer nofollow ugc">pen.So</a> god pleas help me .I dont know why.<br />
<img src="https://ddgobkiprc33d.cloudfront.net/5c456990-b045-4920-9b0f-0b33ce0101d1.png" alt="41261abb-8493-4f8e-a0d0-414b7f69e431-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/post/729714</link><guid isPermaLink="true">https://forum.qt.io/post/729714</guid><dc:creator><![CDATA[nicker player]]></dc:creator><pubDate>Thu, 22 Sep 2022 07:14:20 GMT</pubDate></item><item><title><![CDATA[Reply to How to hide the unnessary column of the qwidgetitem ? on Thu, 22 Sep 2022 05:20:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/nicker-player">@<bdi>nicker-player</bdi></a> If you need 5 columns then insert 5 columns. If you get more then debug your code to see why you're inserting more columns (check itemCount in each iteration of the outer for loop).</p>
]]></description><link>https://forum.qt.io/post/729691</link><guid isPermaLink="true">https://forum.qt.io/post/729691</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Thu, 22 Sep 2022 05:20:03 GMT</pubDate></item><item><title><![CDATA[Reply to How to hide the unnessary column of the qwidgetitem ? on Thu, 22 Sep 2022 05:17:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a><br />
Yeah,<br />
Its hard to describe the container.<br />
For example,I just want 5 columns of the qtablewidget,but it appears 6 columns,and the last of the columns dosent have anything,It's just a blank column.I dont know howto hide it.</p>
]]></description><link>https://forum.qt.io/post/729689</link><guid isPermaLink="true">https://forum.qt.io/post/729689</guid><dc:creator><![CDATA[nicker player]]></dc:creator><pubDate>Thu, 22 Sep 2022 05:17:43 GMT</pubDate></item><item><title><![CDATA[Reply to How to hide the unnessary column of the qwidgetitem ? on Thu, 22 Sep 2022 05:10:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/nicker-player">@<bdi>nicker-player</bdi></a> said in <a href="/post/729686">How to hide the unnessary column of the qwidgetitem ?</a>:</p>
<blockquote>
<p dir="auto">it comes out that an unnessary column on the last of the column</p>
</blockquote>
<p dir="auto">What does this mean please? Do you mean you get a column you don't need? Please explain better.</p>
]]></description><link>https://forum.qt.io/post/729687</link><guid isPermaLink="true">https://forum.qt.io/post/729687</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Thu, 22 Sep 2022 05:10:24 GMT</pubDate></item></channel></rss>