October 20, 2010

wisty wisty
Lab Rat
4 posts

How to identify click events on customised objects?

 

We are rendering an Opengl Object using QGLWidget and we are trying to add signals and slots to the Opengl customised widget.
How do we identity click event on our customised objects?

By click I meant mouse down and mouse up event.
Actually we are rendering a set of customised linear buttons using QGLWidget.
So how do we identify the mouse click in a particular area of our customised buttons?

6 replies

October 21, 2010

Andre Andre
Robot Herder
6295 posts

What do you mean by “identify click event”?
Note that there is no real click event in Qt in the sense of QEvents. There are mouse down and up events, and there is a double click event, but no click event. A click is simply a mouse down, followed by a mouse up in the same region of your widget.

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

October 21, 2010

lyuts lyuts
Lab Rat
169 posts

If understand you correctly, then you just need to override

  1. void QWidget::mousePressEvent ( QMouseEvent * event )

and when the event occurs, this event handler will be automatically called.

 Signature 

I’m a rebel in the S.D.G.

October 21, 2010

wisty wisty
Lab Rat
4 posts

Hi Lyuts,
I am already doing that.But I need to identify a customised Opengl Widget,based on which area it is clicked.
So how do I identify this click area or bounding rectangle of my customised Opengl Widget?

October 22, 2010

Andre Andre
Robot Herder
6295 posts

Well, because you do the rendering of that custom widget, it’s up to you to identify what part of the widget was clicked. Qt can’t help you with that.

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

October 22, 2010

hasnain hasnain
Lab Rat
23 posts

on mouse click event you can get cursor position using

  1. QCursor::pos()

just an idea this might help you. if you know the position of your custom object;

November 2, 2010

Jayakrishnan.M Jayakrishnan..
Lab Rat
200 posts

overriding the mouse event functions should work as said earlier. Do you need to identify an object in an opengl view, a 3d object you added to the scene ?

 
  ‹‹ Newby needs help building QMediaPlayer Example      QFtp strange behavior on ARM (angstrom) ››

You must log in to post a reply. Not a member yet? Register here!