QMessage box in console app slot
Solved
C++ Gurus
-
Hi, Qts!
I make a console app with gui turned on (in project)
In the main function I do like this, and I then I start getting MQTT messages to receive_COMMAND_slot:
int main(int argc, char *argv[]) { QApplication a(argc, argv); ... auto COMMAND_subscription = _mqtt_command_client->subscribe(COMMAND_topic, (int)QOS1); QObject::connect(COMMAND_subscription, &QMqttSubscription::messageReceived, &a, &receive_COMMAND_slot); .... return a.exec(); } //here is the slot void receive_COMMAND_slot(const QMqttMessage &msg) { QMessageBox::information(nullptr, "Message", "tst", QMessageBox::Yes, QMessageBox::No ); } code_text
When I've got a message in receive_COMMAND_slot I see a message box "tst".
But after pressing OK, the app closes without warnings. The problem is in the way
I process the QMessageBox - if I don't use it -- the app is continie its working OK. Can you suggect to me why I can't use a QMessage box in my receive_COMMAND_slot slot? -
@qAlexKo set the quitOnLastWindowClosed property to false
-