[Qt-creator] Class boilerplate builder?

Ziller Eike Eike.Ziller at theqtcompany.com
Mon Dec 21 07:41:43 CET 2015


> On Dec 18, 2015, at 20:43, Jason H <jhihn at gmx.com> wrote:
> 
> I'd be really cool if(tm):
> 
> There was a builder for QObject subclasses.
> 
> Given the class name, the base class, (already there) the next step would be a screen that would ask for property names and types and automatically build up the boilerplate code. I spend a lot of time now since QML is King making exposer classes for C++ to QML. I've got 140 lines of boilerplate code and only 77 of non-boilerplate. If I could enter:
> QStringList propname1
> QVariantList propname2
> ...
> int x
> 
> and have it all populated I'm thinking a grid or rows of:
> Combo Text Combo(Syntax) Check   Check    ...  // UI type
> Class Name MEMBER/READ   Write   Notify   ...  // What for
> 
> 
> And that screen to the new Class wizard would save me a lot of time. 

Hi,

not integrated in a wizard, but if you write Q_PROPERTY you can
1. use the snippet to only provide the property type and name and get the rest filled out with defaults, and
2. use Refactor > "Generate missing Q_PROPERTY members” (or Alt+Return) on the Q_PROPERTY to automatically generate the getter, setter, signal, and member variable.

Br, Eike

-- 
Eike Ziller, Senior Software Engineer | The Qt Company
Digia Germany GmbH, Rudower Chaussee 13, D-12489 Berlin
Geschäftsführer: Mika Pälsi, Juha Varelius, Tuula Haataja
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B



More information about the Qt-creator mailing list