0
votes

Below Code successfully auto-resizes QLineEdit field as needed (new width/height based on dynamic text). Now in order to make the resized QLineEdit fit the container widget, I do adjustsize() on the container widget.

Relevant elements in my code:

void theContainer::resize_to_content(QString text) {
{
// ...
lineedit.setFixedSize(calcualtedWidth, calculatedHigh);
theContainer::adjustSize();
}

the problem encountered is that even though both resizings of the QLineEdit and the parent widget work (to some extent), the limitation in this case is that the QlineEdit, after resizing, overlaps adjacent widgets! It looks like that container widget -- when it adjusts -- seems to ignore other non manipulated children ... Is there a systematic way to prevent such overlapping ?? not just a workaround I mean.

-- Widgets before adjustments

enter image description here

-- Widgets after text change and size adjustments:

enter image description here

1

1 Answers

1
votes

I'm pretty sure using the classes Qt provides specifically for layout management will help.

See Qt documentation on layout

If it won't, I think you could resize the entire window to get more space instead of only the parent widget.