Saw your post after I posted this!
Looking at the API's for QStringListModel (insertRows() setData()),
the code below seems simpler! I don't need a rowCount or model index!
I'll work out the example with those APIs and see what I learn!
The following works! All 3 strings appear!
All this using command line Qt4.3 under Fedora 9
#include <QApplication>
#include <QSplitter>
#include <QTreeView>
#include <QListView>
#include <QListWidget>
#include <QDirModel>
#include <QStringList>
#include <QStringListModel>
int main(int argc, char *argv[])
{
qStringListModel->setStringList(qsl);
qStringListModel->setStringList(qsl);
qlw->setModel(qStringListModel);
qStringListModel->setStringList(qsl);
qlw->setModel(qStringListModel);
splitter->show();
return app.exec();
}
#include <QApplication>
#include <QSplitter>
#include <QTreeView>
#include <QListView>
#include <QListWidget>
#include <QDirModel>
#include <QStringList>
#include <QStringListModel>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QSplitter *splitter = new QSplitter;
QStringList qsl;
qsl.append(QString("abcd1234"));
QStringListModel *qStringListModel;
qStringListModel = new QStringListModel;
qStringListModel->setStringList(qsl);
QListView *qlw = new QListView(splitter);
qsl.append(QString("abc123"));
qStringListModel->setStringList(qsl);
qlw->setModel(qStringListModel);
qsl.append(QString("ab12"));
qStringListModel->setStringList(qsl);
qlw->setModel(qStringListModel);
splitter->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
I tried to do the same thing with QListWidget but ran into a private function compiler error! QListWidget inherits from QListView!
Out of chaos comes understanding!
Research continues!
Bookmarks