Important: Please read the Qt Code of Conduct -

Graphic Appearance after Porting to Qt 5.4

  • 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.

  • Moderators

    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?

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

    Here is some screen shot of the differences...

    "Screen shots here...":

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

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

  • 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;
    ret = desktop->physicalDpiY()/25.4;
    ret = ret * 2; // <---- fixes the problem!!
    delete desktop;
    delete qa;
    return ret;

  • Moderators

    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 ( ) and see if it affects your program.

    You might also be interested in this article:

Log in to reply