[Interest] [QtQuick] Interaction with user from C++

Dmitry Volosnykh dmitry.volosnykh at gmail.com
Tue Apr 26 10:56:22 CEST 2016

Hi, Sina. You may try to wrap those C++-side static methods with
intermediary class that is exposed to QML in a usual way. As far as I
remember there should be some API for opening files as well as for message
notifications. But that will require you to import QtQuick.Controls module.
Please, refer to official documentation for more precise name of the module.

On Tue, Apr 26, 2016, 11:03 AM Sina Dogru <sinadooru at gmail.com> wrote:

> Hello list,
> Before watching this video
> <https://www.youtube.com/watch?v=kvWeE3kurEQ&index=1&list=PL3oL-EW4dhTBgAA1E0DM-IVDAudlkDcNe>,
> I was thinking the Qt-Declarative module is aiming to touch-screen and
> mobile devices. And also after experiencing some QtQuick applications on
> desktop my thought have totally changed. So I started a small desktop
> application with QtQuick.
> I had some problems with QML but also enthused :). If I come to the point,
> my main problem is with C++ backend. I use some C++ classes with QML. I am
> aware of that QML is natively seperates UI and business logic but sometimes
> I need to interact with the user from my C++ classes. I am not sure if this
> is about general architect problem of my design, I am not well exprienced
> programmer. For example, on some points, qml sends some user interaction to
> C++ classes, eg URL of a file. Class checks the url and responds to user
> with QML(emitting a signal).
> On the Widgets world, some of the static functions of QMessageBox and
> QFileDialog (eg getSaveFileName
> <http://doc.qt.io/qt-5/qfiledialog.html#getSaveFileName> and warning
> <http://doc.qt.io/qt-5/qmessagebox.html#warning>) are so handy and
> necessary, IMHO. I do mimic this behaviour with a QML function, which opens
> a file dialog or a message box with the function arguments, connected to a
> signal of a C++ class. So whenever I need to interact with the user from
> C++ I just emit this signal with the proper arguments. For example when I
> need to say to user that his/her input was incorrect, I just emit warning
> signal. But the problem is when I need to get the user respond to this
> warning box. Beauty of the QMessageBox and QFileDialog's static functions
> are they creates their own event loop and they just returns the data that
> needed.
> My question is, I am not sure if this is originated from my design flaws,
> is it possible to create an internal event loop in QML so the event loop
> would return the necessary data?
> Thank you,
> Sina
> _______________________________________________
> 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/20160426/eebde6e0/attachment.html>

More information about the Interest mailing list