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

Sina Dogru sinadooru at gmail.com
Tue Apr 26 11:36: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.
Hello Dmitry, thank you for respond. I think you are talking about the
FileDialog QML type and MessageBox. But my problem is, when I call a static
method of the intermediary class which calls FileDialog's open function
would not return the file URL while QFileDialog::getSaveFileName would
return it. So to do it, QML would need to call another function onAccepted
handler and it would need to know which function it needs to call.

I mean, for example consider a situation where a C++ class process a user
input carried from QML to C++. If the user input is incorrect, I would need
to ask the user some options. So I pop up a message box which presents the
options to the user with this intermediary class. But when I do this, I
would lose the flow of the program. So when the user responds to the
message box, I would need to call another C++ function to process. But
since QMessageBox's and QFileDialog's static functions create their own
event loop and returns the data, I would be able to process new data
without loosing the current stack and flow of the program.

So QMessageBox and QFileDialog's static functions are not need to know on
their event handlers, because they just returns the information that is
needed so program can continue from the same stack.

Like I said, I am not so exprienced with programming. I might be misjudging
your advice or QML and C++ seperation.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160426/1112acff/attachment.html>

More information about the Interest mailing list