[Qt-interest] Fwd: Fwd: QAbstractItemModel edit process

Nikos Gerontidis geronik444 at gmail.com
Thu Apr 22 11:56:42 CEST 2010


---------- Forwarded message ----------
From: CarstenBreuer <CarstenBreuerOSS at textwork.de>
Date: Thu, Apr 22, 2010 at 12:31 AM
Subject: Re: [Qt-interest] Fwd: QAbstractItemModel edit process
To: Nikos Gerontidis <geronik444 at gmail.com>


>> Hello list,
>>
>> I have subclassed the QAbstractItemModel class and reimplemented the
>> setData and the other functions needed in order to make the model
>> editable. I have created custom items and my model follows a tree
>> structure and multiple columns.
>> The problem is that when I edit my model for a given index for decoration
> That depends on how you implemented setData. It sounds like you
accidentally
> implemented it to change the color of all columns instead of just one.

Yes, i think so to. Perhaps the role checking is missing.
if (role == Qt::DecoraticeRole)
{
}
else
{
  return QVariant();
}

Regards,


Carsten
>
>> Thanks in advance..
>>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com <mailto:Qt-interest at trolltech.com>
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
> Hi,
> This could be it, I will check it and post again.
> Thanks anyway.
>
> --
> Best Regards
> Nikos Gerontidis
>
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest


This was it, I had to implement the setData function properly
excerpt code :
setData(..)
{
   if (role == Qt::DecorationRole)
   {
      if (trueVal)
        return true;
     else
       return false
    }
if (role == ...)
..
}
and also in the same way the data function..
Thanks a lot guys..
-- 
Best Regards
Nikos Gerontidis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100422/3779ccb9/attachment.html 


More information about the Qt-interest-old mailing list