show data in external window with custom widget in qt

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();
 
}
Category(s): Qt, Qt-Tips
Tags: , , ,

One Response to show data in external window with custom widget in qt

  1. your function leaks memory. you forgot to delete QDialog. Either allocate the QDialog on stack or set the Qt:Smilie: :DeleteonClose hint on that.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

 

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">