简体   繁体   English

Qt5 Android最大化的应用程序

[英]Qt5 Android maximized application

When you create a default QML application with the Qt SDK for Android your application always starts as small window. 当您使用Qt SDK for Android创建默认的QML应用程序时,您的应用程序始终以小窗口启动。 Normally a showExpanded or showFullscreen helps but this results in a black screen. 通常,showExpanded或showFullscreen会有所帮助,但这会导致黑屏。 The only way to work around is to use setGeometry with a fixed size, but this not very useful for supporting the big variety of Android devices. 解决的唯一方法是使用固定大小的setGeometry,但这对于支持各种Android设备不是很有用。 I somewhere found someone mentioning that the geometry is not correctly recognized by QML at startup and needs to be manually updated using the QDesktopWidget. 我在某处发现有人提到该几何图形在启动时未被QML正确识别,需要使用QDesktopWidget进行手动更新。 Here the quote: 这里引用:

Application starts in “window” mode (with top panel) At start Qt components gets wrong screen size After load Qt gets correct screen size but QML not How to get correct screen size: Connect to signal QDesktopWidget::workAreaResized() Send to QML new screen size from QDesktopWidget::screenGeometry() 应用程序以“窗口”模式启动(带顶部面板)在启动时Qt组件的屏幕尺寸错误加载后Qt的屏幕尺寸正确但QML却不正确如何获得正确的屏幕尺寸:连接到信号QDesktopWidget :: workAreaResized()发送给QML new QDesktopWidget :: screenGeometry()的屏幕大小

Has someone aleady experienced similar poblems? 有领导者经历过类似的问题吗? Btw. 顺便说一句。 I use a splashscreen at startup but I had no poblem with the old Necessitas and on other platforms. 我在启动时使用了启动画面,但是在旧的Necessitas和其他平台上却没有问题。

I'm working on qml apps on android devices. 我正在使用android设备上的qml应用程序。

include <QGuiApplication>
include <QtQml/QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QGuiApplication app(argc,argv);
QQmlApplicationEngine engine;
engine.load(QUrl("qrc:///main.qml"));
return app.exec();
}

(this is my main.cpp) and my main.qml is: (这是我的main.cpp),而我的main.qml是:

import QtQuick 2.1
import QtQuick.Controls 1.0

ApplicationWindow {
id: mainWin
visible: true
...
...

with the above code my app fits full screen on android and i can get the screen size with mainWin.width and mainWin.height. 使用上面的代码,我的应用程序可以在android上全屏显示,并且可以通过mainWin.width和mainWin.height获得屏幕尺寸。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM