Important: Please read the Qt Code of Conduct -

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

  • Lifetime Qt Champion

    for mouseMove Events u might need to enable it

  • Lifetime Qt Champion


    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{
    	void translated_signal(QPointF displacement, QPointF scenePos);
    	void mouseReleased_signal();
    	void mousePressed_signal();
    	void hoverEnterEvent(QGraphicsSceneHoverEvent *e){
    	void hoverLeaveEvent(QGraphicsSceneHoverEvent *e){
    	void mousePressEvent(QGraphicsSceneMouseEvent *event) override{
    		emit this->mousePressed_signal();
    		FlagCheck = false;
    	void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override{
    		emit this->mouseReleased_signal();
    		FlagCheck = true;

    Code that I have Just started in lineartimelineview:

    class LinearTimelineView : public QGraphicsView, public ITimelineView{
    	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


  • Lifetime Qt Champion

    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.

Log in to reply