int width=d->widht(); //屏幕的宽度
int height=d->height(); //屏幕的高度
int width=QApplication::desktop()->width();
int height=QApplication::desktop()->height();
int width=QApplication::desktop()->width();
int height=QApplication::desktop()->height();
setGeometry( (x-width)/2, (y-height)/2, width, height);
或者
move(width/2-100,height/2-20);
本文介绍了如何使用C++和Qt库来获取屏幕尺寸,并将窗口居中显示的方法。通过直接调用QApplication的desktop()函数获取屏幕宽度和高度,然后调整窗口的位置使其处于屏幕中央。
2779

被折叠的 条评论
为什么被折叠?



