Ericson Willians
Ericson Willians

Reputation: 7845

Is there a layout manager for PyQt / Qt similar to MigLayout?

MigLayout is my layout manager of choice (In Java), and I can't find similar functionality in Qt (Tutorials in PyQt only consider QBoxLayout and QGridLayout). From the Qt list of layout managers, is there something similar to Mig?

Example from the guide (Java):

panel.add(comp1)
panel.add(comp2, "span 2") // The component will span two cells.
panel.add(comp3, "wrap") // Wrap to next row
panel.add(comp4, "span")

enter image description here

I love how it's possible to expand an individual cell, instead of spacing them equally within a "grid". It allows you to build really complex UIs.

Upvotes: 0

Views: 123

Answers (1)

goug
goug

Reputation: 2444

QGridLayout does this. The addItem method has rowSpan and columnSpan parameters that allows the cell you're creating to span across, down, or both. It's very easy and works great.

ADDITION:

For inserting a widget, use addWidget. Note that there are two versions, and one of them allows for column and row spanning.

Upvotes: 1

Related Questions