Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, February 2007
QItemDelegate - drawBackground


Message 1 in thread

Hi,

I'm using a QTableView with a custom model and want to have a linear 
gradient in each row that starts leftmost of the scrollarea and stops 
rightmost.
Therefore I provide the QLinearGradient in my model as a QBrush via the 
Qt::BackgroundRole.
The brush origin is set to the topleft of each cell by QItemDelegate 
since Qt 4.2. After drawing is gets set back to the original origin. The 
result of that is that the gradient restarts with each column.
Unfortunately the method QItemDelegate::drawBackground(...) const is the 
only draw... method that is not virtual!
Why is this the case?
Subclassing QItemDelegate to overwrite the paint mehtod is not really a 
solution, because a lot of functionality is encapsulated through the 
private implementation pattern.

How can I achieve a continuous gradient for a line in the table without 
completely rewriting QItemDelegate?

Thanks a lot for you help and ideas!

Greets
Jens


I'm currently using
- MS VS2005 SP1
- Windows XP SP2 (on an AMD Athlon 3500+)
- qt-win-commercial-4.2.2-vs2005

--
 [ signature omitted ] 

Message 2 in thread

Commercial version, why not send to support@xxxxxxxxxxxxx?

Regards,
Liang Qi

On 05/02/07, Jens Schmeling <jens.schmeling@xxxxxxxx> wrote:
> Hi,
>
> I'm using a QTableView with a custom model and want to have a linear
> gradient in each row that starts leftmost of the scrollarea and stops
> rightmost.
> Therefore I provide the QLinearGradient in my model as a QBrush via the
> Qt::BackgroundRole.
> The brush origin is set to the topleft of each cell by QItemDelegate
> since Qt 4.2. After drawing is gets set back to the original origin. The
> result of that is that the gradient restarts with each column.
> Unfortunately the method QItemDelegate::drawBackground(...) const is the
> only draw... method that is not virtual!
> Why is this the case?
> Subclassing QItemDelegate to overwrite the paint mehtod is not really a
> solution, because a lot of functionality is encapsulated through the
> private implementation pattern.
>
> How can I achieve a continuous gradient for a line in the table without
> completely rewriting QItemDelegate?
>
> Thanks a lot for you help and ideas!
>
> Greets
> Jens
>
>
> I'm currently using
> - MS VS2005 SP1
> - Windows XP SP2 (on an AMD Athlon 3500+)
> - qt-win-commercial-4.2.2-vs2005

--
 [ signature omitted ] 

Message 3 in thread

I did as well, but I thought that perhaps someone in the community had a 
similar problem already and that everyone can participate in discusson 
or solution.

Regards,
Jens
> Commercial version, why not send to support@xxxxxxxxxxxxx?
> 
> Regards,
> Liang Qi
> 

--
 [ signature omitted ]