PDA

View Full Version : Delegate paint event bug?



jerry7
19th October 2010, 11:51
hi,

I make my model view and delegate, I find that every time my mouse enter in/out the view,all items delegate's paint event are called. this is very time consume, because these items are not need to be repaint as i only move my mouse in and out to the view. Is it a bug? Or how to disable these event?

thanks !

wysota
19th October 2010, 13:05
Did you enable mouse tracking or did something else non-standard (like asking the widget to accept hover events) on the view or its viewport?

jerry7
20th October 2010, 03:14
No, i have not set mouse tracking, and I can't receive the mouse Move event in MyListView when no button is pressed.

these code in MyListView constructor:

FileClipModel *model = new FileClipModel;
FileClipDelegate *delegate = new FileClipDelegate;
setModel(model);
setItemDelegate(delegate);

this is delegate paint. It is called when mouse enter in/out whitout button pressed. Every time the mouse enter in/out MyListView , all item color changed!

void FileClipDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index)const
{
painter->fillRect(option.rect,QColor(double(qrand())/RAND_MAX*255,double(qrand())/RAND_MAX*255,double(qrand())/RAND_MAX*255));
}