diff options
author | Wang Zichong <[email protected]> | 2024-02-22 17:42:00 +0800 |
---|---|---|
committer | Wang Zichong <[email protected]> | 2024-03-14 21:40:53 +0800 |
commit | 2dbcb25bfa7157729370d964efb3df582e98239d (patch) | |
tree | de7e2f077394cc750ee4b01d3a0a501bace83e1a | |
parent | 2ff93ea0eeddc9c4c01c194e5af2a2c4506a9d9e (diff) |
QMessageBox: ensure setTextFormat() also apply to informative text
QMessageBox::setTextFormat can set the text format for its text label,
but the informative label will still use its default text format. This
change allow the setTextFormat also apply to the informative label, thus
user can use their preferred format like Markdown in the informative label.
Task-number: QTBUG-122712
Change-Id: I6f7487b29712ca07cee27171453312ff1707eea3
Reviewed-by: Tor Arne Vestbø <[email protected]>
-rw-r--r-- | src/widgets/dialogs/qmessagebox.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index f60bdcff8e1..ad501fab9ed 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -1463,6 +1463,8 @@ void QMessageBox::setTextFormat(Qt::TextFormat format) d->label->setTextFormat(format); d->label->setWordWrap(format == Qt::RichText || (format == Qt::AutoText && Qt::mightBeRichText(d->label->text()))); + if (d->informativeLabel) + d->informativeLabel->setTextFormat(format); d->updateSize(); } @@ -2668,9 +2670,14 @@ void QMessageBox::setDetailedText(const QString &text) information to the user, for example describing the consequences of the situation, or suggestion alternative solutions. + The text will be interpreted either as a plain text or as rich text, + depending on the text format setting (\l QMessageBox::textFormat). + The default setting is Qt::AutoText, i.e., the message box will try + to auto-detect the format of the text. + By default, this property contains an empty string. - \sa QMessageBox::text, QMessageBox::detailedText + \sa textFormat, QMessageBox::text, QMessageBox::detailedText */ QString QMessageBox::informativeText() const { @@ -2694,12 +2701,12 @@ void QMessageBox::setInformativeText(const QString &text) label->setTextInteractionFlags(Qt::TextInteractionFlags(style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, nullptr, this))); label->setAlignment(Qt::AlignTop | Qt::AlignLeft); label->setOpenExternalLinks(true); - label->setWordWrap(true); #ifdef Q_OS_MAC // apply a smaller font the information label on the mac label->setFont(qt_app_fonts_hash()->value("QTipLabel")); #endif label->setWordWrap(true); + label->setTextFormat(d->label->textFormat()); d->informativeLabel = label; } d->informativeLabel->setText(text); |