mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 06:53:59 +02:00
Return a JSON string from QML instead of JS object
Idk why QML can't return a JS object, but it can't. Strings work, so I use a string.
This commit is contained in:
parent
d75c2e2a6f
commit
acf4539f4f
2 changed files with 7 additions and 9 deletions
|
@ -265,7 +265,7 @@ ModalWindow {
|
|||
if (checkBox) {
|
||||
result.checkBox = checkBoxField.enabled ? checkBoxField.checked : null;
|
||||
}
|
||||
root.result = result;
|
||||
root.result = JSON.stringify(result);
|
||||
root.selected(root.result);
|
||||
root.destroy();
|
||||
}
|
||||
|
|
|
@ -349,14 +349,12 @@ QVariant OffscreenUi::getCustomInfo(const Icon icon, const QString& title, const
|
|||
}
|
||||
|
||||
QVariant result = DependencyManager::get<OffscreenUi>()->customInputDialog(icon, title, config);
|
||||
if (ok && result.isValid()) {
|
||||
*ok = true;
|
||||
}
|
||||
|
||||
// Casts from QJSValue to QVariantMap (not sure how, just copied from http://lists.qt-project.org/pipermail/development/2014-September/018513.html)
|
||||
Q_ASSERT(!result.isValid() || result.userType() == qMetaTypeId<QJSValue>());
|
||||
if (result.userType() == qMetaTypeId<QJSValue>()) {
|
||||
result = qvariant_cast<QJSValue>(result).toVariant();
|
||||
if (result.isValid()) {
|
||||
// We get a JSON encoded result, so we unpack it into a QVariant wrapping a QVariantMap
|
||||
result = QVariant(QJsonDocument::fromJson(result.toString().toUtf8()).object().toVariantMap());
|
||||
if (ok) {
|
||||
*ok = true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
Loading…
Reference in a new issue