Results 1 to 5 of 5

Thread: problem in displaying a QString in textEdit

  1. #1
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default problem in displaying a QString in textEdit

    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 ...
    "Behind every great fortune lies a crime" - Balzac

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: problem in displaying a QString in textEdit

    A simple, quick and dirty work around would be to use HTML. Otherwise one probably has to deal with the text layout.

  3. #3
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem in displaying a QString in textEdit

    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

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem in displaying a QString in textEdit

    Avahi daemon.. [OK]
    HAL daemon... [FAILED]
    Qt Code:
    1. QString str = "Avahi daemon";
    2. if(str.length() < 20 )
    3. str += " " ; // fill gaps with space
    4. str += [OK]; // or failed...
    To copy to clipboard, switch view to plain text mode 

    Wont above logic work ?

  5. #5
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem in displaying a QString in textEdit

    @aamer4yu: You probably meant

    Qt Code:
    1. while (str.length() < 20)..
    To copy to clipboard, switch view to plain text mode 

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

    Joh

Similar Threads

  1. Problem displaying a QPixmap
    By franco.amato in forum Qt Programming
    Replies: 27
    Last Post: 28th September 2010, 22:40
  2. Qt textedit input method problem. please help!
    By Scott Liu in forum Qt Programming
    Replies: 0
    Last Post: 18th January 2010, 03:10
  3. Problem while displaying the icons name
    By yuvaraj.yadav in forum Qt Programming
    Replies: 2
    Last Post: 23rd April 2009, 14:50
  4. Displaying QString within Eclipse
    By carl in forum Newbie
    Replies: 1
    Last Post: 30th September 2008, 08:42
  5. Problem with displaying float value
    By mirluk in forum Qt Programming
    Replies: 3
    Last Post: 26th June 2008, 14:33

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.