Sometime you need to show data in external window with custom widget(s). This little code will help you.
function showCustomWidget() { QDialog *dlgMultiLine = new QDialog(); QGridLayout *gridLayout = new QGridLayout(dlgMultiLine); QPlainTextEdit *txtMultiline = new QPlainTextEdit(); txtMultiline->setPlainText(this->toPlainText()); gridLayout->addWidget(txtMultiline, 0, 0, 1, 1); dlgMultiLine->show(); }
your function leaks memory. you forgot to delete QDialog. Either allocate the QDialog on stack or set the Qt:
eleteonClose hint on that.