I have no idea how to force pyuic4 to generate QSpacerItem's as a class members in a .py file. Everything else is generate as a members of a class, for example gridLayout
self.gridLay = QtGui.QGridLayout()
Everything except QSpacerItem
spacerItem = QtGui.QSpacerItem(20, 0, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum)
self.gridLay.addItem(spacerItem, 0, 2, 1, 1)
Any idea how to correct that?
PS I don't ask how to correct it manually ;).
There's nothing you can do to change this behaviour through the
pyuic4
interface.However,
pyuic4
is written in PyQt, so if you feel like hacking, the relevant code is inPyQt4/uic/uiparser.py
. Specifically, thecreateSpacer
andsetupObject
methods of theUIParser
class. ThesetupObject
method is what is normally used to create attributes for objects, but obviously thecreateSpacer
method doesn't currently use it.I'm not sure why things are currently done this way. To get a definitive answer, you'd probably have to ask the project maintainer (Phil Thompson) on the PyQt Mailing List.
Also note that, if you know the spacer's position in the grid-layout, you can access it like this: