Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Custom full-screen QDialog with QQuickWidget inside, the latter won't scale properly (Android)



  • Description: The aim is to show a custom dialog-box (no borders, no default buttons, content is to be provided by QML), transparency is desired and the dialog box with the embedded QML should show full-screen. The content of the QML rendered within the dialog-box should scale properly to full-screen.

    Implementation (constructor) of a custom Dialog:

    CIdentityBox::CIdentityBox(QWidget *parent): QDialog(parent)
    {
       setAttribute(Qt::WA_TranslucentBackground);
           QQuickWidget* content = new QQuickWidget();
           content->setParent(this);
            content->rootContext()->setContextProperty(QStringLiteral("applicationData"), this);
             content->setResizeMode(QQuickWidget::SizeRootObjectToView);
            content->setSource(QStringLiteral("qrc:/dialog.qml"));
           content->setClearColor(Qt::transparent);
    
    }
    

    The QML file:

    Item {
        //objectName: "topographySeries"
        height: 750
       width:360
    //other stuff
    }
    

    I show the dialog with a call to dialog->showFullScreen();

    Current State: Now, the dialog shows, the space occupied by the QDialog is full-screen indeed (if I turn off WA_TranslucentBackground the entire screen is white), BUT the inner(?) QQuickWidget is not scaled at all. Even though SizeRootObjectToView is set.

    Ideas? In QML if I change the default(?) height/width or set anchors.fill = parent, the QQuickWidget is not rendered at all. Ideas?

    Any hacky way to accomplish this? Does not need to be clean one, I've spent too much time on this already.

    Question is: how to make the inner QQuickWidget occupy the entire space of QDialog. Other approaches are welcome.


Log in to reply