gpt4 book ai didi

c++ - QML - 启动时的主窗口位置(屏幕中心)

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:52:42 28 4
gpt4 key购买 nike

我如何做以下事情:我想在中央屏幕上显示我的主窗口。

最佳答案

如果使用 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com