If you look for ideal elements fit, like in form in QTCreator, You don't have to use Layout.
Just put widgets on place, make it ALL proportional etc.
include class I put below, I put example too at the end
It works like a charm, if you will have to use QLayouts, make them MaxMin constraint, but results may be strange. When you use it, better forget about layouts ;)
It is as follows:
Pic 3 with these long spacers contains complex widgets MechPartWidget presented in pic 4. You can see a tiny selection above the 2nd vertical spacer
Then, in MechPartWidget there are no layouts/widgets with vertical horizontal policy set to expanding.
Next, in the MechPartWidget there is a custom widget InventoryWidget. I tried to add QVBoxLayout to it, several widgets, and then a vertical spacer - and I expect this own-added layout would be honoured only inside boundaries of InventoryWidget, yet it isn't.
After looking through implementation of Qt positioners (qquickpositioners.* in qtdeclarative) I have found that the positioning itself is done in updatePolish method while in itemChange and onCompleted methods positioning is schedule and polish is called.
At this point I don't completely understand how it works, but it resolved my problem and I didn't have to resort to using qt private modules.
I do most layouts using Designer and loads mostly data from code.
But you dont have to choose one way over the other.
The UI forms is converted to code ( see setupUI() )
so sometimes i use Designer to create a layout/setup and then use the code from my code as templates.
The main reason we like using UI files is that it allows the non UX developers to do a bit of GUI sometimes as its less involving to drag a new button to
a layout than reading heaps of setup code to find right spot.
But basically, its more a matter of taste than anything technical . But there are things you need to do from code as designer cannot do it.
Actually I did try setting QTabWidget setAutoFillBackground(True) previously, but it didn't work.
Now I tried set VGroupBox setAutoFillBackground(True), then the color changed to light grey which is the exact default color I need.
For the code being in the constructor when it should not be, I only did it that way to have the simplest code possible to show my issue. I understand and agree with your point. I am working on an already existing application, I created this QtCreator project to isolate and replicate the issue. I do not call QWidget::show() in the constructor of my application.
I have made an important discovery while working on this issue: calling blue_widget->show() at the end of my code in my QtCreator project does fixe the problem, but doing the same in my application does not fix the issue. This is the 1st time I see a different behavior, I thought I had manage to have the same 1:1 behavior between the QtCreator project and my application.
You change the widget geometry in a way it affects hints. so layout has to be updated.
From the top of my head it might be enough to call the following updateGeometry() on every affected widget. Aka:
Actually I take it back.
If you could show your ui->setupUi(this); code I could probably say more, but as for now it seems you are trying to use the same layout in different dialogs. Make sure you do not.
someone please correct me if i am wrong, but i believe there is no Qt way of doing this. This has to be done in natively using mobile platform's capabilities.
On android this would be altering the manifest file, on iOS i think you need to overrride UINavigationController. See this and this.
The fact that you are using PyQt rather than C++ is neither here nor there to the solution. If the code above in the answers works for C++, you just have to translate it to Python/PyQt and it will work there too.
... jugando con los layout logre bastante lo que quería , nose si de la manera correcta pero al cambiar el tamaño de la ventana los botones se mantienen a la derecha ...
Bueno, si hace lo que buscabas, en principio ya está. Lo único que quizás pueda hacerse con menos layouts, pero eso es algo que irás viendo a medida que diseñes más ventanas y vayas entendiendo su funcionamiento.
Para esto no hay más que practicar, personalmente cuando me inicié con Qt, me costó mucho el tema de los layuot, pero ahora, después de haber diseñado muchas ventanas, las hago mucho más rápido, aunque de vez en cuando me encuentro con alguna que me cuesta diseñar XD