[Qt-jambi-interest] Problem for displaying header and data
Vincent Lebreil
vincent.lebreil at gmail.com
Mon Feb 2 13:31:42 CET 2009
Thanks a lot Gunnar !
It works fine now !
I haven't even thought that returning the same data for all roles could lead
to this behaviour ! So thanks again ! :-D
Best regards !
Vincent
On Mon, Feb 2, 2009 at 1:06 PM, Gunnar Sletta <gunnar at trolltech.com> wrote:
> Vincent Lebreil wrote:
>
>> Hi,
>>
>> I don't understand why nothing is displaying (neither header and data) if
>> I'm using a QTreeView and my own model which inherits QAbstractItemModel.
>>
>> Btw if I use a QStandardItemModel instead, it works fine. Don't understand
>> why ??
>>
>> Best Regards,
>> Vincent
>>
>
> Hi Vincent,
>
> Both the headerData() and data() functions are used to query the model for
> a number of different roles, such as font, color, text, etc. In your
> example, you do not properly distinguish between roles and you probably end
> up with an invalid font and an invalid color. If you add a
>
> if (role == Qt.ItemDataRole.DisplayRole)
> {
> // look up string and return it
> }
> else return null;
>
> around your data accessor functions, you should get the proper results.
>
> -
> best regards,
> Gunnar
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-jambi-interest/attachments/20090202/54287e46/attachment.html
More information about the Qt-jambi-interest
mailing list