[Interest] Qt iOS without QML?

Gian Maxera gmaxera at gmail.com
Tue Oct 27 15:17:36 CET 2015


I don’t have any example I can show to you, but I use QML as the ui and C++ as the logic part in all my Android and iOS application and it’s very straightforward.
There are two steps involved:
1) all C++ classes you want to expose to the UI have to inherit from QObject and use Q_PROPERTY for all attributes you want to access from QML and use Slots and signals are you normally do in Qt
2) register to QML the classes you want to see into the UI.

The step 2 can be done in different ways. What I normally do is to create a singleton C++ class, and I register it into the following way:

qmlengine->rootContext()->setContextProperty( "backend", this );

And then from the QML, I get all other objects passing via properities of the Backend singleton:

C++:
Q_PROPERTY( QQmlListProperty<Link> aboutLinks READ getAboutLinks NOTIFY linksChanged )

QML:
				Repeater {
					model: backend.aboutLinks
					delegate: GoldButton {
						property Link link: modelData
						anchors.horizontalCenter: parent.horizontalCenter
						width: aboutTheShow.width*0.8
						height: container.buttonHeight
						text: link.text
						onClicked: Qt.openUrlExternally( link.url )
					}
				}


And thanks to signals and QML property binding … everytime you change the aboutLinks property on you C++ logic (for example listening on HTTP for notifications), automatically the QML will be updated to reflect the new changes.

Of course, there is other ways to do it. This is my way :-)

Ciao,
Gianluca.



> On 27 Oct 2015, at 13:59, NoRulez via Interest <interest at qt-project.org> wrote:
> 
> The problem is that I don't won't to learn an additional "language" only for ui's.
> 
> I doesn't found really helpful examples which uses QML as the ui and c++ as the logic part.
> 
> Maybe someone have useful links?
> 
> Thanks
> 
> 
>> Am 27.10.2015 um 14:18 schrieb Burak Arslan via Interest <interest at qt-project.org>:
>> 
>> 
>> 
>>> On 10/27/15 16:04, Edward Sutton via Interest wrote:
>>> 
>>> However a Qt widget app can be ugly on Android and iOS.  Buttons and
>>> tables appear too small for fingers.  Font size is out of proportion.  
>> 
>> Maybe that'll change with Qt 5.6 when the QT_SCALE_FACTOR support lands?
>> Did anyone play with it?
>> 
>> Burak
>> 
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20151027/fe1f0492/attachment.html>


More information about the Interest mailing list