[PyQt] Bogus setMargin generated by pyuic4

Saúl Ibarra Corretgé saghul at gmail.com
Tue Nov 20 16:56:29 GMT 2012


Hi all,

I ran into a problem in which pyuic4 will generate a bogus setMargin 
call and Google is not helping much, I hope someone can shed some light.

Here is the test ui file:

https://gist.github.com/4119155#file_test.ui

It's a simple main window with a QHBoxLayout inside a QWidget. Margins 
are all set to the same value: 5. Now, the generated code contains 2 
calls to setMargin, one for 5 (correct) and another one with 0 
(incorrect) for the layout:

https://gist.github.com/4119155#file_test.py

See lines 28-29.

By inspecting uiparser.py, in function createLayout, an extra 'margin' 
element is added (~line 433) because the layout is child of a QWidget 
which is not the child of the main window. The code in that function 
checks if there are individual margin elements but looks like fails in 
the case where there is a single 'margin' element, that is, when all 
margins are equal. If at least one margin is different then problem 
doesn't appear.

Is this a bug in the ui parser or am I doing something wrong here?


Regards,

-- 
Saúl Ibarra Corretgé
http://saghul.net/blog | http://about.me/saghul


More information about the PyQt mailing list