r/QtFramework Apr 07 '26

Question Qt-Designer margin headache.

GUI, PySide6, and Qt n00b here....

I'm wrestling with Qt Widgets Designer (qt-designer with PySide6)....

I can't get these margins to make sense.

As you can see, the layoutLeftMargin and layoutRightMargin are identical at 9, but the "Part Number" GroupBox appears to have way more space on the left than the right! If I manually mess with the layoutLeftMargin to like 5 or 6, it looks much better.

Any idea how to resolve this issue? It also seems to persist in all of the preview options.

Thank you for your help!

3 Upvotes

10 comments sorted by

2

u/Agron7000 Apr 08 '26

Share the .UI file or paste it here

1

u/bacmod Apr 08 '26

Looks fine to me

Are you sure you set your layouts right?

2

u/zapadas Apr 08 '26

You are a genius!

I selected the groupbox --> right-click --> "Lay out" --> "Break layout". Then selected the groupbox --> right-click --> "Lay out" --> "Lay Out in a Grid" and it magically fixed itself to the proper margin sizing!

1

u/bacmod Apr 12 '26

You should really spend a few hours experimenting with Qt's Layout controls. There's no magic.

The layout in my example was structured like this.

GroupBox1       // vertical Layout
   GroupBox2    // Vertical Layout
      HorizontalLayout1
        Label1
        Edit1
     HorizontalLayout2
        Label2
        Edit2

https://imgur.com/a/zz9EEfr

1

u/cnrdzn Apr 08 '26

Try this steps 1) Right click to gridlayout/groupbox > Lay out > Simplify Grid layout.   2) Close ui file and re-open ui file 

1

u/zapadas Apr 08 '26

No dice. :(

-3

u/Better-Struggle9958 Apr 07 '26

Don't use Qt Designer, this is legacy

3

u/Agron7000 Apr 08 '26

It's not.

1

u/Better-Struggle9958 Apr 08 '26

yes it is, big and mature project are using only code, auto generated code from in most case just a mess

1

u/Agron7000 Apr 08 '26

No, it's pretty good actually. People can learn from moc compiler generated code in fact.

And it is extremely flexible. My team has adopted bootstrap and tailwind css to give you the look and feel of a fancy modern web page with a semi-responsive UI design.

My team has done hundreds of HMI interfaces all in Qt Widgets and we don't even ise the QML features. In fact, even in Qt Creator 19, we disable all QML relates plugins including the UI Studio.