Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. I want to understand when we need to write code like below ? i want to know purpose of it ?
Qt 6.11 is out! See what's new in the release blog

I want to understand when we need to write code like below ? i want to know purpose of it ?

Scheduled Pinned Locked Moved Solved C++ Gurus
4 Posts 3 Posters 995 Views
  • 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

    can any body explain me below code ?

        std::vector<unsigned char> VectorResponseData;
        VectorResponseData = txnContext->getPrivateData(); // may be json data
        std::string StrReSponseData(VectorResponseData.begin(),VectorResponseData.end());
    
    JonBJ 1 Reply Last reply
    0
    • Q Qt embedded developer

      can any body explain me below code ?

          std::vector<unsigned char> VectorResponseData;
          VectorResponseData = txnContext->getPrivateData(); // may be json data
          std::string StrReSponseData(VectorResponseData.begin(),VectorResponseData.end());
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Qt-embedded-developer
      What is there to ask? It gets an array of unsigned char into a std::vector, and then builds a std::string out of all the characters.

      Q 1 Reply Last reply
      2
      • JonBJ JonB

        @Qt-embedded-developer
        What is there to ask? It gets an array of unsigned char into a std::vector, and then builds a std::string out of all the characters.

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

        @JonB i want to know when we need to do this type of conversation in real time ?

        is it used for dynamic array data to store into string format ?

        Christian EhrlicherC 1 Reply Last reply
        0
        • Q Qt embedded developer

          @JonB i want to know when we need to do this type of conversation in real time ?

          is it used for dynamic array data to store into string format ?

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Qt-embedded-developer said in I want to understand when we need to write code like below ? i want to know purpose of it ?:

          in real time ?

          What should this mean?

          is it used for dynamic array data to store into string format ?

          No, it copies al elements from VectorResponseData.begin() to VectorResponseData.end() into a std::string as explained in the documentation (7. ctor) ...

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          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