QT QMessageBox control linebreak

130 views Asked by At

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'
1

There are 1 answers

1
HiFile.app - best file manager On

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.