Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. UDP data + circular buffer
Qt 6.12 LTS is out! See what's new in the release blog

UDP data + circular buffer

Scheduled Pinned Locked Moved Solved General and Desktop
15 Posts 5 Posters 5.2k 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.
  • jsulmJ jsulm

    @Chanchan You will need to implement the circular buffer by yourself or find existing one. As far as I know Qt does not have such a container.

    J.HilkJ Offline
    J.HilkJ Offline
    J.Hilk
    Moderators
    wrote on last edited by
    #5

    @jsulm actually, I quick google search resulted in this surprise class

    https://doc.qt.io/archives/qt-5.5/qt3d-qcircularbuffer.html#details

    it's part of qt3d, which would explain, why I haven't heard of it before.


    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.

    jsulmJ C 2 Replies Last reply
    1
    • J.HilkJ J.Hilk

      @jsulm actually, I quick google search resulted in this surprise class

      https://doc.qt.io/archives/qt-5.5/qt3d-qcircularbuffer.html#details

      it's part of qt3d, which would explain, why I haven't heard of it before.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #6

      @J.Hilk Yes, I saw it.
      But I'm not sure why it is part of Qt3D module?! And is it still there in recent versions?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

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

        @jsulm actually, I quick google search resulted in this surprise class

        https://doc.qt.io/archives/qt-5.5/qt3d-qcircularbuffer.html#details

        it's part of qt3d, which would explain, why I haven't heard of it before.

        C Offline
        C Offline
        Chanchan
        wrote on last edited by
        #7

        @J.Hilk
        Yes I saw this page, I tried to implement it to my example but I didn't succeed :/

        1 Reply Last reply
        0
        • jsulmJ jsulm

          @J.Hilk Yes, I saw it.
          But I'm not sure why it is part of Qt3D module?! And is it still there in recent versions?

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #8

          @jsulm said in UDP data + circular buffer:

          And is it still there in recent versions

          that's a god point, I can't find it in the 5.12 docs. Therefore I don't think so ?

          Anyway a basic circular buff is like 40 lines. One should be able to do create on fairly easily with based on e.g. QVector.


          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.

          1 Reply Last reply
          1
          • C Offline
            C Offline
            Chanchan
            wrote on last edited by Chanchan
            #9

            Ok, I will try found it and integrate to my code
            I have another problem but I prefer to open another thread for it ^^
            Thank you :)

            aha_1980A 1 Reply Last reply
            0
            • Kent-DorfmanK Offline
              Kent-DorfmanK Offline
              Kent-Dorfman
              wrote on last edited by Kent-Dorfman
              #10

              Ring buffers are only applicable in specialized situations where you need a container of constant memory footprint and quick deque access of elements (such as hardware device I/O. I can see such a thing being in the 3d graphics modules, but its utility in the general framework is very limited. The buffering of incoming UDP is such a case where its utility is valid. There are many online references describing how to implement the ring buffer container.

              EDIT: a gotcha that the op needs to be aware of is that you CANNOT create a ring buffer of n characters and expect to access sequences of those characters. each element must be explicitly accessed as a single operation. The reason is that when the head/tail loops back to element n[0] the sequence of characters is no longer contiguous.

              The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

              1 Reply Last reply
              0
              • C Chanchan

                Ok, I will try found it and integrate to my code
                I have another problem but I prefer to open another thread for it ^^
                Thank you :)

                aha_1980A Offline
                aha_1980A Offline
                aha_1980
                Lifetime Qt Champion
                wrote on last edited by
                #11

                @Chanchan and @J-Hilk: I might be wrong, but isn't QQueue exactly what you want?

                Qt has to stay free or it will die.

                J.HilkJ 1 Reply Last reply
                0
                • jsulmJ jsulm

                  @Chanchan You will need to implement the circular buffer by yourself or find existing one. As far as I know Qt does not have such a container.

                  aha_1980A Offline
                  aha_1980A Offline
                  aha_1980
                  Lifetime Qt Champion
                  wrote on last edited by
                  #12

                  @jsulm said in UDP data + circular buffer:

                  @Chanchan You will need to implement the circular buffer by yourself or find existing one. As far as I know Qt does not have such a container.

                  As said above, there is QQueue.

                  Qt has to stay free or it will die.

                  1 Reply Last reply
                  0
                  • aha_1980A aha_1980

                    @Chanchan and @J-Hilk: I might be wrong, but isn't QQueue exactly what you want?

                    J.HilkJ Offline
                    J.HilkJ Offline
                    J.Hilk
                    Moderators
                    wrote on last edited by
                    #13

                    @aha_1980 It's probably a better starting point, but the QQueue is not limited in size -> No circular buffer, right?


                    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.

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

                      @aha_1980 It's probably a better starting point, but the QQueue is not limited in size -> No circular buffer, right?

                      aha_1980A Offline
                      aha_1980A Offline
                      aha_1980
                      Lifetime Qt Champion
                      wrote on last edited by
                      #14

                      @J.Hilk said in UDP data + circular buffer:

                      QQueue is not limited in size

                      Correct. If you need this behavior, you have to check size() before enqueue().

                      Qt has to stay free or it will die.

                      1 Reply Last reply
                      1
                      • C Offline
                        C Offline
                        Chanchan
                        wrote on last edited by
                        #15

                        Actually my case is :
                        I receive a lot of UDP data, I have to implement a process function to transfert these data to the good function, this function will implement datas, etc...
                        For this I need a circular buffer, I will take a look on your tips, thank you :)

                        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
                        • Unsolved