Results 1 to 14 of 14

Thread: contextMenuEvent

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Qt products
    Qt3
    Platforms
    Windows
    Thanks
    53

    Default Re: contextMenuEvent

    event is called when I release mouse! But If I pressed dx button for do traslation, menu mustn't appear!
    Regards

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

    Default Re: contextMenuEvent

    Quote Originally Posted by mickey
    event is called when I release mouse! But If I pressed dx button for do traslation, menu mustn't appear!
    Yes, we understood the problem. Here's a couple of pseudo algorithms to solve it. The choice is yours:
    Qt Code:
    1. mousePressEvent:
    2. pressPoint = mouse press event's position
    3.  
    4. contextMenuEvent:
    5. if distance between context menu event's position and pressPoint is less than something
    6. show context menu
    7. else do nothing
    To copy to clipboard, switch view to plain text mode 
    or
    Qt Code:
    1. mousePressEvent:
    2. pressPoint = mouse press event's position
    3.  
    4. mouseReleaseEvent:
    5. if distance between mouse release event's position and pressPoint is less than something
    6. showContextMenu = true
    7. else
    8. showContextMenu = false
    9.  
    10. contextMenuEvent:
    11. if showContextMenu
    12. show context menu
    13. else do nothing
    To copy to clipboard, switch view to plain text mode 
    or
    Qt Code:
    1. mousePressEvent:
    2. showContextMenu = true
    3.  
    4. mouseMoveEvent:
    5. showContextMenu = false
    6.  
    7. contextMenuEvent:
    8. if showContextMenu
    9. show context menu
    10. else do nothing
    To copy to clipboard, switch view to plain text mode 
    or ....
    J-P Nurmi

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

    Default Re: contextMenuEvent

    Hmm... could you provide a minimal compilable example which reproduces the problem? Because as for now we're talking about a bit abstract behaviour.

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

    Default Re: contextMenuEvent

    i think so long...but Do I have use some flag to do this?when right mouse button do some things (translate, change color of scene where I pick (only if I have a pushbutton down). so if traslate or changing color (it works), when I releae mouse appear menu; I can follow advice of jpn (for every things I set a flags menuContext=false), but I hoped find a Qt way....such as ignore() (but I haven't idea how use it):..
    Regards

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

    Default Re: contextMenuEvent

    If you do, remember to reimplement also the release event to clear values which were set in previous handlers.

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

    Default Re: contextMenuEvent

    I'm trying this; with mouseMoving flag it works; but I wonder how use ignore() function
    Qt Code:
    1. void MyWidget::contextMenuEvent(QContextMenuEvent* e) {
    2. if (mouseMoving) {mouseMoving = false; return;}
    3. //if (mouseMoving) e->ignore(); //Must I use ignore() in that way?
    To copy to clipboard, switch view to plain text mode 
    Where do I have to use ignore? and how cal it? thanks
    Regards

Similar Threads

  1. contextMenuEvent has issues since 4.1.3
    By momesana in forum Qt Programming
    Replies: 9
    Last Post: 31st May 2006, 18:27
  2. Replies: 4
    Last Post: 17th February 2006, 15:28

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.