Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. what is way to use array in qt like c ?
Qt 6.11 is out! See what's new in the release blog

what is way to use array in qt like c ?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
4 Posts 2 Posters 480 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.
  • Q Offline
    Q Offline
    Qt embedded developer
    wrote on last edited by
    #1

    How to use below type of array in qt class.
    how to declare it in header file ?
    how to initialize it in constructor of qt ?
    int arr[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

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

      Since it's a fixed size array, just declare it with the right size and then initialize it in the constructor.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi,

        Qt is a C++ framework so there's nothing special to be done.

        Declare the variable as member of your class and initialize the way you need it in the constructor.

        Note that you may want to use a container like a QVector or std::vector to store your data depending on what you are going to do with it.

        What are you going to use it for ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        Q 1 Reply Last reply
        2
        • SGaistS SGaist

          Hi,

          Qt is a C++ framework so there's nothing special to be done.

          Declare the variable as member of your class and initialize the way you need it in the constructor.

          Note that you may want to use a container like a QVector or std::vector to store your data depending on what you are going to do with it.

          What are you going to use it for ?

          Q Offline
          Q Offline
          Qt embedded developer
          wrote on last edited by
          #3

          @SGaist

          i want to use this array to find moving average of 15 data which comes from i2c device

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

            Since it's a fixed size array, just declare it with the right size and then initialize it in the constructor.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            2

            • Login

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