Frage

I have a UI, created from the designer, with a QGridLayout where I add my custom widgets from the code. There is no problem when I add 1~4 custom widgets, but when I try to put more, they overlap.

Here is an image to complete the explanation:

Without overlapping: http://i45.tinypic.com/wve8o6.png

Overlapped: http://i47.tinypic.com/565py.png

I'm trying to find a way to add some kind of scroll to the QGridLayout, so my custom widgets don't overlap between them and I can interact with all of them.

I tried to use a QScrollArea but when I added more than 4 widgets they continue overlapping and the scroll doesn't works properly.

War es hilfreich?

Lösung

Do you have the same problem when designing it codewise, not with the designer? I had couple of problems to, and found coding the gui a cleaner and more elegant way

Andere Tipps

What does minimumSize() and sizeHint() returns on your custom widget? I think you didn't implement those properly.

I had this problem, and resolved it by setting this->setMinimumHeight(267); where 267 is the int height of my widget.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top