QT QMessageBox控制线路破解

发布于 2025-02-03 16:27:23 字数 432 浏览 3 评论 0原文

我使用QT Qmessagebox显示错误消息。 问题是,当错误消息类似于

    Error opening file at location 'C:\Users\User\some_folder\some_file'

QT之后的QT插入“:”路径之后的线路破解时,而不是使用一个空格之一:

    Error opening file at location 'C:
    \Users\User\some_folder\some_file'

有没有办法告诉您在char之后不要断开线':':':'? 我可能有

    Error opening file at location 
    'C:\Users\User\some_folder\some_file'

I use QT QMessageBox to show an error message.
The problem is, when the error message is something like

    Error opening file at location 'C:\Users\User\some_folder\some_file'

qt inserts linebreak after the ':' in the path, instead of using one of the withespaces:

    Error opening file at location 'C:
    \Users\User\some_folder\some_file'

Is there a way to tell not to break line after char ':'?
I would likely have

    Error opening file at location 
    'C:\Users\User\some_folder\some_file'

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

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

发布评论

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

评论(1

夜光 2025-02-10 16:27:23

我不确定这是否有效,因为我尚未测试它,但是您可以使用QT建议的HTML子集。该子集包含< nobr>元素。参见 https://doc.qt.io/qt.io/qt-5/richtext-5/richtext-5/richtext-5/richtext-5/richtext- -html-subset.html

因此,请尝试以下QString msg =“位置< nobr>'c:\ users \ user \ user \ user \ some_folder \ some_file”代码>,然后将此字符串发送到QmessageBox

I am not sure if this will work, as I have not tested it, but you can use HTML subset which is suppoertd by Qt. This subset contains <nobr> element. See https://doc.qt.io/qt-5/richtext-html-subset.html

So try this QString msg = "Error opening file at location <nobr>'C:\Users\User\some_folder\some_file'</nobr>"; and then send this string to the QMessageBox.

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