Auto Generating Model code
-
Hi,
I have just gone through a simple ToDo list tutorial (https://www.youtube.com/watch?v=9BcAYDlpuT8) that uses QML and stores the model in C++
There seems to be a lot of 'gotcha's that need to be implemented for each model in C++ (overriding QAbstractListModel). I guess once you do a few it gets easier.
My Question: Is there an Code generator around that you give an IDL to that can do all this tedious work for you ? (In the same way that DJango does this perhaps ?)
thanks,
tom -
Hi,
AFAIK, no, there's no such tool.
-
Just found Thomas Boutroue's macro's that look after a lot of the gotcha's
https://www.youtube.com/watch?v=96XAaH97XYo
very interesting . i'll try the same todo list with this and report back
-
The fact that I'm not aware of such a tool doesn't mean it doesn't exist. There are lots of stuff going on around Qt ;)
IIRC, he has several libraries and helpers that might be of interest, thanks for the reminder !
-
-
What I usually feel like suggesting is not to subclass the model at all. use
QStandardItemModel
only via theQAbstractItemModel
interface (you can force yourself by declaringQAbstractItemModel* model =new QStandardItemModel(parent);
).If the model's performance is really a drag for your application you can go the length and implement a model subclass (with all its gotchas) changing just 1 line in your existing code