[Qt-jambi-interest] BackgroundRole

Vincent Lebreil vincent.lebreil at gmail.com
Tue Feb 10 14:19:32 CET 2009


Hi !

Do you have the same behaviour with my QTreeView/QAbstractItemModel ? and if
so, do you know why ?

Thx

On Thu, Feb 5, 2009 at 6:52 PM, Vincent Lebreil
<vincent.lebreil at gmail.com>wrote:

> Hi,
>
> I'm trying to display a background color for all items of my model.
> I've tried to return a QColor in my data method for BackgroundRole. But
> this color is only displayed if the mouse is over one row of my view. This
> color is not displayed for all the rows of my view.
> I don't understand why, cause if I do the same thing but with
> DecorationRole, it works great (ie all the rows of my view have this
> decoration).
>
> Thanks for your help
>
> Vincent
>
> ---------------8< -------------------
> public Object data(QModelIndex index, int role) {
>         Object data = null;
>         if (index != null) {
>             if (role == Qt.ItemDataRole.DisplayRole }
>                     data = "data";
>             } else if (role == Qt.ItemDataRole.DecorationRole) {
>                 data = QColor.blue;
>             } else if (role == Qt.ItemDataRole.BackgroundRole) {
>                 data = QColor.blue;
>             }
>         }
>         return data;
>     }
> -------------8<-----------------------
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-jambi-interest/attachments/20090210/33c34e15/attachment.html 


More information about the Qt-jambi-interest mailing list