问题描述:

Yes, you are right. We have QListView already, it is prefect when we are trying to display simple list with Model/View.

But, QListView has lots of problem when we need to display complex list with rich text and widgets. Just think about a timeline-listview for Facebook or Twitter.

Sure, we can implement our own delegate for rich text or images, but ListView can print static item only. So, there isn't a way to show clickable hyperlink (you can calculate position of the mouse and hyperlink, but it is a really drity work) or load asynchronous images.

Well, QListWidget seems our solution. We can put widgets into it. But. we will lost our Model/View/Delegate architecture, that is terrible!

Now, my solution is writing my listview in QML. Other widget are still native Qt widget. (I don't like a non-native pure QML user interface.)

QML is really flexiable when doing that kind of work. Then export my model, finally put a viewer into my QMainWindow. But coding in two programming languages and trying to communicate with other native widget is really difficult.

So, is there a way to use Qt's Model/View architecture with QListWidget? Or I have to implement them by myself?

网友答案:

QListWidget does use Qt's MVC, as it derives from QListView and...

QListWidget uses an internal model to manage each QListWidgetItem in the list.

Just use QListWidget::model () const to access the model.

相关阅读:
Top