what do you mean by sensible and can you please elobrate on this statement ?,because this statement is rather confusing that it is a QWidget namely QGraphicsView.TraniningUI IS ALREADY a QWidget, namely QGraphicsView. And yes, QWidget is a more sensible parent parameter than QGraphicsView.
It is not a Qt thing but C++/OOP thing. You should consult your favourite C++ and OOP books to learn inheritance., I know from OOP that void func():a(1),means that memeber variable 'a' would have a value 1..but i cannot absorb the understanding for
and why it is so neccesaryTrainingUI::TrainingUI(QWIdget *parent):QGraphicsView(parent)
what i understand from this is that that a QGraphicsView member variable is useless since TrainingUI is already QGraphicsView...now question is thatNo, as I said, TrainingUI is already a QGraphicsView, you don't need another one.
If i would not declare the QGraphicsView as member variable then how should i be able to view the scene
what i conclude from this statement is that that every QObject child should be declared on heap so it is not been tried to delete twice ...am i right ?? an i hoped that QGraphicsView would be inherited from QObject but i cannot find it in this listEvery QObject deletes their children upon destruction. If you add the graphics view to a window, the window will delete it once the window itself is deleted. Now if the graphics view is allocated on the stack as a member variable, you'll get a crash due to double free attempt: 1) deleted by parent 2) goes out of scope according to normal C++ rules.
http://doc.trolltech.com/4.4/qobject.html
Bookmarks