PyQt QGridLayout question

V

Volker Lenhardt

Once again a maybe silly question, but I find no solution, neither in
the documentation nor in examples.

I have got some different layouts to change place by the help of a
QGridLayout in its parent widget. To make it nice I use row/col spacing
and stretch respectively as well as multicell widgets. There is no
problem if the layout next to come uses more rows and columns than the
former one. But if it is the other way round, the grid seems to take
those now unused rows and columns into account and uses more space than
expected.

Before changing to another layout I remove and delete all widgets within
the grid and set spacing and stretch of all used rows and columns to 0:

for c in self.gridContents.values():
self.grid.removeChild(c)
self.gridContents.clear()
for i in range(20):
self.grid.addColSpacing(i,0)
self.grid.addRowSpacing(i,0)
self.grid.setColStretch(i,0)
self.grid.setRowStretch(i,0)

Only if I do a total resection and remove the grid and the parent
widget, too, to set them up again, all is fine but for the flicker on
the screen. Is there a more convenient way? Remove rows/columns as can
be done in tables?

Best wishes
Volker
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top