ListView Custom delegate crash in paint
I have created my Listview with custom Delegate. The paint method looks like this:
@void List_view_delegate::paint(QPainter * painter, const QStyleOptionViewItem & option,
const QModelIndex & index) const
// Update data of widget here.
const QString name = index.data(Character_model::CharacterNameRole).toString();
// Paint the widget now.
This List_view is a part of a Widget which has a QPropertyAnimation set on its maximumWidth to give animated sliding of the widget. When the widget maximumWidth becomes 0, the paint() method of listview crashes in the render method.
SOmebody has a clue??
The output shows:
QPaintDevice: Cannot destroy paint device that is being painted
ASSERT: "enginePriv" in file kernel/qwidget.cpp, line 4725
Silly question but why are you painting a widget which has no size ?
No I am not painting on no size.
The animation reduces the size but still paint event is called because animation is resizing the widget.
What if you stop at one and then make the widget invisible rather that go to zero ?
Actually I suspected that the widget is getting of size 0. I tried to print the option.rect.size() in paint() of my delegate and it prints:
and after this it gives segmentation fault.
Strange part is that it asserts in Qt
That is where is asserting. I dont understand
Can you show a complete stack trace ?
I hope this helps:
What is Characters_view_delegate ?
Characters_view_delegate is my custom delegate for my QListView. I paint my delegate in paint. In the above code ,
List_view_delegate = Characters_view_delegate
Can you create a minimal example that shows the crash ?