Results 1 to 6 of 6

Thread: Error Message "Paint device returned engine == 0, type:1"

  1. #1
    Join Date
    Apr 2012
    Posts
    17
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Error Message "Paint device returned engine == 0, type:1"

    hello ,
    I wrote a class named CEditorWin, and inherits QFrame class. I set the Attribute of CEditorWin with "setAttribute(Qt::WA_PaintOutsidePaintEvent);" . And I know what the Qt Assitant say
    "Warning: When the paintdevice is a widget, QPainter can only be used inside a paintEvent() function or in a function called by paintEvent(); that is unless the Qt::WA_PaintOutsidePaintEvent widget attribute is set. On Mac OS X and Windows, you can only paint in a paintEvent() function regardless of this attribute's setting."

    When I run the code below, it will return the Error Message "Paint device returned engine == 0, type:1" and the variable "ret" == FALSE.
    Qt Code:
    1. CEditorWin *m_pCanvas = new CEditorWin();
    2. QPainter *m_pPainter= new QPainter();
    3. assert(m_pPainter != NULL);
    4. bool ret = m_pPainter->begin(m_pCanvas);
    5. assert(ret != FALSE);
    To copy to clipboard, switch view to plain text mode 
    I think I write the code Strictly in accordance with what Qt says, but I also get the error. Why? I need help . Thanks very much.


    Added after 1 47 minutes:


    Sorry, My English is not good. I don't know what i say is clear.
    But I really want to solve it. I follow the source code to qpainter.cpp and qwidget_win.cpp. And I found the difference between the source code of Qt 4.7 and the source code of Qt 4.3 is huge. For example : the function "QPaintEngine *QWidget:aintEngine() const" in qwidget_win.cpp
    Can someone help me and explain to me the reason ?
    Thanks
    Last edited by yuzhouzhiwai; 27th April 2012 at 05:47.

  2. #2
    Join Date
    Jul 2010
    Location
    Indonesia
    Posts
    83
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: Error Message "Paint device returned engine == 0, type:1"

    Is your code inside paintEvent?
    ~ We are nothing in this universe ~

  3. #3
    Join Date
    Apr 2012
    Posts
    17
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Error Message "Paint device returned engine == 0, type:1"

    No, But I set the Attribute:
    m_pCanvas->setAttribute(Qt::WA_PaintOutsidePaintEvent);

  4. #4
    Join Date
    Jul 2010
    Location
    Indonesia
    Posts
    83
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: Error Message "Paint device returned engine == 0, type:1"

    Based on Qt documentation, Qt::WA_PaintOutsidePaintEvent makes it possible to use QPainter to paint on the widget outside paintEvent(). This flag is not supported on Windows, Mac OS X or Embedded Linux.
    ~ We are nothing in this universe ~

  5. #5
    Join Date
    Apr 2012
    Posts
    17
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Error Message "Paint device returned engine == 0, type:1"

    哈哈 是我弄错了。〠。。
    Oh,I know. My English is really bad. I have a wrong interpretation about "On Mac OS X and Windows, you can only paint in a paintEvent() function regardless of this attribute's setting".

    thanks


    Added after 15 minutes:


    Ok. But If I still user QPainter to paint on the widget outside paintEvent(), and I ignore the error message("Paint device returned engine == 0, type:1"), what is the result?

    I do use it like that, And I get right result up to now.

    thanks
    Last edited by yuzhouzhiwai; 27th April 2012 at 09:14.

  6. #6
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Error Message "Paint device returned engine == 0, type:1"

    That message means that the painter wasn't initialized, so you can't use it for paining.

    If you try you should get "Painter not active" error and nothing should be drawn.

Similar Threads

  1. Replies: 4
    Last Post: 25th February 2011, 09:01
  2. got error message "driver not loaded"
    By rivci in forum Newbie
    Replies: 2
    Last Post: 13th January 2011, 09:37
  3. Replies: 5
    Last Post: 15th December 2010, 02:54
  4. "Treat wchar_t as Built-in Type" to "yes" link error
    By sungaoyong in forum Qt Programming
    Replies: 1
    Last Post: 5th June 2008, 11:45
  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.