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.
CEditorWin *m_pCanvas = new CEditorWin();
assert(m_pPainter != NULL);
bool ret = m_pPainter->begin(m_pCanvas);
assert(ret != FALSE);
CEditorWin *m_pCanvas = new CEditorWin();
QPainter *m_pPainter= new QPainter();
assert(m_pPainter != NULL);
bool ret = m_pPainter->begin(m_pCanvas);
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
Bookmarks