Results 1 to 14 of 14

Thread: setMouseTracking() doesn't work.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: setMouseTracking() doesn't work.

    But I'm confused that the contentsMouseMoveEvent() is only called when a mousebutton pressed and moved just as mouseTracking is FALSE.
    Can you please clear about this?

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: setMouseTracking() doesn't work.

    I dont know about Qt3 ...
    but i guess u are overriding the wrong function...
    setMouseTracking(true) enables the widget to receive mouseMoveEvent() ....not contentsMouseMoveEvent ...

    try catching the events in mouseMoveEvent..

    Hope this helps

  3. #3
    Join Date
    Nov 2006
    Posts
    58
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: setMouseTracking() doesn't work.

    Quote Originally Posted by aamer4yu View Post
    I dont know about Qt3 ...
    but i guess u are overriding the wrong function...
    setMouseTracking(true) enables the widget to receive mouseMoveEvent() ....not contentsMouseMoveEvent ...

    try catching the events in mouseMoveEvent..

    Hope this helps
    But in the QanvasView the contentsMouseMoveEvent is the only function that can receive the mouseMoveEvent.

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: setMouseTracking() doesn't work.

    But in the QanvasView the contentsMouseMoveEvent is the only function that can receive the mouseMoveEvent.
    Are you sure ?? i saw Q3CanvasView and it is derived from QWidget ... isnt QCanvasView derived from QWidget ??
    If it is derived, then u can override the mouseMoveEvent.... try it

  5. #5
    Join Date
    Nov 2006
    Posts
    58
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: setMouseTracking() doesn't work.

    The QCanvasView is derived from QScrollView, the contentsMouseMoveEvent() is the member function of QScrollView. And also as the Qt documents example described, when you want to deal with mouseMoveEvent, mouePressEvent, mouseReleaseEvent etc. in the QCanvasView you can directly reimplement the contentsMouse****Event() which are all the member function of the QScrollView.

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: setMouseTracking() doesn't work.

    I'm not sure, but maybe you have to enable the mouse tracking on the viewport widget like in many corresponding situations you have to do in Qt4?
    J-P Nurmi

  7. #7
    Join Date
    Nov 2006
    Posts
    58
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: setMouseTracking() doesn't work.

    What does it mean by "enable the mouse tracking on the viewport widget"?
    What is viewport widget? I have only CanvasView wthin a QWidgetStack.

  8. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: setMouseTracking() doesn't work.

    Quote Originally Posted by luffy27 View Post
    What does it mean by "enable the mouse tracking on the viewport widget"?
    What is viewport widget? I have only CanvasView wthin a QWidgetStack.
    See QScrollView::viewport().

    Try:
    Qt Code:
    1. viewport()->setMouseTracking(TRUE);
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  9. #9
    Join Date
    Nov 2006
    Posts
    58
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: setMouseTracking() doesn't work.

    Quote Originally Posted by luffy27 View Post
    What does it mean by "enable the mouse tracking on the viewport widget"?
    What is viewport widget? I have only CanvasView wthin a QWidgetStack.
    Quote Originally Posted by jpn View Post
    See QScrollView::viewport().

    Try:
    Qt Code:
    1. viewport()->setMouseTracking(TRUE);
    To copy to clipboard, switch view to plain text mode 
    All right I will try it.

  10. #10
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: setMouseTracking() doesn't work.

    Quote Originally Posted by luffy27 View Post
    All right I will try it.
    Qt Code:
    1. viewport()->setMouseTracking(TRUE);
    To copy to clipboard, switch view to plain text mode 
    should work....

  11. #11
    Join Date
    Nov 2006
    Posts
    58
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: setMouseTracking() doesn't work.

    YES!That does work!
    Thank you guys very much and best regards!

  12. #12
    Join Date
    Nov 2006
    Posts
    58
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: setMouseTracking() doesn't work.

    Could anybody are willing to compile the code and run it ?
    When you run it ,you can click the Graphic button to switch to the QCanvasView. Then you hold the left mouse button dow and move it. Finally you can find the output
    "The MouseMoveEvent has been received!" on the console. That means the QCanvasView receives the mouseMoveEvent correctly.
    But when you just move the mouse without any button pressed down. There is no output on the console. So that means QCanvasView can not receive the mouseMoveEvent in the condition of no mouse button pressed down.

    I hope that you can try it on practice. You will see the problem more clearly.
    Thanks a lot!

  13. #13
    Join Date
    Nov 2006
    Posts
    58
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: setMouseTracking() doesn't work.

    Quote Originally Posted by vermarajeev View Post
    Can you please clear about this?
    That means, when I hold a mouse button down and move the mouse, the mouseMoveEvent is sent correctly. And then the contentsMouseMoveEvent() in the CanvasView receives the move event correctly too.
    BUT as I mentioned before, I have already set the CanvasView's mouseTracking to TRUE!
    That means, the contentsMouseMoveEvent() can receive mouseMoveEvent even if when mouse move WITHOUT any mouse button pressed! But now the CanvasView can't receive the mouseMoveEvent by mouse moving WITHOUT any mouse button pressed!
    It seems that the code below doesn't work.
    Qt Code:
    1. CanvasView::CanvasView(QCanvas* canvas, QWidget* parent, const char* name) :QCanvasView(canvas,parent,name)
    2. { setMouseTracking(TRUE);}
    To copy to clipboard, switch view to plain text mode 
    That is what I'm confused about.
    Last edited by luffy27; 26th April 2007 at 07:54.

Similar Threads

  1. QWidget -> updateGeometry dont work.
    By patrik08 in forum Qt Programming
    Replies: 7
    Last Post: 22nd May 2013, 15:55
  2. which ide/editor/database work best with qt4?
    By kkool84 in forum Installation and Deployment
    Replies: 17
    Last Post: 24th August 2006, 06:45
  3. Which version should I work on i686 host for arm target?
    By sliawati in forum Installation and Deployment
    Replies: 4
    Last Post: 11th August 2006, 09:44
  4. QTextEdit Justify align making work
    By dec0ding in forum Qt Programming
    Replies: 2
    Last Post: 13th January 2006, 12:02

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.