Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Why does the Form Editor's Preview not match the actual result at runtime?



  • Hello.

    After a long year of Qt training, I have this question I'm afraid to ask because it seems pretty stupid, but here we go...

    I don't know why all my forms always look ridiculously tiny at runtime. It's not only the form. Everything inside (labels, buttons, etc.) seems like being scaled down for some reason.

    So, I always have to oversize everything at design time to get my desired result, but his is an annoying try-n-error task.

    Strangely, the form preview matches the sizes I see in the editor, but at runtime, it's another story.

    I've experienced this both in Qt Creator and Qt Designer.

    Is there a reason for the design/runtime difference in scale? Am I forgetting something?

    Thanks.


  • Lifetime Qt Champion

    Hi,

    Might be a silly question but are you using layouts when you create your custom widgets ?

    Are you using some high DPI settings ?


  • Lifetime Qt Champion

    Hi @Alvein,

    which platform are you on? And which Qt version are you using?

    Are you using an Hi-DPI screen, or what's your resolution?

    Could you upload a demo project so someone could verify or deny your findings?

    Regards



  • Hello.

    @SGaist,

    At least, I'm always using a layout for the central widget.
    I never place objects using absolute pixel positions.

    My display settings:
    scale-and-layout.JPG
    *No custom scaling.

    @aha_1980,

    Using Windows 10. My Qt version is 5.14.2. I've been experiencing the same problem since my very beginning in Qt (around August 2019). I don't remember what was the last version during those days.

    I have a 4K screen, but I guess that if there was a problem with this, some of my customers had said "why is everything so big" at some point. And that never happened. In fact, I've seen some screenshots (captured by them because of distinct reasons) and never noticed anything different.

    I've uploaded a demo here. It's just the UI. I just placed some controls and set their layouts. Everything else (code and properties) come by default.

    Notice how it looks at design/preview:
    mini-demo-preview.JPG

    Now, notice how it looks at runtime (I've placed the app window over the design form for you to compare the huge difference):
    mini-demo-runtime.JPG

    Thanks guys for your replies.



  • @Alvein
    Can you show picture of the widget hierarchy window in Designer (I think it's the Object view?), at least for me? Do you have a layout on whatever top-level QWidget type you are designing?



  • @JonB, yes but, even a form with a single button will have the problem. I don't think this has to do with the objects hierarchy...

    mini-demo-layout.JPG


  • Lifetime Qt Champion

    Something does look strange, you seem to have several independent layouts there rather than one main containing the others.



  • @SGaist, the centralwidget's layout contains the others. I've placed a bunch of layouts just to sort the controls, but it has little to do with the problem. I don't follow what you said either.

    Anyway. Check this simpler sample:

    Design/preview. Expected size.
    mini-demo-dialog-preview.JPG

    Runtime
    mini-demo-dialog-runtime.JPG

    One single layout. Same problem.

    ....

    Has somebody opened the previously attached sample project?


Log in to reply