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. Graphic Appearance after Porting to Qt 5.4
Forum Update on Monday, May 27th 2025

Graphic Appearance after Porting to Qt 5.4

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 1.6k Views
  • 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.
  • M Offline
    M Offline
    MarkNH
    wrote on last edited by
    #1

    I just ported a very large desktop application from Qt 4.6 to Qt 5.4. The application uses QGraphicsScenes and styles extensively. In the original version of the app we used the setGraphicsSystem("raster"). With this being deprecated in Qt 5, after the port, the aspect ratio, and sizes and shape of graphic elements are no longer the same.
    I think it may be related to the way Qt 5 handles the screens. Is there a simple way to get the same painting characteristic that was available in the previous versions of Qt?

    Note: Using the stock Qt5 binary distribution for VS 2013 32 bit.

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi, and welcome to the Qt Dev Net!

      Are you relying on any other functions/classes that have been deprecated?

      Can you show some example code?

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MarkNH
        wrote on last edited by
        #3

        Not many methods in gui needed to be changed...

        Here is some screen shot of the differences...

        "Screen shots here...":https://drive.google.com/file/d/0B3R4C4nC85UabkR2RU92MTNTRzg/view?usp=sharing

        It will take some time to prepare the code...

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MarkNH
          wrote on last edited by
          #4

          The spacing - margins called out by the style sheets seem to be ignored in Qt5.4 rendering....

          1 Reply Last reply
          0
          • M Offline
            M Offline
            MarkNH
            wrote on last edited by
            #5

            SOLVED: Problem was on Windows - the calculation for Screen Width and Screen Height resolution is not the same as in previous versions of Qt. Seems related to "virtual pixels" and "actual pixels". The resolution returned half of what it was in previous version of Qt.
            Quick fix was to multiply the resolution by two.
            Similar function to get width resolution (getScreenWidthResolution())

            @static qreal getScreenHeightResolution(void)
            {
            QApplication qa = 0;
            QDesktopWidget desktop;
            char argv[2] = { "", "" };
            int argc = 0;
            if(qApp == 0)
            {
            qa = new QApplication(argc, argv);
            }
            desktop = new QDesktopWidget;
            qreal ret = 0;
            #ifdef Q_OS_LINUX
            qreal height = desktop->screenGeometry().height();
            qreal heightMM = desktop->heightMM();
            int dpiY = (height
            254 + heightMM
            5) / (heightMM
            10 );
            ret = dpiY/25.4;
            #else
            ret = desktop->physicalDpiY()/25.4;
            ret = ret * 2; // <---- fixes the problem!!
            #endif
            if(desktop)
            delete desktop;
            if(qa)
            delete qa;
            return ret;
            }@

            1 Reply Last reply
            0
            • JKSHJ Offline
              JKSHJ Offline
              JKSH
              Moderators
              wrote on last edited by
              #6

              Are you using a high-DPI display? I'm not 100% sure, but your method might make the screen height too big on low-DPI screens.

              Try changing Windows' text scaling settings (http://www.sevenforums.com/tutorials/443-dpi-display-size-settings-change.html ) and see if it affects your program.

              You might also be interested in this article: http://doc.qt.io/qt-5/highdpi.html

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              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