Results 1 to 2 of 2

Thread: cannot convert from 'std::_String_iterator<_Elem,_Traits,_Alloc>' to 'char *

  1. #1
    Join Date
    Sep 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: cannot convert from 'std::_String_iterator<_Elem,_Traits,_Alloc>' to 'char *

    hi all

    i have that problem
    cannot convert from 'std::_String_iterator<_Elem,_Traits,_Alloc>' to 'char *

    i try to used Gsoup to send user name & password SP to my webservice

    std::string stds;
    stds=ui->lineEmail->text().toStdString() + ";"+ui->linePassword->text().toStdString();

    v->param= stds; // problem in here
    v->procedure="Sp_LogIn";



    can any one help me


    Added after 8 minutes:


    solution

    QString str1 =stds.c_str();
    QByteArray ba = str1.toLatin1();
    char *c_str2 = ba.data();
    v->param=c_str2 ;
    thanks for all
    Last edited by raed; 22nd September 2011 at 15:26.

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: cannot convert from 'std::_String_iterator<_Elem,_Traits,_Alloc>' to 'char *

    This seems tricky:

    Qt Code:
    1. v->param = ba.data();
    To copy to clipboard, switch view to plain text mode 

    From the error message you gave earlier it seems v->param is of type char*. If that is true, then
    Qt Code:
    1. {
    2. // ...
    3. v->param = ba.data();
    4. }
    5. // v->param is a dangling pointer here
    To copy to clipboard, switch view to plain text mode 

    If v is only used in the same scope the byte array is used (the byte array exists as long as you use v) you should be ok though.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

Similar Threads

  1. How to convert int to char?
    By Bong.Da.City in forum Newbie
    Replies: 12
    Last Post: 9th January 2015, 19:45
  2. Replies: 4
    Last Post: 30th April 2013, 00:49
  3. How to convert unsigned char[] to char *?
    By Gokulnathvc in forum Newbie
    Replies: 2
    Last Post: 29th April 2011, 08:58
  4. How to convert QString to char *
    By rajeshs in forum Qt Programming
    Replies: 7
    Last Post: 27th September 2007, 10:32
  5. How to convert wchar_t* into char*??
    By shailesh in forum Qt Programming
    Replies: 3
    Last Post: 22nd June 2006, 12:39

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.