QPainter behaviour different depending on the pen colour

  • When I draw text with the painter I get really different results when is painted white or black:
    I'm not sure if this is a bug or I don't understand properly something. Any suggestion?

    This is the code that I use:
    @QImage image(mWinWidth, mWinHeight, QImage::Format_ARGB32_Premultiplied);

    QPainter painter(&image);
    painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing);

    QPen newPen = painter.pen();
    painter.setFont(QFont("Helvetica [Calibri]", 14, 10));

    painter.drawText(mViewport, Qt::AlignTop | Qt::AlignLeft, mTopLeftText);
    painter.drawText(mViewport, Qt::AlignTop | Qt::AlignHCenter, mTopMidText);
    painter.drawText(mViewport, Qt::AlignTop | Qt::AlignRight, mTopRightText);
    painter.drawText(mViewport, Qt::AlignCenter, mMiddleText);
    painter.drawText(mViewport, Qt::AlignBottom | Qt::AlignLeft, mBottomLeftText);
    painter.drawText(mViewport, Qt::AlignBottom | Qt::AlignHCenter, mBottomMidText);
    painter.drawText(mViewport, Qt::AlignBottom | Qt::AlignRight, mBottomRightText);
    if(mGUITexture != NULL)
    delete mGUITexture;
    mGUITexture = new Texture( new QImage( QGLWidget::convertToGLFormat(image) ), true );@

  • Image doesn't show for me

    Btw, you can simply do:

    delete mGUITexture;

  • I've changed the image and now it's a link. I hope that you can see.
    About if(mGUITexture) thanks but I will not answer because we could start "a large discussion":http://stackoverflow.com/questions/3825668/c-c-checking-for-null-pointer about what is prefered.

Log in to reply

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