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. [solved] 'invalid conversion' issue
QtWS25 Last Chance

[solved] 'invalid conversion' issue

Scheduled Pinned Locked Moved C++ Gurus
3 Posts 2 Posters 1.4k 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.
  • McLionM Offline
    McLionM Offline
    McLion
    wrote on last edited by
    #1

    Hi,
    I am having a 'invalid conversion' that I don't understand:

    Function:
    @void LongToAsciiQbArrayLeadZ(QByteArray * cAscii, ulong lLongVal, char cNbr)
    {
    while(cNbr--)
    {
    cAscii[cNbr] = (char)((lLongVal ) + '0');
    lLongVal /= 10;
    }
    }
    @

    Call:
    @QByteArray qbTempArray;
    LongToAsciiQbArrayLeadZ(&qbTempArray, uLogCounter.l++, 10);@

    leads to:
    Warnung:array subscript has type 'char'
    Fehler:invalid conversion from 'char' to 'const char*'

    I just don't get what's wrong?
    Same works in native C with char array instead of QByteArray.
    Thanks, McL

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by
      #2

      Hi,

      try modifying the code like this
      @
      void LongToAsciiQbArrayLeadZ(QByteArray &cAscii, ulong lLongVal, char cNbr)
      {
      while(cNbr--)
      {
      cAscii[cNbr] = (char)((lLongVal ) + '0');
      lLongVal /= 10;
      }
      }
      @

      @
      QByteArray qbTempArray;
      LongToAsciiQbArrayLeadZ(qbTempArray, uLogCounter.l++, 10);
      @

      You used a QByteArray pointer.

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      1 Reply Last reply
      0
      • McLionM Offline
        McLionM Offline
        McLion
        wrote on last edited by
        #3

        Works a treat! Thanks :)

        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