Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k Topics 77.4k Posts
  • QT Quick performance with rotation

    Unsolved
    2
    0 Votes
    2 Posts
    246 Views
    H
    For anyone having a similar problem, consider reading the qml performance article: https://doc.qt.io/qt-5/qtquick-performance.html My problem was having a rectangle as root item for my application. QT repaints the whole scene including the rectangle. I switched my root Item to "Item". Now it's smooth. I am still not quite sure why the problem only occured when the rotation is not equal to 0 or 180.
  • Set dynamic text via function

    Unsolved
    8
    0 Votes
    8 Posts
    639 Views
    M
    @GrecKo Ok, it was kinda connected to my Custom Image Button which ... I think overwrites the clicked function. import QtQuick 2.0 import de.martingebske Rectangle{ id: root height: 200 width: 200 color: "transparent" property string kw: "" property string source: "" property double itemHeight: 200 property double itemWidth: 200 property double textMargin: -70 signal clicked() Image { id: img source: root.source height: root.itemHeight width: root.itemWidth Text{ id: txt color: "white" anchors.bottom: img.bottom anchors.horizontalCenter: img.horizontalCenter anchors.bottomMargin: root.textMargin text: root.kw font.pointSize: 20 font.family: "Helvetica" } MouseArea{ id: ma anchors.fill: img enabled: true onClicked: { if(!hpcManager.chargerIsOccupied()){ root.clicked() img.opacity = 0.2; txt.opacity = 0.6; ma.enabled = false } else console.log("No more parking spaces available!") } } } } When I use regular Buttons instead of my custom buttons it works as intended. Still I don't really get it, why the text doesn't change (because it's absolutely not related to the custom Button) but I think it's something in the MouseArea click event.. just a wild guess...
  • Using C++ Models with Qt Quick Views example

    Unsolved
    6
    0 Votes
    6 Posts
    1k Views
    M
    I'm not sure if this solution is ok, because is quite different from the example but at least it works: main.cpp engine.rootContext()->setContextProperty("modelContent", &flow.modelContent); main.qml PathView { id: view ... model: modelContent
  • "visible" property forced to "false"

    Unsolved
    6
    0 Votes
    6 Posts
    1k Views
    jeremy_kJ
    @naprile said in "visible" property forced to "false": I'm not an expert Qt programmer. Do you think my problem is due to having used one Loader for each page or can be due to another reason? Thanks. It could be. Extra code is extra complexity to understand. Even if simplifying doesn't fix the issue, it should make it easier to spot.
  • ComboBox text reset on model update

    Unsolved
    3
    0 Votes
    3 Posts
    406 Views
    I
    @J-Hilk Thank you for your reply! I can see that this binding adds something to model. But what if I type something in text edit, and in my C++ code the model gets reset. For example, I have TextField in ComboBox TextField { text: root.editText onTextChanged: { updateModel() } void CustomModel::updateModel() { beginResetModel(); endResetModel(); } But whenever it happens, text in text edit gets erased. So for example. I write one letter in text edit, model gets updated, then I type another letter, and the text gets erased. The most interesting thing is that text that I typed gets erased every second attempt to write something. And if there was some text before it remains unchanged, only my input is affected. Any ideas why it happens? Thank you
  • How to reset order of QAbstractListModel

    Unsolved
    2
    0 Votes
    2 Posts
    459 Views
    JonBJ
    @PhiBh Depends what you mean by "a better way" :) I know nothing about QML, but this seems to be a straight Qt model/view question. You can use begin/endMove Rows(). But I would do that if you are moving, say, 1 row around. It can get difficult to calculate if you are, say, sorting the entire list, or don't want to calculate which of many rows have been moved where. Then it is simpler to just call QAbstractItemModel::beginResetModel(), do your complete changes, and endResetModel(). Note that you should then read the referenced documentation, telling you that all views and e.g. flags() are reset. You would want to test this to see what effect it has on your existing views and how they refresh in response.
  • How to receive files dragged into apps from other apps, such as from a browser?

    Moved Solved
    6
    0 Votes
    6 Posts
    453 Views
    S
    @J-Hilk @JonB Thanks.Found that the drag from the browser is a link.
  • How do I change a ComboBox model and remember the previous selection?

    Solved
    2
    0 Votes
    2 Posts
    607 Views
    D
    I'm such an idiot, lol. I got it working properly with: /** * Update the number of days when the month changes. * Keep the current selection if it's still valid. */ function updateDays(index) { let numDays = days(); comboDay.model = numDays; if (index < numDays.length) { comboDay.currentIndex = index; } } ... ComboBox { id: comboMonth model: _bridge.months() currentIndex: now.getMonth() onActivated: (index) => updateDays(index) }
  • How to change label text style dynamically

    Solved
    2
    0 Votes
    2 Posts
    1k Views
    M
    Ok that's kinda weird (but perhaps it's another Qt6 Bug?) I've got a similar approach: It's Text{ id: welcomeText anchors.top: chargingBackground.bottom anchors.horizontalCenter: chargingBackground.horizontalCenter anchors.topMargin: 20 text: qsTr("Please select your charging pod!") property alias infoText: welcomeText.text font.pointSize: 20 font.family: "Helvetica" } function slotSelected(id) { if(!hpcManager.chargerIsOccupied()) { hpcManager.setCurrentCharger(id) t.running = false } else { console.log("No more parking spaces available!"); welcomeText.infoText = "No more parking spaces available!"; } } all in "root" space. It all works fine. The Console logs properly... but the text doesn't change. What am I missing here? I tried to apply the alias at different levels (because I found it written that way in other solutions) but I can't make it work.
  • Multiline alignment with Linebreak

    Solved
    3
    0 Votes
    3 Posts
    348 Views
    M
    @GrecKo Ah, thanks! That's awesome! Yeah, I think wrapping would be a bit cooler when it comes to localization! Thanks a lot!
  • TypeError: Property '...' of object ...(0x55fcc300c0d0) is not a function

    Solved
    3
    0 Votes
    3 Posts
    2k Views
    M
    You, sir, are my rescue! :) Thanks a lot! This saved me a lot of headache.
  • I want to develop an app for win7 with Qt6.2. is it ok?i am a primer...

    Unsolved
    5
    1 Votes
    5 Posts
    1k Views
    JKSHJ
    @hello_JiNan said in I want to develop an app for win7 with Qt6.2. is it ok?i am a primer...: Qt6.2 only make friend with window 10~_~ Because Windows 7 reached end-of-life in January 2020. If you need to support an older OS, then stick with older tools that also support that OS.
  • Queries on Commercial license

    Unsolved
    3
    0 Votes
    3 Posts
    276 Views
    P
    @jsulm - Thank you for clarifying
  • Multiple QML files with main

    Unsolved
    2
    0 Votes
    2 Posts
    635 Views
    F
    Use StackView ,It will be helpful for screen navigation as well.
  • Toggle a crossfade between two (or more images)

    Solved
    3
    0 Votes
    3 Posts
    556 Views
    GrecKoG
    Shameless plug: I've implemented that with an easy to use API here : https://github.com/okcerg/quickbehaviors Here's how you can use it when changing a Image source : import QtQuick 2.15 import QtQuick.Window 2.0 Window { id: root visible: true width: 400 height: 400 property bool toggle: true Image { anchors.centerIn: parent source: root.toggle ? "http://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/60/google/56/white-smiling-face_263a.png" : "http://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/60/google/56/winking-face_1f609.png" opacity: 1 CrossFadeBehavior on source { fadeDuration: 2500 delayWhile: fadeTarget.status === Image.Loading } } Timer { interval: 3000 repeat: true running: true onTriggered: root.toggle = !root.toggle } } Here's a demo video for crossfading an Image https://i.imgur.com/vAvxWsV.gifv Rest of the demo : https://imgur.com/a/7DZOYv5
  • Drawer not rotating with the rest of the scene

    Unsolved
    6
    1 Votes
    6 Posts
    1k Views
    K
    I'm facing the same issue, I have a user-specific browser and the address will appear on swipe from the top edge. But when I rotate the screen, the web engine rotates perfectly but the address bar sticks at the same position in 0 deg or landscape. How to rotate the drawer along with the other components. I'm using Qt 5.15 in which I have to play with QML, instead of windowing rotate of the whole system @dbrown: did you resolve this issue and how, please suggest. @raven-worx: app drawer positioning is also not working. Thanks in advance.
  • Modify Tiles on QML Map with OSM plugin.

    Unsolved
    1
    0 Votes
    1 Posts
    316 Views
    No one has replied
  • How do you call a function in a loader

    Solved
    7
    0 Votes
    7 Posts
    2k Views
    F
    @jeremy_k said in How do you call a function in a loader: thisComboBoxLoader.item That works, thanks, I did not know about the item property, good to know.
  • Display numeric keyboard in Windows Surface

    Unsolved
    1
    0 Votes
    1 Posts
    178 Views
    No one has replied
  • SwipeView and TabBar currentIndex issue when dynamic object creation

    Solved
    3
    0 Votes
    3 Posts
    518 Views
    N
    Hi @ndias , Indeed, using count instead of currentIndex solved my issue. Thanks!