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 C++ lambdas affect Qt?

How C++ lambdas affect Qt?

Scheduled Pinned Locked Moved General and Desktop
10 Posts 5 Posters 6.9k 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
    baysmith
    wrote on last edited by
    #1

    I don't know about you, but I'm excited about the next "C++ standard":http://en.wikipedia.org/wiki/C++0x which should be coming out in the next year or two. Lambdas, auto, threading, ...

    But it makes me wonder how it will affect Qt. Especially lambdas. I see lambdas as having game-changing effect on how some code is written. The standard library looks to become much more useful with the help of lambdas. How about Qt? Will it be possible to use these powerful new capabilities with Qt?

    What is your opinion?

    Nokia Certified Qt Specialist.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dangelog
      wrote on last edited by
      #2

      That
      @
      connect(this, SIGNAL(foo(int)), [](int x) { /* ... */ })
      @
      would be simply awesome.

      Software Engineer
      KDAB (UK) Ltd., a KDAB Group company

      1 Reply Last reply
      0
      • ZlatomirZ Offline
        ZlatomirZ Offline
        Zlatomir
        wrote on last edited by
        #3

        My favorite c++0x feature are lambdas too, but i don't think they change that much the way we write code, they are more a "syntactic sugar" for functors, with the advantage that you can just define it "inline", or use smallest 0x feature: the "auto" to name the lambda ;)
        But there are other nice features in C++0x that Qt developers could benefit, like like: initializer lists, move semantics, support for concurrency (we already have that with Qt)

        Anyway 0x it's a good update to C++, and hopefully the next standard (with concepts) won't need another twelve years to complete.

        https://forum.qt.io/category/41/romanian

        1 Reply Last reply
        0
        • B Offline
          B Offline
          baysmith
          wrote on last edited by
          #4

          [quote author="Giuseppe D’Angelo" date="1292049262"]That
          @
          connect(this, SIGNAL(foo(int)), [](int x) { /* ... */ })
          @
          would be simply awesome.[/quote]

          I think this may be the primary use case that I would like to see, and that I would miss the most if not available.

          Nokia Certified Qt Specialist.

          1 Reply Last reply
          0
          • B Offline
            B Offline
            baysmith
            wrote on last edited by
            #5

            [quote author="Zlatomir" date="1292049421"]My favorite c++0x feature are lambdas too, but i don't think they change that much the way we write code, they are more a "syntactic sugar" for functors, with the advantage that you can just define it "inline", or use smallest 0x feature: the "auto" to name the lambda ;)[/quote]

            Have you see Herb Sutter's talk "Lambdas, Lambdas Everywhere":http://bit.ly/dcJcXN? I think it shows how many ways lambdas are useful. Yes, it is just syntactic sugar, but it is very very sweet.

            [quote author="Zlatomir" date="1292049421"]
            But there are other nice features in C++0x that Qt developers could benefit, like like: initializer lists, move semantics, support for concurrency (we already have that with Qt)[/quote]

            I like those too, but I think lambdas may have more impact on how code is written. That is why I specifically selected lambdas for the topic, rather than general C++0x.

            Nokia Certified Qt Specialist.

            1 Reply Last reply
            0
            • ZlatomirZ Offline
              ZlatomirZ Offline
              Zlatomir
              wrote on last edited by
              #6

              That looks nice, but don't forget that signals and slots are member functions.
              Signal/slot mechanism provide inter-object function calls, if you just want to call a functor/lambda/"free" function you don't need signal/slots overhead for that, you just call it.

              LE:
              @Bradley: i didn't see Herb Sutter’s talk, thanks for the link

              https://forum.qt.io/category/41/romanian

              1 Reply Last reply
              0
              • B Offline
                B Offline
                baysmith
                wrote on last edited by
                #7

                Connecting a signal to a lambda would also provide inter-object calls because lambdas capture values in the local scope.

                Nokia Certified Qt Specialist.

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  milot.shala
                  wrote on last edited by
                  #8

                  [quote author="Giuseppe D’Angelo" date="1292049262"]That
                  @
                  connect(this, SIGNAL(foo(int)), [](int x) { /* ... */ })
                  @
                  would be simply awesome.[/quote]

                  Yes indeed! :D

                  1 Reply Last reply
                  0
                  • W Offline
                    W Offline
                    w00t
                    wrote on last edited by
                    #9

                    [quote author="Giuseppe D’Angelo" date="1292049262"]That
                    @
                    connect(this, SIGNAL(foo(int)), [](int x) { /* ... */ })
                    @
                    would be simply awesome.[/quote]

                    Don't know if you knew, but Thiago has a patch working towards allowing exactly that :)

                    --
                    http://rburchell.com

                    1 Reply Last reply
                    0
                    • B Offline
                      B Offline
                      baysmith
                      wrote on last edited by
                      #10

                      [quote author="Robin Burchell" date="1292087574"]Don't know if you knew, but Thiago has a patch working towards allowing exactly that :)[/quote]

                      No, I didn't. Where does he talk about it? Is it available somewhere?

                      Nokia Certified Qt Specialist.

                      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