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. QString::QString(const QByteArray &ba) copying full array.

QString::QString(const QByteArray &ba) copying full array.

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

    Is there some method or contructor or function that copy from QByteArray to Qstring WHITOUT stopping at the first 0 byte??.
    I need to convert QByteArray to qstring and to have a full lenght converted. Since my QByteArray contains some zeros, actrually using QString contructor from const QBytearray will truncate my QBytearray to first 0.
    Is there some way to do that??

    Thanks

    jsulmJ 1 Reply Last reply
    0
    • E emazed

      Is there some method or contructor or function that copy from QByteArray to Qstring WHITOUT stopping at the first 0 byte??.
      I need to convert QByteArray to qstring and to have a full lenght converted. Since my QByteArray contains some zeros, actrually using QString contructor from const QBytearray will truncate my QBytearray to first 0.
      Is there some way to do that??

      Thanks

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

      @emazed How should the resulting string look like? I mean, what should happen with the 0 bytes?

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

      1 Reply Last reply
      3
      • M Offline
        M Offline
        mpergand
        wrote on last edited by
        #3
        const char bytes[]="Hello\0 World";
        QByteArray data(bytes,sizeof(bytes));
        QList<QByteArray> list=data.split('\0');
        QString str=list.join();
        qDebug()<<str;   // -> "Hello World"
        
        1 Reply Last reply
        1

        • Login

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