在QLabel中获得posa 的最佳(最简单)方法mousePressedEvent是什么?(或者基本上只获取相对于QLabel小部件的鼠标点击位置)
编辑
我尝试了Frank以这种方式建议的内容:
bool MainWindow::eventFilter(QObject *someOb, QEvent *ev)
{
if(someOb == ui->label && ev->type() == QEvent::MouseButtonPress)
{
QMouseEvent *me = static_cast<QMouseEvent *>(ev);
QPoint coordinates = me->pos();
//do stuff
return true;
}
else return false;
}
Run Code Online (Sandbox Code Playgroud)
但是,我invalid static_cast from type 'QEvent*' to type 'const QMouseEvent*'在我尝试声明的行上收到编译错误me.我在这里做错了什么想法?