<?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[sizeHintForColumn not returning size including icon size]]></title><description><![CDATA[<p dir="auto">Hi,<br />
I am trying to add item that have icon and label to QlistWidget, and I want to resize my item to its content that where I am using sizeHintForColumn to adjust, but its just returning size of text hence my text is getting cropped.</p>
<p dir="auto"><strong>Code:</strong></p>
<pre><code>void QTListWidget::addItems()
{
    for(int i = 0 ; i &lt; 10 ; i++)
    {
        QLabel* pLabel = new QLabel(QString::fromStdString("labelText") + QString::fromStdString(getString()));
        QListWidgetItem* item = new QListWidgetItem();
        item-&gt;setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);


        //addIcon
        item-&gt;setIcon(QIcon("success-16x16.png"));
        
        //size item to widget current max widget
        item-&gt;setSizeHint(QSize(this-&gt;sizeHintForColumn(0) + 1, 20));

        addItem(item);
        setItemWidget(item, pLabel);
    }
}
</code></pre>
<p dir="auto"><strong>Result:</strong><br />
<img src="https://ddgobkiprc33d.cloudfront.net/11ee0b96-2a51-4f6b-810a-e7f1a2ea4a50.png" alt="05c15c8c-7829-495f-981b-a17b76dd0ec6-Screenshot (125).png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Is there any way we can get size and adjust it to fit the contents?</p>
<p dir="auto">Any help is very much appreciated.</p>
]]></description><link>https://forum.qt.io/topic/142127/sizehintforcolumn-not-returning-size-including-icon-size</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Apr 2026 17:35:08 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/142127.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 11 Jan 2023 13:23:51 GMT</pubDate><ttl>60</ttl></channel></rss>