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

efficiently concatinate

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 903 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.
  • D Offline
    D Offline
    dit8
    wrote on last edited by
    #1

    say I have code looking like:
    QByteArray param = "two";
    QByteArray newStr = "one";
    newStr.append(param).append(" three");

    on each append I suppose there is a reallocation taking place. is there a solution taht enables be to have a single alloaction.

    reserve seems like uncompurtable option.
    I know of QStringBuilder - is there an equivalent for QByteArray?

    thanks!

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

      Hi! You're lucky because QStringBuilder already supports QByteArray :-)

      #include <QStringBuilder>
      #include <QDebug>
      // ...
      QByteArray  say("say");
      QByteArray  hello("hello");
      QByteArray  world("world");
      QByteArray  message =  say % hello % world;
      qDebug() << message;
      

      See also String concatenation with QStringBuilder by Olivier Goffart.

      1 Reply Last reply
      5
      • D Offline
        D Offline
        dit8
        wrote on last edited by
        #3

        thanks! thats great. I was not aware of that

        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