about use QAbstractItemModel and directly use QTreeWidget/QListWidget
-
i know use QAbstractItemModel is more elegant, and only 1 QAbstractItemModel , can be with many View(QListView/QTreeView, etc).
but i met some problem:- how can i preview the picture file if i use QAbstractItemModel method.
when i use QTreeWidget, while i create the QTreeWidgetItem, i can setIcon. - how i can show all the dir and files in QTreeView, but only selected dir and its child files in the QListView.
when i use QTreeWidget and QListWidget, i can control this all by myself.
thank you
- how can i preview the picture file if i use QAbstractItemModel method.
-
Hi,
If I understood correctly you're implementing a sort of FileBrowser. (More info you provide, more you'll get :) )
For question 1 you can write your model in such way to show the file picture (writing the
::data()
method in the right wayFor question 2 you could use a
QSortFilterProxyModel
to filter the contents to show -
yep, is there any open source demo of FileBrowser?
-
and in ur opinion, which method should i use, the QAbstractItemModel or directly use QTreeWidget/QListWidget?
i will preview the file in the QListWidget as picture or even more complicated things(eg, many small widget which contains dynamic OpenGL Models)
thank you -
and how i deal with the Drag and Drop problem while i use QAbstractItemModel.
eg.some TreeView allow DragDrop,while others donot allowed.
and in the Drag and Drop, i willl pass some Data to the MainWindow.
is it able and easy to do all this work use QAbstractItemModel? -
and i will search or filter on some View, even re-sort the files on some View.
is it able and easy to do all this work use QAbstractItemModel? -
Simple question, Why you don't use
QFileSystemModel
for that? -
thank you,is there any examples of QSortFilterProxyModel ?
it seems not work for me to show only files&sub-dir of a Dir in the List, while the Tree shows all the Dir -
QFileSystemModel is not suitable for me, because i want to read data from my database
-
Hi,
So
QSqlTableModel
? -
This might help (I hope I understand your question)
Assuming you have a ui pointer established to a QTreeView or QTreeWidget (Note: some of the following only apply to TreeView (see documentation), but I hope you see the point:ui->treeView->setSelectionMode(QAbstractItemView::SingleSelection); ui->treeView->setSelectionMode(QAbstractItemView::ExtendedSelection); ui->treeView->setSelectionBehavior(QAbstractItemView::SelectRows); ui->treeView->setIndentation(12); ui->treeView->header()->setHighlightSections(true); ui->treeView->header()->setProperty("showSortIndicator", QVariant(false)) ui->treeView->expandAll(); ui->treeView->show(); model = new TreeModel (mainObj*, this ); ui->treeView->setDragDropMode(QAbstractItemView::InternalMove); Hope that helps - Vince