Results 1 to 4 of 4

Thread: QListView

  1. #1
    Join Date
    Jul 2010
    Posts
    72
    Thanks
    35
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QListView

    Hello,

    I would to create a simple listbox with 4 or 5 items. The only thing I could find that could do the job is to use the QListView. I have a book on Qt3 that indicates a member function addColumn that does not exist anymore... Is there any good example on how to use QListView's?

    Cheers

  2. #2
    Join Date
    Jul 2010
    Posts
    72
    Thanks
    35
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QListView

    I found out I can still use Q3ListView or Q3ListBox!

    Thanks

  3. #3
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QListView

    Instead of using Qt3 use something like this:

    Qt Code:
    1. ui->listView->setModel( model );
    2. item = new QStandardItem();
    3. item->setData( StringDescription, Qt::DisplayRole );
    4. item->setData( QImage(":/Pix/Pix.png"), Qt::DecorationRole );
    5. item->setEditable( false );
    6.  
    7. model->appendRow( item );
    To copy to clipboard, switch view to plain text mode 
    This is copy/paste from my app, so modify it to suit Your needs.
    So basically You add item to the model that is displayed by the view (QListView in this example, that is placed on the form already). Look in the documentation for more details.

  4. The following user says thank you to Talei for this useful post:

    Maluko_Da_Tola (10th August 2010)

  5. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QListView

    Yeah, don't use the Qt 3 classes. Also you could have a look at QListWidget. It is easier to use for a small amount of items.

Similar Threads

  1. QListView
    By Yayati.Ekbote in forum Qt Programming
    Replies: 2
    Last Post: 1st March 2010, 11:41
  2. QListView
    By Yayati.Ekbote in forum Qt Programming
    Replies: 1
    Last Post: 23rd January 2010, 18:50
  3. QListView
    By moowy in forum Qt Programming
    Replies: 2
    Last Post: 2nd October 2006, 14:14
  4. [QT3] QListView
    By incapacitant in forum Qt Programming
    Replies: 5
    Last Post: 29th January 2006, 14:31
  5. QListView
    By dragon in forum Newbie
    Replies: 1
    Last Post: 25th January 2006, 21:08

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.