0

how can initial an object from a c++ struct and send them to c++ class like this :

//c++
struct sRange
{
float min;
float max;
};
qmlRegisterType<sRange>("sRange", 0, 1, "sRange");


//QML
import sRange 0.1
function newRange()
{
 sRange range;
 range.min = 10 ;
 range.max = 20 ;

 cppClassObject.newRange(range); // cppClassObject -> registered property context
}

in above code we create and instance from sRange and set to newRange method in c++ class.but we can not instantiate an object from sRange struct tnx

SajadBlog
  • 514
  • 2
  • 12
  • You are looking for `Q_GADGET`, however that is not directly possible: https://stackoverflow.com/questions/42797359/how-to-create-new-instance-of-a-q-gadget-struct-in-qml – Amfasis Mar 14 '19 at 07:29
  • Thats not how qml / c++ interaction works. This link should help: https://doc.qt.io/qt-5/qtqml-cppintegration-topic.html – Rick Pat Mar 16 '19 at 01:25

0 Answers0