Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
19.8k Topics 76.5k Posts
  • 0 Votes
    2 Posts
    60 Views
    No one has replied
  • Why is setPreeditText not directly available in QML?

    Unsolved
    2
    0 Votes
    2 Posts
    67 Views
    U

    I found that the InputContext object in QML does not have a setPreeditText function. This method is only available in the C++ QInputMethodEvent class.
    QML: https://doc.qt.io/qt-5/qml-qtquick-virtualkeyboard-inputcontext.html
    C++: https://doc.qt.io/qt-5/qvirtualkeyboardinputcontext.html

    Below are my remaining questions:

    Is there any official documentation or Qt design guideline that explicitly mentions this limitation? If possible, could you share the recommended way to preedit text in QML?
  • Issues With Customizing ScrollBar

    Solved
    10
    0 Votes
    10 Posts
    2k Views
    R

    Thank you very much. I will try it

  • QML TreeView with custom delegate

    Solved
    6
    0 Votes
    6 Posts
    215 Views
    O

    Hi!

    Thank you for your responses!

    Unfortunately, the documentation for TreeView is not very detailed, and examples are quite scarce. I followed your advice and dug deeper into how the delegate works for TreeView. As a result, I managed to achieve exactly what I needed, as shown in the original screenshot.

    To help others understand this topic more easily, I’ll share my code below.

    Key ideas:

    The entire view layout can be customized using the delegate. There’s no need to come up with complex solutions like DelegateChooser, which I had been trying earlier. You can use the column and row variables to determine which row or column is being processed. As mentioned earlier, to align text, you should use horizontalAlignment. You need to align the row yourself (make indents depending on the nesting). import QtQuick import QtQuick.Controls import Qt5Compat.GraphicalEffects Item { id: root width: 260 height: 700 TreeView { id: treeView anchors.fill: parent anchors.margins: 10 clip: true model: assetModel selectionModel: ItemSelectionModel { model: treeView.model } delegate: Item { implicitWidth: column === 0 ? root.width * 2/3 - padding * 2 : root.width * 1/3 - padding * 2 implicitHeight: label.implicitHeight * 1.5 readonly property real indentation: 20 readonly property real padding: 5 // Assigned to by TreeView: required property TreeView treeView required property bool isTreeNode required property bool expanded required property int hasChildren required property int depth required property int row required property int column required property bool current property Animation indicatorAnimation: NumberAnimation { target: indicator property: "rotation" from: expanded ? 0 : 90 to: expanded ? 90 : 0 duration: 100 easing.type: Easing.OutQuart } TableView.onPooled: indicatorAnimation.complete() TableView.onReused: if (current) indicatorAnimation.start() onExpandedChanged: indicator.rotation = expanded ? 90 : 0 Rectangle { id: background anchors.fill: parent color: row === treeView.currentRow ? "#0085F8" : "transparent" } Label { id: indicator x: padding + (depth * indentation) + 5 anchors.verticalCenter: parent.verticalCenter visible: isTreeNode && hasChildren text: "▶" color: "white" TapHandler { onSingleTapped: { let index = treeView.index(row, column) treeView.selectionModel.setCurrentIndex(index, ItemSelectionModel.NoUpdate) treeView.toggleExpanded(row) } } } Image { id: image x: (isTreeNode ? (depth + 1) * indentation : 0) anchors.verticalCenter: parent.verticalCenter width: 13 height: 13 source: hasChildren ? "../../images/svg-folder.svg" : "../../images/svg-file.svg" visible: column === 0 ? true : false ColorOverlay { source: image anchors.fill: image color: "white" } } Label { id: label x: image.x + image.width + 5 anchors.verticalCenter: parent.verticalCenter width: parent.width - padding - x clip: true text: model.display color: column === 0 ? "white" : "#ABABAB" font.pixelSize: column === 0 ? 14 : 10 horizontalAlignment: isTreeNode ? Text.AlignLeft : Text.AlignRight rightPadding: 10 font.family: "Roboto Medium" } } MouseArea { id: menuMouseArea anchors.fill: parent acceptedButtons: Qt.RightButton Connections { target: menuMouseArea onClicked: { menu.open() menu.x = menuMouseArea.mouseX menu.y = menuMouseArea.mouseY } } } } Menu { id: menu width: 150 leftPadding: 5 font.family: "Roboto Medium" palette.window: "#1f1f1f" palette.text: "white" palette.windowText: "white" palette.light: "#898989" MenuItem { text: "Rename" icon.source: "../../images/svg-edit.svg" icon.width: 14 icon.height: 14 } MenuItem { text: "Delete" icon.source: "../../images/svg-trash.svg" icon.width: 14 icon.height: 14 } } }

    Now it looks like this:
    2025-01-21_16-47-47.png

    Thank you all!

  • Is it possible to use Qt Quick modules without QML?

    Unsolved
    16
    1 Votes
    16 Posts
    932 Views
    B

    @drwho-0 said in Is it possible to use Qt Quick modules without QML?:

    quick widget substantiation

    I'm curious about this - what does this mean?

  • 0 Votes
    2 Posts
    64 Views
    T

    I've managed to get to the bottom of this. We have extended the qml Text item with our own type and use it for building menus, labelling buttons and other widgets. It turns out this extended Text item has a ToolTip added in by us ... this must be a big no-no, because thanks to the heavy use of this Text item we instance 1500 text items and therefor 1500 of the ToolTips .... it's those tool tips that are registering somewhere in the QAccessible system (I think because they inherit PopUp, and I think on Windows a PopUp is a Window which make themselves known to QAccessible). This is killing the performance in that setActive method, I suppose 1500 hidden windows is probably a bit excessive!

    (I realise I contradicted myself in the OP about the number of Text items, it turns out I wasn't counting them correctly in the first place.)

  • 0 Votes
    3 Posts
    73 Views
    napajejenunedk0N

    Qt 6.5.3.16
    Windows 11 Enterprise 23H2 22631.4602
    JAWS 2025.2412.50

  • 0 Votes
    2 Posts
    85 Views
    SGaistS

    Hi and welcome to devnet,

    What exactly are you expecting from people here ?

    On a side note, please using coding tags (using for example de </> button) to make your code readable.

  • 0 Votes
    3 Posts
    657 Views
    P

    For anyone coming across this thread, the answer is...

    tl;dr: You need to add the runFullTrust capability.

    With Qt 5, there was support for UWP apps. This made it possible for Windows apps to be delivered through the Microsoft Store. (This is how my app was built and delivered.)

    Then Microsoft opened up the Microsoft Store for Win32 apps too; i.e. standard desktop apps. As a developer you have a choice of either packaging your own installer and delivering that through the Microsoft Store, or just your app, letting Microsoft Store handle installation. The latter option behaves more like the handling of a UWP app and Microsoft handles the code-signing certificate for you.

    As a consequence, Qt decided to drop support for UWP as of Qt 6. This was done with no public notification to the Qt community 🤬, with just a message on the Qt development mailing list. I eventually found this out via a convoluted bug report.

    What Qt themselves did not realise is that if you submit a Win32 app via the Microsoft Store, because it is a desktop app and does not sit nicely in a sandbox like a UWP app, you need to add the runFullTrust capability. If you don't do this, you get the weird behaviour of the application window opening in a separate window described above.

    However be aware that when you add runFullTrust Microsoft will require you to justify why your app needs access to the whole Windows system. I was able to pass certification with a message along the lines of "My app is built with the Qt framework that only generates Win32 apps. My app does not operate outside the sandbox and behaves nicely."

    One more gotcha if you're going this route. The path QStandardPaths::AppDataLocation was different for UWP apps than Win32 apps. The following only applies if you had a UWP app in Qt 5 and stored data there as the path will be wrong for your Win32 app in Qt 6. To fix this, I use the following: https://gist.github.com/paulmasri/75dcd3386a4e8eaf705058240ef547d1

  • Question about Component.onCompleted: signal handler

    Unsolved
    2
    0 Votes
    2 Posts
    83 Views
    BondrusiekB

    Component is a special type in the QtQml module that acts as a blueprint for creating objects in QML. Every QML object is implicitly part of a Component, even if you don't explicitly wrap it in a Component block. For example:

    import QtQuick Item { Component.onCompleted: { console.log("Hello World") } }

    Internally, QML treats this as if it is wrapped in a Component:

    import QtQuick Component { Item { Component.onCompleted: { console.log("Hello World") } } }

    You can analyze QQuickItem class and you will see that it inherits from QObject and QQmlParserStatus, hence it is possible to call Component.onCompleted() in Item objects.

  • Get properties list from Item

    Solved
    2
    1 Votes
    2 Posts
    98 Views
    BondrusiekB

    I found a solution:

    onClicked: { Object.keys(rectangle).forEach((key) => { if (rectangle.hasOwnProperty(key) && typeof rectangle[key] !== "function") { console.log(key + ": " + rectangle[key]) } }) }
  • Create 2 gst-pipeline on qml

    Unsolved
    1
    0 Votes
    1 Posts
    49 Views
    No one has replied
  • Speech to text conversation

    Unsolved
    5
    0 Votes
    5 Posts
    140 Views
    SGaistS

    @JoeCFD hence my remark about the wip branch named wip/speech-recognition.

  • Unable to assing [undefined] to QString

    Solved
    3
    0 Votes
    3 Posts
    118 Views
    R

    Amazing thank you very much ^^

  • ListView as initial item of StackView (scrolling)

    Unsolved
    1
    0 Votes
    1 Posts
    48 Views
    No one has replied
  • Synchroniziny Animations

    Unsolved
    1
    0 Votes
    1 Posts
    44 Views
    No one has replied
  • QtQuick3D rendering issue

    Solved
    5
    0 Votes
    5 Posts
    244 Views
    J

    It's probably not supported on WebGL since it requires MRT and per rendertarget blending.

  • Getting storage details of disks in a system

    Unsolved
    2
    0 Votes
    2 Posts
    70 Views
    jsulmJ

    @Anjali_AR And what is your exact question?
    And please post code as text, not pictures.

  • 0 Votes
    2 Posts
    64 Views
    GrecKoG

    Because context properties are more ambiguous and have a less performant lookup. A decision was made that when using required properties context properties are disabled to avoid this overhead.

  • Installing a reusable component in Visual Studio?

    Unsolved
    1
    0 Votes
    1 Posts
    51 Views
    No one has replied