GUI looks different and weird on different machines (Qt Creator 4.3.0)

  • Hi. I am a new Qt Creator user. I made a simple GUI using Qt Creator, which mainly includes QLabels and QTextEdits (basically user types some inputs and after clicking calculate, some outputs appear). I defined functionalities using PyQt 5 and made exe file using CX_freeze. The problem I have is that while GUI looks fine on my laptop, some font sizes and QLabel dimensions change on other machines and make the GUI look weird. In Qt Creator, I tried different size policies for QLabel and QTextEdit (expanding, fixed, etc) but did not fix the problem. I will be grateful to hear any suggestion. Thanks.

  • Hi, and welcome to the Qt forum. Can you please post a screenshot of the weird looking window?

  • Thank you! Sure, here is a picture of it running on another machine (while on my laptop it looks nice). 0_1501805583724_myAppOnAnotherMachine.jpg

  • I noticed different OS's have different default fonts and sizes.
    Fonts are larger on linux (ubuntu 16.04 LTS) vs windows if I have been a little lazy to not specify dimensions properly.

    I've found if I have my font pixels calculated it works better, as opposed to just unset or point size.

    Try specifying dimensions not just a points size (is my guess) - something like:
    font.pixelSize: ( parent.height / 2 );

    • you can set it to literally anything you like. It's just another QtObject/Item.

    Anyhow, I don't have a perfect system myself - but this might give you an idea on how to fix yours.

  • Hi @Akzmn
    Welcome to Qt world.
    Using fixed sizes in GUI design is not recommended, inorder to use for multiple screen sizes.
    Based on "const QRect QDesktopWidget::screenGeometry()" sizes of internal widgets should be rearranged.

  • Hi,

    @Akzmn , welcome to Qt,

    Make use of the below code to get width and height :

    QRect m_ScreenSize = qApp->primaryScreen()->geometry();

    int width = m_ScreenSize .width();
    int height = m_ScreenSize .height();

    So make use of width and height values for all visual ui elements , so it will fit to all platforms.
    make use of the width and height values.


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.