Solved warning with qml
-
I write a connect between a circular gauge created with qml and a slider, and the signal is sent by the slider..it works but I have these warnings:
qrc:/Slider.qml:86:5: QML Connections: Cannot assign to non-existent property "onSliderMoved"
qrc:/Slider.qml:78:5: QML Connections: Cannot assign to non-existent property "onTextChanged"
qrc:/Slider.qml:34:7: Unable to assign QQuickAnchorLine to QQuickItem*
qrc:/Slider.qml:79: ReferenceError: yourObject is not defined
qrc:/Slider.qml:87: ReferenceError: yourObject1 is not defined
qrc:/Slider.qml:34:7: Unable to assign QQuickAnchorLine to QQuickItem*
qrc:/Slider.qml:79: ReferenceError: yourObject is not defined
qrc:/Slider.qml:34:7: Unable to assign QQuickAnchorLine to QQuickItem* -
hi
@vale88can you show us the content of Slider.qml, is "Slider.qml" a file created by you ? It should not, When you create your own Components don't use existing QML Type names.
-
@LeLev
import QtQuick 2.6 import QtQuick.Controls 2.1 import QtQuick.Extras 1.4 import QtQuick.Controls.Styles 1.4 Rectangle{ id: rectangle width:200 height: 130 color: "#f0f0f0" //setto il colore dello sfondo transformOrigin: Item.Left CircularGauge{ id: circularGauge x: 0 y: 29 width: 200 height: 150 anchors.verticalCenterOffset: 48 anchors.rightMargin: 0 anchors.topMargin: 31 anchors.verticalCenter: parent.verticalCenter anchors.top: parent.top anchors.right: parent.right anchors.centerIn: parent.bottom minimumValue : -30 maximumValue : 30 style: CircularGaugeStyle { minimumValueAngle : -90 maximumValueAngle : 90 foreground: Item { } tickmark:Rectangle { // visible: styleData.value implicitWidth: outerRadius * 0.02 antialiasing:true implicitHeight: outerRadius * 0.05 color: "Black" } minorTickmark: Rectangle { //visible: styleData.value implicitWidth: outerRadius * 0.01 antialiasing: true implicitHeight: outerRadius * 0.03 color: "Black" } tickmarkLabel:Text { color:"Black" text : styleData.value } } } Connections { target: yourObject onTextChanged: if (yourObject.text == "") circularGauge.value=-30 else {circularGauge.value = yourObject.text} } Connections { target: yourObject1 onSliderMoved: circularGauge.value = (position/10)- 30 } }
-
qrc:/Slider.qml:34:7: Unable to assign QQuickAnchorLine to QQuickItem* is because of :
anchors.centerIn: parent.bottom
qrc:/Slider.qml:87: ReferenceError: yourObject1 is not defined because there is no object width
id : yourObject1
in your qml file.
Where are declared yourObject1 and yourObject ? -
@LeLev I wrote in mainwindow.cpp:
//carico il file qml ui->Slider_Calib->setSource(QUrl("qrc:///Slider.qml")); //connect circularGauge e slider ui->Slider_Calib->engine()->rootContext()->setContextProperty("yourObject1",ui->horizSlider_Calib); //connect circularGauge e text ui->Slider_Calib->engine()->rootContext()->setContextProperty("yourObject",ui->Value_TavRotante_Calib);
-
hi
@vale88 said in warning with qml:I wrote in mainwindow.cpp:
where exactly in mainwindow.h ? can you please show the full method ?
Im non at all experienced with widgets but if your code is working that mean this is only object creation timing issue,
try to call setSource() after setContextProperty()//connect circularGauge e slider ui->Slider_Calib->engine()->rootContext()->setContextProperty("yourObject1",ui->horizSlider_Calib); //connect circularGauge e text ui->Slider_Calib->engine()->rootContext()->setContextProperty("yourObject",ui->Value_TavRotante_Calib); //carico il file qml ui->Slider_Calib->setSource(QUrl("qrc:///Slider.qml"));
-
@LeLev thanks, I tried and it works...only a warning remains:
qrc:/Slider.qml:34:7: Unable to assign QQuickAnchorLine to QQuickItem*
-
@vale88 good
as i said earlier the last error is because you do thisanchors.centerIn: parent.bottom
changeit to anchors.centerIn: parent
.bottomif you just want to center it -
@LeLev thanks it works