[Interest] Using QtQuickControls 2 within a static build of Qt 5.7

Nuno Santos nunosantos at imaginando.pt
Sun Jul 31 13:01:01 CEST 2016


No, I haven’t. I have been digging. This is what I found. qmake is handling correctly the case of a app template, generating the appropriated plugin_import.cpp files. However, if the template is a lib, it is not. This is what happens:

qmlRegisterType was saying that it requires absolute URL's. Therefore, I have added a qDebug() to know what was being passed in a case of a statically linked app. What I found was this as a baseUrl: qrc:/qt-project.org/imports/QtQuick/Controls.2. I have then searched for the source for typeUrl() which is used during the QQuickControls2Plugin initialization to set the selector baseUrl and for the static case that exists there. It was simply returning "qrc". I have changed to "qrc:/qt-project.org/imports/QtQuick/Controls.2". Results: it works now.
QUrl QQuickStylePlugin::typeUrl(const QString &name) const
#ifdef QT_STATIC
    QString url = QLatin1String("qrc:/qt-project.org/imports/QtQuick/Controls.2") + baseUrl().path();
    //QString url = QLatin1String("qrc") + baseUrl().path();
    QString url = baseUrl().toString();
    if (!name.isEmpty())
        url += QLatin1Char('/') + name;
    return QUrl(url);
Obviously, this is an hack. The question is. In the case of app template, in which qmake generates the files and everything is done by Qt. Who fills the baseUrl? Why isn't the baseUrl being filled correctly in the case of a lib? I can live with this hack but I would prefer to use a stock version without hacks. Should I create a bug report regarding the qmake lib template case handling and this detail also?

> On 28 Jul 2016, at 13:01, Mitch Curtis <mitch.curtis at qt.io> wrote:
> Do you have any issues creating a standard Qt Quick Controls 2 application against a static Qt? I just tried with a very basic application and it worked without issues (Ubuntu 16.04, Qt 5.7).
> From: Interest [mailto:interest-bounces+mitch.curtis=qt.io at qt-project.org] On Behalf Of Nuno Santos
> Sent: Wednesday, 27 July 2016 4:26 PM
> To: Qt Project MailingList <interest at qt-project.org>
> Subject: [Interest] Using QtQuickControls 2 within a static build of Qt 5.7
> Hi,
> I’m not being able to use QtQuickControls 2 in a static build of Qt. In order to register the QtQuick stuff within Qt 5.6 I had to manually link with the plugin lib and initialise the plugins manually. I think this was because of a bug: https://bugreports.qt.io/browse/QTBUG-35754 <https://bugreports.qt.io/browse/QTBUG-35754>
> Apparently the bug was fixed and I should be able to use normally however there are no instructions for that so I’m using same registering process I had for QtQuickControls with some nuances and now I have this:
> Q_IMPORT_PLUGIN(QtQuickControls1Plugin)
> Q_IMPORT_PLUGIN(QtQuickControls2Plugin)
> qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuickControls1Plugin().instance())->registerTypes("QtQuick.Controls");
> qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuickControls1Plugin().instance())->registerTypes("QtQuick.Controls.Styles");
> qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuickControls1Plugin().instance())->registerTypes("QtQuick.Controls.Private");
> qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuickControls2Plugin().instance())->registerTypes("QtQuick.Controls”);
> However, it complains about not knowing nothing about, e.g. Slider. It also gives an error: qmlRegisterType requires absolute URLs. I have digged the source down and the qmlRegisterType functions has the following validation:
> if (url.isRelative()) {
>           // User input check must go here, because QQmlPrivate::qmlregister is also used internally for composite types
>           qWarning("qmlRegisterType requires absolute URLs.");
>           return 0;
> }
> So I supposed the types end up not being registered anyway. By the time the plugin is registered, the following url is being passed to the first registration: "qrc/ApplicationWindow.qml”
> What am I missing here?
> Thx!
> Nuno

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160731/bc67c49f/attachment.html>

More information about the Interest mailing list