Hi,
May be the question ahead also comes in domain of Object Oriented ,i am confused with
{
Q_OBJECT
public:
};
class exclass :public QObject, public QGraphicsItem
{
Q_OBJECT
public:
exclass(QGraphicsItem *parent = 0);
};
To copy to clipboard, switch view to plain text mode
#include "exclass.h"
{
}
#include "exclass.h"
exclass::exclass(QGraphicsItem *parent): QGraphicsItem(parent)
{
}
To copy to clipboard, switch view to plain text mode
#include "exclass.h"
#include <QApplication>
int main(int argc, char *argv[])
{
exclass *mainScene = new exclass;
return a.exec();
}
#include "exclass.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
exclass *mainScene = new exclass;
return a.exec();
}
To copy to clipboard, switch view to plain text mode
I am confused with the statement
'exclass(QGraphicsItem *parent = 0); ' in the .h file and
'exclass::exclass(QGraphicsItem *parent): QGraphicsItem(parent){}' in the .cpp file
can anyone explain why the declaration as 'QGraphicsItem *parent' is necessary in the exclass constructor and why do we say it as 'QGraphicsItem *parent = 0 'in the .h file..
i avoided this question so far and just followed it but now i have to develop a QGraphicsItem parent and a child so i am confused with how to do it..
Bookmarks