0

我有 Debian Bullseye,带有集成显卡的 Intel Celeron J1800。Qt 来自 Debian 版本 5.12.5

试图将屏幕旋转到纵向模式。

QT_QPA_EGLFS_ROTATION=90 /opt/app/bin/app

但是窗口只是调整了大小,放大了大约 120%。

我的代码

#include <QGuiApplication>
#include <QQmlApplicationEngine>

int main(int argc, char *argv[])
{
    qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    QGuiApplication app(argc, argv);
    QQmlApplicationEngine engine;
    engine.addImportPath("qrc:/");
    const QUrl url(QStringLiteral("qrc:/main.qml"));
    QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                     &app, [url](QObject *obj, const QUrl &objUrl) {
        if (!obj && url == objUrl)
            QCoreApplication::exit(-1);
    }, Qt::QueuedConnection);
    engine.load(url);
    return app.exec();
}

和 QML

ApplicationWindow {
    id: window
    visible: true
    flags: Qt.FramelessWindowHint
    StackView { ... }
}

QWebEngineView 和小部件运行良好

4

1 回答 1

0

似乎有效

#include <QApplication>
#include <QQmlApplicationEngine>
#include <QMainWindow>
#include <QVBoxLayout>
#include <QQuickWidget>

int main(int argc, char *argv[])
{
    qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
    QApplication app(argc, argv);
    const QUrl url(QStringLiteral("qrc:/main.qml"));
    QQuickWidget *w = new QQuickWidget;
    w->resize(400,300);
    w->setResizeMode(QQuickWidget::SizeRootObjectToView );
    w->engine()->addImportPath("qrc:/");
    w->setSource(url);

    w->showFullScreen();

    return app.exec();
}

和qml

Rectangle {
    id: window
    visible: true
    StackView { ... }
}
于 2020-05-27T00:02:45.163 回答