PDA

View Full Version : QTextBrowser & QPlainTextEdit swallow spaces?



gnreeke
10th September 2009, 22:55
I put some text into a QTextBrowser or a QPlainTextEdit (both have the same problem).
The text has hex numbers separated by multiple blank spaces. In the display, varying numbers of these spaces seem to be deleted. I want the spaces to remain as coded.
In case it matters, I make the text with some old C code and then feed it into the Qt widgets like this (simplified to show the problem):


QString Qmdstr;
char mdln[] = " 13 467AF"
Qmdstr = QString(mdln);
MyApp->DataViewer->appendPlainText(Qmdstr);

What I see in the widget is something like " 13 467AF", i.e. some spaces removed.
I checked with gdb and the char string before conversion to a QString has the right format. I tried using setStyleSheet to get the closest thing I could find in the documentation to monospacing, like this:


MyApp->DataViewer->setStyleSheet("font-family: FixedFont;");

but this didn't help.
Any ideas what I am doing wrong?
[I have Qt 4.5.2 running in RedHat EL 5 64-bit. "DataViewer" is a QPlainTextFile widget created in designer. Everything else about it works OK.]
Thanks
gnreeke

gnreeke
16th December 2009, 19:08
Here is an update to my previous post on this subject:
I found that if I specify a particular monospaced font, namely,
Lucida Typewriter, then the output looks as it should: spaces
are obeyed. But I was trying to give a general request for a
monospaced font in my style sheet, rather than naming a
particular font. Either that feature is broken or I am not using
it correctly. Does anybody know how to request a monospaced
font in a style sheet? What I used is what I thought I had found
in the documentation, and that does not work.
Thanks,
G. Reeke