QTextEdit resizing
-
How do i make textedit field occupy as much place as much text occupies?
When text bounds is bigger than textedit, scrollbar appears, but i want it to resize to fit whole text without vertical scrollbar appearing instead. i implemented such a crutch:
ui->textEdit->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); if (ui->textEdit->verticalScrollBar()->isHidden()) { qDebug() << "no scrollbar"; } else { while(ui->textEdit->verticalScrollBar()->isVisible()) { ui->textEdit->setFixedHeight(ui->textEdit->height() + 1); } }
but it doesnt help, when text block is smaller than actual size of QTextEdit; also, when I perform this function on QTextEdit placed into vertical layout, it begins overlap other widgets, no matter I call after verticalLayout update() and invalidate() methods.
I have played a lot with sizePolicy, still no result. Looking for an advice, if someone can provide minimal running example, it would be great.