Results 1 to 3 of 3

Thread: An old topic,custom list view

  1. #1
    Join Date
    Apr 2010
    Posts
    98
    Thanks
    19
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default An old topic,custom list view

    The default list view in QT is really too basic to satisfy me.And the delegate isn't enough.I want to fully custom it,just like rendering a custom widget in a list.Take twitter as an example.I have a timeline with 70 tweets.I want to show them in a fashion style.

    Here's my few thoughts:
    1.Subclass the QListView,override the paintEvent(),draw everything by myself.

    2.Use Graphics View Framework.The 40000 chips demo really shows its power.I think managing only a list of tweet widgets would be a piece of cake to it.

    3.I take use of the QScrollBar.Since the tweet widget will have a minimum size(say 40*100),So if the viewport's size is(160*100),then I can only see 5 widgets at most(3 of them will totally visible,while the other two will be seen partly).Then I create 5 widgets(instead of creating 70 widgets to save memory).Every time the user drag the scrollbar,I adjust these 5 widgets' content & position.
    Also I have the 6th widget to calculate each of the 70 tweet widgets' actual size.Then I do some math and assign the value to the scollbar,so it knows the scrolling range.


    I'm a newbie to Qt,so I don't know which one would be better.But obviously,the first one would suck.I hope you guys can tell me more about this.All the pros and cons.
    This is not totally a question.And I think bring up a topic is better than just ask and answer.

    It's not the goodbye that hurts,but the flashback that follow.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: An old topic,custom list view

    Well, the first suggestion would definitely not suck. If you have multiple views that need to be synchronized, then a subclass of QAbstractItemView is the best thing to do. Granted, this is very complex. Look at the Chart example on the Qt documentation website.

    If you only want to show a list of items without linking the data to other widgets (think about updating each widget etc...) and you do not want to edit the items, then I personally think using QGraphicsView is a little bit easier.

    The hardest part of subclassing an item view is not the painting but finding the rectangles and regions for items and selections. At least, I like to think so.

  3. #3
    Join Date
    Apr 2010
    Posts
    98
    Thanks
    19
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: An old topic,custom list view

    Well,I saw the Chart example.Unfortunately,the list view is still too simple.
    Thanks your suggestion,I'll take a look at the QGraphicsView.
    It's not the goodbye that hurts,but the flashback that follow.

Similar Threads

  1. Replies: 8
    Last Post: 6th May 2010, 11:17
  2. Custom Model? Custom View? Custom Delegate?
    By Doug Broadwell in forum Newbie
    Replies: 4
    Last Post: 11th February 2010, 20:23
  3. Replies: 2
    Last Post: 1st April 2009, 23:52
  4. Model-view: Creating a custom view
    By taboom in forum Qt Programming
    Replies: 5
    Last Post: 17th August 2007, 20:36
  5. 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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.