Conversion of Qvector<qreal> to QVariant fails
-
wrote on 22 Jul 2024, 06:54 last edited by
-
Why is this conversion from QVector<qreal> to QVariant fails?? same code is working in othermodule while reading values from json and filling in the same type of data structure
Other Module, where it conversion is fine
Any suggestions, what am I missing?
-
@sayan275
I suggest you put in some code (e.g. suitableqDebug()
) to show the result fromQVariant::fromValue()
, and maybe what is inpoints
, rather than relying on interpreting what is shown in the debugger window.wrote on 22 Jul 2024, 08:39 last edited byAnnotationViewerPlugins::RadarChartConfig::on_chartUpdatePBtn_clicked "FRONTLeft_inner_area_yMax" 4.5 AnnotationViewerPlugins::RadarChartConfig::on_chartUpdatePBtn_clicked "FRONTLeft_inner_area_xMin" 4.31 AnnotationViewerPlugins::RadarChartConfig::on_chartUpdatePBtn_clicked "FRONTLeft_inner_area_xMax" 1.81 AnnotationViewerPlugins::RadarChartConfig::on_chartUpdatePBtn_clicked points vec:: QVector(-1.75, 4.5, 4.31, 1.81) AnnotationViewerPlugins::RadarChartConfig::on_chartUpdatePBtn_clicked pt Variant:: QVariant(QVector<double>, )
-
wrote on 22 Jul 2024, 08:55 last edited by JonB
AnnotationViewerPlugins::RadarChartConfig::on_chartUpdatePBtn_clicked pt Variant:: QVariant(QVector<double>, )
So far as I can tell, all that shows is that the result is of type
QVariant(QVector<double>, )
. (Don't know what the significance is of the trailing comma, if any.)I expected you print out the lengths/values, to see what is going on.
Anyway, doesn't the code in the solution at https://stackoverflow.com/questions/40437335/converting-qvariant-to-qvectorint show you what you should be doing?Sorry, that was the wrong way round, it doesQVariant
toQVector
. -
AnnotationViewerPlugins::RadarChartConfig::on_chartUpdatePBtn_clicked pt Variant:: QVariant(QVector<double>, )
So far as I can tell, all that shows is that the result is of type
QVariant(QVector<double>, )
. (Don't know what the significance is of the trailing comma, if any.)I expected you print out the lengths/values, to see what is going on.
Anyway, doesn't the code in the solution at https://stackoverflow.com/questions/40437335/converting-qvariant-to-qvectorint show you what you should be doing?Sorry, that was the wrong way round, it doesQVariant
toQVector
. -
@JonB it's (type, value), since value is empty, there is nothing after ,
penVart:: QVariant(int, 2)
wrote on 22 Jul 2024, 10:18 last edited by JonB@sayan275
I should have been a lot happier if you extracted the vector from the variant and showed, say, its length rather than relying on the interpretation of howqDebug()
displays a variant overall. I trust you are correct.I agree I am not sure, and I don't know why you seem to show it working in one place and not in another. Why don't you start by temporarily making them integers and testing same code with
QVariant<int>
instead ofQVariant<qreal>
so we can eliminate someqreal
issue? -
Why is this conversion from QVector<qreal> to QVariant fails?? same code is working in othermodule while reading values from json and filling in the same type of data structure
Other Module, where it conversion is fine
Any suggestions, what am I missing?
1/7