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:
    "Comparison":http://postimage.org/image/ec49ubn2v/
    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);
    image.fill(Qt::transparent);

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

    QPen newPen = painter.pen();
    //newPen.setColor(Qt::black);
    newPen.setColor(Qt::white);
    painter.setPen(newPen);
    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:

    @if(mGUITexture)
    {
    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.