2016-04-26 12:11 GMT+03:00 Shawn Rutledge <shawn.rutle...@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()),
                                                    QMessageBox::Yes,
QMessageBox::No);
                if (wantSave == QMessageBox::Yes)
                    cont = false;
                else
                    path = QFileDialog::getSaveFileName(nullptr, tr("Save
As"));
            }
            else
                cont = false;
        }
    }
    if (!path.isEmpty())
        doc->save(url);
}

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?
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to