Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-122712

QMessageBox: setTextFormat() won't apply to informative text

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • None
    • 6.7
    • None
    • Any.
    • All
    • 2dbcb25bf (dev)

    Description

      QMessageBox has a default text label and also has a informative label. Developers can set both of them for the message box. Developers can also set the text format for the text label, but not the informative label, so if developers want to use Markdown (introduced in Qt 5.15) in QMessageBox, the informative label won't be able to render markdown text as intended.

      Minimized reproduce code:

      // main.cpp
      // To build: g++ main.cpp `pkg-config --cflags --libs Qt6Widgets`
      #include <QApplication>
      #include <QMessageBox>
      
      int main(int argc, char **argv) {
              QApplication a(argc, argv);
      
              QMessageBox mb;
              QString text("Text [link](#) text");
              mb.setTextFormat(Qt::MarkdownText);
              mb.setText(text);
              mb.setInformativeText(text);
              mb.exec();
      
              return 0;
      }
      

      Result:

      As you can see, the label above rendered the text as markdown, the informative label below rendered the text as plain text.

      Related patch to fix this issue: https://codereview.qt-project.org/c/qt/qtbase/+/542531

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            blumia Gary Wang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes