有其具備以下功能類:問題與qDebug和QString的const引用
FileInfoWrapper(const QFileInfo &_fileInfo) : fileInfo(_fileInfo) {}
const QString& FileName() const { return fileInfo.fileName(); }
但是,當我這樣做:
QFileInfo info(somePath);
qDebug() << info.absoluteDir(); // works
FileInfoWrapper test(info);
qDebug() << test.FileName(); // this crashes the entire application
當我從字符串返回刪除常量&,有用。這就像< <不適用於參考。什麼是錯的,爲什麼會崩潰?
哦是的!謝謝 – chikuba 2012-02-16 07:51:42