Nominate our 2022 Qt Champions!

[solved] QPlainTextEdit to QMessageBox Problem

  • Goodday,

    I am very new to Qt and some assistance. I have created a dialog.ui and add 2 PlainTextEdit. What I need assistance with is:

    How do I concatenate the string from the first edit with the second edit and display the result in a QMessageBox.

    I have been looking for the answer but to no avail.If someone could point in the right direction that would be great.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Since you don't state how you would like that to happen, I'll take a QPushButton as trigger. Write a slot for that button, and in it grab the text from the tow QPlainTextEdit.


    void MyCoolWidget::on_myButton_clicked()
    QString string = ui->myPlainTextEdit1->toPlainText() + ui->myPlainTextEdit2->toPlainText();
    QMessageBox::information(this, tr("My Cool Title"), string);

    Hope it helps

  • Thanks for the assistance

  • Lifetime Qt Champion

    You're welcome !

    If that answers your question then please update the thread title prepending [solved] so other forum users may know a solution has been found :)

    Happy coding !

Log in to reply