C++ (Qt)void TextEdit::setTextAndResize( const QString& text ){ QSize ds = QApplication::desktop()->size(); QTextDocument *doc = document(); QSize sz( ds.width(), ds.height() ); setMaximumSize( sz ); setText( text ); document()->adjustSize(); sz = document()->size().toSize() + QSize( 4, 4 ); doc->setPageSize( QSizeF( sz ) ); setMinimumSize( sz ); setMaximumSize( sz );}