ItemModel class reference
[Model/View module]
Declaration
#include <QtLua/ItemModel>
namespace QtLua {
class ItemModel;
};
This class is a member of the QtLua namespace.
Description
This class together with the ListItem and Item classes enable easy use of list or hierarchical data structures that can be viewed and modified from lua script, Qt view widgets and C++ code.
The hierarchical data structure is accessible from lua as nested tables. Data are not duplicated and any change to the data from lua immediately update to the Qt view widget.
Usage example:
// code from examples/cpp/mvc/itemtreeview.cc:30
state = new QtLua::State();
// Create tree root node
QtLua::ListItem::ptr root = QTLUA_REFNEW(QtLua::ListItem, );
// Set as lua global
(*state)["root"] = root;
// Insert 2 new nodes
QTLUA_REFNEW(QtLua::Item, "foo")->insert(root);
QTLUA_REFNEW(QtLua::Item, "foo2")->insert(root);
// Create Qt view widget and set model
model = new QtLua::ItemModel(root);
treeview = new QTreeView(0);
treeview->setModel(model);
setCentralWidget(treeview);
// Rename node from lua script
state->exec_statements("root.bar = root.foo2");

Inheritance
Members
Functions
- ItemModel(Item::ptr root, QObject *parent = [...])
- ~ItemModel()
- int columnCount(const QModelIndex &parent) const
- Qt::ItemFlags flags(const QModelIndex &index) const
- QVariant headerData(int section, Qt::Orientation orientation, int role = [...]) const
- QModelIndex index(int row, int column, const QModelIndex &parent) const
- QModelIndex parent(const QModelIndex &index) const
- int rowCount(const QModelIndex &parent) const
- bool setData(const QModelIndex &index, const QVariant &value, int role)
Protected functions
- virtual Item::ptr from_mimedata(const QMimeData *data)
- virtual QStringList mimeTypes() const
Static functions
- static Item::ptr get_item(const QModelIndex &index)
- static Value get_selection(State &ls, const QAbstractItemView &view)
Members detail
Create a new item model with pointer to root item
No documentation available
int columnCount(const QModelIndex &parent) const
No documentation available
Qt::ItemFlags flags(const QModelIndex &index) const
No documentation available
This member access is protected.
May be reimplemented to return a new item created from mime data. Used when dropping external objects.
static Item::ptr get_item(const QModelIndex &index)
Get pointer to Item from QT model index.
static Value get_selection(State &ls, const QAbstractItemView &view)
Get a lua table value with selected items on given view
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const
No documentation available
QModelIndex index(int row, int column, const QModelIndex &parent) const
No documentation available
virtual QStringList mimeTypes() const
This member access is protected.
Return supported mime type. May be reimplemented to add more types.
QModelIndex parent(const QModelIndex &index) const
No documentation available
int rowCount(const QModelIndex &parent) const
No documentation available
bool setData(const QModelIndex &index, const QVariant &value, int role)
No documentation available