17#include "private/qglobal_p.h"
22# include "private/qcore_mac_p.h"
25#if QT_CONFIG(relocatable) && QT_CONFIG(dlopen) && !QT_CONFIG(framework)
29#if QT_CONFIG(relocatable) && defined(Q_OS_WIN)
39#if QT_CONFIG(settings)
43struct QLibrarySettings
52 bool reloadOnQAppAvailable;
56QLibrarySettings::QLibrarySettings() :
paths(
false), reloadOnQAppAvailable(
false)
61QSettings *QLibrarySettings::configuration()
68bool QLibrarySettings::havePaths()
75void QLibrarySettings::load()
85 paths = !children.contains(
"Platforms"_L1)
86 || children.contains(
"Paths"_L1);
92 if (QLibraryInfoPrivate::qtconfManualPath)
99 CFBundleRef bundleRef = CFBundleGetMainBundle();
106 QCFString path = CFURLCopyFileSystemPath(urlRef, kCFURLPOSIXPathStyle);
115 qtconfig = pwd.filePath(u
"qt" QT_STRINGIFY(QT_VERSION_MAJOR)
".conf"_s);
118 qtconfig = pwd.filePath(
"qt.conf"_L1);
125const QString *QLibraryInfoPrivate::qtconfManualPath =
nullptr;
127QSettings *QLibraryInfoPrivate::configuration()
129 QLibrarySettings *ls = qt_library_settings();
130 return ls ? ls->configuration() :
nullptr;
133void QLibraryInfoPrivate::reload()
135 if (qt_library_settings.exists())
136 qt_library_settings->load();
139static bool havePaths() {
140 QLibrarySettings *ls = qt_library_settings();
141 return ls && ls->havePaths();
171QLibraryInfo::QLibraryInfo()
174#if defined(Q_CC_CLANG)
175# define COMPILER_STRING __VERSION__
176#elif defined(Q_CC_GHS)
177# define COMPILER_STRING "GHS " QT_STRINGIFY(__GHS_VERSION_NUMBER)
178#elif defined(Q_CC_GNU)
179# define COMPILER_STRING "GCC " __VERSION__
180#elif defined(Q_CC_MSVC)
182# define COMPILER_STRING "MSVC 2015"
183# elif _MSC_VER < 1917
184# define COMPILER_STRING "MSVC 2017"
185# elif _MSC_VER < 1930
186# define COMPILER_STRING "MSVC 2019"
187# elif _MSC_VER < 2000
188# define COMPILER_STRING "MSVC 2022"
190# define COMPILER_STRING "MSVC _MSC_VER " QT_STRINGIFY(_MSC_VER)
193# define COMPILER_STRING "<unknown compiler>"
196# define DEBUG_STRING " release"
198# define DEBUG_STRING " debug"
201# define SHARED_STRING " shared (dynamic)"
203# define SHARED_STRING " static"
259 return QVersionNumber(QT_VERSION_MAJOR, QT_VERSION_MINOR, QT_VERSION_PATCH);
268 CFBundleRef bundleRef = CFBundleGetMainBundle();
272 QCFString path = CFURLCopyFileSystemPath(urlRef, kCFURLPOSIXPathStyle);
275 if (
QDir(bundleContentsDir).exists())
292#if QT_CONFIG(relocatable)
293#if !defined(QT_STATIC) && !(defined(Q_OS_DARWIN) && QT_CONFIG(framework)) \
294 && (QT_CONFIG(dlopen) || defined(Q_OS_WIN))
295static QString prefixFromQtCoreLibraryHelper(
const QString &qtCoreLibraryPath)
299 const QString prefixDir = libDir +
"/" QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH;
305static HMODULE getWindowsModuleHandle()
309 GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
321#if defined(QT_STATIC)
326 constexpr size_t binDirLength = binDir.
size() + 1;
327 prefixPath.
chop(binDirLength);
329#elif defined(Q_OS_DARWIN) && QT_CONFIG(framework)
332 #define QT_LIBINFIX ""
334 auto qtCoreBundle = CFBundleGetBundleWithIdentifier(CFSTR(
"org.qt-project.QtCore" QT_LIBINFIX));
341 auto allBundles = CFBundleGetAllBundles();
342 auto bundleCount = CFArrayGetCount(allBundles);
343 for (
int i = 0;
i < bundleCount; ++
i) {
344 auto bundle = CFBundleRef(CFArrayGetValueAtIndex(allBundles,
i));
347 if (CFStringHasSuffix(
path, CFSTR(
"/QtCore" QT_LIBINFIX
".framework"))) {
361 QCFType<CFURLRef> libDirCFPath = CFURLCreateCopyDeletingLastPathComponent(NULL, qtCorePathAbsolute);
363 const QCFString libDirCFString = CFURLCopyFileSystemPath(libDirCFPath, kCFURLPOSIXPathStyle);
365 const QString prefixDir =
QString(libDirCFString) +
"/" QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH;
368#elif QT_CONFIG(dlopen)
374#elif defined(Q_OS_WIN)
376 HMODULE hModule = getWindowsModuleHandle();
391#if defined(Q_CC_MINGW)
398 const QString qtCoreImpLibFileName = implibPrefix
400 const QString qtCoreImpLibPath = qtCoreDirPath
401 + slash + QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH
403 + slash + qtCoreImpLibFileName;
411 prefixPath = prefixFromQtCoreLibraryHelper(qtCoreFilePath);
413#error "The chosen platform / config does not support querying for a dynamic prefix."
416#if defined(Q_OS_LINUX) && !defined(QT_STATIC) && defined(__GLIBC__)
422 QDir prefixDir(prefixPath);
423 while (!prefixDir.exists(libdir)) {
425 prefixPath = prefixDir.absolutePath();
426 if (prefixDir.isRoot()) {
434 "Failed to find the Qt prefix path.");
441#if QT_CONFIG(relocatable)
442 return getRelocatablePrefix(usageMode);
459 "Documentation",
"doc",
460 "Headers",
"include",
463 "LibraryExecutables",
"bin",
465 "LibraryExecutables",
"libexec",
468 "Plugins",
"plugins",
474 "Translations",
"translations",
475 "Examples",
"examples",
479 static_assert(
dot.size() == 1);
480 static_assert(
dot[0] ==
'.');
484 if (
int(loc) < qtConfEntries.count()) {
487 if (
result.key == u
"QmlImports")
488 result.fallbackKey = u
"Qml2Imports"_s;
491 result.key =
"Settings"_L1;
525 bool fromConf =
false;
526#if QT_CONFIG(settings)
531 if (!li.key.isNull()) {
534 config->beginGroup(
"Paths"_L1);
536 if (li.fallbackKey.isNull()) {
537 ret =
config->value(li.key, li.defaultValue).toString();
541 v =
config->value(li.fallbackKey, li.defaultValue);
547 startIndex =
ret.indexOf(u
'$', startIndex);
550 if (
ret.size() < startIndex + 3)
552 if (
ret.at(startIndex + 1) != u
'(') {
559 auto envVarName =
QStringView{
ret}.mid(startIndex + 2, endIndex - startIndex - 2);
561 ret.replace(startIndex, endIndex - startIndex + 1,
value);
562 startIndex +=
value.size();
575 }
else if (
int(loc) <= qt_configure_strs.count()) {
583 const char *
volatile path = QT_CONFIGURE_SETTINGS_PATH;
617#if QT_CONFIG(settings)
686 return QT_VERSION_STR;
689#if QT_DEPRECATED_SINCE(6, 9)
691bool qSharedBuild() noexcept
700#if defined(Q_CC_GNU) && defined(ELF_INTERPRETER)
705#include "private/qcoreapplication_p.h"
712# if defined(Q_OS_LINUX)
715# ifdef QT_ELF_NOTE_OS_TYPE
718 static_assert(
sizeof(Elf32_Nhdr) ==
sizeof(Elf64_Nhdr),
719 "The size of an ELF note is wrong (should be 12 bytes)");
724# ifdef QT_ELF_NOTE_OS_PATCH
730 .n_namesz =
sizeof(
name),
731 .n_descsz =
sizeof(Payload),
732 .n_type = NT_GNU_ABI_TAG
734 char name[
sizeof ELF_NOTE_GNU] = ELF_NOTE_GNU;
735 Payload payload = {};
741extern const char qt_core_interpreter[]
__attribute__((section(
".interp")))
744extern "C" void qt_core_boilerplate()
__attribute__((force_align_arg_pointer));
745void qt_core_boilerplate()
747 printf(
"This is the QtCore library version %s\n"
748 "Copyright (C) 2016 The Qt Company Ltd.\n"
749 "Contact: http://www.qt.io/licensing/\n"
751 "Installation prefix: %s\n"
755 QT_CONFIGURE_PREFIX_PATH,
constexpr qsizetype size() const noexcept
static QCoreApplication * instance() noexcept
Returns a pointer to the application's QCoreApplication (or QGuiApplication/QApplication) instance.
static QString applicationDirPath()
Returns the directory that contains the application executable.
static bool isRelativePath(const QString &path)
Returns true if path is relative; returns false if it is absolute.
static QString fromNativeSeparators(const QString &pathName)
static QString cleanPath(const QString &path)
Returns path with directory separators normalized (that is, platform-native separators converted to "...
static QString currentPath()
Returns the absolute path of the application's current directory.
\inmodule QtCore \reentrant
QString completeBaseName() const
Returns the complete base name of the file without the path.
QString absolutePath() const
Returns a file's path absolute path.
bool exists() const
Returns true if the file exists; otherwise returns false.
bool exists() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QString path(QLibraryInfo::LibraryPath p, UsageMode usageMode=RegularUsage)
static LocationInfo locationInfo(QLibraryInfo::LibraryPath loc)
static bool isSharedBuild() noexcept Q_DECL_CONST_FUNCTION
static bool isDebugBuild() noexcept Q_DECL_CONST_FUNCTION
static QStringList platformPluginArguments(const QString &platformName)
Returns additional arguments to the platform plugin matching platformName which can be specified as a...
static QString path(LibraryPath p)
LibraryPath
\keyword library location
static QVersionNumber version() noexcept Q_DECL_CONST_FUNCTION
static const char * build() noexcept
Returns a string describing how this version of Qt was built.
QVariant value(QAnyStringView key, const QVariant &defaultValue) const
Returns the value for setting key.
QStringList childGroups() const
Returns a list of all key top-level groups that contain keys that can be read using the QSettings obj...
\macro QT_RESTRICTED_CAST_FROM_ASCII
void chop(qsizetype n)
Removes n characters from the end of the string.
static QString fromLocal8Bit(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void clear()
Clears the contents of the string and makes it null.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static QString fromWCharArray(const wchar_t *string, qsizetype size=-1)
QStringList toStringList() const
Returns the variant as a QStringList if the variant has userType() \l QMetaType::QStringList,...
#define QT_ELF_NOTE_OS_PATCH
#define QT_ELF_NOTE_OS_TYPE
#define QT_ELF_NOTE_OS_MINOR
#define QT_ELF_NOTE_OS_MAJOR
Combined button and popup list for selecting options.
#define QT_WARNING_DISABLE_INTEL(number)
#define QT_WARNING_DISABLE_GCC(text)
#define QT_WARNING_DISABLE_CLANG(text)
static QString header(const QString &name)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
static const int kBufferSize
static const char * qt_build_string() noexcept
static QString getPrefix(QLibraryInfoPrivate::UsageMode usageMode)
static QString prefixFromAppDirHelper()
constexpr auto qOffsetStringArray(const char(&...strings)[Nx]) noexcept
GLsizei const GLfloat * v
[13]
GLsizei const GLuint * paths
GLsizei const GLchar *const * path
static qreal dot(const QPointF &a, const QPointF &b)
#define Q_ASSERT_X(cond, x, msg)
Int aligned(Int v, Int byteAlign)
#define QStringLiteral(str)
#define QT_MANGLE_NAMESPACE(name)
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
QT_BEGIN_NAMESPACE Q_CORE_EXPORT Q_DECL_CONST_FUNCTION const char * qVersion(void) Q_DECL_NOEXCEPT
QT_END_NAMESPACE typedef QT_PREPEND_NAMESPACE(quintptr) WId
QFileInfo info(fileName)
[8]
QSettings settings("MySoft", "Star Runner")
[0]
QUrl url("example.com")
[constructor-url-reference]
\inmodule QtCore \reentrant