开发者

Failling Qt application on Ubuntu

I have Ubuntu 10.04 and have the Qt library install. When I run the code

#include <QDir>
#include <QFileInfo>

#include <QtDebug>

int main( int argc, char **argv )
{
    foreach( QFileInfo drive, QDir::drives() )
    {
        qDebug() << "Drive: " << drive.absolutePath();

        QDir dir = drive.dir();
        dir.setFilter( QDir::Dirs );

        foreach( QFileInfo rootDirs, dir.entryInfoList() )
            qDebug() << "  " << rootDirs.fileName();
    }

    return 0;
}

I get the following errors.

g++ qt.cpp -o test
qt.cpp:1:16: error: QDir: No such file or directory
qt.cpp:2:21: error: QFi开发者_开发技巧leInfo: No such file or directory
qt.cpp:4:19: error: QtDebug: No such file or directory
qt.cpp: In function ‘int main(int, char**)’:
qt.cpp:8: error: ‘QFileInfo’ was not declared in this scope
qt.cpp:8: error: ‘QDir’ has not been declared
qt.cpp:8: error: ‘foreach’ was not declared in this scope
qt.cpp:9: error: expected ‘;’ before ‘{’ token

How do I fix this problem?


g++ seems to not find Qt includes files.

You should add an include directory when compiling. and linked with the Qt library.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜