new class didn't work correcltly
-
Hello guys , i created a new class (Personnage ) which contains a QLabel , and in the Qlabel there are a Pixmap (the green ball ) after this i called this object from another program (it work ) and i created a function in this new class to move my object (i used move which come from QLabel ) but it didn't work , can someone help me please , thanks


-
Hello guys , i created a new class (Personnage ) which contains a QLabel , and in the Qlabel there are a Pixmap (the green ball ) after this i called this object from another program (it work ) and i created a function in this new class to move my object (i used move which come from QLabel ) but it didn't work , can someone help me please , thanks


@Zunneh
I shall be surprised if someone can discern exactly what you are saying here....after this i called this object from another program (it work )
What does that mean? You can't call objects from other programs....
i created a function in this new class to move my object (i used move which come from QLabel )
So your code does not move the object (
Personnage), it just moves the label within thePersonnagewidget.... To be specific, yourtest->move(0, m_y)moves theQLabelwithin your widget, while thethis->move(60, 0)moves yourPersonnage, which one were you talking about...?but it didn't work
What does that mean...?
-
i created the main program with Qt designer and after this i added a class in this project which contains the green ball , now from the main program (look at the previous screen shot ) i created the object (the green ball whose name is bat) and i want to control this object from main program , i tried but i can' move the object from the main program (i can move it only from the constructor of the class with test->move , me i want to move all the new object Personnage for example when i write bat->movetoUp() it move the object to Up
") -
batis local to the constructor so can't be referenced outside it. move thePersonnage* bat;definition in the header (.h) and in the constructor just putbat = new Personnage(this);. Now you can usebateverywhere in yourMainWindow.P.S.
The constructor ofPersonnagedoes some weird stuff, basically the label insidePersonnageandPersonnagehave completely distinct lives and that's unusual to say the least -
i find the solutions , my problem that in the first i put QLabel who is inside Personnage the parent , now i put my Personnage the parent so i can move the personnage not the Qlabel inside the personnage, i added the command this->setParent(parent)
by the way thank you guys for the help
-
i find the solutions , my problem that in the first i put QLabel who is inside Personnage the parent , now i put my Personnage the parent so i can move the personnage not the Qlabel inside the personnage, i added the command this->setParent(parent)
by the way thank you guys for the help