[Interest] Executing C++ code from a QML menu item.

Alan Alpert 416365416c at gmail.com
Sun Jun 30 00:28:14 CEST 2013


On Fri, Jun 28, 2013 at 1:26 AM, Rutledge Shawn
<Shawn.Rutledge at digia.com> wrote:
>
> On 28 Jun 2013, at 8:28 AM, Bache-Wiig Jens wrote:
>
>> On Jun 27, 2013, at 11:28 PM, Joseph Crowell <joseph.w.crowell at gmail.com> wrote:
>>
>>> Now that the desktop Widgets are out, I'm trying them out and seeing if
>>> I can figure out how it works. By reading and snipping code from the
>>> examples I've been able to make a simple dialog with menus, but I ran in
>>> to a snag when I wanted to add an "About Qt" menu item. How do you
>>> actually execute C++ code from QML like QApplication::AboutQt()?
>>
>> You might want to read up on how to expose methods or properties from C++ to Qt Quick:
>> http://qt-project.org/doc/qt-5.0/qtqml/qtqml-cppintegration-exposecppattributes.html
>>
>> Note that the "Text" example provided with Qt Quick Controls is using a C++ backend.
>> (though we left AboutQt() as an exercise to the reader)
>
> Should we have a QtQuick.Dialogs AboutDialog API?  ;-)  You could give it rich text (HTML markup) to display, which would let you insert your own logo etc., and have a markup element that expands to the About Qt info so can position it however you like.

That's not a bad idea, except I don't think we need that level of
customization (http://qt-project.org/doc/qt-5.0/qtwidgets/qmessagebox.html#aboutQt
doesn't even have a text string!). We can just provide an aboutQt slot
on the application object, same as QApplication.

I think the QtWidgets about dialog APIs were about pure convenience,
just creating automatic dialogs for you based on information you set
on the application earlier. With a better approach for creating custom
Dialogs, I think we can focus even more on the convenience side for
about dialog APIs in QtQuick.

--
Alan Alpert



More information about the Interest mailing list