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. How to write in to QVector?
Forum Updated to NodeBB v4.3 + New Features

How to write in to QVector?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 4 Posters 848 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.
  • E Offline
    E Offline
    Engelard
    wrote on 8 Nov 2018, 17:25 last edited by
    #1

    WINAPI function ReadProcessMemory if succeeds write the result in to users single variable or an array, like this:

    char *tempByte = new char[memInfo.RegionSize];
    size_t ssss;
    ReadProcessMemory(currHandle, (LPVOID)addr, tempByte, memInfo.RegionSize, &ssss);
    

    Dynamic array of my chars is filled with correct data. Why i can't do the same with vectors, why only with default C++ array? Here is analog, it compiles, but crash program when i run it:

    QVector<char> tempByte;
    tempByte.resize(memInfo.RegionSize);
    size_t ssss;
    ReadProcessMemory(currHandle, (LPVOID)addr, &tempByte, memInfo.RegionSize, &ssss);
    
    A 1 Reply Last reply 8 Nov 2018, 17:44
    0
    • E Engelard
      8 Nov 2018, 17:25

      WINAPI function ReadProcessMemory if succeeds write the result in to users single variable or an array, like this:

      char *tempByte = new char[memInfo.RegionSize];
      size_t ssss;
      ReadProcessMemory(currHandle, (LPVOID)addr, tempByte, memInfo.RegionSize, &ssss);
      

      Dynamic array of my chars is filled with correct data. Why i can't do the same with vectors, why only with default C++ array? Here is analog, it compiles, but crash program when i run it:

      QVector<char> tempByte;
      tempByte.resize(memInfo.RegionSize);
      size_t ssss;
      ReadProcessMemory(currHandle, (LPVOID)addr, &tempByte, memInfo.RegionSize, &ssss);
      
      A Offline
      A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on 8 Nov 2018, 17:44 last edited by
      #2

      @Engelard Have your tried QVector::data()?

      "This function is mostly useful to pass a vector to a function that accepts a plain C++ array."

      Regards

      Qt has to stay free or it will die.

      1 Reply Last reply
      6
      • V Offline
        V Offline
        VRonin
        wrote on 8 Nov 2018, 17:54 last edited by
        #3

        Small side note, for this cases you normally would use QByteArray rather than QVector<char>

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        E 1 Reply Last reply 9 Nov 2018, 16:54
        6
        • V VRonin
          8 Nov 2018, 17:54

          Small side note, for this cases you normally would use QByteArray rather than QVector<char>

          E Offline
          E Offline
          Engelard
          wrote on 9 Nov 2018, 16:54 last edited by
          #4

          @VRonin i can't it rejects to compile, i've used byte array from std. Plus, i need to use that data in qSort and qBindariFind, it require array of int values, not raw bytes.

          @aha_1980 tnx!

          J 1 Reply Last reply 9 Nov 2018, 19:23
          0
          • E Engelard
            9 Nov 2018, 16:54

            @VRonin i can't it rejects to compile, i've used byte array from std. Plus, i need to use that data in qSort and qBindariFind, it require array of int values, not raw bytes.

            @aha_1980 tnx!

            J Offline
            J Offline
            JonB
            wrote on 9 Nov 2018, 19:23 last edited by
            #5

            @Engelard

            Plus, i need to use that data in qSort and qBindariFind, it require array of int values, not raw bytes.

            One thing. If you have some data which is an array of bytes or chars or a QByteArray from what you've been saying, and you now say you intend to use that data for sorts/finds "which require ints not bytes", it's strange data that you can treat as bytes or ints. Not impossible, but...?

            1 Reply Last reply
            0

            1/5

            8 Nov 2018, 17:25

            • Login

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