There is too much space around my widgets in my application and I want to track down which widgets are causing this space. Is the only source of space contentMargins? Is there extra space created by QBoxLayout objects? What about the matplotlib FigureCanvas?
My main question is:
Is there a program that recursively traverses the Qt widget tree displaying margins and sources of space?
I am not aware of such program, but if you use Qt Designer, you can open *.ui files with any text viewer and look for properties with suspicious names such as “margin” or “spacing”. Box layouts have them too, for example:
As you can see, a lot of additional 6-pixel margins and spacing here. Once you’ve figured out which properties are responsible for your troubles, just set them to zero or something reasonable.
If you don’t use Qt Designer, it’s harder. You can still use Designer to create a sample GUI that will help you figure out the culprits. Then you can write a piece of code that traverses the widget tree and prints out that properties.