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 use QString object in string operations.??
Forum Updated to NodeBB v4.3 + New Features

How to use QString object in string operations.??

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 2.0k 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.
  • A Offline
    A Offline
    aekam
    wrote on last edited by
    #1

    Hello,
    I want to use QString in string operations like say strCpy (char *dest, const char *source).
    i have a normal array @string1[10]@ as destination and QString string2 as source.

    It gives me error, that QString can't be converted to char *, even though i used string2.constData().

    any solution.??

    [[moved from Qt Quick forum, Tobias]]

    If you take care of inches, you won't have to worry about miles... :)

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Might be that const data is too const for the compiler here :) Make a copy of it, or use QString::toUtf8().data().

      Or just use QStrings only, they are powerful.

      (Z(:^

      1 Reply Last reply
      0
      • G Offline
        G Offline
        guziemic
        wrote on last edited by
        #3

        Try to convert to Utf8 and then take pointer to char
        @
        string2.toUtf8().constData()
        @

        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