Results 1 to 2 of 2

Thread: showing menu mouseclick event with opengl object

  1. #1
    Join Date
    Feb 2008
    Posts
    36
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default showing menu mouseclick event with opengl object

    Hi, I draw objects such as dog and cat with opengl. When I click mouse right button in a location ,if there is a cat in this loation a menu opens and shows cat' s properties , if there is a a dog in this location a menu opens and shows dog' s properties .How can I do this .Please help

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

    Default Re: showing menu mouseclick event with opengl object

    In general you need to be able to tell what items collide with a line starting in the camera position and crossing the projection plane at the coordinates pointed by the mouse event. You'll need to do some math or better yet search on OpenGL (or 3D in general) sites for appropriate formulas. Then it's just a matter of creating a QMenu object and using QMenu::exec() to trigger the menu. And it'll be better if you use QWidget::contextMenuEvent() instead of QWidget::mouseReleaseEvent() or similar.

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.