Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k Topics 77.1k Posts
  • 0 Votes
    2 Posts
    2k Views
    I have the same problem in 2025. Did you find a solution?
  • 0 Votes
    8 Posts
    190 Views
    @JKSH removing RESOURCE_PREFIX / is no problem, works still fine, thanks. :D However do you mean changing all mymodules mentions to mymodulesplugin or only this one? Cause when changing only one it gives me errors. Here are all my files: [image: ea7f99db-02e4-4cd6-b307-2682ee306007.png] CMakeLists.txt inside mymodules subfolder: cmake_minimum_required(VERSION 3.16) project(mymodules VERSION 1.0 LANGUAGES CXX) find_package(Qt6 REQUIRED COMPONENTS Quick) qt_add_library(mymodules STATIC) # <--- STATIC instead of SHARED/PLUGIN qt_add_qml_module(mymodules URI mymodules # entspricht: import mymodules 1.0 VERSION 1.0 QML_FILES Buttons.qml Qmld.qml XP3DDebugViewer.qml SOURCES Myhelper.hpp Myhelper.cpp ) set_target_properties(mymodules PROPERTIES QT_QML_MODULE TRUE ) target_link_libraries(mymodules PRIVATE Qt6::Quick ) Main CMakeLists.txt: cmake_minimum_required(VERSION 3.16) project(QmlLibraryTest VERSION 0.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) find_package(Qt6 REQUIRED COMPONENTS Quick) qt_standard_project_setup(REQUIRES 6.8) qt_add_executable(appQmlLibraryTest main.cpp ) qt_add_qml_module(appQmlLibraryTest URI QmlLibraryTest VERSION 1.0 QML_FILES Main.qml ) # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. # If you are developing for iOS or macOS you should consider setting an # explicit, fixed bundle identifier manually though. set_target_properties(appQmlLibraryTest PROPERTIES # MACOSX_BUNDLE_GUI_IDENTIFIER com.example.appQmlLibraryTest MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} MACOSX_BUNDLE TRUE WIN32_EXECUTABLE TRUE ) # Baue und installiere das Sub‑Modul mit add_subdirectory(mymodules) target_link_libraries(appQmlLibraryTest PRIVATE Qt6::Quick mymodules # <-- statische lib (ohne "plugin") ) include(GNUInstallDirs) install(TARGETS appQmlLibraryTest BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) In Main.qml i import it as: import mymodules 1.0 Qmld { id: krass anchors.fill: parent } Buttons { id: neubtn anchors.bottom: parent.bottom anchors.right: parent.right }
  • Correct way to make QML modules Qt 6.5-6.9

    Unsolved 19 days ago
    0 Votes
    16 Posts
    340 Views
    @JKSH Thanks for answer, QT_QML_OUTPUT_DIRECTORY on top of qt_add_qml_module() really helped and now everything is working fine! @JKSH said in Correct way to make QML modules Qt 6.5-6.9: To use MButton, you need import UI.Components and not import UI.Assets my bad, my eyes were busy with the warnings and I didn't notice :) @JKSH said in Correct way to make QML modules Qt 6.5-6.9: QML_IMPORT_PATH is used by Qt Creator's old code model. It is not used by the new QML Language Server (qmlls). Likewise, QT_QML_GENERATE_QMLLS_INI is only used by qmlls and not the old code model. By default, you'll be using qmlls if: You're running the latest Qt Creator, AND You're using Qt 6.8 or newer for your project So can i use modules with "old" approach if I have Qt 6.5 and 16 creator? What is the difference when using without QMLLS on Qt 6.5? or is it the same, just don't write QT_QML_GENERATE_QMLLS_INI and add QML_IMPORT_PATH? @JKSH said in Correct way to make QML modules Qt 6.5-6.9: Note: There is no point linking your executable to Assets, Components, and Pages libraries because your executable does not use any C++ symbols from those libraries and if I use C++ in this module, as I understand it, I will just need to link these modules, and the behavior will remain the same?
  • Prevent resize and flicker when showing a window

    Unsolved 5 days ago
    0 Votes
    4 Posts
    81 Views
    The layout only finalizes after the window is part of the scene graph, so showing it immediately causes visible resizing. Instead, set the QQuickView visibility to hidden or move it off-screen first. After creating and adding the QML component, wait for implicitWidth and implicitHeight to be valid (you can use a short QTimer::singleShot ). Then resize the window and show it—this way, the user only sees the final, correct size.
  • Table selection not working

    Unsolved 5 days ago
    0 Votes
    3 Posts
    67 Views
    @jhayar Thank you, that makes sense. But ItemSelectionModel.Select doesn't work either. So I'm not sure what you are supposed to use there. Update: I figured out what the problem was. The standard practice is to use a bitwise or with SelectionModel objects. Also I got the index line wrong from the start. The below works: tableView.selectionModel.select( tableView.model.index(row, 0), ItemSelectionModel.Toggle | ItemSelectionModel.Rows) And now I have found out that selections made this way don't survive the filter proxy so I need to do my own logic anyway. Thanks for the learning.
  • QML icon, text and button in listView, look like mosaic on Windows

    Unsolved 5 days ago
    0 Votes
    1 Posts
    28 Views
    No one has replied
  • visibility of elements(rectangle) while using chartview in qml

    Unsolved 5 days ago
    0 Votes
    1 Posts
    19 Views
    No one has replied
  • ListView with Flow layout

    Unsolved qml listview layout 5 days ago
    0 Votes
    3 Posts
    62 Views
    @SuhasKrishanamurthy, thanks for your help, but the GridView component has fixed cell's width and height. Items' height can grow up, but if it will be greater than cell's size, the collision occures. If I adjusted GridView's cell size depending on size of largest item, there were too much free space between small items. The following code lays items out with collision: GridView { id: gridView width: 600 height: 400 cellWidth: 200 cellHeight: 100 flow: GridView.FlowTopToBottom model: ListModel { ListElement { value: "Lorem ipsum dolor sit amet, consectetur adipiscing elit" } ListElement { value: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." } ListElement { value: "Lorem ipsum dolor sit amet" } ListElement { value: "Lorem ipsum dolor sit amet" } ListElement { value: "Lorem ipsum dolor sit amet" } ListElement { value: "Lorem ipsum dolor sit amet" } ListElement { value: "Lorem ipsum dolor sit amet" } ListElement { value: "Lorem ipsum dolor sit amet" } ListElement { value: "Lorem ipsum dolor sit amet" } ListElement { value: "Lorem ipsum dolor sit amet" } ListElement { value: "Lorem ipsum dolor sit amet" } ListElement { value: "Lorem ipsum dolor sit amet" } ListElement { value: "Lorem ipsum dolor sit amet" } ListElement { value: "Lorem ipsum dolor sit amet" } ListElement { value: "Lorem ipsum dolor sit amet" } ListElement { value: "Lorem ipsum dolor sit amet" } } // orientation: Qt.Horizontal // GridView doesn't have this property boundsBehavior: Flickable.StopAtBounds clip: true delegate: Item { width: gridView.cellWidth height: contentItem.implicitHeight required property string value Rectangle { id: contentItem width: parent.width color: "lightgray" implicitHeight: tex.implicitHeight + 20 Text { id: tex text: value wrapMode: Text.WordWrap anchors.margins: 10 anchors.fill: parent } } } } [image: 5511da81-8d79-4306-a3e0-805fb1a8683a.png] The desired behavior is lay items out onto the first column until it has free space and then turn into the next column (see picture in the question). Unfortunately, GridView lays item out strictly as a grid. This is partially implemented with Flow + Repeater layout: [image: 0887646e-c6a2-4106-b30c-ff9f8b07a38f.png]
  • Exclusive menu item check-mark not working

    Moved Unsolved 6 days ago
    0 Votes
    2 Posts
    43 Views
    Use Actions inside the Repeater, associate them with the ActionGroup, and bind them to the MenuItem. Menu { title: "Mouse mode" id: mouseModesMenu Repeater { model: mouseModes Action { id: mouseAction text: modelData checkable: true ActionGroup.group: mouseModeActions onTriggered: { console.log("selected", modelData) topoDataItem.setMouseMode(modelData) } } delegate: MenuItem { action: mouseAction } } } ActionGroup { id: mouseModeActions exclusive: true }
  • Qt3D Extras and Qt3D Core support in Qt 6.7.2 ?

    Unsolved 9 days ago
    0 Votes
    4 Posts
    85 Views
    @IamSumit said in Qt3D Extras and Qt3D Core support in Qt 6.7.2 ?: QQmlApplicationEngine failed to load component qrc:/qt/qml/Test3D/Main.qml:114:9: Qt3DExtras.Camera - Qt3DExtras is neither a type nor a namespace According to the docs, the Camera type is in Qt3D.Render, not Qt3D.Extras: https://doc.qt.io/qt-6/qml-qt3d-render-camera.html In QML, you don't prefix the type with the module/namespace. So write Camera instead of Qt3DRender.Camera (exception: If you apply a Qualifier to the import statement, then you would prefix the type with the Qualifier; see https://doc.qt.io/qt-6/qtqml-syntax-imports.html )
  • 0 Votes
    2 Posts
    40 Views
    I've found a solution. Find the folder with the same name as your Qml module which defined though qt_add_qml_module in the Debug folder ,copy it to the same-level directory as the exe file you want to publish, and then call windeployqyt. Hope this helps save some time for those who encounter this baffling error.
  • Qt 6.9 - maximumFlickVelocity and flickDeceleration not working

    Solved 6 days ago
    0 Votes
    3 Posts
    41 Views
    @jsulm I didn't but I did now and it is indeed a behavior that was changed and there are bugs logged already.
  • Properties not accessible, of a custom QML type

    Solved 6 days ago
    0 Votes
    3 Posts
    63 Views
    Sorry man, my bad. I had a conflicting and similar type somewhere else named CameraDialog in APSS module. I don't know why QML Engine did not prefer the one in the same directory over the other. But it's solved.
  • Qt Multimedia QAbstractVideoFilter Missing in Qt 6.9

    Unsolved 22 days ago
    0 Votes
    8 Posts
    182 Views
    Then you should compare your code to it and adjust it.
  • QT Quick 3d or Qt 3d?

    Unsolved qml qtquick3d qt3d 8 days ago
    0 Votes
    1 Posts
    32 Views
    No one has replied
  • QtQuick Treeview + PySide6

    Solved 10 days ago
    0 Votes
    5 Posts
    74 Views
    @RynoJ Two observations: C# is a lot closer to C++ than to Python, which is a completely different language. QML is a declarative language, and not really a programming language. Quite different from normal procedural programming like C# (or for that matter C++ or Python). It is a totally different paradigm. Depending on what you did in C# about e.g. the UI, using Qt widgets (with either C++ or Python) would likely be a lot closer than anything QML.
  • 0 Votes
    1 Posts
    30 Views
    No one has replied
  • 0 Votes
    3 Posts
    58 Views
    Ooh, don't know how I missed that. So, what should I use?
  • This topic is deleted!

    Unsolved 11 days ago
    0 Votes
    1 Posts
    11 Views
    No one has replied
  • How are y'all making global variables in QML

    Unsolved 13 days ago
    1 Votes
    6 Posts
    161 Views
    A QML singleton file is hardly more complicated and has the benefit of being typed and using a proper module import, making the tooling easy. // Globals.qml pragma singleton import QtQml QtObject { readonly property string defaultUrl: "https://www.qt.io" }