Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Monospaced detailedText in QMessageBox

I've been using a QMessageBox to display the outcome of a statistical test. It's nice, because I can put a summary result in the informative text, then the full result in the detailed text. The trouble is, the full result is a table, so I'd like it to be monospaced so that it looks right, and QMessageBox doesn't use a monospace font in the detailed text area.

So I'm looking at either subclassing QMessageBox, or subclassing QDialog to make something that looks like a QMessageBox but uses a monospace font in the detailed text area. I'm a bit rusty at the moment, and having a hard time figuring out which is the better option. Could I subclass QMessageBox, just add my own QTextEdit and my own "show detailed text" button, and leave the QMessageBox detailed text area and button hidden? Or is there some easier way to do this?

like image 724
rainbowgoblin Avatar asked Jan 10 '23 23:01

rainbowgoblin


1 Answers

You can use html text in the fields of a QMessageBox, that would be the easiest way. As a hint, try putting

 <pre>Test</pre>

in your QString.

Any other customization of the message box will probably imply a subclass, though.

like image 114
Vince Avatar answered Feb 01 '23 05:02

Vince