Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. QMessage box in console app slot
Forum Updated to NodeBB v4.3 + New Features

QMessage box in console app slot

Scheduled Pinned Locked Moved Solved C++ Gurus
3 Posts 2 Posters 366 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qAlexKo
    wrote on last edited by qAlexKo
    #1

    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?

    J.HilkJ 1 Reply Last reply
    0
    • J.HilkJ J.Hilk

      @qAlexKo set the quitOnLastWindowClosed property to false

      Q Offline
      Q Offline
      qAlexKo
      wrote on last edited by
      #3

      @J-Hilk said in QMessage box in console app slot:

      @qAlexKo set the quitOnLastWindowClosed property to false

      It works, thank you!

      1 Reply Last reply
      1
      • Q qAlexKo

        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?

        J.HilkJ Online
        J.HilkJ Online
        J.Hilk
        Moderators
        wrote on last edited by
        #2

        @qAlexKo set the quitOnLastWindowClosed property to false


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        Q 1 Reply Last reply
        2
        • J.HilkJ J.Hilk

          @qAlexKo set the quitOnLastWindowClosed property to false

          Q Offline
          Q Offline
          qAlexKo
          wrote on last edited by
          #3

          @J-Hilk said in QMessage box in console app slot:

          @qAlexKo set the quitOnLastWindowClosed property to false

          It works, thank you!

          1 Reply Last reply
          1
          • Q qAlexKo has marked this topic as solved on

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved