Reputation: 117
I am wondering if there is a way to do this.
code of DerivedView class:
class DerivedView : public QGraphicsView {
...
I would like my new DerivedView class to control this widget. I can access a pointer to the object through ui->myView. Is there any way to do get my derived class to work with the already instantiated QGraphicsView?
DerivedView * dView = ui->myView;
Or do I need to not derive my class from QGraphicsView and just add a pointer as a data member?
class DerivedView {
QGraphicsView * gv;
...
Upvotes: 2
Views: 1512
Reputation: 244132
You should promote your QGraphicsView
to DerivedView
, for this follows the following steps.
Right click on QGraphicsView
and select promote to ..
:
And add the name of the class and header
And press add.
And then press on promote.
After this, ui->myView
is already a member of the DerivedView
class
Upvotes: 3