QLibraryInfoQLibraryInfo::location(QLibraryInfo::PrefixPath)C:\work3\qt-4.7-vs2010-x86C:\Qt\qt-4.7.2qt.conf
[Paths]
Prefix=C:/Qt/qt-4.7.2/

现在我使用了一个符号链接来绕过这个问题,但是我想知道是否有一个合适的解决方案。
谢谢。
编辑
下面是使用
QLibraryInfo
的程序:
int main(int argc, char ** argv)
{
    QCoreApplication app(argc, argv); //< added after Piotr's suggestion

    QFile outf("qtdirs.out");

    if (!outf.open(QIODevice::WriteOnly|QIODevice::Truncate|QIODevice::Text))
        return 1;

    QTextStream out(&outf);

    out << QLibraryInfo::location(QLibraryInfo::PrefixPath) << '\n';
    out << QLibraryInfo::location(QLibraryInfo::HeadersPath) << '\n';

...
}

最佳答案:

QCoreApplication::applicationDirPath()