UserItemModel class reference
[Model/View module]

Declaration  

#include <QtLua/UserItemModel>

namespace QtLua {
class UserItemModel;
};

This class is a member of the QtLua namespace.

Description  

This class together with the UserListItem and UserItem 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::UserListItem::ptr root = QTLUA_REFNEW(QtLua::UserListItem, );

// Set as lua global
(*state)["root"] = root;

// Insert 2 new nodes
QTLUA_REFNEW(QtLua::UserItem, "foo")->insert(root);
QTLUA_REFNEW(QtLua::UserItem, "foo2")->insert(root);

// Create Qt view widget and set model
model = new QtLua::UserItemModel(root);

treeview = new QTreeView(0);
treeview->setModel(model);
setCentralWidget(treeview);

// Rename node from lua script
state->exec_statements("root.bar = root.foo2");

Members  

Functions  

Protected functions  

Static functions  

  • static Ref<UserItem> get_item(const QModelIndex &index)
  • static Value get_selection(State *ls, const QAbstractItemView &view)

Members detail  

UserItemModel(Ref<UserListItem> root, QObject *parent = 0)  

Create a new item model with pointer to root item

~UserItemModel()  

No documentation available

virtual Ref<UserItem> from_mimedata(const QMimeData *data)  

This member access is protected.

May be reimplemented to return a new item created from mime data. Used when dropping external objects.

static Ref<UserItem> get_item(const QModelIndex &index)  

Get pointer to UserItem from QT model index.

static Value get_selection(State *ls, const QAbstractItemView &view)  

Get a lua table value with selected items on given view

virtual QStringList mimeTypes() const  

This member access is protected.

Return supported mime type. May be reimplemented to add more types.

Valid XHTML 1.0 StrictGenerated by diaxen on Sun Jan 24 22:02:24 2016 using MkDoc