How to show icons without text in QListWidget?

Dmitriy picture Dmitriy · Nov 6, 2011 · Viewed 11.5k times · Source

I want to show only icons in my QListWidget. I set text to empty string. When I select an icon I see an empty selected square on the text place. See the screenshot How can I get rid of this empty space?!

Answer

compiler picture compiler · Jul 3, 2014

use NULL instead

ui->listWidget->addItem(new QListWidgetItem(QIcon(":/res/icon"),NULL));