Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QMousemove and QMouseDrag event at the same time
QtWS25 Last Chance

QMousemove and QMouseDrag event at the same time

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    praveen0991kr
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      hi
      for mouseMove Events u might need to enable it
      with
      setMouseTracking(true);
      http://doc.qt.io/qt-5.5/qwidget.html#mouseTracking-prop

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        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 ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1
        • P Offline
          P Offline
          praveen0991kr
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            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.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved