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. QByteArray error
Qt 6.11 is out! See what's new in the release blog

QByteArray error

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 5.5k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    this line of code gave me the error : expected primary-expression before ‘)’ token

    @
    QByteArray buff = new QByteArray(cnt, Qt::Initialization);
    @

    how come? cnt is an input passed into the function...

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tony
      wrote on last edited by
      #2

      Hi,

      QByteArray has these four constructors:

      @
      QByteArray ()
      QByteArray ( const char * str )
      QByteArray ( const char * data, int size )
      QByteArray ( int size, char ch )
      @

      I cannot find Qt::Initialization in Qt documentation, so I guess you're using QByteArray in a wrong way. Maybe you mean QByteArray(cnt)????

      T.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        I see that in the document as well but when I am programming, the intellisense pops up with 7 constructors...

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tony
          wrote on last edited by
          #4

          I see ...

          anyway, Qt documentation comes first when you need to check if you're right or wrong :)

          T.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            alexander
            wrote on last edited by
            #5

            phamtv, this constructor constructs a byte array with uninitialized contents. For internal usage.

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              You are also assigning a pointer to a non-pointer... but I guess that is not the issue you are asking about:-)

              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