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?

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.
  • EngelardE Offline
    EngelardE Offline
    Engelard
    wrote on 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);
    
    aha_1980A 1 Reply Last reply
    0
    • EngelardE Engelard

      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);
      
      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on 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
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on 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

        EngelardE 1 Reply Last reply
        6
        • VRoninV VRonin

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

          EngelardE Offline
          EngelardE Offline
          Engelard
          wrote on 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!

          JonBJ 1 Reply Last reply
          0
          • EngelardE Engelard

            @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!

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on 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

            • Login

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