By chaning the order MqttClient::isConnected() returns true in slot connected to MqttClient::connected().