View Full Version : QListView
Maluko_Da_Tola
10th August 2010, 19:13
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
Maluko_Da_Tola
10th August 2010, 19:56
I found out I can still use Q3ListView or Q3ListBox!
Thanks
Talei
10th August 2010, 20:17
Instead of using Qt3 use something like this:
QStandardItemModel *model = new QStandardItemModel();
ui->listView->setModel( model );
QStandardItem *item;
item = new QStandardItem();
item->setData( StringDescription, Qt::DisplayRole );
item->setData( QImage(":/Pix/Pix.png"), Qt::DecorationRole );
item->setEditable( false );
model->appendRow( item );
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.
Lykurg
10th August 2010, 22:21
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.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.