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';
...
}
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".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With