Qt获取屏幕等的信息
Qt获取屏幕等的信息
窗口大小信息
使用三个函数:setGeometry()
, resize()
, move()
.
控件的位置信息
返回相对于Widget的位置:
QPoint QMouseEvent::pos()
鼠标的全局坐标:
QPoint QMouseEvent::globalPos()
const QPointF &QMouseEvent::screenPos() const
相对显示器的坐标
QPoint QCursor::pos() [static]
它和前面的QMouseEvent::globalPos()相等.
窗口坐标转换成显示器坐标
QPoint QWidget::mapToGlobal(const QPoint & pos) const
显示器坐标转换成窗口坐标
QPoint QWidget::mapFromGlobal(const QPoint & pos) const
窗口坐标转换成父类widget的坐标
QPoint QWidget::mapToParent(const QPoint & pos) const
将父类窗口坐标转换成当前窗口坐标
QPoint QWidget::mapFromParent(const QPoint & pos) const
当前窗口坐标转换成指定parent的坐标
QPoint QWidget::mapTo(const QWidget * parent, const QPoint &pos) const
当前控件在父窗口的坐标
QWidget::pos() : QPoint
获取系统屏幕大小
Qt5之前,使用QDesktopWidget
, Qt5之后, 使用QScreen
.
1 |
|
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 编程随笔!