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::drawText display corrupted text on a QOpenGLWidget
Forum Updated to NodeBB v4.3 + New Features

QPainter::drawText display corrupted text on a QOpenGLWidget

Scheduled Pinned Locked Moved Solved General and Desktop
qt5.6.3qopenglwidgetqpainter
3 Posts 2 Posters 1.6k Views 2 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.
  • A Offline
    A Offline
    Alain38 0
    wrote on last edited by Alain38 0
    #1

    Hi,
    I have a QOpenGLWidget. This widget is used to display different elements:

    • a background image (OpenGL texture),

    • a list of selected pixels (OpenGL texture displayed on the background)

    • A text displaying the distance between two selected pixels (QPainter::drawText)

    All OpenGL drawing are enclosed by a beginNativePainting/EndNativePainting. But I have a strange behavior on the text drawing.

    At the beginning of the application, when the layer with selected pixels has not yet been displayed, if I'm using the measure tool, text is correctly displayed and still be correctly displayed once the selected pixels layer is activated.

    But, if I start the application, activate the display of the selected pixels layer, and then use my measure tool, displayed text is corrupted. And it is no more possible to have a correct display (even with the selected pixels layer disabled). The text is displayed has in the below image:
    0_1524640385224_corrupted text.PNG
    In fact this text looks like I had a shift between each pixel row. Any ideo of the origin of this problem?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Alain38 0
      wrote on last edited by
      #2

      Problem found. In my program I have a line

          func->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
      

      As long as the layer is not displayed, this line is not executed. So, once active, I supposes that it has a side effect on the loading of the glyphs. Once glyphs are loaded with standard alignment everything works well. But, with a byte alignment something is broken.

      Now it is not normal that a call to an OpenGL function changes the way glyphs are loaded.

      1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Glad you found out and thanks for sharing !

        What version of Qt are you using ?
        On which platform ?
        Did you check the bug report system to see if it's something known ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        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