PDA

View Full Version : QPainter::setPen() painter not active



tesmai4
29th August 2013, 18:17
I have two scenarios.

In first scenario: I added a QFrame in QWidget (acting as my mainwindow). I have a function drawline(). I call this function in QFrame::paintevent(). This works fine without any errors and lines are drawn.


In the second scenario, I am drawing on a QFrame after receiving response from my server.
My QFrame is add into MainWindow. When I call my draw function (outside QFrame's paintevent), I get the following errors:

QPainter::begin: Paint device returned engine == 0, type: 1
drawing lines w/o painter
QPainter::setPen: Painter not active
QPainter::setPen: Painter not active
QPainter::setPen: Painter not active
QPainter::setPen: Painter not active


Can anyone help me in solving the problem?

thanks

Santosh Reddy
29th August 2013, 20:18
When I call my draw function (outside QFrame's paintevent),
Painting should be done only in paintEvent() function or other functions called from paintEvent().

BTW QPainter has to created with QWidget/QFrame as parent