Results 1 to 2 of 2

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

  1. #1
    Join Date
    Dec 2013
    Posts
    2
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

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

    Hi,
    I made class inherit from QListWidget and overrride resizeEvent:

    Qt Code:
    1. void ImageList::resizeEvent(QResizeEvent *event)
    2. {
    3. QListWidget::resizeEvent(event);
    4.  
    5. int width = event->size().width() / columnNumber - 10;
    6. setIconSize(QSize(width, width));
    7. setGridSize(iconSize());
    8. }
    To copy to clipboard, switch view to plain text mode 

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QListWidgdet resizeEvent QPainter::begin: Paint device returned engine == 0, type

    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,
    _

Similar Threads

  1. Error Message "Paint device returned engine == 0, type:1"
    By yuzhouzhiwai in forum Qt Programming
    Replies: 5
    Last Post: 30th April 2012, 09:33
  2. Replies: 0
    Last Post: 27th April 2012, 13:54
  3. Replies: 4
    Last Post: 25th February 2011, 09:01
  4. Replies: 5
    Last Post: 20th October 2009, 07:18
  5. paint device returned engine == 0, type: 3
    By MarkoSan in forum Qt Programming
    Replies: 14
    Last Post: 12th December 2007, 10:42

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.