Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QPainter behaviour different depending on the pen colour

QPainter behaviour different depending on the pen colour

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    limdor
    wrote on last edited by
    #1

    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 );@

    1 Reply Last reply
    0
    • U Offline
      U Offline
      utcenter
      wrote on last edited by
      #2

      Image doesn't show for me

      Btw, you can simply do:

      @if(mGUITexture)
      {
      delete mGUITexture;
      }@

      1 Reply Last reply
      0
      • L Offline
        L Offline
        limdor
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved