Qt 5.12.0 QML iOS: QtQuick Dialogs "QtQuick.Dialogs.Private" is not installed
-
I have a cross platform project for Mac, PC, Android and iOS. With Qt 5.12, the following import produces a runtime error on my iOS project.
import QtQuick 2.12 import QtQuick.Dialogs 1.3
I get the following error...
qrc:/MyFile.qml:41 Type FileDialog unavailable
qrc:/qt-project.org/imports/QtQuick/Dialogs/DefaultFileDialog.qml:44 module "QtQuick.Dialogs.Private" is not installedPrevious versions of Qt seem to work fine. Doe anyone know of a work around?
Any help would be most appreciated, thanks!
-
I have a cross platform project for Mac, PC, Android and iOS. With Qt 5.12, the following import produces a runtime error on my iOS project.
import QtQuick 2.12 import QtQuick.Dialogs 1.3
I get the following error...
qrc:/MyFile.qml:41 Type FileDialog unavailable
qrc:/qt-project.org/imports/QtQuick/Dialogs/DefaultFileDialog.qml:44 module "QtQuick.Dialogs.Private" is not installedPrevious versions of Qt seem to work fine. Doe anyone know of a work around?
Any help would be most appreciated, thanks!
@mooglus
sadly, that's due to a inattention that was made for the 5.12 iOS preocmpiled libs, currently (5.12.0) QQuickControls 1, that includes Dialogs, are disabled.You have 3 options,
- use 5.11.3
- wait for 5.12.1 - I reported the issue and was told it will be fixed with the next update - it should be right around the corner
- compile 5.12 form sources with QuickControlls 1 enabled
If you decide on option 3 I'll provide div files from my current build, if you want them.
-
@mooglus
sadly, that's due to a inattention that was made for the 5.12 iOS preocmpiled libs, currently (5.12.0) QQuickControls 1, that includes Dialogs, are disabled.You have 3 options,
- use 5.11.3
- wait for 5.12.1 - I reported the issue and was told it will be fixed with the next update - it should be right around the corner
- compile 5.12 form sources with QuickControlls 1 enabled
If you decide on option 3 I'll provide div files from my current build, if you want them.
Hi @J-Hilk, I think I might need to take you up on this. How do you enable QQuickControls1 for 5.12.3 or 5.13.0 builds?
If you decide on option 3 I'll provide div files from my current build, if you want them.
Everything was working fine for me on 5.13.0 until I added my own static plugin. Now, I'm stuck with the following:
qrc:/qml/media/MediaLibraryForm.qml:154 Type FileDialog unavailable qrc:/qt-project.org/imports/QtQuick/Dialogs/DefaultFileDialog.qml:181 Type SplitView unavailable file::/qt-project.org/imports/QtQuick/Controls/qmldir:-1 module ":.qt-project.imports.QtQuick.Controls" plugin "qtquickcontrolsplugin" not found
-
Hi @J-Hilk, I think I might need to take you up on this. How do you enable QQuickControls1 for 5.12.3 or 5.13.0 builds?
If you decide on option 3 I'll provide div files from my current build, if you want them.
Everything was working fine for me on 5.13.0 until I added my own static plugin. Now, I'm stuck with the following:
qrc:/qml/media/MediaLibraryForm.qml:154 Type FileDialog unavailable qrc:/qt-project.org/imports/QtQuick/Dialogs/DefaultFileDialog.qml:181 Type SplitView unavailable file::/qt-project.org/imports/QtQuick/Controls/qmldir:-1 module ":.qt-project.imports.QtQuick.Controls" plugin "qtquickcontrolsplugin" not found
hi @hendrenja and welcome,
I'll search for them, will take a moment as it's been a while.
However 5.13 is not officially jet released. And as far as I know QuickControls 1 is still not draped from support. So that seems to be an Error in the prerelease precompiled libs.
Chances are high, that its fixed in the official release.
You should at the very least open a bug report on the issue. So that the developers do not forget it ;-) -
Hi @J-Hilk, thank you for the prompt reply.
I can do that!
I'm building from src. I've got two static builds that I'm using to try to discover a valid workaround to this issue -
- 5.12.3
- 5.13.0-Beta1 (This was Working just fine before I added a Third-Party static Library)
-
For others seeking a workaround, I did the following:
- Ditch the use of QML QFileDialog
- QML requests C++ object to open QWidget FileDialog
Required Changes
- Change
QGuiApplication
toQApplication
inmain.cpp
- Provide Auxiliary QWindow in QML:
main.qml
AppWindow { id: window objectName: qsTr("ApplicationWindow") visible: true width: 1024 height: 768 RootView {} Window { id: aux objectName: qsTr("AuxWindow"); visible: false width: window.width height: window.height } }
- Replace FormDialog
mediaSelect
is a C++ QObject exposed usingsetContextProperty
Button { id: pathSelect width: body.width * .25 text: qsTr("Open Browser") onClicked: openFileDialog() Keys.onEnterPressed: openFileDialog() function openFileDialog() { mediaSelect.openFileDialog() } }
- Implement
openFileDialog
slot inmediaSelect
object
void CMediaSelectController::openFileDialog() { QWindow *qmlWindow = m_pEngine->rootObjects()[0]->findChild<QWindow *>( "AuxWindow"); QWindow *window = new QWindow(qmlWindow); QWidget *container = QWidget::createWindowContainer(window); container->setMinimumSize(qmlWindow->size()); container->setAttribute(Qt::WA_DeleteOnClose, false); QWidget *widget = new QWidget(container); widget->setAttribute(Qt::WA_DeleteOnClose, false); QFileDialog *fileDialog = new QFileDialog(widget); QFont font = fileDialog->font(); font.setFamily("Roboto"); container->setFont(font); fileDialog->setFont(font); widget->setFont(font); QStringList fileNames; fileDialog->show(); }
Beware: This is stripped down example code and should not be used in production before verifying you've closed any memory leaks
-
For others seeking a workaround, I did the following:
- Ditch the use of QML QFileDialog
- QML requests C++ object to open QWidget FileDialog
Required Changes
- Change
QGuiApplication
toQApplication
inmain.cpp
- Provide Auxiliary QWindow in QML:
main.qml
AppWindow { id: window objectName: qsTr("ApplicationWindow") visible: true width: 1024 height: 768 RootView {} Window { id: aux objectName: qsTr("AuxWindow"); visible: false width: window.width height: window.height } }
- Replace FormDialog
mediaSelect
is a C++ QObject exposed usingsetContextProperty
Button { id: pathSelect width: body.width * .25 text: qsTr("Open Browser") onClicked: openFileDialog() Keys.onEnterPressed: openFileDialog() function openFileDialog() { mediaSelect.openFileDialog() } }
- Implement
openFileDialog
slot inmediaSelect
object
void CMediaSelectController::openFileDialog() { QWindow *qmlWindow = m_pEngine->rootObjects()[0]->findChild<QWindow *>( "AuxWindow"); QWindow *window = new QWindow(qmlWindow); QWidget *container = QWidget::createWindowContainer(window); container->setMinimumSize(qmlWindow->size()); container->setAttribute(Qt::WA_DeleteOnClose, false); QWidget *widget = new QWidget(container); widget->setAttribute(Qt::WA_DeleteOnClose, false); QFileDialog *fileDialog = new QFileDialog(widget); QFont font = fileDialog->font(); font.setFamily("Roboto"); container->setFont(font); fileDialog->setFont(font); widget->setFont(font); QStringList fileNames; fileDialog->show(); }
Beware: This is stripped down example code and should not be used in production before verifying you've closed any memory leaks
@hendrenja
Great that you could solve it yourself, and thanks for sharing.Like asked, I post the 2 dif files or at least the content, as file uploading is not supported in this forum ;-)
//for QtBase --- a/mkspecs/features/resources.prf +++ b/mkspecs/features/resources.prf @@ -73,17 +73,14 @@ for(resource, RESOURCES) { } !isEmpty(RESOURCES):contains(TEMPLATE, .*lib):plugin:static { - pluginName = $$lower($$replace(_PRO_FILE_, .*/([^/.]+)\\.[^/.]+, \\1)) - - resource_init_function = $${pluginName}_plugin_resource_init + resource_init_function = $$lower($$basename(TARGET))_plugin_resource_init DEFINES += "QT_PLUGIN_RESOURCE_INIT_FUNCTION=$$resource_init_function" - - RESOURCE_INIT_CPP = $$OUT_PWD/$${pluginName}_plugin_resources.cpp + RESOURCE_INIT_CPP = $$OUT_PWD/$$lower($$basename(TARGET))_plugin_resources.cpp GENERATED_SOURCES += $$RESOURCE_INIT_CPP QMAKE_DISTCLEAN += $$RESOURCE_INIT_CPP - !build_pass { + isEmpty(BUILDS)|build_pass { RESOURCE_INIT_CONT = \ "// This file is autogenerated by qmake. It contains a function that" \ "// references all resources the plugin includes and the function is" \
//for qtQuickControlls --- a/src/controls/Styles/styles.pri +++ b/src/controls/Styles/styles.pri @@ -109,5 +109,6 @@ STYLES_QML_FILES += \ $$PWD/Base/images/needle.png AUX_QML_FILES += $$PWD/qmldir +static: QML_FILES += $$AUX_QML_FILES ios:static: include(iOS/iOS.pri) !qtquickcompiler|static: QML_FILES += $$STYLES_QML_FILES --- a/src/controls/plugin.cpp +++ b/src/controls/plugin.cpp @@ -73,10 +73,12 @@ QT_BEGIN_NAMESPACE -static const struct { +struct QmldirStruct { const char *type; int major, minor; -} qmldir [] = { +}; + +static const QmldirStruct qmldir [] = { { "ApplicationWindow", 1, 0 }, { "Button", 1, 0 }, { "Calendar", 1, 2 }, @@ -119,6 +121,43 @@ static const struct { { "Slider", 1, 6 } }; +static const QmldirStruct stylesQmldir [] = { + { "ApplicationWindowStyle", 1, 3 }, + { "ButtonStyle", 1, 0 }, + { "BusyIndicatorStyle", 1, 1 }, + { "CalendarStyle", 1, 1 }, + { "CheckBoxStyle", 1, 0 }, + { "ComboBoxStyle", 1, 0 }, + { "MenuStyle", 1, 2 }, + { "MenuBarStyle", 1, 2 }, + { "ProgressBarStyle", 1, 0 }, + { "RadioButtonStyle", 1, 0 }, + { "ScrollViewStyle", 1, 0 }, + { "SliderStyle", 1, 0 }, + { "SpinBoxStyle", 1, 1 }, + { "SwitchStyle", 1, 1 }, + { "TabViewStyle", 1, 0 }, + { "TableViewStyle", 1, 0 }, + { "TreeViewStyle", 1, 4 }, + { "TextAreaStyle", 1, 1 }, + { "TextFieldStyle", 1, 0 }, + { "ToolBarStyle", 1, 0 }, + { "StatusBarStyle", 1, 0 }, + { "CircularGaugeStyle", 1, 0 }, + { "CircularButtonStyle", 1, 0 }, + { "CircularTickmarkLabelStyle", 1, 0 }, + { "CommonStyleHelper", 1, 0 }, + { "DelayButtonStyle", 1, 0 }, + { "DialStyle", 1, 1 }, + { "GaugeStyle", 1, 0 }, + { "HandleStyle", 1, 0 }, + { "HandleStyleHelper", 1, 0 }, + { "PieMenuStyle", 1, 3 }, + { "StatusIndicatorStyle", 1, 1 }, + { "ToggleButtonStyle", 1, 0 }, + { "TumblerStyle", 1, 2 } +}; + QtQuickControls1Plugin::QtQuickControls1Plugin(QObject *parent) : QQmlExtensionPlugin(parent) { } @@ -172,6 +211,12 @@ void QtQuickControls1Plugin::registerTypes(const char *uri) #ifdef QT_WIDGETS_LIB qmlRegisterType<QQuickStyleItem1>(private_uri, 1, 0, "StyleItem"); #endif + + const char *styles_uri = "QtQuick.Controls.Styles"; + const QString baseStyleLocation = filesLocation + "/Styles/Base"; + for (int i = 0; i < int(sizeof(stylesQmldir)/sizeof(stylesQmldir[0])); i++) + qmlRegisterType(QUrl(baseStyleLocation + "/" + stylesQmldir[i].type + ".qml"), styles_uri, + stylesQmldir[i].major, stylesQmldir[i].minor, stylesQmldir[i].type); } void QtQuickControls1Plugin::initializeEngine(QQmlEngine *engine, const char *uri)
this is for 5.12 and therefore may need to be adjusted for newer versions of Qt