Results 1 to 4 of 4

Thread: question about text alignment in QListWidget

  1. #1
    Join Date
    Apr 2008
    Posts
    44
    Thanks
    21
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Lightbulb question about text alignment in QListWidget

    i want to show 3 strings in each QlistWidgetItem.
    for example,the desired format is :
    str1 str2 str3
    0 search welcome
    1 member calendar

    the 3 strings have different length;but i hope them left-aligned.
    how could i realize the function?
    thanks very much for any advice!!!
    Last edited by to_guliang; 21st May 2008 at 03:43.

  2. #2
    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: question about text alignment in QListWidget

    You can set the aligment urself. Make fixed size for listwidgetitem, and then merge the three strings accordingly in it.

    Otherwise u can have a look at QListView also. You can use row/columns. There you can use columns to show each string.

    Hope this helps

  3. The following user says thank you to aamer4yu for this useful post:

    to_guliang (21st May 2008)

  4. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: question about text alignment in QListWidget

    You'd have to implement your own delegate to achieve that and it would be quite difficult if you wanted to align each pseudo-column in every row. It might be much easier to use a real table with real columns and display each string in a different column.

  5. #4
    Join Date
    Apr 2008
    Posts
    44
    Thanks
    21
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Lightbulb Re: question about text alignment in QListWidget

    thanks for aamer4yu and wysota;
    you are right,it's easy to use Qlistview because Qlistview have real column.
    But in my program, using pseudo-column is better.I'm develop the HPP of PLC in HMI.
    The number of string to be show may be 1,may be 2,may be 3,that means the number of column is unsure.

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. Text Alignment in a ListWidget
    By Krish_ng in forum Qt Programming
    Replies: 2
    Last Post: 21st July 2007, 02:19
  3. QPushButton, stylesheets, text alignment
    By SiLiZiUMM in forum Qt Programming
    Replies: 1
    Last Post: 4th July 2007, 19:53
  4. QToolButton text alignment
    By Vladimir in forum Qt Programming
    Replies: 6
    Last Post: 2nd March 2007, 07:42
  5. Text Browser Link Question
    By taylor34 in forum Qt Programming
    Replies: 2
    Last Post: 20th June 2006, 19:54

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.