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. How to match different paras for signal and slots using new functional-style "connect"?
Forum Updated to NodeBB v4.3 + New Features

How to match different paras for signal and slots using new functional-style "connect"?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 1.6k Views 2 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.
  • goldenhawkingG Offline
    goldenhawkingG Offline
    goldenhawking
    wrote on last edited by
    #1

    Hello !
    In Qt4, we know that we can connect a signal which have more parameters than a slot :

    connect(timer, SIGNAL(timeout()), widget, SLOT(update()));
    

    timer is a QTimer object pointer, and widget is a QWidget.

    However , it seems that new functional style connect requires signal and slot functions have same parameters table.

    connect (timer, &QTimer::timeout, widget, &MyWidget::update);
    

    The code above fired a compiler error, that is caused by Exact Match Parameter Table.

    Question1:
    For qt5 new functional style connect, how to deal with function overload and different paras connection?
    Question2:
    Will old style connect (using marco) be supported in future?

    Thanks!

    Qt is the best C++ framework I've ever met.

    joeQJ 1 Reply Last reply
    0
    • goldenhawkingG goldenhawking

      Hello !
      In Qt4, we know that we can connect a signal which have more parameters than a slot :

      connect(timer, SIGNAL(timeout()), widget, SLOT(update()));
      

      timer is a QTimer object pointer, and widget is a QWidget.

      However , it seems that new functional style connect requires signal and slot functions have same parameters table.

      connect (timer, &QTimer::timeout, widget, &MyWidget::update);
      

      The code above fired a compiler error, that is caused by Exact Match Parameter Table.

      Question1:
      For qt5 new functional style connect, how to deal with function overload and different paras connection?
      Question2:
      Will old style connect (using marco) be supported in future?

      Thanks!

      joeQJ Offline
      joeQJ Offline
      joeQ
      wrote on last edited by
      #2

      @goldenhawking Hi,friend. Welcome.

      You can see this thread About signal and slots in Qt4 and Qt5.

      If I remember correctly, you should be a Chinese teacher. So, i find Chinese blog from cnblog for you. cnblog Qt Signal and slot.

      End, if you want to get more information, you could search signal and slot in Qt help manual.

      Just do it!

      goldenhawkingG 1 Reply Last reply
      3
      • joeQJ joeQ

        @goldenhawking Hi,friend. Welcome.

        You can see this thread About signal and slots in Qt4 and Qt5.

        If I remember correctly, you should be a Chinese teacher. So, i find Chinese blog from cnblog for you. cnblog Qt Signal and slot.

        End, if you want to get more information, you could search signal and slot in Qt help manual.

        goldenhawkingG Offline
        goldenhawkingG Offline
        goldenhawking
        wrote on last edited by
        #3

        @joeQ said in How to match different paras for signal and slots using new functional-style "connect"?:

        cnblog

        thanks!

        Qt is the best C++ framework I've ever met.

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          Will old style connect (using marco) be supported in future?

          Maybe in some distant future it will be removed
          but it will break heaps of code so i be surprised
          if they removed anytime soon.

          But it would make porting 4.X code to 5.X extra complicated so
          i really doubt it will be removed in this decade.

          The real benefit of the new syntax is that it fails at compile time and not
          runtime.
          Also Docs says

          Connecting C++ Objects to QML Objects
          
          The string-based syntax can connect C++ objects to QML objects, but the functor-based syntax cannot. 
          

          So that give me some reassurance as long as widgets exists.

          http://doc.qt.io/qt-5/signalsandslots-syntaxes.html

          goldenhawkingG 1 Reply Last reply
          2
          • mrjjM mrjj

            Will old style connect (using marco) be supported in future?

            Maybe in some distant future it will be removed
            but it will break heaps of code so i be surprised
            if they removed anytime soon.

            But it would make porting 4.X code to 5.X extra complicated so
            i really doubt it will be removed in this decade.

            The real benefit of the new syntax is that it fails at compile time and not
            runtime.
            Also Docs says

            Connecting C++ Objects to QML Objects
            
            The string-based syntax can connect C++ objects to QML objects, but the functor-based syntax cannot. 
            

            So that give me some reassurance as long as widgets exists.

            http://doc.qt.io/qt-5/signalsandslots-syntaxes.html

            goldenhawkingG Offline
            goldenhawkingG Offline
            goldenhawking
            wrote on last edited by
            #5

            @mrjj said in How to match different paras for signal and slots using new functional-style "connect"?:

            ome rea

            Thank you very much of these answers!

            Qt is the best C++ framework I've ever met.

            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