Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Const string& in QScript (Qt 4.6)
StevenEBarbaro last edited by
I've been using QScriptable to enable a c++ class to be used in QScript.
I've also been registering some of the return types of the (newly set as) public slots for the above mentioned class to be available in QScript as well
I can’t seem to figure out a way to register a (const string&) to be a recognized type for use in the script nor have I found a solution online.
This is an example of how I hooked up std::string successfully
//Register string with the meta system
//Identify to the script engine what conversion functions to use for type string
qScriptRegisterMetaType<string>(&this->engine, & MyScriptHandlingClass::stdStringToScriptValue, & MyScriptHandlingClass::stdStringFromScriptValue);
QScriptValue string_ctor = this->engine.newFunction(&MyScriptHandlingClass::createStdString);
//Identify to the script engine what function is to be used to create new strings in the script
Does anyone have any solutions and/or advice that would help me resolve this issue?
Thank you very much in advance,
Franzk last edited by
If I remember correctly, you have to include the namespace in the metatype declaration:
But why not use QString and QString::toStdString() when needed?