PDA

View Full Version : QListWidgdet resizeEvent QPainter::begin: Paint device returned engine == 0, type: 2



WezSieTato
30th December 2013, 11:59
Hi,
I made class inherit from QListWidget and overrride resizeEvent:


void ImageList::resizeEvent(QResizeEvent *event)
{
QListWidget::resizeEvent(event);

int width = event->size().width() / columnNumber - 10;
setIconSize(QSize(width, width));
setGridSize(iconSize());
}

But sometimes when I resize the widget by splitter, the application crash with this message:


QPainter::begin: Paint device returned engine == 0, type: 2

What is the proper way to change iconSize and gridSize when user resize widget? I try to use BlockingQueuedConnection and emit signal to yourself, but this make dead lock.

anda_skoa
30th December 2013, 17:06
A BlockingQueuedConnection blocks (as its name suggests) the emitting thread. If the receiver is the same thread, it is now waiting for itself.

What you could try instead is using a QTimer, setup for single shot with a short interval. In resizeEvent() you restart it, in the slot connected to it you do the size adjustments.

Cheers,
_