how to repaint the custom delegate
hi:
i have a listview with custom delegate and model. i want a checkbox in each row,and click the checkbox or the row will lead to different functions. i do not know how to handle this.but i found a method to handle it. i use a bool to determine whether to draw checkbox or not.this codes were written in QAbstractItemDelegate::paint.and a button to decide the bool's value.
so here comes the problem,when i click the button,the checkbox did not show.when i move my mouse,it will appear.so i know i should send some singals or somethings to trigger the checkbox show.but i do not know ,how to do that things.please help me.thankx.
Re: how to repaint the custom delegate
Do you really need custom delegate ? You could have used QListWidgetItem and QListWidgetItem::setCheckState .
Still hard to help you without seeing some code.
4 Attachment(s)
Re: how to repaint the custom delegate
thanks for you reply.
i do need use custom delegate. my list view is like that.
Attachment 7881
the code works fine and have noting to do with the problem i asked. i want to improve the performance,so i encounter that problem.when i click the edit button, i change a bool value in the subclass of QAbstractItemDelegate,and in the function paint.
Attachment 7882
Attachment 7883
when i move my mouse ,the paint will be called and the checkbox will showed in the list.
but now i want to automatic repaint the listview ,not the movement of my mouse will activate it.so please help me, how to do that thing.
Re: how to repaint the custom delegate
Did you try QListView::update or QListView::repaint when the Edit button is clicked ?
Re: how to repaint the custom delegate
i had tried QListIView::repaint, it no works. but QListView::update need a QModelIndex, and i do not know how to make one.so it is still stuck. and do you know how to send out the mouse movement event,if we know that,this problem will be solved.
Re: how to repaint the custom delegate
i found a special method to solve this problem. when i clicked the button,i call a function in delegate,which emit dataChanged signal.thus the paint function in model will be called and my checkbox will show in the frame.
Re: how to repaint the custom delegate
Quote:
hi yuyue,
can you explain and/or post your solution, because I have the same kind of issue with my paint update from my delegate ?
Best Regards.
Domzique.
Ok I find a way to repaint using