Good way to make a standard tree model for develop CLI and GUI application
I used QStandardModelItemModel for treeview show in GUI.
But I can't using QStandardModelItemModel for develop CLI app.
I want to create subclass of QAbstractItemModel for both TreeView and Model of CLI app.
I saw simple tree model, but It is still difficult to modify for tree model, example: edit model, set, get property of item,....
Where or How to help me make StandardTreeModel which I can use to devboth GUI app and CLI app
Re: Good way to make a standard tree model for develop CLI and GUI application
Quote:
Originally Posted by
madawg
But I can't using QStandardModelItemModel for develop CLI app.
Why not?
Code:
#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;
}
Re: Good way to make a standard tree model for develop CLI and GUI application
because I want to develop CLI app
in .pro file, I set Because QStandardModelItemModel is a GUI class
Re: Good way to make a standard tree model for develop CLI and GUI application
Yes, QStandardItemModel requires the QtGui library but it does not require you to use a GUI. You can have a usable command-line only application and use the standard model. It may have issues running in an environment without X though... haven't tried.
You state you want a QAbstractItemModel interface. That interface is in QtCore so you can do this without QtGui. Take a look at Editable Tree Model Example. It is not trivial to fully implement a model, but the example goes through a working internal data structure and extensions for editing.