ISTB
ISTB

Reputation: 1817

Qt and std::string

I have a strange problem. My tool is running properly when I open a file through my Qt file dialog. However, when I bind dlls from other library into my project in VS 2010, the tool crashes when I open a file. By debugging I discovered that it happens in the destructor of the basic string. The following line is causing the problem:

std::string inputFilename = aFilenames.at(i).toStdString();

where aFilenames is a QStringList. If instead I write:

std::string inputFilename = "C:\\test.txt";

then it works. What is then going wrong with std::string and why this happens when I bind dlls from another library into my project?

Upvotes: 0

Views: 1105

Answers (1)

Al2O3
Al2O3

Reputation: 3203

Try this:

string(aFilenames.at(i).toLocal8Bit())

Upvotes: 1

Related Questions