Unsolved Automatic resizing problem
-
Hello,
Je suis nouveau sur QT et j'essaie de tout redimensionner avec la fenêtre (avec Qt Designer).
I have set up the various elements in a layout, and when I resize directly with QTDesigner, it works.
However, when I run the application, the elements do not resize.
Additional Info
Did I forget something?
Thank -
Hi and welcome to devnet,
One strange thing I see is that you have your two horizontal layouts beside each other. AFAIK, it's not something that should be possible. You can have only one layout applied on a widget. That layout however can contain other layouts like horizontalLayout_2 does.
-
Hello,
I couldn't answer before. I did some tests with what you explained to me, but nothing changes.
-
In the first image, you have no layout and in the second it looks like the layout was bit applied to the widget (I might be wrong though), how are you handling the layouts exactly ?
-
@SGaist
Hello,This is what I do:
I don't know why it is not displayed, but after adding the buttons, I right click on the main window, and in "layout", I choose "place horizontally".
At the end, on the image, the window is not also displayed, but it is launched. I resize it, but the buttons don't.
-
What do you get if you put just the buttons on the widget and then call layout horizontally using the contextual menu has explained here ?
-
@SGaist
Hello,
It is the same result. In Qtdesigner, resizing works.
Once run, no.
-
Additional info,
When I use pyside2 without qt creator it seems to work.
I tested the following code:
https://doc.qt.io/qtforpython/quickstart.html -
@moas
Then I would compare the code which ends up being generated from Designer (viapyuic
) into the.py
file against the example which works, see what it is that is different, and work back from there? -
Here are the 2 files:
On the left, the .QUI converts
The only differences are highlighted in red. -
@moas These two code snippets do not match at all. On the left side you have two buttons in a horizontal layout. On the right side you have a button and a label in a vertical layout.
-
Normal, in one is the code snippet of the link, in the other it's just a test on my part. I did not see the point of making the same layout as on the link, because to compare, I think that is enough.
Besides, I do not see any real difference once the same layout.
-
On the other hand, I don't know if there is a link, but I don't see self.setLayout (self.verticalLayout)
-
If you are talking about the UI_test code, that's because
self.verticalLayout
is created with at parent. When you give a layout a parent at construction time it's directly applied to it.