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. [Solved] invalid conversion from 'char' to 'char*'
Forum Updated to NodeBB v4.3 + New Features

[Solved] invalid conversion from 'char' to 'char*'

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 6.2k Views 1 Watching
  • 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.
  • Y Offline
    Y Offline
    Yash
    wrote on last edited by
    #1

    @char *argv[30];
    QStringList m; m <<"dd" <<"ss";

    for (int i = 0; i < m.count (); i++)
    argv[i] = (m.at (i).data ())->toLatin1 ();@

    error: invalid conversion from 'char' to 'char*'

    Where should I put & ?

    http://kineticwing.com : Web IDE, QSS Editor
    http://speedovation.com : Development Lab

    1 Reply Last reply
    0
    • T Offline
      T Offline
      t3chNo
      wrote on last edited by
      #2

      @(m.at (i).data ())@ returns QChar*

      @->toLatin1 ()@ returns char. argv[i] is char*.

      i think you want sth like this:
      @argv[i] = m.at(i).toLocal8Bit().data()@

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dangelog
        wrote on last edited by
        #3

        [quote author="t3chNo" date="1293294118"]@(m.at (i).data ())@ returns QChar*

        @->toLatin1 ()@ returns char. argv[i] is char*.

        i think you want sth like this:
        @argv[i] = m.at(i).toLocal8Bit().data()@[/quote]

        ... which is completely invalid, you can't store what data() returns!

        Software Engineer
        KDAB (UK) Ltd., a KDAB Group company

        1 Reply Last reply
        0
        • I Offline
          I Offline
          Immii
          wrote on last edited by
          #4

          There is one FAQ about the conversion of" QString to char":http://developer.qt.nokia.com/faq/answer/how_can_i_convert_a_qstring_to_char_and_vice_versa see if this is of any help to you.

          1 Reply Last reply
          0
          • T Offline
            T Offline
            t3chNo
            wrote on last edited by
            #5

            yes, sorry. proper way is:
            @argv[i] = new char[32];
            strncpy(argv[i], m.at(i).toLocal8Bit().data(), 32);@
            [quote author="peppe" date="1293299729"]
            [quote author="t3chNo" date="1293294118"]@(m.at (i).data ())@ returns QChar*

            @->toLatin1 ()@ returns char. argv[i] is char*.

            i think you want sth like this:
            @argv[i] = m.at(i).toLocal8Bit().data()@[/quote]

            ... which is completely invalid, you can't store what data() returns!
            [/quote]

            1 Reply Last reply
            0
            • Y Offline
              Y Offline
              Yash
              wrote on last edited by
              #6

              It's working :) Thanks
              [quote author="t3chNo" date="1293305300"]yes, sorry. proper way is:
              @argv[i] = new char[32];
              strncpy(argv[i], m.at(i).toLocal8Bit().data(), 32);@
              [quote author="peppe" date="1293299729"]
              [quote author="t3chNo" date="1293294118"]@(m.at (i).data ())@ returns QChar*

              @->toLatin1 ()@ returns char. argv[i] is char*.

              i think you want sth like this:
              @argv[i] = m.at(i).toLocal8Bit().data()@[/quote]

              ... which is completely invalid, you can't store what data() returns!
              [/quote]

              [/quote]

              http://kineticwing.com : Web IDE, QSS Editor
              http://speedovation.com : Development Lab

              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