Class Promotion ?
-
You mean events that have been sent to A but haven't been "delivered" to it yet?
-
Call QCoreApplication::processEvents before destroying A.
-
@Walux
the simple version is
class Master
all variables..class A : Master
paintEventclass B : Master
paintEventthe more lame is
class A :B
PaintAsA(QPainter *)
PaintAsB(QPainter *)paintevent(...)
if(UseB)
PaintAsB
else
PaintAsAwhich is bad with more sublasses
Maybe i should do this instead :
I start by creating a class B that uses the paintEvent of class A , then when i reach the certain state , it calls the paintEvent of class B .
I have no problem doing it now , since the difference is only in the painting , but later when the new classes have new variables , that'll be a problem .
-
Call QCoreApplication::processEvents before destroying A.
-
I dont understand why it ever need to change "type".
I think you need to rethink the design.
Normally u use base class pointers and childs for polymorph operations but
i cannot understand your use case.Its like circle that must sudden draw as a rect?
-
I dont understand why it ever need to change "type".
I think you need to rethink the design.
Normally u use base class pointers and childs for polymorph operations but
i cannot understand your use case.Its like circle that must sudden draw as a rect?
@mrjj
@WielandI'll try to minimize the code , to help clarify my situation :
Class myScene : public QGraphicsScene { //... void MousePressEvent(QGraphicsSceneMouseEvent *event) //... private: A *a; //... }"myScene.cpp"
myScene::myScene { a = new A; } void myScene::MousePressEvent(QGraphicsSceneMouseEvent *event) { a->doesSmth(); if(a->reachesSomePoint()) a = new B; // Compiles good but i lose the events and the whole paint of a; }Class A : public QObject , public QGraphicsItem { //... A(); QRectF boundingRect() const Q_DECL_OVERRIDE; QPainterPath shape() const Q_DECL_OVERRIDE; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE; // This is the first painting //... protected: qreal myValue1; int myValue2; //... }Class B : public Class A { void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE; // This is the second painting //Future Variables private: qreal futureValue1; //... } -
hi
You only need to go from base to child?
You can use a cast for that.
http://www.bogotobogo.com/cplusplus/upcasting_downcasting.phpand you dont lose A paint as you are free to call the A::paintEvent from
B::paintEvent. -
hi
You only need to go from base to child?
You can use a cast for that.
http://www.bogotobogo.com/cplusplus/upcasting_downcasting.phpand you dont lose A paint as you are free to call the A::paintEvent from
B::paintEvent. -
Hmm , very informative , and i can get the slicing problem now :)
But , it won't be of any harm till late versions of my program :)
Thank you very much :DTopic->setAsSloved(true);