相关疑难解决方法(0)

获取鼠标在QLabel中的位置

在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.我在这里做错了什么想法?

c++ qt point-of-sale mousepress

0
推荐指数
1
解决办法
9967
查看次数

标签 统计

c++ ×1

mousepress ×1

point-of-sale ×1

qt ×1