[Qt5-feedback] C++ api to use for UI in addition to QML
Alan Alpert
alan.alpert at nokia.com
Tue May 17 03:00:51 CEST 2011
On Tue, 17 May 2011 06:58:51 ext Alan Ezust wrote:
> On Mon, May 16, 2011 at 5:57 AM, Andre Somers <andre at familiesomers.nl>
wrote:
> > Op Ma, 16 mei, 2011 2:43 pm, schreef Thiago Macieira:
> >> On Monday, 16 de May de 2011 12:03:30 Serhiy wrote:
> >>> So my point is that since QT itself uses C++ why not to have C++ api
> >>> for new features as well.
> >>
> >> Because we lock ourselves to that API, due to C++'s binary compatibility
> >> requirements.
> >>
> >> We like to have a minimal API that addresses the use-cases. We'll be
> >> doing it
> >> once in QML. Doing it again in C++ is more work and also harder to
> >> change later.
> >
> > Sure. But there needs to be some sort of sane way to interact with QML
> > elements from C++, if QML is to be the main UI paradigm of Qt. At the
> > very least, it would make sense to make it possible to get a pointer to
> > a QObject based on a QML id.
>
> in QML 1.x, you can set
> objectName: "someObjectName"
> on any QML Item and then use
> QObject::findChild<QDeclarativeItem*>("someObjectName")
> to find it.
>
> But that assumes the QML Items derive from QObject. When we move over
> to sceneGraph in QML 2.0, will that still be true?
>
> I don't know how to find something by id, but I'll be following this
> thread in case someone else does.
You can't find an item by id from C++, it's a detail internal to the QML
engine. ObjectName will continue to work in Qt 5 though.
In fact, QML 2.0 should have a very similar C++ API to QML1.x (because we
expose so little of it). You will be able to instantiate QML scenes with
components, and use the meta object system for introspection. It would help if
you provide more detail than 'interact with'. What's missing from the QML 1.x
C++ support that you want (keeping Thiago's points in mind, as he is entirely
correct) ?
Another thing to keep in mind is that you won't have to write Javascript to
use QML. Qt Creator has a QML design view that you can use, and then
everything gets hooked up like it used to be with .ui files. Except with
greater customization and more animations. With Qt 5, you will be able to
create UIs without 'writing' QML, just by using the tools.
--
Alan Alpert
Senior Engineer
Nokia, Qt Development Frameworks
More information about the Qt5-feedback
mailing list