How to add item to listview
-
I want to add item to my listview but i can't find how.
I am new in Qt. -
Is it in QML or Qt ? Please confirm. We can tell you. Anyway if you can refer QTableView in Qt or ListView in QML documentation give you good information. You need to use model to fill the data. Set the model to view. Then it will start displaying. You can use QListWidget as well. If you need sample, do let know. I can you send you the code.
-
it's qt , the listview widget(QListView)
-
"Using models and views":http://doc-snapshot.qt-project.org/qdoc/model-view-programming.html#using-models-and-views
@
QListView *list = new QListView(splitter);
list->setModel(model);
list->setRootIndex(model->index(QDir::currentPath()));
@ -
and how i get the selected index?
-
Did you read document?
http://qt-project.org/doc/qt-5/qlistview.html#selectedIndexes
-
when i using this function i get compile error:
'QListView::selectedIndexes' : cannot access protected member declared in class 'QListView' -
Did you look at the signals from view ? activated, clicked etc signals are emitted with QModelIndex. This will give you the selected index.
-
I suggest you try QTPATH\examples\widgets\tutorials\modelview\7_selections