Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to identify click events on customised objects?
QtWS25 Last Chance

How to identify click events on customised objects?

Scheduled Pinned Locked Moved Mobile and Embedded
8 Posts 6 Posters 10.7k Views
  • 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.
  • W Offline
    W Offline
    wisty
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lyuts
        wrote on last edited by
        #3

        If understand you correctly, then you just need to override

        @void QWidget::mousePressEvent ( QMouseEvent * event )@

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

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

        1 Reply Last reply
        0
        • W Offline
          W Offline
          wisty
          wrote on last edited by
          #4

          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?

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • H Offline
              H Offline
              hasnain
              wrote on last edited by
              #6

              on mouse click event you can get cursor position using
              @QCursor::pos()@
              just an idea this might help you. if you know the position of your custom object;

              1 Reply Last reply
              0
              • J Offline
                J Offline
                jaak
                wrote on last edited by
                #7

                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 ?

                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  heatblazer
                  wrote on last edited by
                  #8

                  Hi, I am doing the same thing. I am working with the QGraphicsView/Scene. I want to add invisible rectangular areas, that has multiple properties, like clickable, repaintable, updatable, etc. Are only the event handlers option here or SIGNAL/SLOT mechanism still can be used?

                  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