Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Display coordinate information whenever cursor is hovered over a primitive object.

Display coordinate information whenever cursor is hovered over a primitive object.

Scheduled Pinned Locked Moved Game Development
2 Posts 2 Posters 1.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    codefy
    wrote on last edited by
    #1

    I have rendered a OpenGL ES(2.0) triangle using QGLWidget and QGLFunctiions. So if I hover the mouse cursor over rendered scene it should show respective (x,y) coordinates on the screen.How can I achieve this.Is it possible using Qt?
    I heard about QHoverEvent but not sure how it can be useful. please suggest.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tilsitt
      wrote on last edited by
      #2

      Hi,

      Events are a mechanism of QObject: your OpenGL context can't detect you're hovering a drawn primitive. Nevertheless you can track your cursor inside your widget -- just activate "mouse tracking":http://qt-project.org/doc/qt-5/qwidget.html#mouseTracking-prop on it and handle events by reimplementing QGLWidget::mouseMoveEvent() -- an then detect the primitive hovered with OpenGL picking. Show the coordinates on the screen using "QGLWidget::renderText()":http://qt-project.org/doc/qt-5/qglwidget.html#renderText.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved