Skip to content

Instantly share code, notes, and snippets.

@liangqi
Created July 16, 2013 08:03
Show Gist options
  • Select an option

  • Save liangqi/6006742 to your computer and use it in GitHub Desktop.

Select an option

Save liangqi/6006742 to your computer and use it in GitHub Desktop.
Q_INVOKABLE QJSValue get(int index) const;
QJSValue QQuickWritingSystemListModel::get(int idx) const
{
Q_D(const QQuickWritingSystemListModel);
QQmlEngine *engine = qmlContext(this)->engine();
if (idx < 0 || idx >= count())
return engine->newObject();
QJSValue result = engine->newObject();
int count = d->roleNames.keys().count();
for (int i = 0; i < count; ++i)
result.setProperty(QString(d->roleNames[Qt::UserRole + i + 1]), data(index(idx, 0), Qt::UserRole + i + 1).toString());
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment