I have multiple Object classes(like Plot,Bars, Dial Box,flight Instrument). I am creating object from object Interface class.Object Interface class has all object class creating object and returning object to client.But adding objects and changing properties of object later on tedious job. To resolve this which design pattern i have to use and how? I get to to know i have to use Factory Design pattern sub classes will decide creation of object. in my situation m not getting how to do.
client code
void GraphView::dropEvent(QDropEvent *event)// client side code
{
if (event->mimeData()->hasFormat(itemlistMimeType()))
{
if(event->mimeData()->text() == "Plot")
{
ObjInterfaceClass * pObjInterface = new ObjInterfaceClass ;// object creation
pObjInterface->CreateObject(CUSTOM_PLOT_NAME) ;
pObjInterface->DrawObject();
}
}
}
Object Interface Class.h
class ObjInterfaceClass : public QObject
{
public:
ObjInterfaceClass(QObject *parent = nullptr);
static QStringList GetObjectDetails();
static ObjectPropStruct LoadObjProperty(char *pObjName);
void CreateObject(char* pObjectName) ;
void DrawObject() ;
};
Concrete class like this concrete class so many are there
class AlphaNumLabel : public QLabel
{
Q_OBJECT
public:
AlphaNumLabel( int type, QWidget *parent = NULL );
void setLabelText(int parameter);
void setLabelText(double parameter);
void setLabelText(QString parameter);
private:
QLabel *mpLabel;
int mLabelType;
};
AlphaNumLabel::AlphaNumLabel(int type,QWidget *parent ): QLabel( parent )
{
mpLabel = new QLabel(this);
mLabelType = type ;
}
Any ideas or references are welcome
Aucun commentaire:
Enregistrer un commentaire