Pergunta

I'm having problems with QTextEdit not shrinking below certain size. To be more precise. I have a widget with horizontal layout. This widget has two children, another container widgets. Each of this child widgets contain more or less the same elements (labels, QLineEdits, buttons,...). The only difference is, that the right container widget also has QTextEdit elements, right next to each other in another horizontal layout.

When the window is big enough, everything is positioned and sized correctly. The two container widget take 1/2 of the window each and the two QTextEdits take roughly 1/4 of the window each, all aligned properly. However, when the window gets small enough, the QTextEdits refuse to downsize, they keep constant width - breaking the proper alignment of the elements.

Have anyone ever encountered it? Do you know how to make the QTextEdits get smaller bellow the artificial threshold?

I was playing around with minimum size, various size policies. I've also looked into the Qt source of QTextEdit, QTextControl and QTextDocument to find some magical fixed minimal width to no success.

Attaching picture demonstrating the issue in Qt Designer Demonstration of QTextEdit ied minimal width in Qt Designer

Foi útil?

Solução

The trick is to set the minimum width of the QTextEdits to 0 (zero) and change the horizontal size policy to Ignored.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top