[qtcharts iOs error : unknown method return type: QAbstractAxis*]
-
I have same problem like the post below.
There's a answer for that question but not works for my case.
Re: qtcharts iOs error : unknown method return type: QAbstractAxis*In my case, when I try to run 'createSeries' method in QML, It makes error like as below. This problem only occurs in IOS but Android and Windows, and Mac doesn't.
qrc:/qml/templete/C_ChartView.qml:251: Error: Unknown method return type: QAbstractSeries*
my .pro file is like this.
QT += quick bluetooth sql charts android { QT += androidextras } ios { QMAKE_INFO_PLIST = ios/Info.plist } CONFIG += qml_debug c++11 # You can make your code fail to compile if it uses deprecated APIs. # In order to do so, uncomment the following line. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ backend.cpp \ com/ble/ble.cpp \ com/com.cpp \ db/db.cpp \ db/dbsettings.cpp \ device/device.cpp \ device/devicesettings.cpp \ main.cpp \ supervisor/supervisor.cpp \ supervisor/supervisorsettings.cpp \ ui/ui.cpp RESOURCES += \ img.qrc \ qml.qrc # Additional import path used to resolve QML modules in Qt Creator's code model QML_IMPORT_PATH = # Additional import path used to resolve QML modules just for Qt Quick Designer QML_DESIGNER_IMPORT_PATH = # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target HEADERS += \ backend.h \ com/ble/ble.h \ com/com.h \ db/db.h \ db/dbsettings.h \ device/device.h \ device/devicesettings.h \ supervisor/supervisor.h \ supervisor/supervisorsettings.h \ ui/loglistmodel.h \ ui/ui.h android { DISTFILES += \ android/AndroidManifest.xml \ android/build.gradle \ android/gradle.properties \ android/gradle/wrapper/gradle-wrapper.jar \ android/gradle/wrapper/gradle-wrapper.properties \ android/gradlew \ android/gradlew.bat \ android/res/values/libs.xml \ android/res/xml/filepaths.xml \ android/src/utils/QShareUtils.java ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android } # QXlsx code for Application Qt project QXLSX_PARENTPATH=./utils/QXlsx/ # current QXlsx path is . (. means curret directory) QXLSX_HEADERPATH=./utils/QXlsx/header/ # current QXlsx header path is ./header/ QXLSX_SOURCEPATH=./utils/QXlsx/source/ # current QXlsx source path is ./source/ include(./utils/QXlsx/QXlsx.pri) DISTFILES +=
my 'C_ChartView.qml' file is like this.
import QtQuick 2.15 import QtQuick.Controls 2.15 import QtCharts 2.15 ChartView { property string chartName: "" property var instantValues: ({}) property real vLineX: 0 property bool vLineEnabled: vLine.visible; Rectangle { id: vLine; width: 1; height: plotArea.height; x: plotArea.x + plotArea.width*vLineX/(axisX.max-axisX.min); y: plotArea.y; visible: false; } Text { anchors.right: parent.right; anchors.top: parent.top; anchors.rightMargin: 5*widthUnit; visible: vLine.visible; text: "<h2>"+vLineX.toFixed(1)+"</h2>"; color: C_Style.textColor2; width: 5*widthUnit; height: 10*heightUnit; leftPadding: 2*widthUnit; horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignVCenter; } id: chartView width: parent.width; height: parent.height; antialiasing: true; margins.top: 0; margins.bottom: 0; margins.left: 0; margins.right: 0; backgroundColor: C_Style.chartViewBackgroundColor; plotAreaColor: C_Style.chartViewPlotAreaBackgroundColor; legend.alignment: "AlignBottom"; legend.visible: false; anchors.margins: 0; backgroundRoundness: 0; ValueAxis { id: axisX min: 0; max: 20; tickType: ValueAxis.TicksDynamic; tickInterval: 5; minorTickCount: 1; color : C_Style.dimColor1; gridLineColor : C_Style.dimColor1; minorGridLineColor : C_Style.dimColor1; labelFormat: "%.1f"; } ValueAxis { id: axisYLeft min: 0; max: 12; tickCount: 6; minorTickCount: 1; color : C_Style.dimColor1; gridLineColor : C_Style.dimColor1; minorGridLineColor : C_Style.dimColor1; labelFormat: "%.1f"; } ValueAxis { id: axisYRight min: 0; max: 100; tickCount: 6; minorTickCount: 1; color : C_Style.dimColor1; gridLineColor : C_Style.dimColor1; minorGridLineColor : C_Style.dimColor1; labelFormat: "%d"; } onSeriesAdded: { backend_ui.chartView_registerSeries(series); } Connections { target: backend_ui; function onQml_chartView_createSeries(_chartName, type, name, axisRight, visible) { if (chartName === _chartName) { if (chartView.series(name)===null) { console.warn("CREATESERIES 2:",_chartName,type,name,axisRight,visible); if (axisRight) { chartView.createSeries(type, name); chartView.series(name).axisX = axisX; chartView.series(name).axisYRight = axisYRight; } else { chartView.createSeries(type, name); chartView.series(name).axisX = axisX; chartView.series(name).axisY = axisYLeft; } chartView.series(name).visible = visible; if (name.includes("Reference")) { if (name.includes("Pressure")) { chartView.series(name).color = C_Style.referencePressureSereisColor; } else if (name.includes("FilterTemperature")) { chartView.series(name).color = C_Style.referenceFilterTemperatureSereisColor; } else if (name.includes("SpoutTemperature")) { chartView.series(name).color = C_Style.referenceSpoutTemperatureSereisColor; } else if (name.includes("ElectricalConductivity")) { chartView.series(name).color = C_Style.referenceElectricalConductivitySereisColor; } else if (name.includes("Weight")) { chartView.series(name).color = C_Style.referenceWeightSereisColor; } else if (name.includes("Flow")) { chartView.series(name).color = C_Style.referenceFlowSereisColor; } else if (name.includes("PuckResistance")) { chartView.series(name).color = C_Style.referencePuckResistanceSereisColor; } chartView.series(name).width = 1.0; chartView.series(name).style = Qt.DashLine; } else { if (name.includes("Pressure")) { chartView.series(name).color = C_Style.pressureSereisColor; } else if (name.includes("FilterTemperature")) { chartView.series(name).color = C_Style.filterTemperatureSereisColor; } else if (name.includes("SpoutTemperature")) { chartView.series(name).color = C_Style.spoutTemperatureSereisColor; } else if (name.includes("ElectricalConductivity")) { chartView.series(name).color = C_Style.electricalConductivitySereisColor; } else if (name.includes("Weight")) { chartView.series(name).color = C_Style.weightSereisColor; } else if (name.includes("Flow")) { chartView.series(name).color = C_Style.flowSereisColor; } else if (name.includes("PuckResistance")) { chartView.series(name).color = C_Style.puckResistanceSereisColor; } } } } } function onQml_chartView_removeSeries(_chartName, name) { if (chartName === _chartName) { console.warn("CREATESERIES REMOVE 2:",_chartName,name); chartView.removeSeries(chartView.series(name)); } } function onQml_chartView_setAxisX(_chartName, min, max) { if (chartName === _chartName) { axisX.min = min; axisX.max = max; } } function onQml_chartView_setAxisYLeft(_chartName, min, max) { if (chartName === _chartName) { axisYLeft.min = min; axisYLeft.max = max; } } function onQml_chartView_setAxisYRight(_chartName, min, max) { if (chartName === _chartName) { axisYRight.min = min; axisYRight.max = max; } } function onQml_chartView_setReferenceSeriesVisible(_chartName, visible) { if (chartName === _chartName) { for (var i=0; i<chartView.count; i++) { if (chartView.series(i).name.includes(" Reference ")) { chartView.series(i).visible = visible; } } } } } MouseArea { anchors.fill: parent; onPositionChanged: { var l_instantValues = {}; var instValKey = ""; var x = axisX.min + (axisX.max - axisX.min)*(mouseX - chartView.plotArea.x)/chartView.plotArea.width; var isRef = false; if (x>=axisX.min && x<=axisX.max) { x = Math.round(x*10.0)/10.0; vLineX = x; vLine.visible = true; for (var i=0; i<chartView.count; i++) { instValKey = ""; if (chartView.series(i).name.includes("Reference")) instValKey = instValKey + "Ref."; if (chartView.series(i).name.includes("Pressure")) instValKey = instValKey + "Pres."; else if (chartView.series(i).name.includes("FilterTemperature")) instValKey = instValKey + "F.Temp."; else if (chartView.series(i).name.includes("SpoutTemperature")) instValKey = instValKey + "C.Temp."; else if (chartView.series(i).name.includes("ElectricalConductivity")) instValKey = instValKey + "EC"; else if (chartView.series(i).name.includes("Weight")) instValKey = instValKey + "Weight"; else if (chartView.series(i).name.includes("Flow")) instValKey = instValKey + "Flow"; else if (chartView.series(i).name.includes("PuckResistance")) instValKey = instValKey + "Puck R."; l_instantValues[chartView.series(i).name] = chartView.series(i).at(10*x).y; // l_instantValues[instValKey] = chartView.series(i).at(10*x).y; } instantValues = l_instantValues; } else { vLine.visible = false; instantValues = {}; } } onReleased: { vLine.visible = false; } } Component.onCompleted: { var lineSeries1 = createSeries(ChartView.SeriesTypeLine,"initS1",axisX,axisYLeft); var lineSeries2 = createSeries(ChartView.SeriesTypeLine,"initS2",axisX); lineSeries2.axisYRight = axisYRight; removeSeries(lineSeries1); removeSeries(lineSeries2); } }
A mysterious thing is, when I make a whole new project with a QML file like as below, this works fine.
import QtQuick 2.15 import QtQuick.Window 2.15 import QtCharts 2.15 import QtQuick.Controls 2.15 Window { width: 640 height: 480 visible: true title: qsTr("Hello World") ChartView { title: "Line" anchors.fill: parent antialiasing: true LineSeries { name: "LineSeries" XYPoint { x: 0; y: 0 } XYPoint { x: 1.1; y: 2.1 } XYPoint { x: 1.9; y: 3.3 } XYPoint { x: 2.1; y: 2.1 } XYPoint { x: 2.9; y: 4.9 } XYPoint { x: 3.4; y: 3.0 } XYPoint { x: 4.1; y: 3.3 } } ValueAxis { id: axisX; min: 0; max: 10; } ValueAxis { id: axisY; min: 0; max: 10; } Component.onCompleted: { var lineSeries1 = createSeries(ChartView.SeriesTypeLine,"initS1",axisX,axisY); lineSeries1.axisYRight = axisY; } } }
Therefore, I tried to remove my C_ChartView.qml and make a new simple ChartView with createSeries in onCompleted function, but it doesn't work.
I think there's some linking bug or something but how to solve this problem?
Do anyone have any solution for this? -
As I mentioned post, qtcharts iOs error : unknown method return type: QAbstractAxis*, there's a makeshift.
This works fine when I build it in release settings instead of debug settings.This problem is not really solved but I'll close this thread for now.
If anyone have proper solution for this, please leave more opinion for this thread.