Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k Topics 77.3k Posts
  • 0 Votes
    1 Posts
    121 Views
    No one has replied
  • ListView with Flow layout

    Unsolved qml listview layout 20 May 2025, 01:06
    0 Votes
    3 Posts
    315 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 19 May 2025, 21:02
    0 Votes
    2 Posts
    259 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 16 May 2025, 12:01
    0 Votes
    4 Posts
    339 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
    227 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.
  • 0 Votes
    3 Posts
    235 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 19 May 2025, 04:11
    0 Votes
    3 Posts
    295 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 Quick 3d or Qt 3d?

    Unsolved qml qtquick3d qt3d 17 May 2025, 16:25
    0 Votes
    1 Posts
    141 Views
    No one has replied
  • QtQuick Treeview + PySide6

    Solved 15 May 2025, 19:45
    0 Votes
    5 Posts
    301 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
    96 Views
    No one has replied
  • This topic is deleted!

    Unsolved 14 May 2025, 20:55
    0 Votes
    1 Posts
    11 Views
    No one has replied
  • How are y'all making global variables in QML

    Unsolved 12 May 2025, 14:35
    1 Votes
    6 Posts
    434 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" }
  • Discovered a strange bug in QML

    Unsolved 12 May 2025, 04:47
    0 Votes
    2 Posts
    242 Views
    Please try a more recent Qt version. 5.15 is EOL. I can’t reproduce this on 6.5.
  • Connecting C++ with QML

    Unsolved 4 May 2025, 16:22
    0 Votes
    25 Posts
    2k Views
    That depends on what you specify for your UX. If you don't want to have to use a submit button then mapping each textfield to a c++ property is the more direct way yes. Doing that on editingFinished is a good solution.
  • How to get current theme color ?

    Unsolved theme color qml 4 Mar 2021, 09:58
    1 Votes
    5 Posts
    3k Views
    @SeeLook, is it accessible from outside QML?
  • 0 Votes
    1 Posts
    105 Views
    No one has replied
  • QQuick Designer question

    Unsolved 9 May 2025, 00:13
    0 Votes
    4 Posts
    252 Views
    Sounds correct yes.
  • import qml error:no such directory

    Solved 9 May 2025, 10:49
    0 Votes
    9 Posts
    558 Views
    This import does not import a file, but a directory, which is why the above error is always reported: no such directory I understand a little bit now. The use of qml is like the classes and objects of c++. What are defined in the qml file are types. When using them, they cannot be directly referenced by the type name (unless a singleton object is defined). Instead, an object instance should be created using the type defined in qml, and then this instance object should be referenced. For example: [image: 657e3e2e-02f6-4281-a2e6-b140b5aaa175.png] [image: 2b622949-0b55-46e7-82e9-4037d087037f.png] [image: 9f3149dd-971c-4580-a884-3aaa349f0e46.png]
  • Dialog input form validation

    Unsolved 17 Apr 2025, 06:18
    0 Votes
    2 Posts
    248 Views
    Use client-side validation in QML (e.g., IntValidator, DoubleValidator) for immediate input checks. After that, call a C++ Q_INVOKABLE method to perform server-side validation (e.g., check for unique name/image in the database). Ensure the database check is asynchronous to avoid blocking the UI, and provide feedback if the check fails (e.g., show an error message if the name/image isn't unique). This ensures both local and database validation while maintaining a smooth user experience.
  • Sizing QML Dialog to text

    Unsolved 9 May 2025, 10:32
    0 Votes
    2 Posts
    222 Views
    To address this problem, you can try improving the dynamic sizing logic of the dialog using a more flexible approach that leverages implicit sizes more naturally. Here is an updated version of the dialog component, with improved sizing logic to handle dynamic text wrapping without manually adjusting the size of the dialog: import QtQuick 2.9 import QtQuick.Controls 2.2 Dialog { id: dlg visible: true title: "My Dialog" property var msgText: "" // Initialize msgText to avoid undefined issues property var parentWindow width: Math.min(buttons.implicitWidth * 1.5, parentWindow ? parentWindow.width : 600) height: Math.min(msg.implicitHeight + footer.implicitHeight + 20, parentWindow ? parentWindow.height : 400) x: (parentWindow ? parentWindow.width : 600) / 2 - width / 2 y: (parentWindow ? parentWindow.height : 400) / 2 - height / 2 header: Label { text: dlg.title font.bold: true } Text { id: msg text: msgText || "No message provided." width: dlg.width - 40 // Padding for the dialog's width textFormat: Text.StyledText wrapMode: Text.WordWrap anchors.horizontalCenter: parent.horizontalCenter color: "black" } footer: Item { width: dlg.width height: buttons.implicitHeight Row { id: buttons anchors.horizontalCenter: parent.horizontalCenter padding: 5 spacing: 10 Button { text: "OK" onClicked: dlg.accept() } Button { text: "Cancel" onClicked: dlg.reject() } } } }