Getting mouse click location of a label in qt

前端 未结 3 439
被撕碎了的回忆
被撕碎了的回忆 2020-12-17 22:31

I googled around and found this forum thread in which the OP seems to have had the exact problem I am having. The question is, how would I inherit from QLabel a

3条回答
  •  甜味超标
    2020-12-17 23:09

    Is it just me, or doesn't QMouseEvent already give the information you need?

    int QMouseEvent::x () const

    Returns the x position of the mouse cursor, relative to the widget that received the event.

    See also y() and pos().

    int QMouseEvent::y () const

    Returns the y position of the mouse cursor, relative to the widget that received the event.

    See also x() and pos().

    Ref: http://doc.qt.nokia.com/4.7.old/qmouseevent.html#x

提交回复
热议问题