I've a problem with QMouseEvent:
void Gioco::gioco_G1()
{
QMouseEvent *mouse = new QMouseEvent;
bool stato = false;
do
{
if (mouse->KeyPress() == Qt::MouseButton::LeftButton) {
qDebug()<<"entra nell'if";
if (img_mano1G1 -> isUnderMouse()) {giocata_G1 = manoG1[0]; stato = true;}
else if (img_mano2G1 -> isUnderMouse()) {giocata_G1 = manoG1[1]; stato = true;}
else if (img_mano3G1 -> isUnderMouse()) {giocata_G1 = manoG1[2]; stato = true;}
}
} while (stato == false); //repeat until I enter an if
}
I've created a scene and I've inserted some QGraphicsPixmapItem in the scene. Now I want to enter in the "if" when I click on a specified QGraphicsPixmapItem.
For example when I click on img_manoG1 I want to enter in the first "if"
How can I tell the program to stop and wait for the mouse input ?
TI'm new to Qt and it's the first time i use the objects so I make a lot of logical mistake, so using QStateMachine it's a big problem...
It's the only way to do thath ? I try to explain my program:
I want to create a card's game and in the previous version I've used an old graphics library with this sequence of commands:
-> print cards on the scene
-> wait for a mouse input (with a do-while)
-> if(isMouseClick(WM_LBUTTONDOWN))
-> if(mouse position is on the first card)
-> select that card. So i wish to do the same thing with QGraphics.
In this way I tell the program:
-> print cards
-> wait for a mouse event
-> print the card that I've selected with that event.
Now I want to change the program graphics and I've introduced QGraphics. I've created a scene and print all the objects "card" on it so now i want to tell the program:
-> print the object and wait the mouse input
-> if a card is to selected with the left clik
-> print that card in scene, wait 1/2 second and go ahead with the program
The problem is that I use a for
1 to 20 (I must run that 20 times in a match).
I've tried to lauch the program with a random G1 and COM play but the application freeze until the last execution of the for
and I print on the scene only the last configuration of cards.
That is the reason because previously I said I want the program to stop...
It is possible to do without QStateMachine ? Simply telling him: "pause", print this situation, wait for mouse and go ahead ?