Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You cannot use <code>QQuickView</code> with an <code>ApplicationWindow</code> class. Not only is your destructor not called, your constructor isn't <em>either</em>, because the loading doesn't ever succeed.</p> <p>The code below works fine under Qt 5.1.1. Tested on both OS X 10.8 and Windows 7.</p> <p><strong>main.qrc</strong></p> <pre><code>&lt;RCC&gt; &lt;qresource prefix="/"&gt; &lt;file&gt;main.qml&lt;/file&gt; &lt;/qresource&gt; &lt;/RCC&gt; </code></pre> <p><strong>main.pro</strong></p> <pre><code>QT += core gui qml quick TARGET = qml-appwin-end-18597527 TEMPLATE = app SOURCES += main.cpp OTHER_FILES += main.qml RESOURCES += main.qrc </code></pre> <p><strong>main.cpp</strong></p> <pre><code>#include &lt;QGuiApplication&gt; #include &lt;QQmlApplicationEngine&gt; #include &lt;QSettings&gt; #include &lt;QQuickWindow&gt; #include &lt;QtQml&gt; #include &lt;QDebug&gt; class Settings : public QSettings { Q_OBJECT public: Settings() : QSettings("Marcin Mielniczuk", "BigText") {} ~Settings() { qDebug() &lt;&lt; "Dying"; } }; int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine; qmlRegisterType&lt;Settings&gt;("BigText", 1, 0, "Settings"); engine.load(QUrl("qrc:/main.qml")); QObject *topLevel = engine.rootObjects().value(0); QQuickWindow *window = qobject_cast&lt;QQuickWindow *&gt;(topLevel); window-&gt;show(); return app.exec(); } #include "main.moc" </code></pre> <p><strong>main.qml</strong></p> <pre><code>import QtQuick 2.0 import QtQuick.Controls 1.0 import BigText 1.0 ApplicationWindow { width: 300; height: 300 Settings {id: settings} } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload