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. QGLWidget Viewport Ugly Text
Forum Updated to NodeBB v4.3 + New Features

QGLWidget Viewport Ugly Text

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 3.2k 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.
  • T Offline
    T Offline
    tallen
    wrote on last edited by
    #1

    When using a QGLWidget as a viewport for a QGraphicsView causes fonts to be insanely ugly. I am using a QGraphicsSimpleTextItem. Is there a way to make rendered text look as nice as it does when using the default viewport?

    Secondly, to work around this I am trying to render the background png-image and text off-screen into a pixmap, then adding the pixmap to the scene that is displayed on the screen. The problem is I cannot make the background transparent. Here is essentially what I am doing:

    • create a QGraphicsItemGroup
    • Add a QPixmap (which is a png image containing transparent parts)
    • Add a QGraphicsSimpleText item on top of the QPixmap
    • Add the QGraphicsItemGroup to a new QGraphicsScene
    • Create a QPixmap and a QPainter
    • Call QGraphicsScene::render into the QPainter.
    • Add the QPainter's QPixmap to the output scene that is displayed on the screen.

    The rendered text looks good again however no matter what I try, the QGraphicsScene always fills in the transparent parts of the background png with a background color. Even when I set the background color of the scene to have a 0 alpha value, I still get a background color. I also tried adding another step and putting the scene into a viewport and using setAutoFillBackground to false which did not help either. Is there something I am missing here or maybe a better way to do this? I cannot have rendered text looking like we are back in the 80's.

    Thanks!

    Travis

    [EDIT: list formatting, Volker]

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jim_kaiser
      wrote on last edited by
      #2

      If you are using a QPainter to paint.. Could you turn on Anti-Aliasing.. see QPainter::RenderHint. Also, if you're scaling the text or image, then that could cause it to look ugly, if you scale a QImage, pass the Qt::TransformationMode argument and set it as Qt::SmoothTransformation. I'm not sure if this would help, but maybe you get some hint as to why its happening.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tallen
        wrote on last edited by
        #3

        From what I have read, it is a known problem that fonts in Qt look absolutely ridiculously ugly when drawn using a QGlWidget. If I paint them in the background using a QPainter then simply use the QPixmap I generate as the text instead of a QGraphicsSimpleTextItem directly it looks as it should, however I cannot make the QPainter/QGraphicsScene draw a transparent background color into the generated QPixmap. Therefore you get a grey background filling the QPixmap behind the text. Is there a way to have it draw the background transparent? I have tried everything I could find in the API docs that seemed like it should affect the background.

        Travis

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jim_kaiser
          wrote on last edited by
          #4

          Hi Travis,

          I will try it out and let you know if I could get it working. The transparency in my opinion shouldn't be an issue and usually isn't (atleast with the QPainter, we do a lot of transparency in our app with QPainter with no issue). Anyways, I'll try it and get back to you.

          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