[Interest] Idea: QML Text source property?

Jason H jhihn at gmx.com
Thu May 20 19:28:44 CEST 2021


I wanted to post a thought I had about adopting a source property approach for text-ish things (Text, TextEdit, Text*) as well as images. Currently, images support a source property, which can be routed to a remote url, local file, compiled resource, or QQuickImageProvider.

I think it could be argued that there could be a use case for text to have a similar source scheme as well.  Example:
Text {
   source: "https://qt.io/eula"
   source: "sqlite://query?queryparams"
}

Reading is simple, writing a little more complicated. The "QQuickTextProvider" provider would have to provide a setter in addition to getter and might have to have a notifier signal.

Currently, yes, all this could be done by just having a QObject with exposed properties and binding the Text.text property to the object property. BUT I'm working on model where I want to be able to reuse the UI. And to do it, I want to specify:
Repeater {
  model : [
    {"label": "First name", "source": "provider://"+rowid+"?first"},
    {"label": "Last name", "source": "provider://"+rowid+"?last"}
  ]
  Column {
    Text {text: model[index].label}
    TextEdit {text: model[index].source}
  }
}

But the gist is that the value being bound to is provided /as data/. I think it would be really useful to have this level of indirection.
Yeah, SQLLite doesn't support LISTEN(https://www.postgresql.org/docs/9.0/sql-listen.html), but I'd expect the provider to implement the notification internally, through whatever means necessary.




More information about the Interest mailing list