Qt坐标相关的函数
int QMouseEvent::globalX() const Returns the global position of the mouse cursor aQPoint QWidget::pos();//这个属性获得的是当前目前控件在父窗口中的位置QPoint QMouseEvent::pos();//返回相对这个widget的位置QPoint QMouseEvent::globalPos
·
int QMouseEvent::globalX() const Returns the global position of the mouse cursor a QPoint QWidget::pos();//这个属性获得的是当前目前控件在父窗口中的位置 QPoint QMouseEvent::pos();//返回相对这个widget的位置 QPoint QMouseEvent::globalPos();//窗口坐标,这个是返回鼠标的全局坐标 const QPointF& QMouseEvent::screenPos()const;//和QPoint QMouseEvent::globalPos() 值相同,但是类型更高精度的QPointF QPoint QWidget::mapFromGlobal(const QPoint &pos) const;//将全局的屏幕坐标转化为窗口坐标. QPoint QWidget::mapToGlobal(const QPoint &pos) const;//反过来.举个例子,在MainWindow中运行mapToGlobal(pos(0,0)), 得到全局位置为(0,22). (0,0)表示主窗口的左上角,从这里可以看出主窗口在全局中的y坐标为22. QPointQWidget::mapToParent(constQPoint& pos)const;//将窗口坐标获得的pos转换成父类widget的坐标 QPointQWidget::mapFromParent(constQPoint& pos)const;//将父类窗口坐标转换成当前窗口坐标 QPointQWidget::mapTo(constQWidget* parent,constQPoint& pos)const;//将当前窗口坐标转换成指定parent坐标 QCursor().pos()或者cursor().pos()://获取鼠标在全局坐标主屏幕(primary screen)上的绝对位置(比如(947,648)), 可以通过mapFromGlobal获得窗口坐标(比如(947,626)).
参考文章:https://www.cnblogs.com/lomper/p/4249575.html
更多推荐
所有评论(0)