Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Status messages from different class
Forum Updated to NodeBB v4.3 + New Features

Status messages from different class

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 1.4k Views 1 Watching
  • 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.
  • B Offline
    B Offline
    BinuJanardhanan
    wrote on 26 Dec 2017, 10:01 last edited by
    #1

    I have developed a desktop application. Different modules forms are opened in the centralwidget area of mainwindow.
    I want to show the status messages from different module in a popup area or status bar area in the mainwinodw. how can i acheive the task ?

    A 1 Reply Last reply 26 Dec 2017, 10:17
    0
    • B BinuJanardhanan
      26 Dec 2017, 10:01

      I have developed a desktop application. Different modules forms are opened in the centralwidget area of mainwindow.
      I want to show the status messages from different module in a popup area or status bar area in the mainwinodw. how can i acheive the task ?

      A Offline
      A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on 26 Dec 2017, 10:17 last edited by aha_1980
      #2

      Hi @BinuJanardhanan,

      you can emit signals from the subwidgets and evalute them in a slot in your main window.

      Qt has to stay free or it will die.

      B 1 Reply Last reply 26 Dec 2017, 10:51
      2
      • A aha_1980
        26 Dec 2017, 10:17

        Hi @BinuJanardhanan,

        you can emit signals from the subwidgets and evalute them in a slot in your main window.

        B Offline
        B Offline
        BinuJanardhanan
        wrote on 26 Dec 2017, 10:51 last edited by
        #3

        @aha_1980
        thanks for your reply

        That quite complex. I have a number of classes. so that much signal slot leads to complications. So need a better solution.

        A 1 Reply Last reply 26 Dec 2017, 10:54
        0
        • B BinuJanardhanan
          26 Dec 2017, 10:51

          @aha_1980
          thanks for your reply

          That quite complex. I have a number of classes. so that much signal slot leads to complications. So need a better solution.

          A Offline
          A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on 26 Dec 2017, 10:54 last edited by aha_1980
          #4

          @BinuJanardhanan Did you know that you can connect multiple signals to the same slot? and other way round, one signal can connect to many slots.

          the system is very flexible.

          Qt has to stay free or it will die.

          B 1 Reply Last reply 26 Dec 2017, 11:03
          2
          • A aha_1980
            26 Dec 2017, 10:54

            @BinuJanardhanan Did you know that you can connect multiple signals to the same slot? and other way round, one signal can connect to many slots.

            the system is very flexible.

            B Offline
            B Offline
            BinuJanardhanan
            wrote on 26 Dec 2017, 11:03 last edited by
            #5

            @aha_1980
            Yes, i know sir.
            Even though I have to write more connect and signal emit.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 26 Dec 2017, 11:25 last edited by
              #6

              Hi
              There is no better way as if you are not using
              signals and slot, then you need a pointer to the actual statusbar to set text
              and that is even worse.

              also, its

              signals:
              showStatusMessage(const QString & message, int timeout = 0);

              in each of the modules. pr class.

              Then in mainwindow where you construct the modules.
              then connect the objects
              showStatusMessage
              to
              void QStatusBar::showMessage(const QString & message, int timeout = 0)

              How many classes do you have?

              1 Reply Last reply
              2
              • B Offline
                B Offline
                Buckwheat
                wrote on 27 Dec 2017, 19:50 last edited by
                #7

                Hi and Welcome!

                This is purely a matter of design. There should be a well defined system for handling the messages (statii) that you wish to display. The classes should only be concerned with that interface. Your client should only be concerned with processing that interface.

                The first questions that come to mind are: Are your modules forked processes (*nix), threads, or using QProcess? This makes all the difference in the world on how to handle things.

                There are patterns you can use. One I have used is making my qApp act like a router with a defined signal that my main window can connect its slot to and then each module can attach its corresponding signal to. This forwards the signal to the main window but assumes you have a common interface and a single process with a single or multiple threads but abstracts the user interface from the classes.

                Another, and very flexible method, that works for single process or multiple processes is using 0MQ to send messages around. Your main client application will have the handler and can then parse the messages as they come in and display them accordingly. Again, it is all in the design. What makes this so flexible is 0MQ is a messaging system. You can develop your patterns and have them connect directly or through a routing system, move across networks, use UDP, TCP, pipes, etc.

                Again, I strongly suggest you map out what messages and how you want them to communicate. So you could know, this latter technique is actually used in aircraft systems for decades between 1553 and now Ethernet and to a smaller scale extent using CANbus networks in marine, automotive, and industrial applications.

                Enjoy!

                Dave Fileccia

                1 Reply Last reply
                0

                1/7

                26 Dec 2017, 10:01

                • Login

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