Promoted Widget within a Promoted Widget programmatically
Hi
Widget Promotion
Based on several forums I managed to promote a graphicsView accordingly.
The issue comes when within the promoted class I need to create a QLabel (within the graphicsView) that itself needs to be promoted.
1. Promote Graphics View :) (through the designer)
2. Add QLabel Widget within graphicsView (programatically) :)
Code:
label->setFixedSize(320, 320);
label->setText("Test Label");
proxy = myScene->addWidget(label);
proxy->setZValue(0);
3. try to promote the generated label (That is within the graphicsView) to another class in code
Since i only have access to the label in the code and not via the designer. :confused:
How do I promote a QLabel to a specified class within code? (Not through the designer)
Your assistance is appreciated
Regards
Re: Promoted Widget within a Promoted Widget programmatically
There is no such thing as widget promotion in code.
Widget promotion, in the context of Designer, is the mechanism by which the user can add a widget of some class C in design mode and make Designer, in the generated code setting up this UI, actually instantiate a specified subclass of C. E.g. if you have a QLabel-derived class MyLabel, you can add a QLabel in design mode and promote it to MyLabel. You will be limited, in design mode, to the QLabel interface (properties, signals), but Designer will generate code that instantiates a MyLabel and sets its QLabel-inherited properties accordingly.
If you write the code directly, just instantiate the correct class. Instead of
, do something like
Code:
MyLabel *label = new MyLabel();
[SOLVED] Promoted Widget within a Promoted Widget programmatically
Yes Thanks,
Your proposition of correctly instantiating a class would work.:cool:
(I don't know why i did not think of that... I'm still learning the ropes, i guess)
Thanks yeye ;)