草庐IT

CustomLabel

全部标签

c++ - 在qt中获取标签的鼠标点击位置

我用谷歌搜索并找到了thisforumthread其中OP似乎遇到了我遇到的确切问题。问题是,我如何从QLabel继承并重新实现mousepressed事件?我猜它会是这样的:classCustomLabel:publicQLabel{public://whatabouttheconstructors?voidmousePressEvent(QMouseEvent*ev);}voidCustomLabel::mousePressEvent(QMouseEvent*ev){QPoint=ev->pos();//Iwanttohaveanotherfunctiongettheeventpo