[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Libqtlua-list] Implementing domain model classes/tables in Lua
From: |
Alexandre Becoulet |
Subject: |
Re: [Libqtlua-list] Implementing domain model classes/tables in Lua |
Date: |
Sat, 22 Jan 2011 00:27:22 +0100 |
User-agent: |
KMail/1.13.5 (Linux/2.6.36-ARCH; KDE/4.5.5; x86_64; ; ) |
On Tuesday, January 18, 2011 02:43:54 am you wrote:
Hi,
> > This is what they have been developped for. Item, ItemList... are
> > designed to implement a tree structure which can be accessed from both
> > lua and Qt tree/list view. Data is stored in user C++ classes which
> > inherit from Item and ItemList. This is really powerfull, view are
> > updated in realtime when you manipulate data from lua. This is the best
> > approach to me because lua script is only used to extend the application
> > and is not involved in storing data. Support for table/grid structure is
> > still missing.
>
> Unless I'm missing some important point, in my case I think QtLua MVC
> does not apply very well. My models need to be presented in many forms
> of views (timeline, graphicsview, table, tree, etc). Your application
> seems to present, in most of the time, data in tabular or tree format,
> right?
Qt MVC QModelIndex index are based on x,y coordinates and parent pointer.
How does your view exactly use models?
> >> 3) I've started to implement this approach (source in
> >> http://pastebin.com/UtSepwTT), but I'm stuck with an error. In line
> >> 62, when I try to read the table size property with return
> >> value["size"]; I'm getting the following error: "Can not make value
> >> reference with lua::nil type as table.". Could you help me?
> >
> > The ValueRef was instanciated empty, its table value is nil.
>
> I didn't understand. I've initialized ValueRef in line 53. Did you notice
> that?
I missed that. But I do not understand exactly what you are trying to achieve
with the ValueRef class this way. You are using the following constructor:
ValueRef(const Value &table, const Value &key);
53 value(state, state.exec_statements("return { size = 10}").first())
This implicitly builds a nil value as first argument:
53 value(Value(state), ...
See
http://www.nongnu.org/libqtlua/manual/Value_class_reference.html#_Value_const_State_ls_
Accessing the ValueRef would do nil[{size=10}] which is what the "Can not make
value reference with lua::nil type as table." message stands for.
Note that you can build a table value without using exec_statements:
Value t(state, Value::TTable);
t["size"]=10;
If you are trying to get a reference to a value in a lua table (a ValueRef)
you may use:
http://www.nongnu.org/libqtlua/manual/Value_class_reference.html#_ValueRef_operator_const_Value_key_1
http://www.nongnu.org/libqtlua/manual/State_class_reference.html#_ValueRef_operator_const_Value_key_
Best,
--
Alexandre