Whenever the button is pressed, the sendRequest() slot is called:
void MainWindow::sendRequest() { if (m_reply != nullptr && m_reply->isRunning()) { m_reply->abort(); } ui->result->clear(); //... }
In this slot, we first check whether there is an old request, which was stored in m_reply, and whether it is still running. If that is true, we abort the old request, as we are about to schedule a new one. Then, we also wipe out the result of the last request by calling QPlainTextEdit::clear() on the text edit.
Next, we will construct the URL for the request. We can do this by composing the string by hand where we add the query parameters to the base URL similar to the following:
// don't do this!QString ...