PDA

View Full Version : problem in displaying a QString in textEdit



wagmare
8th February 2011, 06:13
hi friends,

i have a problem with displaying a QString in a QTextEdit ..
as i tried to display it like Linux booting up GUI ..

Avahi daemon.. [OK]
HAL daemon... [FAILED]

actually i dont know how to add two qstrings one at left end and other at right end in same line ..

i can give space while appending but QTextEdit size is indefinite ...

please help me to solve this problem ..

Thanks in advance ...

Lykurg
8th February 2011, 06:25
A simple, quick and dirty work around would be to use HTML. Otherwise one probably has to deal with the text layout.

JohannesMunk
8th February 2011, 10:31
Also dirty, but you could use a tab and setTabStopWidth to the width of your textedit. Maybe subclass and do that adjustment in the resizeEvent.

Joh

aamer4yu
8th February 2011, 13:50
Avahi daemon.. [OK]
HAL daemon... [FAILED]


QString str = "Avahi daemon";
if(str.length() < 20 )
str += " " ; // fill gaps with space
str += [OK]; // or failed...

Wont above logic work ?

JohannesMunk
8th February 2011, 14:06
@aamer4yu: You probably meant


while (str.length() < 20)..

Unless you use a monospaced font (like courier) this won't align properly though.

Joh