跳到內容

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k 主題 77.4k 貼文
  • 0 評價
    12 貼文
    2k 瀏覽
    Pablo J. RoginaP
    @Jimit-Rupani said in I'm trying to call a C++ function from qml to read a csv and enter that data into sql table, but it freezes the UI.: resolved so please don't forget to mark your post as solved!
  • mapboxgl dont work

    Unsolved
    2
    0 評價
    2 貼文
    238 瀏覽
    Pablo J. RoginaP
    @agunggumilang please don't double post.
  • Where to get example of a classic Table in Controls 2 (5.15)

    Unsolved
    1
    1 評價
    1 貼文
    184 瀏覽
    尚無回覆
  • QML Timer not working for every 100ms

    Unsolved
    6
    0 評價
    6 貼文
    1k 瀏覽
    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

    已移動 Unsolved
    3
    0 評價
    3 貼文
    365 瀏覽
    M
    @JonB Right, the post is moved to QML and Qt Quick sub-forum =)
  • 此主題已被刪除!

    Unsolved
    1
    0 評價
    1 貼文
    2 瀏覽
    尚無回覆
  • ListView delegates of different heights overlap

    Solved
    3
    0 評價
    3 貼文
    834 瀏覽
    R
    Thanks a lot! Your soultion wokred perfectly.
  • Position change when parent resizes

    Unsolved
    1
    0 評價
    1 貼文
    121 瀏覽
    尚無回覆
  • 此主題已被刪除!

    Unsolved
    1
    0 評價
    1 貼文
    9 瀏覽
    尚無回覆
  • Get a pointer from QML to a cartography plugin class

    Unsolved
    1
    0 評價
    1 貼文
    123 瀏覽
    尚無回覆
  • iOS App in QML how to navigate backward through StackView via swipe gestures

    Solved
    8
    1 評價
    8 貼文
    3k 瀏覽
    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 評價
    7 貼文
    7k 瀏覽
    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 評價
    9 貼文
    743 瀏覽
    B
    @LeLev @fcarney Thank you! This solves my problem!
  • Unable to load from qrc after "Add new... (QML file)" 🍀

    Solved
    3
    0 評價
    3 貼文
    646 瀏覽
    enjoysmathE
    Thanks @sierdzio that was very helpful! :)
  • Newbie : pass C++ instances to QML

    Solved
    6
    0 評價
    6 貼文
    612 瀏覽
    S
    @Bob64 Perfect !
  • error: /.dll invalid argument. Makefile not recognizing .dll file?

    Unsolved
    2
    0 評價
    2 貼文
    472 瀏覽
    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 評價
    12 貼文
    2k 瀏覽
    ?
    @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 評價
    1 貼文
    228 瀏覽
    尚無回覆
  • 0 評價
    3 貼文
    2k 瀏覽
    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 評價
    2 貼文
    1k 瀏覽
    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.