qmouseevent

How to draw a rectangle and adjust its shape by drag and drop in PyQt5

血红的双手。 提交于 2019-12-03 21:16:11
I'm trying to draw a rectangle on GUI created by PyQt5 by drag and drop. I managed to do that, but the rectangle is drawn when the mouse left key is released. What I want to do is like this link : When the mouse left button is pressed, start drawing the rectangle. While dragging, adjust the rectangle shape with the mouse movement. When the mouse left button is released, determine the rectangle shape. How can I implement this? Thanks in advance. Here's my code. # -*- coding: utf-8 -*- import sys from PyQt5 import QtWidgets, QtCore from PyQt5.QtGui import QPainter class MyWidget(QtWidgets

QStateMachine - QMouseEvent

谁说我不能喝 提交于 2019-12-02 16:23:40
问题 In another question you tell me to use QStateMachine. I'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

QStateMachine - QMouseEvent

孤街醉人 提交于 2019-12-02 08:25:47
In another question you tell me to use QStateMachine. I'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