Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k Topics 77.3k Posts
  • Network programming with Qt

    Unsolved
    7
    0 Votes
    7 Posts
    756 Views
    GrecKoG
    Networking is such a broad concept that if you don't have a specific use case it's hard to give advices. The client code for a REST API can be very boring. see this code I made a long time ago to display the bike share network of my city as an example : https://github.com/oKcerG/MeetupSFPMMap/blob/master/main.qml the code to fetch the data is barely 10 lines (and simple ones). The model is handled via https://github.com/benlau/qsyncable , don't populate data manually in a for loop like done in the QML book. For more advance use case you would use QNetworkAccessManager in C++, potentially with OAuth and expose a nice API to QML. Or maybe you need to use a third party lib or implement a binary protocol with QTcpSocket. Or maybe something with zmq or protobuf ...
  • Calling C++ method from QML before UI is shown

    Unsolved
    3
    0 Votes
    3 Posts
    305 Views
    J.HilkJ
    @ocgltd Colors is a singleton, so why don't you create a c++ instance/get a reference and call the default color change setter there. After that you load your main.qml. Order of execution is important here.
  • form serial port communication. Send the data from Gui to another board

    Unsolved
    2
    0 Votes
    2 Posts
    242 Views
    jsulmJ
    @kk2507 You should start here: https://doc.qt.io/qt-5/qtserialport-index.html There is also link to examples.
  • 0 Votes
    3 Posts
    291 Views
    KroMignonK
    @kk2507 Your are mixing up several things: error unknown module: do you have installed QSerialPort? By the way how did you install Qt and which version are you using?(not Qt Creator which is only an IDE) If there is no serial port not available in "Tera Term", it is perhaps because your PC does not have any serial port available?
  • "Item could be not created" under Quick

    Unsolved
    1
    0 Votes
    1 Posts
    159 Views
    No one has replied
  • How to use virtualkeyboard in popup

    Unsolved
    1
    1 Votes
    1 Posts
    149 Views
    No one has replied
  • CustomMaterial shader compile error message and log absent

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

    Unsolved
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • Slot Machine in Qt Quick

    Unsolved
    5
    0 Votes
    5 Posts
    2k Views
    ndiasN
    @NullByte : I don't have any example implementing thins. But, with little effort, you can generate a random number and set the currentIndex for every Tumbler component. But I'm not sure how you can increase the speed to have a movement effect when incrementing the currentIndex. he movement effect can also be done by quickly incrementing the currentIndex. import QtQuick import QtQuick.Window import QtQuick.Controls ApplicationWindow { property var numItens: 5 Rectangle { anchors.fill: parent Row { Tumbler { id: tumbler1 model: numItens wrap: true } Tumbler { id: tumbler2 model: numItens wrap: true } Tumbler { id: tumbler3 model: numItens wrap: true } } Timer { id: incTimer1 property var counter: 0 property var frequency: 2 interval: 1000 / frequency repeat: true running: counter != 0 onTriggered: { tumbler1.currentIndex = counter % numItens; counter = counter-1 console.debug(incTimer1.counter + " " + tumbler1.currentIndex) } } MouseArea { id: playArea anchors.fill: parent onPressed: { incTimer1.startIndex = incTimer1.counter incTimer1.counter = 5*incTimer1.frequency + Math.floor(Math.random() * numItens) // 5 seconds + X variable time console.debug(incTimer1.counter) } } } }
  • Is it possible to queue events in QML?

    Solved
    4
    0 Votes
    4 Posts
    554 Views
    GrecKoG
    Or use StackView, push or replace pages onto it and pop them when needed.
  • MacOS: previous border remains when animating in transparent mode

    Unsolved
    1
    0 Votes
    1 Posts
    119 Views
    No one has replied
  • How use QtGraphicalEffects in Qt6

    Solved
    4
    0 Votes
    4 Posts
    2k Views
    MarkkyboyM
    I've only just started using QT6, for me, just adding the import statement was not enough in my case. I had to use the maintenance tool to add the compatibility module. Notably, there is also no shortcut in Start Menu for the maintenance tool, which can be found in the installation folder of Qt itself.
  • QtQuick.Extras is not working using qt 6.1.3 version

    Unsolved
    2
    0 Votes
    2 Posts
    316 Views
    MarkkyboyM
    https://www.qt.io/blog/qt-extras-modules-in-qt-6
  • This topic is deleted!

    Unsolved
    2
    0 Votes
    2 Posts
    28 Views
  • QML - SwipeDelegate

    Unsolved
    1
    0 Votes
    1 Posts
    206 Views
    No one has replied
  • Qtquick\Qml Arc

    Unsolved arc shape canvas beginner help
    4
    0 Votes
    4 Posts
    3k Views
    ndiasN
    Hi @fallouthase, Please find bellow a simple example using PathAngleArc: https://doc.qt.io/qt-6/qml-qtquick-pathanglearc.html import QtQuick.Shapes Shape { width: 200 height: 200 anchors.top: parent.top anchors.left: parent.left // Enable multisampled rendering layer.enabled: true layer.samples: 4 // Outer gray arc: ShapePath { fillColor: "transparent" strokeColor: "gray" strokeWidth: 20 capStyle: ShapePath.RoundCap PathAngleArc { centerX: 100; centerY: 100 radiusX: 100-20/2; radiusY: 100-20/2 startAngle: 135 sweepAngle: 270 } } // Inner blue arc: ShapePath { fillColor: "transparent" strokeColor: "blue" strokeWidth: 20 capStyle: ShapePath.RoundCap PathAngleArc { centerX: 100; centerY: 100 radiusX: 100-20/2; radiusY: 100-20/2 startAngle: 135 sweepAngle: 180 } } } [image: 512e5cf8-7b1e-4b4c-aa93-d98a1b78f9c0.png] You can also use already implemented customizable QML Circular Slider: https://github.com/arunpkqt/CircularSlider Best Regards
  • Passing QByteArray to a callable QJSValue

    Unsolved qjsvalue qbytearray
    3
    0 Votes
    3 Posts
    1k Views
    C
    In the event that anyone else comes across this looking for a solution (like I was), Qt 5 and above can convert QByteArray to a Javascript ArrayBuffer. To do this, use toScriptValue: QJSEngine jsEngine = qjsEngine(this); QJSValueList args; args << title; args << jsEngine->toScriptValue(byteArray); callback.call(args);
  • Can Items be told to subtract rather than add when laying over each other?

    Solved
    2
    0 Votes
    2 Posts
    378 Views
    fcarneyF
    This is kind of a proof of concept. It seems really messy: Rectangle { id: maskrect visible: false width: 256 height: width color: "black" Rectangle { id: maskrectcir anchors.centerIn: parent width: parent.width * 0.9 height: width radius: width color: "white" Rectangle { anchors.centerIn: parent width: parent.width * 0.8 height : width radius: width color: "black" } } } Rectangle { id: rotategradient visible: false width: maskrect.width height: width gradient: Gradient { GradientStop { position: 0.0 color: "white" } GradientStop { position: 1.0 color: "blue" } } } ShaderEffectSource { id: rotategradient_source sourceItem: rotategradient } ShaderEffectSource { id: maskrect_source sourceItem: maskrect } ShaderEffect { anchors.fill: rotategradient visible: true property variant source: rotategradient_source property variant maskSource: maskrect_source fragmentShader: " varying highp vec2 qt_TexCoord0; uniform highp float qt_Opacity; uniform lowp sampler2D source; uniform lowp sampler2D maskSource; void main(void) { gl_FragColor = vec4(texture2D(source, qt_TexCoord0.st).rgb * texture2D(maskSource, qt_TexCoord0.st).r, texture2D(maskSource, qt_TexCoord0.st).r); } " RotationAnimation on rotation { loops: Animation.Infinite from: 0 to: 360 } }
  • Create custom widget for project

    Solved
    1
    0 Votes
    1 Posts
    140 Views
    No one has replied
  • Qt via conan package manager - macOS - "Could not resolve plugin "qtquick2plugin""

    Solved
    2
    0 Votes
    2 Posts
    664 Views
    J
    I got it working : A bit of context : 1.: official qt conan package MUST be consumed using the --generator=virtualenv 2.: this generator generates activate.sh and environment.sh.env 3.: source activate.sh must be called for both the build, and to run the built app So the issue was that I was calling source activate.sh from my build script, so the variables weren't defined any more, when I tried to run my built app (outside of the script). So now I can use this script to run this texteditor example app (/Users/myUser/Qt/Examples/Qt-6.2.1/quickcontrols2/texteditor/) : set -e conan install qtbuildprofiles/6.2.2@qt/everywhere -r qt conan install -u conanfile.txt --profile=macos-universal-clang --build=never --update --generator=virtualenv -r qt source activate.sh mkdir -p build cd build echo "cmake ../ -G Ninja -DCMAKE_BUILD_TYPE=Release" cmake ../ -G Ninja -DCMAKE_BUILD_TYPE=Release VERBOSE=1 cmake --build . --config Release --clean-first cd .. #Run the built app : ./build/texteditor.app/Contents/MacOS/texteditor