B
B
becks2016-07-08 17:34:46
Qt
becks, 2016-07-08 17:34:46

What is the correct way to use QMovie when waiting for a long method to complete?

When connecting to the server, you need to display a widget with QMovie and some message, the connection has ended - close the panel. The problem is that while the QMovie connection itself is in progress, it is frozen, after which, when a warning appears, it starts to move. It is understandable - the connection works in a stream with graphics. What I have not tried, nothing works normally, how to do it right? Now I have reached QFutureWatcher. It turns out something like:

QFutureWatcher<bool> watcher;
    ....

    LoadingSplashScreen screen("Подключение к серверу...", this);
    screen.show();

    connect(&watcher, SIGNAL(finished()), this, SLOT(handleFinished()));
    future = QtConcurrent::run(this, &MainWindow::connectToServer, info.server);
    watcher.setFuture(future);

It turns out that you need to globally store watcher, future and screen for closing. For me, this is overkill. Tell me how to do it right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
Jacob E, 2016-07-09
@Zifix

In your opinion, class fields are "stored globally"?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question