Results 1 to 2 of 2

Thread: QTextBrowser & QPlainTextEdit swallow spaces?

  1. #1
    Join Date
    Sep 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Unhappy QTextBrowser & QPlainTextEdit swallow spaces?

    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):

    Qt Code:
    1. QString Qmdstr;
    2. char mdln[] = " 13 467AF"
    3. Qmdstr = QString(mdln);
    4. MyApp->DataViewer->appendPlainText(Qmdstr);
    To copy to clipboard, switch view to plain text mode 

    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:

    Qt Code:
    1. MyApp->DataViewer->setStyleSheet("font-family: FixedFont;");
    To copy to clipboard, switch view to plain text mode 

    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

  2. #2
    Join Date
    Sep 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTextBrowser & QPlainTextEdit swallow spaces?

    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.