Easiest way to display icons in a table
Hi there,
while using a TableView and costum item delegates would be one way to display Icons in a table, I suspect there is a simpler way, possibly even with QTableWidget.
However, when I simply create a new QTableWidgetItem with an Icon and insert it into the table, it won't be shown.
The code below doesn't will insert a table widget item, but won't show the icon.
Code:
table->setItem(row, 0, iconItem);
So, what would be the correct (and simplest) way to show Icons in a Table?
Re: Easiest way to display icons in a table
Something pretty much similar works fine for me. I'm suspecting that the image just cannot be loaded. Is the usage of resources intentional? Are the resources compiled correctly? Do you have a line similar to:
Quote:
RESOURCES += <something>.qrc
in the .pro file? RCC would give an error in case the image couldn't be found.
Re: Easiest way to display icons in a table
If you're using a TableView you can simply return a QIcon in your QAbstractItemModel's data function. That should display the icon you want in the table.
Re: Easiest way to display icons in a table
Quote:
Originally Posted by
jpn
Something pretty much similar works fine for me. I'm suspecting that the image just cannot be loaded.
Yes, that was it. Works now as it is supposed to. Thanks!