我如何做以下事情:我想在中央屏幕上显示我的主窗口。
最佳答案
如果使用 QtQuick,可以这样做:
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Window 2.0
ApplicationWindow {
visible: true
width: 320
height: 480
Component.onCompleted: {
// Commenting this to use properties instead of setters
//setX(Screen.width / 2 - width / 2);
//setY(Screen.height / 2 - height / 2);
x = Screen.width / 2 - width / 2
y = Screen.height / 2 - height / 2
}
}
关于c++ - QML - 启动时的主窗口位置(屏幕中心),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8970766/