Promote To... button
-
When you want to create a custom widget and form a class out of it, one should use the "Promote To..." option, which allows you to promote it to a custom class.
How does this work? Does the widget still retain all it's properties? What changes in this process?
-
This is for using widgets that don't provide a QtDesigner plugin in projects that use .ui files (QtDesigner files). So you add the base class (e.g. QWidget) in QtDesigner and promote it to the subclass. All this changes is what class name is used in the generated code file and thus what class gets instantiated during runtime. Nothing changes in QtDesigner, though.
-
How does it change its class? Shouldn't the properties change as well then?
Does the widget still retain properties of a regular widget? Does it gain properties of the class it becomes? Does it change the class itself?
-
bq. Does the widget still retain properties of a regular widget?
Yes, as DerManu said, nothing changes in QtDesigner, which it will still be a widget.
bq. Does it gain properties of the class it becomes?
Absolutely, else, this process won't be called "promote", wouldn't it?
bq. Does it change the class itself?
Pretty yes. The new class should gain the funtion defined inside the header file you created.
-
So I promoted a widget to a class called mypanelopengl.h, but I didn't see a new function in the class. Does it only happen when I build the project, or am I doing something wrong?
-
[quote author="Flurite" date="1346021970"]So I promoted a widget to a class called mypanelopengl.h, but I didn't see a new function in the class. Does it only happen when I build the project, or am I doing something wrong?[/quote]
Does the header file mypanelopengl.h exist and contain a class with new functions?
What means that you didn't "see" a new function?
-
[quote author="Flurite" date="1346021970"]So I promoted a widget to a class called mypanelopengl.h, but I didn't see a new function in the class. Does it only happen when I build the project, or am I doing something wrong?[/quote]
I think you're talking about auto-complete for the funtion inside that header?
Try open the file with QtCreator?
-
I think I am confused about what A.A.B.A said here:
bq.
Pretty yes. The new class should gain the funtion defined inside the header file you created.