9

I builded static version of the Qt libraries and compile the test application based on QtQuick2ApplicationViewer. When starting it produces an error:

file:///F:/qt_projects/untitled9-build-5_0_0_static-__________________________/qml/untitled9/main.qml:1:1: module "QtQuick" plugin "qtquick2plugin" not found 
     import QtQuick 2.0 
     ^ 
Remove me: fixing toplevel window flags
Unable to find a renderable master window QtQuick2ApplicationViewer(0x28fe38) when trying to render QtQuick2ApplicationViewer(0x28fe38)  ( QRect(8,30 116x0) ). 

how i can add plugin "qtquick2plugin" to my aplication?

animuson
  • 53,861
  • 28
  • 137
  • 147
ctinka
  • 393
  • 1
  • 5
  • 11

2 Answers2

4

I have the same problem. I've sent bugreport to Qt-community:

https://bugreports.qt-project.org/browse/QTBUG-28357

This link contains description and my solution of your problem. Unfortunately it doesn't help me, but really may help in your case or just clear the situation.

Avassen
  • 69
  • 5
1

Qt warns about this on configuring a static build (or at least it does so in recent versions):

Note: Using static linking will disable the use of dynamically loaded plugins. Make sure to import all needed static plugins, or compile needed modules into the library.

And qtquick2plugin is one of those, apparently. Here's also some documentation on the matter.

For CMake, starting with Qt 5.14, there is qt5_import_qml_plugins function (and hopefully qt6_import_qml_plugins in Qt 6 too):

get_target_property(QT_TARGET_TYPE Qt5::Core TYPE)
if(${QT_TARGET_TYPE} STREQUAL "STATIC_LIBRARY")
    find_package(Qt5QmlImportScanner REQUIRED)
    qt5_import_qml_plugins(${CMAKE_PROJECT_NAME})
endif()

For Qt versions older than 5.14 one can use this external module.

retif
  • 1,495
  • 1
  • 22
  • 40
  • 1
    Works for Qt6 with the obvious changes: `Qt6QmlImportScanner`, `qt6_import_qml_plugins`... thanks! – cbuchart Nov 21 '22 at 08:14