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);
91const QString *qtconfManualPath =
nullptr;
94void QLibraryInfoPrivate::setQtconfManualPath(
const QString *
path)
96 qtconfManualPath =
path;
101 if (qtconfManualPath)
108 CFBundleRef bundleRef = CFBundleGetMainBundle();
110 QCFType<CFURLRef> urlRef = CFBundleCopyResourceURL(bundleRef,
115 QCFString path = CFURLCopyFileSystemPath(urlRef, kCFURLPOSIXPathStyle);
124 qtconfig = pwd.filePath(u
"qt" QT_STRINGIFY(QT_VERSION_MAJOR)
".conf"_s);
127 qtconfig = pwd.filePath(
"qt.conf"_L1);
134QSettings *QLibraryInfoPrivate::configuration()
136 QLibrarySettings *ls = qt_library_settings();
137 return ls ? ls->configuration() :
nullptr;
140void QLibraryInfoPrivate::reload()
142 if (qt_library_settings.exists())
143 qt_library_settings->load();
146static bool havePaths() {
147 QLibrarySettings *ls = qt_library_settings();
148 return ls && ls->havePaths();
178QLibraryInfo::QLibraryInfo()
181#if defined(Q_CC_CLANG)
182# define COMPILER_STRING __VERSION__
183#elif defined(Q_CC_GHS)
184# define COMPILER_STRING "GHS " QT_STRINGIFY(__GHS_VERSION_NUMBER)
185#elif defined(Q_CC_GNU)
186# define COMPILER_STRING "GCC " __VERSION__
187#elif defined(Q_CC_MSVC)
189# define COMPILER_STRING "MSVC 2015"
190# elif _MSC_VER < 1917
191# define COMPILER_STRING "MSVC 2017"
192# elif _MSC_VER < 1930
193# define COMPILER_STRING "MSVC 2019"
194# elif _MSC_VER < 2000
195# define COMPILER_STRING "MSVC 2022"
197# define COMPILER_STRING "MSVC _MSC_VER " QT_STRINGIFY(_MSC_VER)
200# define COMPILER_STRING "<unknown compiler>"
203# define DEBUG_STRING " release"
205# define DEBUG_STRING " debug"
208# define SHARED_STRING " shared (dynamic)"
210# define SHARED_STRING " static"
266 return QVersionNumber(QT_VERSION_MAJOR, QT_VERSION_MINOR, QT_VERSION_PATCH);
275 CFBundleRef bundleRef = CFBundleGetMainBundle();
277 QCFType<CFURLRef> urlRef = CFBundleCopyBundleURL(bundleRef);
279 QCFString path = CFURLCopyFileSystemPath(urlRef, kCFURLPOSIXPathStyle);
282 if (
QDir(bundleContentsDir).exists())
299#if QT_CONFIG(relocatable)
300#if !defined(QT_STATIC) && !(defined(Q_OS_DARWIN) && QT_CONFIG(framework)) \
301 && (QT_CONFIG(dlopen) || defined(Q_OS_WIN))
302static QString prefixFromQtCoreLibraryHelper(
const QString &qtCoreLibraryPath)
306 const QString prefixDir = libDir +
"/" QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH;
312static HMODULE getWindowsModuleHandle()
316 GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
328#if defined(QT_STATIC)
333 constexpr size_t binDirLength = binDir.
size() + 1;
334 prefixPath.chop(binDirLength);
336#elif defined(Q_OS_DARWIN) && QT_CONFIG(framework)
339 #define QT_LIBINFIX ""
341 auto qtCoreBundle = CFBundleGetBundleWithIdentifier(CFSTR(
"org.qt-project.QtCore" QT_LIBINFIX));
348 auto allBundles = CFBundleGetAllBundles();
349 auto bundleCount = CFArrayGetCount(allBundles);
350 for (
int i = 0;
i < bundleCount; ++
i) {
351 auto bundle = CFBundleRef(CFArrayGetValueAtIndex(allBundles,
i));
352 auto url = QCFType<CFURLRef>(CFBundleCopyBundleURL(bundle));
353 auto path = QCFType<CFStringRef>(CFURLCopyFileSystemPath(
url, kCFURLPOSIXPathStyle));
354 if (CFStringHasSuffix(
path, CFSTR(
"/QtCore" QT_LIBINFIX
".framework"))) {
355 qtCoreBundle = bundle;
362 QCFType<CFURLRef> qtCorePath = CFBundleCopyBundleURL(qtCoreBundle);
365 QCFType<CFURLRef> qtCorePathAbsolute = CFURLCopyAbsoluteURL(qtCorePath);
368 QCFType<CFURLRef> libDirCFPath = CFURLCreateCopyDeletingLastPathComponent(NULL, qtCorePathAbsolute);
370 const QCFString libDirCFString = CFURLCopyFileSystemPath(libDirCFPath, kCFURLPOSIXPathStyle);
372 const QString prefixDir =
QString(libDirCFString) +
"/" QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH;
375#elif defined(Q_OS_WASM)
380#elif QT_CONFIG(dlopen)
386#elif defined(Q_OS_WIN)
388 HMODULE hModule = getWindowsModuleHandle();
403#if defined(Q_CC_MINGW)
410 const QString qtCoreImpLibFileName = implibPrefix
412 const QString qtCoreImpLibPath = qtCoreDirPath
413 + slash + QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH
415 + slash + qtCoreImpLibFileName;
422 if (!qtCoreFilePath.isEmpty())
423 prefixPath = prefixFromQtCoreLibraryHelper(qtCoreFilePath);
425#error "The chosen platform / config does not support querying for a dynamic prefix."
428#if defined(Q_OS_LINUX) && !defined(QT_STATIC) && defined(__GLIBC__)
434 QDir prefixDir(prefixPath);
435 while (!prefixDir.exists(libdir)) {
437 prefixPath = prefixDir.absolutePath();
438 if (prefixDir.isRoot()) {
445 Q_ASSERT_X(!prefixPath.isEmpty(),
"getRelocatablePrefix",
446 "Failed to find the Qt prefix path.");
453#if QT_CONFIG(relocatable)
454 return getRelocatablePrefix(usageMode);
471 "Documentation",
"doc",
472 "Headers",
"include",
475 "LibraryExecutables",
"bin",
477 "LibraryExecutables",
"libexec",
480 "Plugins",
"plugins",
486 "Translations",
"translations",
487 "Examples",
"examples",
495 if (
int(loc) < qtConfEntries.count()) {
498 if (
result.key == u
"QmlImports")
499 result.fallbackKey = u
"Qml2Imports"_s;
502 result.key =
"Settings"_L1;
536 bool fromConf =
false;
537#if QT_CONFIG(settings)
542 if (!li.key.isNull()) {
545 config->beginGroup(
"Paths"_L1);
547 if (li.fallbackKey.isNull()) {
548 ret =
config->value(li.key, li.defaultValue).toString();
552 v =
config->value(li.fallbackKey, li.defaultValue);
562 startIndex =
ret.indexOf(u
'$', startIndex);
565 if (
ret.size() < startIndex + 3)
567 if (
ret.at(startIndex + 1) != u
'(') {
574 auto envVarName =
QStringView{
ret}.
mid(startIndex + 2, endIndex - startIndex - 2);
576 ret.replace(startIndex, endIndex - startIndex + 1,
value);
577 startIndex +=
value.size();
590 }
else if (
int(loc) <= qt_configure_strs.count()) {
598 const char *
volatile path = QT_CONFIGURE_SETTINGS_PATH;
632#if QT_CONFIG(settings)
633 QScopedPointer<const QSettings>
settings(findConfiguration());
701 return QT_VERSION_STR;
704#if QT_DEPRECATED_SINCE(6, 9)
706bool qSharedBuild() noexcept
715#if defined(Q_CC_GNU) && defined(ELF_INTERPRETER)
720#include "private/qcoreapplication_p.h"
727# if defined(Q_OS_LINUX)
730# ifdef QT_ELF_NOTE_OS_TYPE
733 static_assert(
sizeof(Elf32_Nhdr) ==
sizeof(Elf64_Nhdr),
734 "The size of an ELF note is wrong (should be 12 bytes)");
739# ifdef QT_ELF_NOTE_OS_PATCH
745 .n_namesz =
sizeof(
name),
746 .n_descsz =
sizeof(Payload),
747 .n_type = NT_GNU_ABI_TAG
749 char name[
sizeof ELF_NOTE_GNU] = ELF_NOTE_GNU;
750 Payload payload = {};
756extern const char qt_core_interpreter[]
__attribute__((section(
".interp")))
759extern "C" void qt_core_boilerplate()
__attribute__((force_align_arg_pointer));
760void qt_core_boilerplate()
762 printf(
"This is the QtCore library version %s\n"
764 "Contact: https://www.qt.io/licensing/\n"
766 "Installation prefix: %s\n"
771 QT_CONFIGURE_PREFIX_PATH,
772 qt_configure_strs[QT_PREPEND_NAMESPACE(
QLibraryInfo)::LibrariesPath - 1],
773 qt_configure_strs[QT_PREPEND_NAMESPACE(
QLibraryInfo)::PluginsPath - 1]);
struct capHdr __attribute__
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.
QString completeBaseName() const
Returns the complete base name of the file without the path.
QString absolutePath() const
Returns the absolute path of the file system entry this QFileInfo refers to, excluding the entry's na...
bool exists() const
Returns true if the file system entry this QFileInfo refers to 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...
constexpr QStringView mid(qsizetype pos, qsizetype n=-1) const noexcept
Returns the substring of length length starting at position start in this object.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLocal8Bit(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
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)
QList< QString > QStringList
Constructs a string list that contains the given string, str.
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
QSettings settings("MySoft", "Star Runner")
[0]
QUrl url("example.com")
[constructor-url-reference]
manager patch(request, myData, this, [this](QRestReply &reply) { if(reply.isSuccess()) })
[9]
\inmodule QtCore \reentrant