Delete a clicked object from the scene?
-
I want to come back to this, because I can't seem to get things together.
It seems to me that if I could get to return the object clicked in my scene (that being a card), I could finally move on. Documentation just confuse me further, even my own code has the same effect at the moment..
-
Hi,
Pseudo code:
@
MyClass::whereItNeedsToBeFunction(){
// Create the card
connect(card, SIGNAL(clicked()), this, SLOT(cardClicked());
}void MyClass::cardClicked()
{
CardClass *card = qobject_cast<CardClass *>(sender());
if (card) {
// do what you want with the card
}
}
@Hope it helps
-
Since you are already compiling a Qt project with VS, there should not be any problem
-
Your Card class is not a QObject ?
-
No they are not, for their original use case, deriving from QObject would not make sense. If you need signals and slots in a QGraphicsItem there's also QGraphicsObject to have a look at
-
The documentation is your friend ;)