Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-53845

Cannot disable QGraphicsSimpleText antialiasing with Qt 5.x

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4: Low
    • None
    • 5.4.2, 5.6.0
    • GUI: Font handling
    • None
    • * Windows 8.1 x64 with Qt 5.6.0 using MSVC 2013 (64 bits);
      * Mageia 5 x64 with Qt 5.4.2 using both gcc 4.9 and clange 3.5 (64 bits)
      * Mageia 5 x64 with Qt 4.8.6 using gcc 4.9 (64 bits)

    Description

      I'm trying to display a grayscale picture, on which areas of interest are shown with superimposed reticle-like objects and a small text using the QGraphic View Framework.
      I had problem on some hardware with the OpenGL layer, therefore my goal is to let the CPU do the rendering. I added an option to disable antialiasing on displayed view, triggered by a right-click on the picture. The slot which toggles the antialiasing is implemented as:

      void PictureDisplay::toggleSmoothing()
      {
          QPainter::RenderHints hints( renderHints() );
          hints ^= QPainter::Antialiasing;
          hints ^= QPainter::TextAntialiasing;
          hints ^= QPainter::SmoothPixmapTransform;
          hints ^= QPainter::HighQualityAntialiasing;
          setRenderHints( hints );
          QFont font( "Arial", 18 );
          if ( ( hints & QPainter::HighQualityAntialiasing ) != 0 )
          {
              font.setStyleStrategy( QFont::PreferAntialias );
              foreach ( QGraphicsSimpleTextItem* item, OverlaidTexts )
              {
                  item->setFont( font );
              }
              PixmapItem->setTransformationMode( Qt::SmoothTransformation );
          }
          else
          {
              font.setStyleStrategy( QFont::NoAntialias );
              foreach ( QGraphicsSimpleTextItem* item, OverlaidTexts )
              {
                  item->setFont( font );
              }
              PixmapItem->setTransformationMode( Qt::FastTransformation );
          }
      }
      

      I've tested this code with Qt 5.6.0 64bits on Windows 8.1 using MSVC 2013, Qt 5.4.2 64bits on Mageia 5 using both gcc 4.9 and clang 3.5, Qt 4.8.6 64bits on Mageia 5 using gcc 4.9.
      Now, here's the catch:

      • the Windows Qt 5.6 version does not disable text antialiasing, unless I use the OpenGL viewport;
      • the Linux Qt 5.4 version does not disable text antialiasing (and I have no OpenGL output, i.e. blank widget, but never mind);
      • the Linux Qt 4.8 does disable text antialiasing (and I have no OpenGL output, i.e. blank widget, but never mind).

      In all cases, the displayed picture and the reticle-like shape respond correctly to the antialiasing toggling.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            johansolo Johan Luisier
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes