Originally Posted by
madawg
But I can't using QStandardModelItemModel for develop CLI app.
Why not?
#include <QCoreApplication>
#include <QStandardItemModel>
#include <QDebug>
int main(int argc, char **argv) {
qDebug() << "No GUI here";
for (int row = 0; row < 4; ++row) {
for (int column = 0; column < 4; ++column) {
model.setItem(row, column, item);
}
}
for (int row = 0; row < 4; ++row) {
for (int column = 0; column < 4; ++column) {
qDebug() << index.data();
}
}
return 0;
}
#include <QCoreApplication>
#include <QStandardItemModel>
#include <QDebug>
int main(int argc, char **argv) {
QCoreApplication app(argc, argv);
qDebug() << "No GUI here";
QStandardItemModel model(4, 4);
for (int row = 0; row < 4; ++row) {
for (int column = 0; column < 4; ++column) {
QStandardItem *item = new QStandardItem(QString("row %0, column %1").arg(row).arg(column));
model.setItem(row, column, item);
}
}
for (int row = 0; row < 4; ++row) {
for (int column = 0; column < 4; ++column) {
QModelIndex index = model.index(row, column);
qDebug() << index.data();
}
}
return 0;
}
To copy to clipboard, switch view to plain text mode
Bookmarks