QMousemove and QMouseDrag event at the same time
-
Hi All,
I want to use Qmousemove and drag event at the same time. I have a mouse released and pressed event too on the same ui so therefore I am getting issue.
Right now : Pressed / Dragged / Released are working fine as soon as i have to add Mousemove event all are not working so how to do it .help Me,..
Thanks and regards ,
Praveen K -
hi
for mouseMove Events u might need to enable it
with
setMouseTracking(true);
http://doc.qt.io/qt-5.5/qwidget.html#mouseTracking-prop -
Hi,
How are you handling that mouse move event ? Are you calling the base class implementation of the method so that your widget can properly handle the drag and drop stuff ?
-
Hi SGaist,
I have one ui component that is lineartimelineview that having a mouse tracking event that I have enabled to make it work.
Initially :
the same ui component that is lineartimelineview on form ; there is one scrubber on Lineartimelineview that can be dragged and one class is created for same to paint rectangle and have Dragging and Pressed and Released on that recangle only.All was working fine;
but when i have enable mousemoveevent in lineartimelineview all have stopped working :
Here is the code for Scrubbergraphics.h :
class BackgroundRectItem : public QObject,public QGraphicsRectItem{ Q_OBJECT signals: void translated_signal(QPointF displacement, QPointF scenePos); void mouseReleased_signal(); void mousePressed_signal(); protected: void hoverEnterEvent(QGraphicsSceneHoverEvent *e){ QGraphicsRectItem::hoverEnterEvent(e); this->setCursor(Qt::SizeHorCursor); } void hoverLeaveEvent(QGraphicsSceneHoverEvent *e){ QGraphicsRectItem::hoverLeaveEvent(e); this->setCursor(Qt::ArrowCursor); } void mousePressEvent(QGraphicsSceneMouseEvent *event) override{ //QGraphicsRectItem::mousePressEvent(event); emit this->mousePressed_signal(); FlagCheck = false; } void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override{ QGraphicsRectItem::mouseReleaseEvent(event); emit this->mouseReleased_signal(); FlagCheck = true; }
Code that I have Just started in lineartimelineview:
class LinearTimelineView : public QGraphicsView, public ITimelineView{ Q_OBJECT Q_INTERFACES(ITimelineView) public: protected: /** Start end time for each input clips */ QList<Chrono> clipChronos; QGraphicsScene *scene; QTimer *timer; QMouseEvent *store; // BarsGraphics *bargrahics; // __int64 value; //LinearBarsModel *linearBarsModel; LinearBarsGraphics *linearBarsGraphics; int thumbSize[2]; int resolution; int originalResolution; void mouseMoveEvent(QMouseEvent * event) { // Declaring fuction only led to not work Drag/Press/Released functionality };
Thanks for your help and time
Praveen
-
One thing I see is that you commented out the call to the base class of mousePressEvent which is bad idea since you are working on drag and drop.