【问题标题】:Multiline QInputDialog prompt多行 QInputDialog 提示
【发布时间】:2014-01-22 22:07:52
【问题描述】:

我目前正在使用这样的东西:

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

现在我想要对话框中的文本

"Hello World !! What goes in here"

分布在两行。像这样

        Hello World !! 
       What goes in here

对我能做什么有什么建议吗??

【问题讨论】:

    标签: c++ qt


    【解决方案1】:

    只需插入一个换行符:

    "Hello World!!\nWhat goes in here"
    

    完整的可编译示例说明了为什么有时使用应用程序框架并不是一个坏主意。假设您有一个适当的、基于 Unicode 的标准库作为开始,它不再是一个类似的命令行变体。

    #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;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多