MistyD
MistyD

Reputation: 17223

Multiline QInputDialog prompt

I am currently using something like this:

QString text = QInputDialog::getText(this, tr("title"),"Hello World !! What goes in here",  QLineEdit::Normal, QString(""), &ok);

Now I want the text in the Dialog

"Hello World !! What goes in here"

to be spread over two lines. like this

        Hello World !! 
       What goes in here

Any suggestions on what I could do ??

Upvotes: 0

Views: 705

Answers (1)

Simply insert a line break:

"Hello World!!\nWhat goes in here"

The complete compileable example shows why sometimes using an application framework isn't that bad of an idea. It's no longer than a comparable command-line variant would be, assuming that you had a proper, Unicode-based standard library to start with.

#include <QApplication>
#include <QInputDialog>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QInputDialog::getText(nullptr, "Title", "Hello World !!\nWhat goes in here");
    return 0;
}

Upvotes: 4

Related Questions