Auto Generating Model code
-
wrote on 7 Nov 2017, 23:58 last edited by
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.
-
wrote on 10 Nov 2017, 09:07 last edited by
thanks..
if you haven't seen it i bet it doesn't exist -
wrote on 10 Nov 2017, 12:37 last edited by
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 !
-
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 !
wrote on 12 Nov 2017, 04:42 last edited byOh wow. I just re-implemented the todo list example with heaps less code.
i think i'll keep using this.now see if i can also use QuickFlux in the same application....
(third try but i usually get lost towards the end of the tutorial ) -
wrote on 13 Nov 2017, 10:36 last edited by
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
1/7