#include <QApplication> #include <QStringList> #include <QStringListModel> #include <QListView> int main(int argc, char *argv[]) { QApplication a(argc, argv); QStringList list; list << "one" << "two" << "three"; QStringListModel *model = new QStringListModel(list); QListView *view = new QListView; view->setModel(model); view->show(); return a.exec(); }
效果如下:
原文:http://www.cnblogs.com/billxyd/p/6915549.html