在Qt QDialog中使用fstat

时间:2012-10-10 08:06:41

标签: c++ c qt

好吧,我认为解决两个具有相同名称的功能时遇到问题,我不知道如何解决它。

我有一个Qt类,它是QDialog(Qt)的子类。我想使用'fstat'来获取有关该文件的信息,使用如下代码

struct stat file_info;
int hd = open("/home/test/file.xml", O_RDONLY);
fstat(hd, &file_info);
close(hd);

但是当我这样做时,我从编译器那里得到了这个抱怨。

error: no matching function for call to 'Test::open(const char [19], int)'
/usr/local/Trolltech/Qt-4.7.3/include/QtGui/qdialog.h::99:10: note: candidate is: void QDialog::open()

有什么方法可以解决这个问题吗?

感谢。

答案:

Caladan提到的那样,:: open()就可以了。第二个答案(使用stat而不是fstat)同样有效。谢谢!

2 个答案:

答案 0 :(得分:3)

您可以尝试调用:: open(),这将提示编译器不应该在当前范围内查找。

您也可以使用stat()来获取文件名而不是描述符。

答案 1 :(得分:0)

您是否包含这些头文件?

#include <sys/types.h> 
#include <sys/stat.h> 
#include <fcntl.h> 
相关问题