Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QLibraryInfo doesn't seem to load qt.conf

Tags:

c++

windows

qt

I jsut installed Qt 4.7.2 and I'm trying to use the QLibraryInfo class. My problem is that QLibraryInfo::location(QLibraryInfo::PrefixPath) always returns C:\work3\qt-4.7-vs2010-x86 which doesn't exist on my generation machine (should be C:\Qt\qt-4.7.2).

According to the documentation I tried to create a qt.conf file alongside my program, but the problem still remains. Here's its content:

[Paths]
Prefix=C:/Qt/qt-4.7.2/

For now I used a symlink to bypass the issue, but I'd like to know if there's a proper solution. Thanks.

EDIT Here's the program using the 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';

...
}
like image 617
gregseth Avatar asked Nov 06 '22 01:11

gregseth


1 Answers

A QCoreApplication must be created because that is how the QLibraryInfo is able to determine the application directory (QCoreApplication::applicationDirPath()) from which to load the qt.conf file. Alternatively, the qt.conf can be built into the application as a resource with the path ":/qt/etc/qt.conf".

like image 98
baysmith Avatar answered Nov 09 '22 14:11

baysmith