Results 1 to 11 of 11

Thread: EventFilter and MouseMoveEvent

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: EventFilters

    Quote Originally Posted by mickey
    but don't appear: MouseButtonPress = 2, MouseButtonRelease = 3, MouseButtonDblClick = 4,MouseMove = 5.
    And how MouseMove is Called?
    Don't you need to enable mouse tracking to get these?

  2. #2
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: EventFilters

    Hi,
    I link a loadButton to a SLOT:
    Qt Code:
    1. MainfForm::load {
    2. loadButton->installEventFilter(this->myWidget1);
    3. loadButton->installEventFilter(this->myWidget2);
    4. loadButton->installEventFilter(this->myWidget3);
    5. ......
    6. QString te = fd.getOpenFileName(xdir.path()+"/"+" ....",
    7. ...........
    8. }
    To copy to clipboard, switch view to plain text mode 
    Then:
    Qt Code:
    1. bool MyWidget::eventFilter(QObject* obj, QEvent* e) {
    2. cout << "filter\n";
    3. cout << e->type() << endl;
    4. if ( e->type() == QEvent::Move) {
    5. cout << "filter out\n";
    6. return TRUE;
    7. }
    8. return QGLWidget::eventFilter(obj,e);
    9. }
    To copy to clipboard, switch view to plain text mode 
    I have 3 instance of MyWidget. The MouseMoveEvent in myWidget start when I choose a file "with doubleClick" in QFileDialog but printf inside QMouseEvent (in MyWidget) says
    that only mouseMove start...

    A hint? Thanks
    Regards

  3. #3
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: EventFilters

    did you enable mouse tracking ??? Basically a widget records mose move only when a click occurs...

    You can change that settings :
    Qt Code:
    1. setMouseTracking(true) ;
    To copy to clipboard, switch view to plain text mode 
    Current Qt projects : QCodeEdit, RotiDeCode

  4. #4
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: EventFilters

    Quote Originally Posted by fullmetalcoder
    did you enable mouse tracking ??? Basically a widget records mose move only when a click occurs...

    You can change that settings :
    Qt Code:
    1. setMouseTracking(true) ;
    To copy to clipboard, switch view to plain text mode 
    yes I proved.Don't change...I'm thinking that QmouseMoveEvent starts for some strange
    reason.......
    Regards

  5. #5
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: EventFilters

    Because you tried to contact me via skype and sending message failed, here's what I said there:

    It would help if you'd provide a full working example with source as short as possible so I can try on my machine. I and others already suggested what could be the reason. If none of our tipps work, we have to see code. Often while you create such a like 100 LOC application, you solve the problem because the problem does not occur in the small testapp. Then you will compare what is different and hopefully find the reason. If not, post the programm
    It's nice to be important but it's more important to be nice.

  6. #6
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: EventFilters (SOLVED)

    axeljaeger, thanks for reply...
    I solved my problem but I don't understand why qMouseMoveEvent of MyWidget:: starts
    starts after the code of loadButton():
    Qt Code:
    1. void MainForm::loadbutton()
    2. {
    3. this->myWidget->installEventFilter(this->myWidget);
    4. .............
    5. printf("end mainform()LoadButt\n");
    6. }
    To copy to clipboard, switch view to plain text mode 
    (With the printf above I see that QMouseMoveEvent of myWidget starts after (out) loadButtton(). But Why? I coded removeFilter at the end of loadbutton() but QmouseMoveEvent starts after and so don't filter it)

    Qt Code:
    1. bool MyWidget::eventFilter(QObject* obj, QEvent* e) {
    2. if (obj == this) {
    3. cout << e->type() << endl;
    4. if ( e->type() == QEvent::MouseMove) {
    5. this->removeEventFilter(this);
    6. cout << "filter out\n";
    7. return TRUE;
    8. }
    9. else {
    10. return QGLWidget::eventFilter(obj,e);
    11. }
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 
    With cout << e->type I see all QEvent on myWidget and MouseMove runs only after the oadButton()...so I filter out only one (setMouseTracking is off) QMouseMove and I put removeFilter in the eventFilter (but I don't LIKE this....) .
    What do you think of this?
    thanks
    Regards

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.