[Qt-interest] How make multi-column ListView with row type icon and status icon in status column?
Michael Leupold
lemma at confuego.org
Thu Jul 30 19:08:31 CEST 2009
Ed Sutton wrote:
> Which Qt widget(s) could meet the following requirements:
>
> - Can display a device type icon on left-side of columns 0
> - Can display a pass or fail status icon on right-side of column 2
>
> For example:
>
> Device Type | Location | Status Message
> -------------------------------------------------------
> <iconDeviceTypeA.png> DeviceA | Rack1 | Good <iconGreen.png>
> <iconDeviceTypeA.png> DeviceA | Rack2 | Failure - No response
> <iconRed.png> <iconDeviceTypeB.png> DeviceB | Rack3 | Warning - Over
> temperature<iconYellow.png>
>
> I am having trouble getting oriented with QListViews, QTreeViews, models,
> and such.
>
> I currently have a QTreeView prototype derived the example
> /itemviews/simpletreemodel.
QTreeView is what you want. Setting rootIsDecorated to false will make it
look like a multi-column list (if there are no nested subitems).
> The prototype polls and displays device status information retrieved via
> SNMP and the QTreeView consumes data formatted as a a hierarchical xml
> doc. I am having trouble discovering how to place icons in desired column
> or as
> an alternative changing cell background color to indicate status. Should
> I be using a different type of list view widget?
Make your reimplemented QAbstractItemModel's data() method return the icon
when the requested role is Qt::DecorationRole. The preferred background
color can be returned by the model if Qt::BackgroundRole is requested. Also
have a look at http://doc.trolltech.com/4.5/model-view-model.html#item-
roles.
Regards,
Michael
More information about the Qt-interest-old
mailing list