Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML Module not found (QtMultimedia)

QML Module not found (QtMultimedia)

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 2.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bob_harris
    wrote on last edited by
    #1

    I am getting this error while trying to use a Video QML type from QtMultimedia. I have tried everything I can think of.

    I am using Qt 5.12, Qt Creator 4.9.0, C++ 17, and CMake 3.13

    QML file
    Error displayed in Qt Creator

    CMakeLists.txt

    ...
    
    set(CMAKE_CXX_STANDARD 17)
    
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTOUIC ON)
    set(CMAKE_AUTORCC ON)
    set(CMAKE_CXX_STANDARD 17)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
    set(Qt5_DIR "/usr/local/opt/qt/lib/cmake/Qt5")
    
    find_package(Qt5 COMPONENTS Core Quick Widgets Multimedia REQUIRED)
    
    set(SRC_FILES main.cpp backend.h backend.cpp)
    set(QML_FILES qml/BackButton.qml qml/DecodeView.qml qml/EncodeView.qml qml/FileLoader.qml main.qml qml/SubtitleView.qml qml/videoTranscription.qml)
    set(RES_FILES qml.qrc resources/icon.icns resources/logo_transparent.png)
    
    add_executable(${PROJECT_NAME} ${SRC_FILES} ${QML_FILES} ${RES_FILES})
    target_compile_definitions(${PROJECT_NAME} PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
    target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Quick Qt5::Widgets Qt5::Multimedia)
    
    ...
    

    I tried to set the QML_IMPORT_PATH to the location of QtMultimedia but to no avail

    QML_IMPORT_PATH

    set(QML_IMPORT_PATH ${CMAKE_SOURCE_DIR}/qml ${CMAKE_BINARY_DIR}/imports /usr/local/opt/qt/lib/ CACHE STRING "" FORCE)
    
    J.HilkJ 1 Reply Last reply
    0
    • B bob_harris

      I am getting this error while trying to use a Video QML type from QtMultimedia. I have tried everything I can think of.

      I am using Qt 5.12, Qt Creator 4.9.0, C++ 17, and CMake 3.13

      QML file
      Error displayed in Qt Creator

      CMakeLists.txt

      ...
      
      set(CMAKE_CXX_STANDARD 17)
      
      set(CMAKE_INCLUDE_CURRENT_DIR ON)
      set(CMAKE_AUTOMOC ON)
      set(CMAKE_AUTOUIC ON)
      set(CMAKE_AUTORCC ON)
      set(CMAKE_CXX_STANDARD 17)
      set(CMAKE_CXX_STANDARD_REQUIRED ON)
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
      set(Qt5_DIR "/usr/local/opt/qt/lib/cmake/Qt5")
      
      find_package(Qt5 COMPONENTS Core Quick Widgets Multimedia REQUIRED)
      
      set(SRC_FILES main.cpp backend.h backend.cpp)
      set(QML_FILES qml/BackButton.qml qml/DecodeView.qml qml/EncodeView.qml qml/FileLoader.qml main.qml qml/SubtitleView.qml qml/videoTranscription.qml)
      set(RES_FILES qml.qrc resources/icon.icns resources/logo_transparent.png)
      
      add_executable(${PROJECT_NAME} ${SRC_FILES} ${QML_FILES} ${RES_FILES})
      target_compile_definitions(${PROJECT_NAME} PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
      target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Quick Qt5::Widgets Qt5::Multimedia)
      
      ...
      

      I tried to set the QML_IMPORT_PATH to the location of QtMultimedia but to no avail

      QML_IMPORT_PATH

      set(QML_IMPORT_PATH ${CMAKE_SOURCE_DIR}/qml ${CMAKE_BINARY_DIR}/imports /usr/local/opt/qt/lib/ CACHE STRING "" FORCE)
      
      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by J.Hilk
      #2

      Hi @bob_harris
      and welcome.

      I' ve little experience with cmake, so I can't give you a 100% straight answer. But I'm pretty sure what the issue is and how you could fix it. But if no-one else can help you more directly, it should point you in the correct direction.

      QtMultimedia is it's own module. In qmake you would simply write QT += multimedia to link against it.
      cmake has qt5_use_modules(target [LINK_PUBLIC|LINK_PRIVATE] module ... )
      see here for more information
      https://doc.qt.io/qt-5/cmake-manual.html#module-variables


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      1
      • B Offline
        B Offline
        bob_harris
        wrote on last edited by
        #3

        That qt5_use_modules() is fairly confusing. It states the macro is obsolete and target_link_libraries should be used instead.

        Regardless I managed to fix this, QtCreator was defaulting to a version of Qt that CMake wasn't using.

        I changed this by manually adding the location of the Homebrew installed version of Qt to QtCreator.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved