我的应用程序是全屏的。
当使用QtQuick2时,如何避免在iOS设备上放置带有凹槽的项?
我的应用程序运行在有和没有凹槽的设备上,我试图避免在没有凹槽的设备顶部和底部出现空白区域。
发布于 2019-04-08 13:47:28
我联系了QT支持并得到了真正的答案。在全屏运行应用程序时,使用安全区域边距。
#include <qpa/qplatformwindow.h>
void MainWindowBackend::setWindow(QObject *window)
{
QWindow *qwin = qobject_cast<QWindow*>(window);
QPlatformWindow *pWin = qwin->handle();
QMargins safeArea = pWin->safeAreaMargins();
}还添加
QT += gui-private在你的专业档案里
发布于 2019-04-05 17:57:00
如果其他人也有同样的问题。
首先,让你的应用程序在iOS上没有全屏,这将在你的应用程序的顶部和底部创建黑色区域。
您可以更改黑色区域的颜色以更好地适应您的应用程序:
notch.h
#ifndef NOTCH_H
#define NOTCH_H
#include <QObject>
class Notch : public QObject{
Q_OBJECT
public:
Notch();
};
#endifnotch.mm
#include <UIKit/UIKit.h>
#include "notch.h"
Notch::Notch()
{
//Top
UIView *statusBar = (UIView *)[[UIApplication sharedApplication] valueForKey:@"statusBar"];
statusBar.backgroundColor = [UIColor colorWithRed:0.09 green:0.14 blue:0.19 alpha:1.0];
//Bottom
UIApplication *app = [UIApplication sharedApplication];
app.windows.firstObject.backgroundColor = [UIColor whiteColor];
}现在只需在main.cpp文件中调用Notch();
https://stackoverflow.com/questions/55537619
复制相似问题