Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. .c_str() is not coming up
Forum Updated to NodeBB v4.3 + New Features

.c_str() is not coming up

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
4 Posts 4 Posters 1.5k 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.
  • Q Offline
    Q Offline
    QTlearner90
    wrote on last edited by QTlearner90
    #1

    Hi,

    I want to perform
    ui->lineedit->text()->tostdstring().c_str();
    but when I wrote ui->lineedit->text()->tostdstring() , after that .cstr() is not coming up.
    How can i slove this??
    Thanks.

    jsulmJ aha_1980A 2 Replies Last reply
    0
    • KillerSmathK Offline
      KillerSmathK Offline
      KillerSmath
      wrote on last edited by KillerSmath
      #2

      include <string> on top of your file

      #include <QString>
      #include <string>
      ...
      
      QString string= "Apple";
      
      std::string s = string.toStdString();
      
      const char* c = s.c_str();
      

      @Computer Science Student - Brazil
      Web Developer and Researcher
      “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

      1 Reply Last reply
      1
      • Q QTlearner90

        Hi,

        I want to perform
        ui->lineedit->text()->tostdstring().c_str();
        but when I wrote ui->lineedit->text()->tostdstring() , after that .cstr() is not coming up.
        How can i slove this??
        Thanks.

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

        @QTlearner90 said in .c_str() is not coming up:

        How can i slove this??

        You can simply write it.
        Also, you can use http://doc.qt.io/qt-5/qstring.html#constData

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

        1 Reply Last reply
        1
        • Q QTlearner90

          Hi,

          I want to perform
          ui->lineedit->text()->tostdstring().c_str();
          but when I wrote ui->lineedit->text()->tostdstring() , after that .cstr() is not coming up.
          How can i slove this??
          Thanks.

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @QTlearner90

          you need case correct writing: it's toStdString

          the rest was already told in the answers before.

          Qt has to stay free or it will die.

          1 Reply Last reply
          2

          • Login

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