Reese
Reese

Reputation: 253

QWidget - Always resizing by window size

I have a QTextEdit Control and I want it to resize widh window size always. My solution is using a timer, but that won't be really elegant, so I thought, there must be a property.

Could you help me? Uncle Google wasn't any help.

Thanks in advance.

P.S.: I've tried to write in proper English, but I'm from germany, so there could be some mistakes. I hope you excuse it.

Upvotes: 1

Views: 639

Answers (2)

hydron
hydron

Reputation: 1

Generaly, You can do that just with layouts, just wrap the QTextEdit inside one, (QVBoxLayout or QHBoxLayout for example). Or if you have a specific case, you can use the method prposed by Mailerdaimon.

Upvotes: 0

Mailerdaimon
Mailerdaimon

Reputation: 6080

You could use your Windows resizeEvent to update the size of your QTextEdit.

Read more about the resizeEvent in the QWindow documentation: http://doc.qt.io/qt-5/qwindow.html#resizeEvent

And here is an Example:

void MyQWindow::resizeEvent(QResizeEvent* event)
{
   QWindow::resizeEvent(event);
   this->resizeTextEdit(); // In this function you update the size
}

Upvotes: 1

Related Questions