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

Sina Dogru sinadooru at gmail.com
Tue Apr 26 11:58:49 CEST 2016

2016-04-26 12:11 GMT+03:00 Shawn Rutledge <Shawn.Rutledge at qt.io>:

> You shouldn’t need to do this.  Just write onAccepted/onRejected handlers
> which call back to QML and/or C++ code as necessary.  Is there some reason
> why that is difficult?
> Well the problem is (like I tried to explain on the email to Dmitry) while
using QFileDialog's and QMessageBox's static functions, program can
continue to flow from where those functions called.

Let me please explain myself with a piece of code;

void App::saveAs(const QString &path)
    bool cont = true;

    while (cont) {
        if (path.isEmpty())
            cont = false;
        else {
            QFileInfo fi = path;

            if (fi->exists()) {
                int wantSave = QMessageBox::warning(nullptr, tr("Warning"),
tr("File %1 exists.\n"
                                                    "Do you wish to
overwrite it?").arg(fi->fileName()),
                if (wantSave == QMessageBox::Yes)
                    cont = false;
                    path = QFileDialog::getSaveFileName(nullptr, tr("Save
                cont = false;
    if (!path.isEmpty())

For example, when the user press the save as tool button of the QML
ApplicationWindow, this slot is called onAccepted handler of the
FileDialog. But depending on the user input, application might need to do
something else.

But I am not sure if I am violating the "UI and business logic seperation"
with this approach?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160426/e77622c9/attachment.html>

More information about the Interest mailing list