Results 1 to 6 of 6

Thread: Set mouse tracking issue

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Set mouse tracking issue

    Hello forum

    let me re-iterate what is written in the Qt manual about mouse tracking:

    "This property holds whether mouse tracking is enabled for the widget.
    If mouse tracking is disabled (the default), the widget only receives mouse move events when at least one mouse button is pressed while the mouse is being moved.
    If mouse tracking is enabled, the widget receives mouse move events even if no buttons are pressed."


    I have sub-classed QGraphicsView and did not enable mouse tracking inside the subclass construcor.


    But the mouse move is tracked inside the mouse move event even when no mouse buttons are pressed.


    Any explanation ? I am using Qt 4.4.3



    Regards
    Sajjad

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Set mouse tracking issue

    You are saying that this always outputs "Move" messages regardless of mouse buttons:
    Qt Code:
    1. #include <QtGui>
    2. #include <QDebug>
    3.  
    4. class MyView: public QGraphicsView {
    5. Q_OBJECT
    6. public:
    7. MyView(QWidget *p = 0): QGraphicsView(p)
    8. {
    9. resize(QSize(320, 240));
    10. qDebug() << hasMouseTracking(); // outputs false
    11. }
    12.  
    13. protected:
    14. void mouseMoveEvent( QMouseEvent * event )
    15. {
    16. qDebug() << "Move";
    17. }
    18. };
    19.  
    20.  
    21. int main(int argc, char *argv[])
    22. {
    23. QApplication app(argc, argv);
    24.  
    25. MyView m;
    26. m.show();
    27.  
    28. return app.exec();
    29. }
    30. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 
    Certainly doesn't here with Qt 4.7.4.

    Post a small, compilable example that demonstrates the problem.

  3. The following user says thank you to ChrisW67 for this useful post:

    sajis997 (24th January 2012)

  4. #3
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Set mouse tracking issue

    Hello ChrisW67,

    I have made some changes within the diagram scene example and mouse tracking is set to false explicitly and still i get the mouse tracking enabled in Qt 4.4.3.


    Please check it out if this is one of the bugs inside it or is it something that i am missing while re-engineering ?



    Regards
    Sajjad
    Attached Files Attached Files

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Set mouse tracking issue

    Mouse tracking is enabled on the viewport. This is caused by the following call:

    Qt Code:
    1. setTransformationAnchor(AnchorUnderMouse);
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. The following user says thank you to wysota for this useful post:

    sajis997 (24th January 2012)

  7. #5
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Set mouse tracking issue

    Thanks

    Is there any reference to this informational hint or you digged down to the source ?



    Regards
    Sajjad

  8. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Set mouse tracking issue

    I did what you should have done. I took your code and started commenting out lines that might have enabled features requiring mouse tracking. This was the second thing I tried.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. tracking mouse coordinates
    By lightning2911 in forum Newbie
    Replies: 8
    Last Post: 11th December 2011, 23:51
  2. qwtplot and mouse tracking
    By fearu in forum Qwt
    Replies: 6
    Last Post: 15th October 2010, 09:28
  3. mouse tracking on image
    By vermarajeev in forum Qt Programming
    Replies: 14
    Last Post: 12th May 2010, 13:06
  4. mouse tracking in QGraphicsItem
    By christina123y in forum Qt Programming
    Replies: 10
    Last Post: 9th March 2009, 08:23
  5. [QT3+XP] transparency and mouse tracking
    By incapacitant in forum Newbie
    Replies: 9
    Last Post: 17th February 2006, 18:49

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
  •  
Qt is a trademark of The Qt Company.