Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k Topics 77.4k Posts
  • QML Timer not working for every 100ms

    Unsolved
    6
    0 Votes
    6 Posts
    1k Views
    jsulmJ
    @Mamatha Can't the backend emit signals every 100ms to let the UI know that it should update?
  • Custom column order in tree view

    Moved Unsolved
    3
    0 Votes
    3 Posts
    365 Views
    M
    @JonB Right, the post is moved to QML and Qt Quick sub-forum =)
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    2 Views
    No one has replied
  • ListView delegates of different heights overlap

    Solved
    3
    0 Votes
    3 Posts
    834 Views
    R
    Thanks a lot! Your soultion wokred perfectly.
  • Position change when parent resizes

    Unsolved
    1
    0 Votes
    1 Posts
    121 Views
    No one has replied
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    9 Views
    No one has replied
  • Get a pointer from QML to a cartography plugin class

    Unsolved
    1
    0 Votes
    1 Posts
    123 Views
    No one has replied
  • iOS App in QML how to navigate backward through StackView via swipe gestures

    Solved
    8
    1 Votes
    8 Posts
    3k Views
    alex_spataruA
    Sorry for replying to a topic so old, however, I needed to implement this behavior and made some modifications to the code in this forum. To help someone avoid loosing time, I'll post my modifications. Summary of modifications: Created separate QML item to implement swipe gesture (only enabled on iOS) Played with the "mouse.accepted" assignments to get same behavior without drastically affecting full-page Flickable-based items Instead of filling the whole stack view, we create the object after the rest of the UI items, and anchor it to the left part of the screen. We set a relatively small width to avoid issues with Flickables, ListViews, GridViews, etc. First, I created a new QML file named BackGestureDetector.qml, with the following code: import QtQuick 2.12 MouseArea { width: 32 hoverEnabled: true scrollGestureEnabled: false propagateComposedEvents: true enabled: Qt.platform.os === "ios" signal backGestureDetected() property int xPrev: 0 property int xStart: 0 property real velocity: 0.0 property bool tracing: false property bool allowedToWork: false onPressed: { if (allowedToWork) { xStart = mouse.x xPrev = mouse.x velocity = 0 tracing = true mouse.accepted = true } else mouse.accepted = false } onPositionChanged: { if (!tracing) { mouse.accepted = false return } var currVel = (mouse.x - xPrev) velocity = (velocity + currVel)/2.0 xPrev = mouse.x mouse.accepted = false } onReleased: { if (!tracing) { mouse.accepted = false return } tracing = false if (velocity > 15 && mouse.x > parent.width * 0.2) backGestureDetected() mouse.accepted = false } } Finally, I integrate it to the UI as follows: import QtQuick 2.12 import QtQuick.Window 2.12 import QtQuick.Controls 2.12 ApplicationWindow { id: app // // Set window geometry // width: 800 height: 600 visible: true title: qsTr("Swipe gestures example") // // Page display // StackView { id: stackView focus: true initialItem: page1 anchors.fill: parent Page { id: page1 visible: false width: parent.width height: parent.height Button { text: qsTr("Go to page 2") anchors.centerIn: parent onClicked: stackView.push(page2) } } Page { id: page2 visible: false width: parent.width height: parent.height Label { text: qsTr("Page 2") anchors.centerIn: parent } } } // // Swipe back to navigate // BackGestureDetector { allowedToWork: stackView.depth > 1 onBackGestureDetected: stackView.pop() anchors { top: parent.top left: parent.left bottom: parent.bottom } } } Any comments are welcome, hope everyone is safe regarding the pandemic.
  • Connect QML signal to C++11 lambda slot (Qt 5)

    7
    0 Votes
    7 Posts
    7k Views
    fcarneyF
    Use the Connections object to connect to a signal on a known C++ object (setContextProperty or similar). Have that signal be connected to your lambda in C++. Edit: You don't need the Connections object. class SignalHolder : public QObject { Q_OBJECT public: SignalHolder(){} signals: void relaySignal(QString msg); }; ... QQmlApplicationEngine engine; SignalHolder sh; sh.connect(&sh, &SignalHolder::relaySignal, [](QString msg){ qDebug() << "relay message:" << msg; }); auto context = engine.rootContext(); context->setContextProperty("signalholder", &sh); In QML: Item { id: qmlsignalholder signal relayMessage(string message) Component.onCompleted: { relayMessage.connect(signalholder.relaySignal) relayMessage("Hello Signal") } }
  • Default image from QRC resource, but customized image from filesystem?

    Solved
    9
    0 Votes
    9 Posts
    743 Views
    B
    @LeLev @fcarney Thank you! This solves my problem!
  • Unable to load from qrc after "Add new... (QML file)" 🍀

    Solved
    3
    0 Votes
    3 Posts
    646 Views
    enjoysmathE
    Thanks @sierdzio that was very helpful! :)
  • Newbie : pass C++ instances to QML

    Solved
    6
    0 Votes
    6 Posts
    612 Views
    S
    @Bob64 Perfect !
  • error: /.dll invalid argument. Makefile not recognizing .dll file?

    Unsolved
    2
    0 Votes
    2 Posts
    472 Views
    jsulmJ
    @CaptainJuice On Windows you link against *.lib files not *.dll, see https://doc.qt.io/qtcreator/creator-project-qmake-libraries.html You should have Fraction.lib, use that to build, at runtime Fraction.dll is then used.
  • ListView QML Component: Cannot create delegate

    Unsolved
    12
    0 Votes
    12 Posts
    2k Views
    ?
    @sierdzio I solved the problem. The problem was solved when I performed my operations using WorkerScript. Thanks @sierdzio the code you wrote gave an idea and helped me solve my problem In this way, my application data is displayed in an accurate and practical way. But I keep getting the problem with my first post. I think there is a problem with the delegates, because of the wrong positioning or a limit problem. I'm working on it WorkerScript { id: fixtureThread source: "qrc:/fixtureThread.js" onMessage: { fixtureData = messageObject.data dataModel.clear() for(let i = 0; i < dataModel.count; i++) { dataModel.remove(i, 1) } for(let k = 0; k < fixtureData.length; k++) { dataModel.append(fixtureData[k]) } fixtureList.forceLayout() control.running = false fixtureList.visible = true } } WorkerScript.onMessage = function(message) { .... WorkerScript.sendMessage({ 'data': tmpData.data }) .... }
  • Virtual Keyboard change font

    Unsolved
    1
    0 Votes
    1 Posts
    228 Views
    No one has replied
  • 0 Votes
    3 Posts
    2k Views
    mbruelM
    The issue comes from the fact I'm updating the data from a ConnectionWorker Thread instead of the GUI one... I've opened another thread more general to see how I could fix that.
  • QT code to send data on Postman http Post request.

    Unsolved
    2
    0 Votes
    2 Posts
    1k Views
    sierdzioS
    You can send and receive REST requests using QNetworkAccessManager. You can create and parse JSON documents using QJsonDocument, QJsonObject and QJsonArray classes. If you need something a bit more high-level, you can take a look at MRestApi.
  • Disable/Hide/Remove 'QML Connections' runtime warning

    Solved
    3
    0 Votes
    3 Posts
    2k Views
    Aleksey_KA
    @aran said in Disable/Hide/Remove 'QML Connections' runtime warning: Oh, nevermind, should have done a better job searching this forum, it already was answered here before: Where is the link where it was answered? How to disable only 1 category?
  • Custom style isn't applied

    Unsolved qml qtcreator styling custom style
    1
    0 Votes
    1 Posts
    556 Views
    No one has replied
  • QVideoFrame::Format_Y16

    Unsolved
    4
    0 Votes
    4 Posts
    451 Views
    SGaistS
    The QtMultimedia sources is the starting point.