PDA

View Full Version : Custom multicolumn list, where to start



andytork
5th January 2009, 07:48
Hi,

I am trying to look at building a custom tree/list to display a multicolumn list with the following requirements :-

1) I want to be able to custom draw the row when clicked/selected so as to expand it vertically and add a few buttons under the list data
2) I want to paint the background of rows in alternating colours, not only rows with content, but empty rows all down the control.

Under Windows / MFC I would do this by extending the measureitem etc and adding the controls to the row and use erasebackground to do the colours.
I have looked at numerous samples, scoured many QT forums and have not seen anything similar

Can anyone give me some pointers to how I would go about this, I am new to QT but have lots of GUI experience under windows and heaps of C++

Thanks in advance

Andy

spirit
5th January 2009, 08:19
take a look at QListWidget/QTableWidget, then for alternating row colors you can use alternatingRowColors (http://doc.trolltech.com/4.4/qabstractitemview.html#alternatingRowColors-prop). and also take a look Style sheets (http://doc.trolltech.com/4.4/stylesheet.html). in your case Customizing QListView (http://doc.trolltech.com/4.4/stylesheet-examples.html#customizing-qlistview) should help you.

andytork
5th January 2009, 08:42
Hi & Thanks

I setup a control with alternatingRowColors and a stylesheet however the alternating colours only extend where there are items , not all down the control if only 1 list item etc

I have done quite a lot of standard investigation and come to the conclusion I will have to look into custom drawing / paiting the control

Thanks for the suggestions anyway

Andy

wysota
5th January 2009, 08:48
Just be aware QListWidget is single column only. You might want to use QTreeWidget instead.

spirit
5th January 2009, 08:51
take a look at QItemDelegate/QStyledItemDelegate and read this article Designing Delegates (http://doc.trolltech.com/qq/qq24-delegates.html)

andytork
5th January 2009, 09:07
In the source for QTreeView I found a reference to

SH_ItemView_PaintAlternatingRowColorsForEmptyArea

Which should allow me to get the rows painted to the bottom when I can work out how to set this without generating a custom style

andytork
5th January 2009, 09:12
Just be aware QListWidget is single column only. You might want to use QTreeWidget instead.

Yes, I already have a setup for a tree in my code

Thanks

Andy

wysota
5th January 2009, 21:26
Which should allow me to get the rows painted to the bottom when I can work out how to set this without generating a custom style

Take a look at style proxy in our wiki.

andytork
5th January 2009, 21:32
Thanks to all, THere should be enough useful reading there to keep me busy for a couple of days

Andy