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. Circular buffer in Qt
Forum Updated to NodeBB v4.3 + New Features

Circular buffer in Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 5 Posters 4.3k 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.
  • A Offline
    A Offline
    Andrew23
    wrote on last edited by
    #1

    I need to use an circular buffer and I found the QCircularBuffer class which seems to be the solution. But I noticed that it is a part of Qt3D library like it is a class defined for 3D applications. Maybe I'm wrong but since I think that a circular buffer is a common component in most applications (comunications for example, like in mine) I have a doubt in the use of the QCircularBuffer in my application. Maybe is there another class other than QCircularBuffer which define a circular buffer?

    JonBJ 1 Reply Last reply
    0
    • A Andrew23

      I need to use an circular buffer and I found the QCircularBuffer class which seems to be the solution. But I noticed that it is a part of Qt3D library like it is a class defined for 3D applications. Maybe I'm wrong but since I think that a circular buffer is a common component in most applications (comunications for example, like in mine) I have a doubt in the use of the QCircularBuffer in my application. Maybe is there another class other than QCircularBuffer which define a circular buffer?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Andrew23 said in Circular buffer in Qt:

      Maybe is there another class other than QCircularBuffer which define a circular buffer?

      I think not, because https://stackoverflow.com/questions/45415745/qcircularbuffer-functionality-without-qt3d offers you proposed code without 3D?

      There was also a discussion of this > 9 years ago: https://development.qt-project.narkive.com/VWc3Ab98/new-circular-buffer-container-for-qt5 :)

      There is also a circular buffer in Boost C++ libraries, https://www.qtcentre.org/threads/66466-qt-way-of-having-a-ring-or-circular-buffer-set

      1 Reply Last reply
      0
      • fcarneyF Offline
        fcarneyF Offline
        fcarney
        wrote on last edited by
        #3

        I would just write a templated class using QVector and 2 index variables to track head and tail. I say use QVector and preallocate the space and just read and write to locations. An empty buffer would just be head and tail pointing to the same index. If this is templated you can use it for more than one data type easily.

        C++ is a perfectly valid school of magic.

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

          since it is wholely implmented in templates I wrapped boost::circular_buffer in a class that adds a semaphore lock and called it good.

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DannySW
            wrote on last edited by
            #5

            I was looking for this, shame it is not considered standard!

            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