Results 1 to 3 of 3

Thread: List display options, QListView, QListWidget, QStyledItemDelegate....

  1. #1
    Join Date
    Feb 2010
    Posts
    27
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default List display options, QListView, QListWidget, QStyledItemDelegate....

    Hi Guys,

    I am pretty new to programming and I am starting to learn C++ and QT.

    As a little project to get me going I am writing a little Twitter application.

    My problem is that I want to have a List with with the users icon, name and status listed.

    I have implemented this using a QListWidget and adding QListWidgetItems using a QWidget with the information laid out (see attachment).

    This seems a pretty ugly way to implement what should be a simple feature and is causing real problem when implementing reply and open link features when the user clicks the list item.

    I have read the documentation, googled and searched this forum and I am a bit dizzied by all the information.

    What i think I need to do is subclass QStyledItemDelegate to draw the information and react to the users click.

    Please could you suggest the best way to implement this?

    Should I use a subclassed tree model and draw the information from there and on users click pass the model index to the next function?

    Any help will be very appreciated!!

    Thanks,

    Dubstar_04


  2. #2
    Join Date
    Oct 2008
    Posts
    71
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: List display options, QListView, QListWidget, QStyledItemDelegate....

    The QAbstractItemModel classes do not allow you to draw anything special, but they do simplify things A LOT when it comes to tree/list manipulations. So you could implement a QAbstractListModel for you application, since you need a list. Then you could implement a QAbstractItemDelegate to present the records in the list with custom widgets.

    Read mode about model/view framework, and about delegation of item representation via custom widgets. There are plenty examples to cover this in Qt.

  3. #3
    Join Date
    Feb 2010
    Posts
    27
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: List display options, QListView, QListWidget, QStyledItemDelegate....

    Thanks for your reply.

    I have read all the documentation over and over, so much that i am actually confused over how to impliment the features and functions I want.

    You think I should use:

    A Subclassed QAbstractListModel to hold the, QIcon, and 2 QStrings,
    Then Subclass QStyledItemDelegate or QAbstractItemDelegate to draw the listitems to a QListView and react to user clicks?

    The example I showed in the picture uses custom QWidgets to impletement the required functions but this seems a very heavy way to retrieve information,

    1. Pass item index to a function
    2. retrieve the widget name from the item index
    3. findchild <QLabel * >"twitterName" or "Status";
    4. retrieve the text from the label and pass it to a processing function to parse the urls and return them with the users name.

    So if the data is stored in a model i should be able to used QStyledItemDelegate to retrieve the data using the item index?

    Are there any performance issues / benefits with any particular method of implimentation?

    Thanks,

    Dubstar_04

Similar Threads

  1. QMenu: want a QListView in submenu to handle lots of options
    By chezifresh in forum Qt Programming
    Replies: 1
    Last Post: 12th November 2009, 23:55
  2. Replies: 0
    Last Post: 4th April 2009, 15:54
  3. QListWidget or QListView with QLabel(s)
    By lukass in forum Newbie
    Replies: 6
    Last Post: 11th August 2008, 09:48
  4. QListWidget::currentRowChanged() for QListView
    By Lykurg in forum Qt Programming
    Replies: 1
    Last Post: 13th March 2007, 15:27
  5. QListWidget / QListView Bug ?
    By guilugi in forum Qt Programming
    Replies: 5
    Last Post: 16th November 2006, 11:33

Tags for this Thread

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.