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

Custom QQuickWindow



  • Hello,

    I'm new in QML. I try to create a custom version of QQuickWindow.
    I'm started by creating the C++ class simply like this:

    class MainWindow : public QQuickWindow
    {
    	Q_OBJECT
    };
    

    Then in the main I,m registering the type and creating the component:

    qmlRegisterType<MainWindow>("hud.gui",1,0,"MainWindow");
    QQmlApplicationEngine engine;
    engine.load(QUrl("qrc:/qml/Application"));
    

    Here is the Application.qml:

    import QtQuick.Window 2.2
    import hud.gui 1.0
    
    MainWindow {
    	x: 100
    	y: 100
    	width: 100
    	height: 100
    	visible: true
    	visibility: Window.FullScreen
    }
    

    I have an error message about visibility property :

    "MainWindow.visibility" is not available in hud.gui 1.0.
    

    I saw that visiblity have a revision number. What i don't understand is why other property works, but this one don't? My first answer is the revision number but how can I can make it work with my own class?

    Thank a lot



  • Ok, I found a solutions in documentation. I just need to register base class version to use for my uri.

    qmlRegisterRevision<QWindow, 1>("hud.gui", 1, 0);
    

    I should register the revision of the property "visibility" to be able to use it in my own QML element.


Log in to reply