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. What is the advantage & disadvantage of Qt's signal-slot mechanism compared to MFC's message mechanism?
Qt 6.11 is out! See what's new in the release blog

What is the advantage & disadvantage of Qt's signal-slot mechanism compared to MFC's message mechanism?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 5.1k 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.
  • O Offline
    O Offline
    opengpu
    wrote on last edited by
    #1

    what is the advantage & disadvantage of Qt's signal-slot mechanism compared to MFC's message mechanism?
    is there anything which Qt can do but MFC can't?
    or Qt can easily realize but MFC is very hard?
    Meanwhile, the efficience problem, which one is more efficient on Windows?
    thank you very much

    1 Reply Last reply
    0
    • O Offline
      O Offline
      opengpu
      wrote on last edited by
      #2

      anyone help? :D

      1 Reply Last reply
      0
      • Chris KawaC Offline
        Chris KawaC Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by
        #3

        I suspect no one is willing to answer this because the questions you ask are very broad and many answers would be purely opinion based.

        I don't know MFC that well, but for what I do I can offer few biased points in Qt favor:

        • signal/slot mechanism is dynamic i.e. you can connect and disconnect at runtime while (from what I understand) MFC messages are "static" i.e. defined as macro blocks and "connections" are evaluated at compile time.
        • As a result of above MFC messages are "targeted" i.e. the object posting a message needs to specify a receiver. Qt model on the other hand is subscription based. An object sends a signal and doesn't care who responds to it. Any other object can. This is IMO more flexible.
        • Similar is true in threading contexts. In MFC you need to post a message to a known thread object, while in Qt you don't even need to consider there are threads. The synchronization will be done for you automatically when you connect objects in different threads.

        All in all I think Qt is easier to work with and more dynamic. As to performance I can't say. I haven't seen or done any comparisons, but it would certainly be interesting to see some.

        Some less to the point arguments:

        • Qt is portable, MFC is Windows desktop specific
        • Qt is actively developed and opensourced while MFC is slowly bleeding to death and has mostly just bug fixes these days
        • In my opinion the amount of macro spew in MFC is ridiculous. Of course if you like macros this is a null-argument
        • Qt designer is sooo much nicer to work with than MFC form editor ;)
        1 Reply Last reply
        0
        • O Offline
          O Offline
          opengpu
          wrote on last edited by
          #4

          yeh, thank you very much.
          i know it's hard to compare Qt with MFC
          However, my question here is compare their Message Mechanism :D

          1 Reply Last reply
          0
          • G Offline
            G Offline
            giesbert
            wrote on last edited by
            #5

            Hi,

            If you onyl compare the message mechanism, you have it in both. Windows message loop in MFC and Qts event loop.
            I know both ways, and what I can say is Qt is a easier, better to understand (Class based messages) and easier to maintain. You have more options (event filter, ...).

            But Qts signal/slot mechanism is something different than MFCs (Windows) message mechanism. Signals and slots make object interactions, windows messages are not. You can use them that way, but it's not the standard way.

            Qts signal/slot work inter-thread, are thread save, can be used synchronously and asynchronously, etc. You can specify any type of parameters, POD or classes, and they are cleaned up. You can connect to signals which have more parameters, unless the ones you have in your slot exist in the signal also, and so on.

            By the way, I have never seen performance problems here...

            Nokia Certified Qt Specialist.
            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

            1 Reply Last reply
            0
            • O Offline
              O Offline
              opengpu
              wrote on last edited by
              #6

              very complete interpretation.
              thanks a lot:)

              1 Reply Last reply
              0

              • Login

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