跳到內容

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k 主題 77.4k 貼文
  • javascript type annotations do not work in code-behind .js files

    Unsolved javascript qml type safety
    1
    0 評價
    1 貼文
    465 瀏覽
    尚無回覆
  • MediaPlayer often does not play video

    Unsolved
    5
    0 評價
    5 貼文
    533 瀏覽
    JoeCFDJ
    @Mark81 Multimedia is reworked in Qt 6.2 from the recent talk of Lars Knoll and could have a lot of issues. I would not use it now. I do not use it and still apply gstreamer for playing videos.
  • 0 評價
    6 貼文
    690 瀏覽
    V
    Got it working. Initially tried to inherit QApplication and incorporate the eventFilter and the signal to be sent in there. That didn't work. Then sorted through Grecko's suggestion, which BTW, qmlRegisterSingletonInstance appears nowhere in the link provided, initially trying to make the QApplication object accessible from QML. That didn't work. Finally got it to work by making the custom object containing the eventFilter and signal accessible from QML (you would think that, installEventFilter, would reparent the object, but then again a custom QApplication that incorporated one didn't work either) and that allowed it to work.
  • Communication between Virtual Keyboard and the rest of my QML

    Unsolved
    1
    0 評價
    1 貼文
    200 瀏覽
    尚無回覆
  • Enum/Flags from C++ to QML

    Solved
    8
    0 評價
    8 貼文
    2k 瀏覽
    KroMignonK
    @Mark81 said in Enum/Flags from C++ to QML: But in the links I provided there is no mention of qmlRegisterUncreatableType nor about the needs of import the domain Then you don't have read carefully the documentation. To get access to enum on QML side, you have to register it (cf. Enumeration Type documentation) Providing the Message class has been registered with the QML type system. The given link is Registering C++ Types with the QML Type System There are multiple way to achieve this, depending on Qt Version you are using and build system (qmake or cmake). But the way exposed by @J-Hilk works in every case.
  • Is it possible to define another set of states in the same qml file

    Solved
    3
    0 評價
    3 貼文
    266 瀏覽
    J
    @GrecKo Thanks for helping out
  • 0 評價
    7 貼文
    502 瀏覽
    GrecKoG
    => isn't valid c++ either.
  • QML - Seeking best method to detect user inactivity.

    Solved
    9
    0 評價
    9 貼文
    2k 瀏覽
    GrecKoG
    @VFCraig That was meant as the name of the class you would need to create to watch the events of your application.
  • QT Quick performance with rotation

    Unsolved
    2
    0 評價
    2 貼文
    246 瀏覽
    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 評價
    8 貼文
    640 瀏覽
    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 評價
    6 貼文
    1k 瀏覽
    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 評價
    6 貼文
    1k 瀏覽
    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 評價
    3 貼文
    406 瀏覽
    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 評價
    2 貼文
    460 瀏覽
    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?

    已移動 Solved
    6
    0 評價
    6 貼文
    453 瀏覽
    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 評價
    2 貼文
    608 瀏覽
    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 評價
    2 貼文
    1k 瀏覽
    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 評價
    3 貼文
    348 瀏覽
    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 評價
    3 貼文
    2k 瀏覽
    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 評價
    5 貼文
    1k 瀏覽
    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.