[Interest] Converting std::string.c_str() code to use QString methods
Konstantin Tokarev
annulen at yandex.ru
Tue Sep 3 10:06:34 CEST 2013
03.09.2013, 08:00, "baneyue" <baneyue at gmail.com>:
> On Fri, Aug 30, 2013 at 03:08:42PM -0400, Michael Jackson wrote:
>
>> I have a large code base that we are migrating to more fully utilize Qt classes. Many places in the code have lines like the following:
>>
>> std::string path("/path/to/foo.txt");
>> FILE* f = fopen(path.c_str(), "wb");
>>
>> If the "path" variable is now declared as a QString which QString method would be me the equivalent as the "c_str()" of std::string?
>>
>> Not sure if I should be using "toASCII()" or "data()" or "toUtf8()" or what exactly.
>> Google didn't really give me a definitive answer.
>>
>> Many Thanks
>> --
>> Mike Jackson
>> imikejackson & gmail * com
>
> I think `path.toStdString().c_str() will fit you.
This is the worst way that could be imagined here.
--
Regards,
Konstantin
More information about the Interest
mailing list