Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k Topics 77.4k Posts
  • How change source in Video

    Unsolved
    4
    0 Votes
    4 Posts
    281 Views
    SGaistS
    Is it on auto play ?
  • Periodically update data in QML [Solved?]

    Solved
    4
    0 Votes
    4 Posts
    495 Views
    JoeCFDJ
    @Kuzma30 said in Periodically update data in QML [Solved?]: void setChannelData(QList<double> channelData) { m_channelData = channelData; //set current data value } No timer is needed. void setChannelData(QList<double> channelData) { if (channelData.size() != m_channelData.size() /*or something like contents changed*/ ) { m_channelData = channelData; //set current data value emit channelDataChanged(); //to tell qml things have changed for update } }
  • Laying one item on top of another

    Solved
    7
    0 Votes
    7 Posts
    2k Views
    mzimmersM
    I got this working with anchors and margins: import QtQuick 2.12 Item { id: sliderTile Item { id: sliderItem height: sliderTile.height width: sliderTile.width anchors.top: parent.top anchors.horizontalCenter: parent.horizontalCenter CircularSlider { id: circularSlider width: sliderTile.width * 0.8 height: width } RowLayout { anchors.top: sliderTile.verticalCenter anchors.topMargin: 30 anchors.left: sliderTile.left anchors.leftMargin: (sliderTile.width - sliderProperties.diameter) / 2 Text { text: "some text here" } } } (this code snippet isn't complete; just showing how I got the text into the correct position.) [image: 15e59e81-bb7d-4890-8548-ad4d14058188.PNG] Definitely not the most elegant, but it works. I'll improve upon it down the road. Thanks for all the suggestions...
  • This topic is deleted!

    Unsolved
    3
    0 Votes
    3 Posts
    182 Views
  • Video can play only one video

    Solved
    3
    0 Votes
    3 Posts
    275 Views
    M
    I fix this using this code function playVideo() { videoStep.position = 0 // videoStep.play() videoStep2.position = 0 if (videoStep.visible) { videoStep.visible = false videoStep.stop() videoStep2.visible = true videoStep2.play() } else { videoStep2.visible = false videoStep2.stop() videoStep.visible = true videoStep.play() } }
  • ScatterSeries marker shapes: brushFilename seems to be ignored?

    Unsolved
    7
    1 Votes
    7 Posts
    3k Views
    A
    @peteispo Hi For adding any icons or shapes(as png or svg) you need to create a 'QBrush' in c++ side and pass it to qml. for example: .h side: public slots: QBrush chartBrush() const; .cpp side: QBrush GUI::chartBrush() const { QBrush m_chartBrush; QPixmap texture("/home/allenmvi/Downloads/triangle_PNG112.png"); //or svg file int w = 30; //set width for your shape int h = w; //set height for your shape m_chartBrush.setTexture(texture.scaled(w,h,Qt::KeepAspectRatio)); return m_chartBrush; } in qml side: ScatterSeries{ id:scatterSery axisX: myAxisX axisY: myAxisY markerSize: 30 name:"Scatter" borderColor: "transparent" brush: gui.chartBrush markerShape: ScatterSeries.MarkerShapeRectangle } *Note: the useOpenGL property should be false , if it is true , scatter just read your QBrush color.
  • resolvedUrl is unexpectedly prefixed

    Unsolved
    1
    0 Votes
    1 Posts
    335 Views
    No one has replied
  • QT Application issue for Android

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

    Unsolved
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • How to add C++ QQuickPaintedItem in QML

    Unsolved qt6 qml types qml c++
    4
    0 Votes
    4 Posts
    1k Views
    C
    I am pretty sure you need to register it to the qmlEngine via qmlRegisterType<NotchedRectangle>("My.Items", 1, 0, "NotchedRectangle"); In your main.cpp, then you should be able to use it. (https://www.qt.io/blog/qml-type-registration-in-qt-5.15) In your qml file you can then just type: import My.Items and then you should be able to use NotchedRectangle
  • How can I check window mode

    Solved qml
    5
    0 Votes
    5 Posts
    542 Views
    A
    @JoeCFD said in How can I check window mode: Window.FullScreen Thanks! This works fine) height: (mainWindow.visibility === Window.FullScreen) ? parent.height : mainTitle.titleHeight * 1.5
  • Correct way to do test for null in QML?

    Solved
    6
    0 Votes
    6 Posts
    2k Views
    SPlattenS
    @SPlatten , SOLVED: StaleDataModel.qml: import QtQuick 2.0 import QtQuick.Controls 2.15 import QtQuick.Controls.Styles 1.4 import QtQuick.Layouts 1.3 import QtQuick.Extras 1.4 import QtQuick.Window 2.12 import SimonsCPP 1.0 Item { id: root property var fontPointSize: 16 property string label property string labelColor: "#FF000000" property var percision: 4 property real textWidth: 80 property var value: simonP.value function checkStaleStatus(strToolTip) { if ( typeof strToolTip != "string" ) { simonP.stale() return } rImage.ToolTip.text = strToolTip rImage.visible = (strToolTip.length > 0) if ( rImage.visible === true ) { rText.color = simonP.strStale() } else { rText.color = simonP.strNormal() } } function rad2Deg(rad_) { return rad_ * 180.0 / Math.PI; } function setPrecision (val_, sigDigit_) { var precision = Math.abs (val_) >= 1000 ? sigDigit_ - 4 : Math.abs (val_) >= 100 ? sigDigit_ - 3 : Math.abs (val_) >= 10 ? sigDigit_ - 2 : 2; if (precision < 0) precision = 0; return val_.toFixed (precision); } function setValue(newValue) { simonP.setValue(newValue) rText.text = setPrecision (newValue, percision) } StaleData { id: simonP onValueChanged: { checkStaleStatus(strToolTip) } } Text { id: rText anchors { right: root.right top: root.top } verticalAlignment: Text.AlignTop horizontalAlignment: Text.AlignRight font.pointSize: 16//root.fontPointSize text: { root.value ? String(setPrecision (rad2Deg (root.value), percision)) : "N/A" } width: root.textWidth } Label { id: rLabel text: root.label anchors.top: rText.bottom anchors.right: rText.right verticalAlignment: Text.AlignTop horizontalAlignment: Text.AlignRight font.pointSize: root.fontPointSize color: root.labelColor } Image { id: rImage anchors { right: rLabel.left top: rLabel.top } visible: false source: "/stale.svg" ToolTip.visible: (rImage.visible && ToolTip.text.length) > 0 && ma.containsMouse MouseArea { id: ma anchors.fill: parent hoverEnabled: true onContainsMouseChanged: checkStaleStatus() } } Timer { interval: 250 running: true repeat: true onTriggered: simonP.stale() } } Usage: import QtQuick 2.0 import QtQuick.Controls 2.15 import QtQuick.Controls.Styles 1.4 import QtQuick.Layouts 1.3 import QtQuick.Extras 1.4 import QtQuick.Window 2.12 import SimonsCPP 1.0 Window { id: root visible: true width: 640 height: 480 title: qsTr("Playground / Staging Arena") StaleDataModel { id: hdg label: "HDG" anchors { right: parent.right top: parent.top } fontPointSize: parent.width < 150 ? 30 : 16 textWidth: 256 } Button { id: btnData text: "Click Me..." anchors { left: parent.left top: parent.top } onClicked: { hdg.setValue(parseFloat(hdg.value) + 0.01); } } }
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    55 Views
    No one has replied
  • 'Connections' object does not listen to changes in target?

    Unsolved
    3
    0 Votes
    3 Posts
    280 Views
    dheerendraD
    This should work. It is ok to change the larget. It works in c++. I have not tried with Python.
  • Custom object property

    Unsolved
    2
    0 Votes
    2 Posts
    214 Views
    dheerendraD
    Instead of TabButton.qml try with MyTabButton.qml. TabButton is QML Type.
  • QML: Design studio is very slow to drag and drop components and configuring it ?

    Unsolved
    1
    0 Votes
    1 Posts
    183 Views
    No one has replied
  • SVG zoom in qml

    Unsolved
    1
    0 Votes
    1 Posts
    186 Views
    No one has replied
  • Need advice. Multiple Loader and values from C++

    Unsolved
    4
    0 Votes
    4 Posts
    367 Views
    K
    I made another code refactor. Now it uses QList for stroring values such color, height of bar, status for each of 8 channel of sensor. I use only one sensor with 8 channel now(and emulate it as random() and QTimer) What I get at this moment The height of each bar is changed every second Color changing not working on QML side. On C++ it change status and color when data is changed. I get error during program run qrc:/QML/qml/mainView/hub_wiev.qml:21:13: QML Rectangle: Binding loop detected for property "realValue" Actual code for this error is here https://github.com/Kuzma30/QML/commit/c60a1a7a87090eb2e48cc36a0081953b094c93b1
  • Image movement

    Unsolved
    3
    0 Votes
    3 Posts
    312 Views
    D
    @fcarney Unfortunately, specifying x and y values does not make the png file move or shift it.
  • Assigning QObject pointer works via assignment but not binding

    Unsolved
    4
    0 Votes
    4 Posts
    328 Views
    fcarneyF
    QVariant::fromValue<QObject*>(thing.get()); If your object is QObject based then return QObject. QML can still call slots, properties, and signals on the object just fine.