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. copying byte to Qstring
Qt 6.11 is out! See what's new in the release blog

copying byte to Qstring

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 726 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.
  • S Offline
    S Offline
    seok
    wrote on last edited by
    #1

    hi
    i am getting an error while using the strcpy

    strcpy(arr[i][j], str); here arr is a 2D array and str is Qstring

    i tried using qstrcpy also still the same error
    error says i cannot copy a connst char * to QString

    i canot change the data type of both of them because it is used in many places in the prooject and i need arr as 2D array only same with the str also i cannot change its datatype

    this is very urgent please someone help me out thanks in advance

    jsulmJ 1 Reply Last reply
    0
    • ahmad122A Offline
      ahmad122A Offline
      ahmad122
      wrote on last edited by
      #2

      @seok said in copying byte to Qstring:

      strcpy(arr[i][j]
      Try using this one:
      strcpy(arr[i][j], str.toStdString().c_str());
      or
      qstrcpy(arr[i][j], str.toStdString().c_str());

      S 1 Reply Last reply
      0
      • ahmad122A ahmad122

        @seok said in copying byte to Qstring:

        strcpy(arr[i][j]
        Try using this one:
        strcpy(arr[i][j], str.toStdString().c_str());
        or
        qstrcpy(arr[i][j], str.toStdString().c_str());

        S Offline
        S Offline
        seok
        wrote on last edited by
        #3

        @ahmad122 i will try this thank you

        1 Reply Last reply
        0
        • S seok

          hi
          i am getting an error while using the strcpy

          strcpy(arr[i][j], str); here arr is a 2D array and str is Qstring

          i tried using qstrcpy also still the same error
          error says i cannot copy a connst char * to QString

          i canot change the data type of both of them because it is used in many places in the prooject and i need arr as 2D array only same with the str also i cannot change its datatype

          this is very urgent please someone help me out thanks in advance

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

          @seok said in copying byte to Qstring:

          error says i cannot copy a connst char * to QString

          Of course, strcpy has no idea what QString is (check its signature).
          Why do you want to use strcpy in a C++ Qt application?
          You can use https://doc.qt.io/qt-5/qstring.html#append-1 instead.

          str.append(QChar(arr[i][j]));
          

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

          1 Reply Last reply
          5

          • Login

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