qt - 在全屏和窗口模式之间切换
问题描述
我的问题与这个有关:Full-screen desktop application with QML
这是我的 MWE:
import QtQuick 2.11
import QtQuick.Window 2.2
import QtQuick.Controls 2.2
Window
{
property string windowFull: "FullScreen";
property string windowWindowed: "Windowed";
width: 400
height: 400
visible: true
title: "Example"
visibility: windowFull;
id: theWindow;
Button
{
onClicked:
{
if (theWindow.visibility === windowWindowed)
theWindow.visibility = windowFull;
else
theWindow.visibility = windowWindowed;
}
}
}
在此示例中,我尝试在单击按钮时从窗口模式切换到全屏模式,反之亦然。我的问题是从窗口模式进入全屏工作,但从全屏到窗口不工作。为了从全屏进入窗口模式,是否有任何特殊要求?
解决方案
在 Ubuntu 上,使用Window.AutomaticVisibility
将窗口可见性设置为窗口(默认窗口)。请检查QML 窗口示例。
import QtQuick 2.11
import QtQuick.Window 2.2
import QtQuick.Controls 2.2
Window
{
property string windowFull: "FullScreen";
property string windowWindowed: "Windowed";
width: 400
height: 400
visible: true
title: "Example"
visibility: windowFull;
id: theWindow;
Button
{
onClicked:
{
if (theWindow.visibility === Window.FullScreen)
theWindow.visibility = Window.AutomaticVisibility;
else
theWindow.visibility = Window.FullScreen;
}
}
}
推荐阅读
- javascript - CSV not returning rows
- reactjs - 返回结果没有标识时出错
- python - 如何参数化 pytest 的函数,以便从文本文件中获取参数和测试名称
- java - WSO2 和创建可部署存档从 Maven 获取旧属性
- android - 从数据库设置微调器初始值,微调器项目来自android中的数组字符串
- python - Keras ValueError:输入 0 与 flatten_11 层不兼容
- java - 防止 Android 在多任务视图上显示敏感信息
- laravel-5 - 共享主机上的 Laravel 未使用 CKEditor 的 Unisharp 文件管理器上传图像
- google-contacts-api - 使用 Google-contacts API 创建的联系人未从 Android 设备同步
- c# - 如何为不重复的年度创建 Linq 查询仅返回年度总和?