List of custom widgets in QtCreator
julienangel last edited by
So my question is:
I am trying to create a custom widget(small example: a widget with 3 labels), but for each widget, I would change the text on the 3 labels.
And then I would like to insert into a list of widgets.
I tried alot this, but I can’t find a proper tutorial or something.
If you guys could help me would be so much awesome!
Hi and welcome to the forums.
First Question is :
do you want to create a real custom widget for using in Designer ?
This requires/have some rules about compiler used.
Or do mean just to create a reusable setup of some widget and be able to reuse them in
other projects ? It would not need to add new properties from the custom widget
as all properties comes from default QWidgets ?
This one is super easy,
Just create the widget how u want it in Designer and simple select it and drag to the widget list
It will be listed under scratchpad in the list.
option 3 is
You create a custom widget and use promotion feature of Creator
This is basically like
add a qwidget to the form.
Right click and select promote
tell it class name of the customWidget
tell it .h where to find this class
click Add and then Promote
When you then run app. the Qwidget is now your custom widget.
Think of it as placeholder feature. U add normal QWidget but when run its your
This allows to use in Design mode but you cannot have editable properties
directly in Designer.
My clever friend Luca made me realize i read your question all wrong.
If u want a list of widgets with 3 labels, you should look into
QListview and delegates
since labes are just text you might not even need a delegate so a
ListView/LstWidget should just do it for u.
if u want each cell to have like 3 texts, then delegate is needed.
see here for delegate