Qt + in porting + i got error QWidget::paintEngine: Should no longer be called QPainter::begin: Paint device returned engine == 0, type: 1

  • hi,
    In my code i use to draw a real time graph outside paintEvent by setting property WA_PaintOutsidePaintEvent to true for qframe. It is plotting properly in my linux desktop as it is having x11. when i ran the same app in my arm based processor for which we have ported qt, i am getting error
    QWidget::paintEngine: Should no longer be called
    QPainter::begin: Paint device returned engine == 0, type: 1

    As my arm environment is not having x11,Is this is the problem to draw outside paint event.

  • Well: don't do that. Paint on a QImage / QPixmap buffer and schedule a repaint, then just blit the buffer.

  • Then i need to use paintEvent function because repaint / update will call paintEvent function.
    Any other solution to draw outside paintEvent function because in my application there are 15 different graphs. some page will display 4 graphs at a time on a same gui-page depending on real time value.

    Thanks for reply

  • Yes, but the paintEvent will be easy to code (just blit the buffer you prepared, i.e.

    QPainter p(this);

    . And in the other places where you used to paint directly on the widget, just open the painter on that buffer instead. I know it's a hack, but painting outside paint events is definitely something you shouldn't do in the first place.

  • Hi sushmars,

    if you are not using X11, which painting system do you use? Qt embedded with framebuffer? then perhaps a "QDirectPainter":http://doc.qt.nokia.com/latest/qdirectpainter.html could help, as you xcan access the framebuffer also outside the paint event. But then you loos Qt's double buffer features...

  • Here is a piece of code which displays 2 graphs at a time Which is called by 2 threads simultaneously.

    QPainter *Dys_ecgpainter;
    QPainter *Dys_Balpainter;

    in init function i declare those 2 painters

    Dys_ecgpainter= new QPainter;

    Dys_Balpainter = new QPainter;
    Dys_Balpainter->begin( (QWidget*)ansiscopeMainWindow->ui->DysAutonomia_Test_balANS_frame);


    Dys_DrawECG function is called from ECG thread which plots ecg on a qframe

    void Dys_DrawECG(int data)

    if(Dys_ECGgraph.currentplot.X >= Dys_ECGgraph.rightbottom.X)
        Dys_ECGgraph.currentplot.X = 0;
        //qWarning("\nAfter reaching end of frame 200\n");


    Dys_DrawbalANS function is called from BalANS thread which plots balANS on a qframe

    void Dys_DrawbalANS(POINT *Dys_points)

    int i;
    int firsttime=1;
    float x,y;
    int Xvalue ,Yvalue ;
    int Xpos, Ypos;
    int balCurrentPlotX, balCurrentPlotY, balLastPlotX, balLastPlotY;
    balCurrentPlotX = 0;
    balCurrentPlotY = 0;
    balLastPlotX = 0;
    balLastPlotY = 0;
    firsttime =1;
    for(i = 0; i< 312; i++)
            // Balpainter->moveTo(Xpos,Ypos);  //Pen Position
        {   Dys_Balpainter->drawLine(balCurrentPlotX, balCurrentPlotY, balLastPlotX, balLastPlotY);
        balLastPlotX = balCurrentPlotX;
        balLastPlotY = balCurrentPlotY;


    EDIT: please use @-tags for code highlighting, Gerolf

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.