怎么把标题加粗呢?

发布于 2024-08-27 23:34:34 字数 455 浏览 9 评论 0原文

QMessageBox中如何使标题文本变为粗体? 下面是示例代码,我用它来显示消息框:

int ret = QMessageBox::warning(this, tr("My Application"),
          tr("document has been modified.\n"
          "Do you want to save your changes?"),
          QMessageBox::Save | QMessageBox::Discard
          | QMessageBox::Cancel,
          QMessageBox::Save);

我只希望 tr("My Application") 为粗体,其余为正常字体。 我怎样才能做到这一点?
默认情况下,我获得标题和描述性文本的正常字体。

谢谢。

In QMessageBox how can I make the title text bold?
Here is the sample code, which I am using to disply a messagebox:

int ret = QMessageBox::warning(this, tr("My Application"),
          tr("document has been modified.\n"
          "Do you want to save your changes?"),
          QMessageBox::Save | QMessageBox::Discard
          | QMessageBox::Cancel,
          QMessageBox::Save);

I just want tr("My Application") to be bold, and rest to be in normal font.
How can I do that?
By default I am getting the normal font for both title and descriptive text.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你另情深 2024-09-03 23:34:34

您可以向消息框内容添加一些类似 HTML 的格式,即:

// ...
"Do you want to save your <b>changes</b>?"),
// ...

我无法访问 S60 环境来检查它是否也适用于消息框标题。它不适用于 Windows,但是,嘿,值得一试。

You can add some HTML-like formatting to the message box contents, i.e. :

// ...
"Do you want to save your <b>changes</b>?"),
// ...

I do not have access to S60 environment to check if it works for message box title too. It doesn't work on Windows, but hey, it's worth a shot.

我ぃ本無心為│何有愛 2024-09-03 23:34:34

这是不可能的,因为大多数窗口管理器不允许在窗口标题中包含富文本。

This is not possible since most window managers do not allow rich text inside the window title.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文