PDA

View Full Version : question about text alignment in QListWidget



to_guliang
21st May 2008, 04:21
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!!!

aamer4yu
21st May 2008, 08:38
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 :)

wysota
21st May 2008, 09:26
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.

to_guliang
21st May 2008, 12:04
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.