hello.
I have implemented a CViewBase class (is a sort of interface):
class CViewBase
{
public:
CViewBase(void) ;
virtual ~CViewBase(void){};
virtual void GetActions(int& n){}
};
typedef std::shared_ptr<CViewBase*> ptrViewBase;
}
class CViewBase
{
public:
CViewBase(void) ;
virtual ~CViewBase(void){};
virtual void GetActions(int& n){}
};
typedef std::shared_ptr<CViewBase*> ptrViewBase;
}
To copy to clipboard, switch view to plain text mode
GetActions(int& n) set an int , but in the future must contains a custom struct with some custom data.
class CGlWidgetImage
: public QGLWidget,
public CViewBase
{
.
.
void GetActions(int & n){/*implementation*/};
class CGlWidgetImage : public QGLWidget, public CViewBase
{
.
.
void GetActions(int & n){/*implementation*/};
To copy to clipboard, switch view to plain text mode
now, the problem is that:
this works:
int n;
ptrGlWidgetImage ptrGlWidgetImage = std::shared_ptr<CGlWidgetImage>( new CGlWidgetImage(ptrFactory, ptrQModel, ptrModelG, ptrController, format)) ;
((CViewBase*)ptrGlWidgetImage.get())->GetActions(n);
int n;
ptrGlWidgetImage ptrGlWidgetImage = std::shared_ptr<CGlWidgetImage>( new CGlWidgetImage(ptrFactory, ptrQModel, ptrModelG, ptrController, format)) ;
((CViewBase*)ptrGlWidgetImage.get())->GetActions(n);
To copy to clipboard, switch view to plain text mode
but this no!:
int n;
QMdiSubWindow* pSub = new QMdiSubWindow();
pSub->setWidget(ptrGlWidgetImage.get());
((CViewBase*)pSub->widget())->GetActions(n);//does nothing and not enter in //function GetActions
int n;
QMdiSubWindow* pSub = new QMdiSubWindow();
pSub->setWidget(ptrGlWidgetImage.get());
((CViewBase*)pSub->widget())->GetActions(n);//does nothing and not enter in //function GetActions
To copy to clipboard, switch view to plain text mode
there is in qt a sort of tag property that can contains all type of data?
Then i can setting the data in this property.
or there is another solution?
I wish use the polymorphism because i can have many ptrGlWidgetImage each with his custom actions(commands objects)data hardcoded .
When implements a new "CGlWidgetImage" , i setting his properties in code and implements a GetActions that returns the current widget's Actions(that are show in the toolbar.)
I do this because i have an mdi application and each subwindow can contains a custom different widget, next on the subWindowActivated event i can get all actions of the current widget with a simple GetActions() and modify the toolbar.
void CMainDiag::subWindowActivated(QMdiSubWindow* pWin)
{
((CViewBase*)pWin->widget())->GetActions(n);//now don't works
}
void CMainDiag::subWindowActivated(QMdiSubWindow* pWin)
{
((CViewBase*)pWin->widget())->GetActions(n);//now don't works
}
To copy to clipboard, switch view to plain text mode
thanks
Bookmarks