Results 1 to 2 of 2

Thread: Choosing between QListWIdget / QListView with QItemDelegate

  1. #1
    Join Date
    Nov 2010
    Posts
    3
    Qt products
    Qt4

    Question Choosing between QListWIdget / QListView with QItemDelegate

    Hi,

    Let's say I need to display a list of items. Each item contains a QPushButton an image and some text. WHen a user clicks on the button something should happen ( ie I need to get the signal ). What is the right way to implement this in Qt?

    After some reading, I understand that if I use a QListWidget and QListWidgetItem, this can be achieved. I can subclass each QListWidgetItem according to my needs and set them in the list widget.

    However, I also read that a more appropriate approach ( the MOdel View approach ) is to use a QlistView coupled with a QItemDelegate. But if I'm using QItemDelegate, it seems that I can only paint the widgets. How can I get the push button event?

    Sorry for this huge post. I'm kind of confused about the whole concept of when to use a QListWidget / QListView.

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Choosing between QListWIdget / QListView with QItemDelegate

    Don't use the list widget. Model/View/Delegate helps you separate GUI from business logic. The QListWidget doesn't do that. In very simple cases you could use consider using the list widget, but as soon as you want complex stuff, use the MVD approach.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

Similar Threads

  1. QListView Text Elide Like QListWidget
    By Kel Solaar in forum Qt Programming
    Replies: 6
    Last Post: 13th May 2010, 05:44
  2. Multiple Lines per item in a QListWidget/QListView
    By youkai in forum Qt Programming
    Replies: 1
    Last Post: 27th August 2008, 21:44
  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.