如题,我已经在paintEvent中设定
QStylePainter painter(this);
painter.setWindow(-50,-50,100,100); //设定
窗口 painter.drawLine(0,0,10,10); //画一条线
然后
void MapControl2D::mouseMoveEvent(QMouseEvent *event)
{
mousePoint2d =event->globalPos(); //获取鼠标指针上的点坐标
emit backTipPoints2d(); //发射信号
}
emit backTipPoints2d(); //发射信号 之后我在主窗体上,已经能实现坐标值
显示,
但是若用event->pos(); 则只能显示出视口坐标,若用上面的坐标却又与我的逻辑坐标不同。。
event在QT中帮助说有很多个获取坐标的函数,我该用那个才能从鼠标移动事件中获得我定义的逻辑坐标呢?
我试了很多个都没成功呢。。万分感谢啊。。。
const QPoint &QMouseEvent::globalPos () const
Returns the global position of the mouse cursor at the time of the event
中 global position 是指什么位置。。原点不知道那去了
[ 此帖被liaowei5566在2011-04-04 16:38重新编辑 ]