Results 1 to 9 of 9

Thread: Custom multicolumn list, where to start

  1. #1
    Join Date
    Jan 2009
    Posts
    11
    Thanks
    5

    Default Custom multicolumn list, where to start

    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

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Custom multicolumn list, where to start

    take a look at QListWidget/QTableWidget, then for alternating row colors you can use alternatingRowColors. and also take a look Style sheets. in your case Customizing QListView should help you.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Jan 2009
    Posts
    11
    Thanks
    5

    Default Re: Custom multicolumn list, where to start

    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

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

    Default Re: Custom multicolumn list, where to start

    Just be aware QListWidget is single column only. You might want to use QTreeWidget instead.

  5. #5
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Custom multicolumn list, where to start

    take a look at QItemDelegate/QStyledItemDelegate and read this article Designing Delegates
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  6. The following user says thank you to spirit for this useful post:

    andytork (5th January 2009)

  7. #6
    Join Date
    Jan 2009
    Posts
    11
    Thanks
    5

    Default Re: Custom multicolumn list, where to start

    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

  8. #7
    Join Date
    Jan 2009
    Posts
    11
    Thanks
    5

    Default Re: Custom multicolumn list, where to start

    Quote Originally Posted by wysota View Post
    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

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

    Default Re: Custom multicolumn list, where to start

    Quote Originally Posted by andytork View Post
    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.

  10. The following user says thank you to wysota for this useful post:

    andytork (5th January 2009)

  11. #9
    Join Date
    Jan 2009
    Posts
    11
    Thanks
    5

    Default Re: Custom multicolumn list, where to start

    Thanks to all, THere should be enough useful reading there to keep me busy for a couple of days

    Andy

Similar Threads

  1. list of custom item views?
    By Beluvius in forum Qt Programming
    Replies: 1
    Last Post: 29th March 2008, 06:43
  2. Custom widget in list view
    By fusoin23 in forum Qt Programming
    Replies: 1
    Last Post: 18th November 2006, 14:09

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
  •  
Qt is a trademark of The Qt Company.