今天在Qt中开发程序时,遇到一个QString::toStdString()的内存问题,用法如下:

void test(const QString& theFileName)
{
    std::string aFileName = theFileName.toStdString();

    std::ofstream aFile(aFileName);
    aFile << aFileName;
    
}

在函数还没执行完就崩溃了,跟踪发现是std::string的问题。最后发现是因为引用的库的Runtime Library不同导致的,一个是MDd,一个是MTd,后来改成一致即可。

QString::toStdString() crashes

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-30
  • 2021-07-21
  • 2021-06-12
  • 2022-02-05
猜你喜欢
  • 2022-12-23
  • 2022-02-12
  • 2021-12-24
  • 2021-08-13
  • 2021-09-26
  • 2021-05-22
  • 2022-12-23
相关资源
相似解决方案