Getting mouse click location of a label in qt

前端 未结 3 444
被撕碎了的回忆
被撕碎了的回忆 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:07

    just like this :D

    void CustomLabel::mousePressEvent(QMouseEvent *ev) 
    {
    QString x = QString::number(ev->x());
    QString y = QString::number(ev->y());
    qDebug() << x << "," << y;
    }
    

提交回复
热议问题