//屏幕分辨率:
QDesktopWidget* desktopWidget = QApplication::desktop();
QRect screenRect = desktopWidget->screenGeometry();
int g_nActScreenW = screenRect.width();
int g_nActScreenH = screenRect.height();
//固定控件的大小: setFixedSize(90,60);
QPoint GlobalPoint(ui.widgetGameArea->mapToGlobal(QPoint(0, 0)));//获取控件在窗体中的坐标
int x = GlobalPoint.x();
int y = GlobalPoint.y();//重新调节控件位置
void CGameChatRoomDlg::resizeEvent( QResizeEvent *e )
{
if (!m_hwndGame)
return ;
QPoint GlobalPoint(ui.widgetGameArea->mapToGlobal(QPoint(0, 0)));//获取控件在窗体中的坐标
int x = GlobalPoint.x();
int y = GlobalPoint.y();
QRect rect = ui.widgetGameArea->geometry() ;
QPoint point = mapTo(nativeParentWidget(), QPoint (rect.x(), rect.y())) ;
SetWindowPos(m_hwndGame,NULL,point.x(), point.y(), 0,0,SWP_NOSIZE | SWP_NOACTIVATE);
Log(LL_DEBUG,TAG(L"GameWindowsPostion"),L"resizeEvent X:%d,Y:%d",point.x(), point.y());
}
QT 控件基础
最新推荐文章于 2023-04-13 15:56:44 发布