char * str = "Notice\0\0\0\0"; QString filePath(str); int index = filePath.indexOf(QChar::Null); if(-1 != index)filePath.truncate(index);