user2054339
user2054339

Reputation: 495

Design UI on QML or C++, BB10

I need to write a BB-10 app. The app might have quite involved UI, with dynamic pages etc. I am thinking to write the application logic (data models, etc.) in C++. Should I use QML for UI design? How well and flexible is integration between C++ and QML? Will I not encounter some problems? My UI may consist of many QML pages (or dialogs, shown in Navigation Panes etc.), and when user clicks some actions in QML I may want to invoke some C++ code or navigate to other QML pages etc. Thank you for help.

Upvotes: 2

Views: 1567

Answers (3)

Jean
Jean

Reputation: 329

Short answer: C++/QML integration is very good. May be very verbose at times, but there is nothing you can’t do in C++.

Even if doing everything in C++ is a tenny bit faster. BlackBerry is pushing the idea to code all the UI workflow in QML/Javascript.

The advantage would be clear separation between business logic & app flow. Another advantage is that QML is shorter to write and hopefully to maintain. Don’t forget that you can create new QML objects in C++.

onTriggered: {
    var item = dataModel.data(indexPath);
    if (item.count > 0) {
        appLogic.updateFeed(item.id);
        navPane.push(resultPage);
    }
}

Upvotes: 1

Ajeet47
Ajeet47

Reputation: 1879

i also go through such situation when you need control over application using C++ that qml not much do.best way inherit your class by NavigationPane and put there logic add your first page using QmlDocument::create() if you had some page beside navigation use sheet and add some method to this class which Q_INVOKABLE and pass setContext this class when ever you create new page using QmlDocument::create() to access those methods .. finally never forget to add or handle OnTrasitionEnded(Page*) signal to delete pages and release memory

Upvotes: 1

AkiRoss
AkiRoss

Reputation: 12273

I do not know anything about mobile development, but QML is nice, should make interfaces easier to maintain, modify and port to other devices.

Integration of QML and C++ is easy as long as you use well the Qt framework, using QObjects, Q_PROPERTY and Q_INVOKABLE methods... It is really easy.

EDIT: I must add, though, that I did not find accessing QML objects from C++ as easy as the contrary. This is because QML organizes objects in a hierarchy of few data types, and you have to discover child nodes dynamically, using findChild or checking objectName.

Anyway, since QML allows to bind properties, you should be able to create some C++ classes with your data, and access them on the UI without much effort ;)

Upvotes: 4

Related Questions