QPainter crashed with QT 4.8.6 in iOS 10.6.8

129 views Asked by At

As title, I am using Qt4.8.6.

I design a UI to paint something on a QWidget in iOS 10.6.8.

It works fine in Ubuntu 14, but the same code crash in iOS.

I got the following error message:

Wed Nov 12 22:33:01 MacBook1.local main[75787] <Error>: CGContextSetLineDash: invalid context 0x0
Wed Nov 12 22:33:01 MacBook1.local main[75787] <Error>: CGContextSetStrokeColorWithColor: invalid context 0x0
Wed Nov 12 22:33:01 MacBook1.local main[75787] <Error>: CGContextSetFillColorWithColor: invalid context 0x0
Wed Nov 12 22:33:01 MacBook1.local main[75787] <Error>: CGContextSetShouldAntialias: invalid context 0x0
Wed Nov 12 22:33:01 MacBook1.local main[75787] <Error>: CGContextSetFontSize: invalid context 0x0
Wed Nov 12 22:33:01 MacBook1.local main[75787] <Error>: CGContextGetTextMatrix: invalid context 0x0
Wed Nov 12 22:33:01 MacBook1.local main[75787] <Error>: CGContextSetTextMatrix: invalid context 0x0
Wed Nov 12 22:33:01 MacBook1.local main[75787] <Error>: CGContextSetTextDrawingMode: invalid context 0x0
Wed Nov 12 22:33:01 MacBook1.local main[75787] <Error>: CGContextSetFont: invalid context 0x0
Wed Nov 12 22:33:01 MacBook1.local main[75787] <Error>: CGContextSetTextPosition: invalid context 0x0
Wed Nov 12 22:33:01 MacBook1.local main[75787] <Error>: CGContextShowGlyphsWithAdvances: invalid context 0x0

and my PaintEvent code:

void Widget_captcha::paintEvent(QPaintEvent* e)
{
    if(this->canRoll)
    {
        this->showWidget->update();
        rollChar_Font();
        this->canRoll=false;
    }
    QPainter p(this->showWidget);

    // p.setBackgroundMode(Qt::TransparentMode );

    QColor color[11]=
    {
        Qt::black,
        Qt::darkRed,
        Qt::darkGreen,
        Qt::darkBlue,
        Qt::darkCyan,
        Qt::darkMagenta,
        Qt::darkYellow,
        Qt::darkGray,
        Qt::cyan,
        Qt::magenta,
        Qt::gray
    };

    QTransform trans[5];
    trans[0].translate(0,0);
    trans[0].rotate(0);
    trans[0].scale(1.1,1);

    trans[1].translate(5, 0);
    trans[1].rotate(10);
    trans[1].scale(1, 0.5);

    trans[2].translate(5, 5);
    trans[2].rotate(-5);
    trans[2].scale(0.9, 1.1);

    trans[3].translate(0, 35);
    trans[3].rotate(0);
    trans[3].scale(0.9, 0.4);

    trans[4].translate(0, 5);
    trans[4].rotate(0);
    trans[4].scale(0.9, 0.4);

    for(int i=0;i<6;i++)
    {
        p.setTransform(trans[this->iTransform[i]]);
        p.setFont(this->font[i]);
        QPen pen(color[this->iColor[i]],5);
        p.setPen(pen);
        p.drawText(38*i, 50,this->code[i]);
    }
}

Thank you.

0

There are 0 answers