summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/CMakeLists.txt345
-rw-r--r--src/corelib/Qt6AndroidMacros.cmake129
-rw-r--r--src/corelib/Qt6CTestMacros.cmake199
-rw-r--r--src/corelib/Qt6CoreConfigExtras.cmake.in30
-rw-r--r--src/corelib/Qt6CoreDeploySupport.cmake376
-rw-r--r--src/corelib/Qt6CoreMacros.cmake1021
-rw-r--r--src/corelib/Qt6WasmMacros.cmake97
-rw-r--r--src/corelib/QtCompressMimeDatabase.cmake156
-rw-r--r--src/corelib/QtInstallPaths.cmake.in16
-rw-r--r--src/corelib/animation/qabstractanimation.cpp10
-rw-r--r--src/corelib/animation/qabstractanimation_p.h2
-rw-r--r--src/corelib/animation/qanimationgroup.cpp4
-rw-r--r--src/corelib/animation/qpropertyanimation.cpp4
-rw-r--r--src/corelib/animation/qsequentialanimationgroup.cpp6
-rw-r--r--src/corelib/animation/qvariantanimation.cpp12
-rw-r--r--src/corelib/compat/removed_api.cpp59
-rw-r--r--src/corelib/configure.cmake39
-rw-r--r--src/corelib/doc/include/QtCoreDoc1
-rw-r--r--src/corelib/doc/qtcore.qdocconf3
-rw-r--r--src/corelib/doc/snippets/cmake-macros/deployment.cmake27
-rw-r--r--src/corelib/doc/snippets/cmake-macros/examples.cmake2
-rw-r--r--src/corelib/doc/snippets/code/doc_src_containers.cpp71
-rw-r--r--src/corelib/doc/snippets/code/doc_src_qplugin.pro4
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_animation_qpropertyanimation.cpp94
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp13
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qmetaobject.cpp33
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qmetatype.cpp10
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_text_qstring.cpp3
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_text_qstringiterator.cpp2
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp6
-rw-r--r--src/corelib/doc/snippets/code/src_gui_dialogs_qmessagebox.cpp4
-rw-r--r--src/corelib/doc/snippets/fileinfo/main.cpp8
-rw-r--r--src/corelib/doc/snippets/qmetatype/registerConverters.cpp8
-rw-r--r--src/corelib/doc/snippets/qsignalmapper/buttonwidget.cpp7
-rw-r--r--src/corelib/doc/snippets/qstringlist/main.cpp18
-rw-r--r--src/corelib/doc/snippets/resource-system/CMakeLists.txt2
-rw-r--r--src/corelib/doc/src/animation.qdoc338
-rw-r--r--src/corelib/doc/src/cbor.qdoc78
-rw-r--r--src/corelib/doc/src/cmake/cmake-configure-variables.qdoc131
-rw-r--r--src/corelib/doc/src/cmake/cmake-deploy-variables.qdoc82
-rw-r--r--src/corelib/doc/src/cmake/cmake-properties.qdoc93
-rw-r--r--src/corelib/doc/src/cmake/qt_add_big_resources.qdoc2
-rw-r--r--src/corelib/doc/src/cmake/qt_add_binary_resources.qdoc2
-rw-r--r--src/corelib/doc/src/cmake/qt_add_executable.qdoc33
-rw-r--r--src/corelib/doc/src/cmake/qt_add_library.qdoc3
-rw-r--r--src/corelib/doc/src/cmake/qt_add_plugin.qdoc16
-rw-r--r--src/corelib/doc/src/cmake/qt_add_resources.qdoc6
-rw-r--r--src/corelib/doc/src/cmake/qt_allow_non_utf8_sources.qdoc2
-rw-r--r--src/corelib/doc/src/cmake/qt_android_add_apk_target.qdoc2
-rw-r--r--src/corelib/doc/src/cmake/qt_android_apply_arch_suffix.qdoc2
-rw-r--r--src/corelib/doc/src/cmake/qt_android_generate_deployment_settings.qdoc2
-rw-r--r--src/corelib/doc/src/cmake/qt_deploy_qt_conf.qdoc9
-rw-r--r--src/corelib/doc/src/cmake/qt_deploy_runtime_dependencies.qdoc37
-rw-r--r--src/corelib/doc/src/cmake/qt_deploy_translations.qdoc76
-rw-r--r--src/corelib/doc/src/cmake/qt_disable_unicode_defines.qdoc2
-rw-r--r--src/corelib/doc/src/cmake/qt_extract_metatypes.qdoc2
-rw-r--r--src/corelib/doc/src/cmake/qt_finalize_project.qdoc24
-rw-r--r--src/corelib/doc/src/cmake/qt_finalize_target.qdoc4
-rw-r--r--src/corelib/doc/src/cmake/qt_generate_deploy_app_script.qdoc32
-rw-r--r--src/corelib/doc/src/cmake/qt_generate_deploy_script.qdoc66
-rw-r--r--src/corelib/doc/src/cmake/qt_generate_moc.qdoc2
-rw-r--r--src/corelib/doc/src/cmake/qt_import_plugins.qdoc2
-rw-r--r--src/corelib/doc/src/cmake/qt_set_finalizer_mode.qdoc2
-rw-r--r--src/corelib/doc/src/cmake/qt_standard_project_setup.qdoc8
-rw-r--r--src/corelib/doc/src/cmake/qt_wrap_cpp.qdoc2
-rw-r--r--src/corelib/doc/src/containers.qdoc74
-rw-r--r--src/corelib/doc/src/datastreamformat.qdoc5
-rw-r--r--src/corelib/doc/src/external-resources.qdoc10
-rw-r--r--src/corelib/doc/src/includes/cmake-android-qt-finalize-project-warning.qdocinc (renamed from src/corelib/doc/src/includes/cmake-android-qt-finalize-project-warning.cmake)4
-rw-r--r--src/corelib/doc/src/includes/cmake-deploy-runtime-dependencies.qdocinc12
-rw-r--r--src/corelib/doc/src/includes/permissions.qdocinc51
-rw-r--r--src/corelib/doc/src/objectmodel/bindableproperties.qdoc14
-rw-r--r--src/corelib/doc/src/qtcore-index.qdoc1
-rw-r--r--src/corelib/global/archdetect.cpp4
-rw-r--r--src/corelib/global/q20algorithm.h91
-rw-r--r--src/corelib/global/q20functional.h6
-rw-r--r--src/corelib/global/q20iterator.h6
-rw-r--r--src/corelib/global/q23functional.h6
-rw-r--r--src/corelib/global/qassert.cpp22
-rw-r--r--src/corelib/global/qassert.h36
-rw-r--r--src/corelib/global/qcompare.qdoc2
-rw-r--r--src/corelib/global/qcompilerdetection.h178
-rw-r--r--src/corelib/global/qcompilerdetection.qdoc394
-rw-r--r--src/corelib/global/qconfig-bootstrapped.h4
-rw-r--r--src/corelib/global/qconstructormacros.h38
-rw-r--r--src/corelib/global/qdarwinhelpers.h37
-rw-r--r--src/corelib/global/qdarwinhelpers.qdoc34
-rw-r--r--src/corelib/global/qendian.cpp16
-rw-r--r--src/corelib/global/qendian.h2
-rw-r--r--src/corelib/global/qexceptionhandling.cpp20
-rw-r--r--src/corelib/global/qexceptionhandling.h45
-rw-r--r--src/corelib/global/qflags.h14
-rw-r--r--src/corelib/global/qflags.qdoc459
-rw-r--r--src/corelib/global/qfloat16.cpp16
-rw-r--r--src/corelib/global/qfloat16.h184
-rw-r--r--src/corelib/global/qforeach.h30
-rw-r--r--src/corelib/global/qforeach.qdoc72
-rw-r--r--src/corelib/global/qfunctionpointer.h23
-rw-r--r--src/corelib/global/qfunctionpointer.qdoc9
-rw-r--r--src/corelib/global/qglobal.cpp3765
-rw-r--r--src/corelib/global/qglobal.h872
-rw-r--r--src/corelib/global/qlibraryinfo.cpp53
-rw-r--r--src/corelib/global/qlibraryinfo.h31
-rw-r--r--src/corelib/global/qlogging.cpp263
-rw-r--r--src/corelib/global/qlogging.h1
-rw-r--r--src/corelib/global/qmalloc.cpp1
-rw-r--r--src/corelib/global/qmalloc.h26
-rw-r--r--src/corelib/global/qminmax.h88
-rw-r--r--src/corelib/global/qminmax.qdoc39
-rw-r--r--src/corelib/global/qnamespace.h14
-rw-r--r--src/corelib/global/qnamespace.qdoc53
-rw-r--r--src/corelib/global/qnumeric.cpp203
-rw-r--r--src/corelib/global/qnumeric.h12
-rw-r--r--src/corelib/global/qnumeric_p.h39
-rw-r--r--src/corelib/global/qoperatingsystemversion.cpp57
-rw-r--r--src/corelib/global/qoperatingsystemversion.h11
-rw-r--r--src/corelib/global/qoverload.h2
-rw-r--r--src/corelib/global/qprocessordetection.h24
-rw-r--r--src/corelib/global/qprocessordetection.qdoc414
-rw-r--r--src/corelib/global/qrandom.cpp4
-rw-r--r--src/corelib/global/qsimd.h2
-rw-r--r--src/corelib/global/qsimd_p.h21
-rw-r--r--src/corelib/global/qswap.h54
-rw-r--r--src/corelib/global/qswap.qdoc14
-rw-r--r--src/corelib/global/qsysinfo.cpp1054
-rw-r--r--src/corelib/global/qsystemdetection.h63
-rw-r--r--src/corelib/global/qsystemdetection.qdoc202
-rw-r--r--src/corelib/global/qt_windows.h2
-rw-r--r--src/corelib/global/qtclasshelpermacros.h123
-rw-r--r--src/corelib/global/qtclasshelpermacros.qdoc59
-rw-r--r--src/corelib/global/qtconfigmacros.h160
-rw-r--r--src/corelib/global/qtdeprecationmarkers.h87
-rw-r--r--src/corelib/global/qtdeprecationmarkers.qdoc64
-rw-r--r--src/corelib/global/qtenvironmentvariables.cpp (renamed from src/corelib/global/qenvironmentvariables.cpp)16
-rw-r--r--src/corelib/global/qtenvironmentvariables.h (renamed from src/corelib/global/qenvironmentvariables.h)12
-rw-r--r--src/corelib/global/qtnamespacemacros.h85
-rw-r--r--src/corelib/global/qtnoop.h13
-rw-r--r--src/corelib/global/qtpreprocessorsupport.h26
-rw-r--r--src/corelib/global/qtpreprocessorsupport.qdoc20
-rw-r--r--src/corelib/global/qtresource.h21
-rw-r--r--src/corelib/global/qtresource.qdoc54
-rw-r--r--src/corelib/global/qttranslation.h (renamed from src/corelib/global/qtranslation.h)13
-rw-r--r--src/corelib/global/qttranslation.qdoc (renamed from src/corelib/global/qtranslation.qdoc)18
-rw-r--r--src/corelib/global/qttypetraits.h50
-rw-r--r--src/corelib/global/qttypetraits.qdoc108
-rw-r--r--src/corelib/global/qtversionchecks.cpp2
-rw-r--r--src/corelib/global/qtversionchecks.h62
-rw-r--r--src/corelib/global/qtypeinfo.h17
-rw-r--r--src/corelib/global/qtypeinfo.qdoc55
-rw-r--r--src/corelib/global/qtypes.cpp402
-rw-r--r--src/corelib/global/qtypes.h163
-rw-r--r--src/corelib/global/qversiontagging.h2
-rw-r--r--src/corelib/global/qxpfunctional.h6
-rw-r--r--src/corelib/global/qxptype_traits.h63
-rw-r--r--src/corelib/io/qabstractfileengine.cpp13
-rw-r--r--src/corelib/io/qbuffer.cpp15
-rw-r--r--src/corelib/io/qbuffer.h8
-rw-r--r--src/corelib/io/qdataurl.cpp4
-rw-r--r--src/corelib/io/qdebug.cpp95
-rw-r--r--src/corelib/io/qdebug.h41
-rw-r--r--src/corelib/io/qdebug_p.h2
-rw-r--r--src/corelib/io/qdir.cpp247
-rw-r--r--src/corelib/io/qdir.h16
-rw-r--r--src/corelib/io/qdir_p.h2
-rw-r--r--src/corelib/io/qdiriterator.cpp2
-rw-r--r--src/corelib/io/qfile.cpp11
-rw-r--r--src/corelib/io/qfile.h39
-rw-r--r--src/corelib/io/qfiledevice.cpp6
-rw-r--r--src/corelib/io/qfileinfo.h10
-rw-r--r--src/corelib/io/qfileselector.cpp2
-rw-r--r--src/corelib/io/qfilesystemengine.cpp6
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp70
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp29
-rw-r--r--src/corelib/io/qfilesystemmetadata_p.h14
-rw-r--r--src/corelib/io/qfilesystemwatcher_inotify.cpp2
-rw-r--r--src/corelib/io/qfilesystemwatcher_kqueue.cpp2
-rw-r--r--src/corelib/io/qfilesystemwatcher_win.cpp8
-rw-r--r--src/corelib/io/qfilesystemwatcher_win_p.h5
-rw-r--r--src/corelib/io/qfsfileengine.cpp2
-rw-r--r--src/corelib/io/qfsfileengine_unix.cpp20
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp4
-rw-r--r--src/corelib/io/qiodevice.cpp30
-rw-r--r--src/corelib/io/qipaddress.cpp32
-rw-r--r--src/corelib/io/qlockfile.h6
-rw-r--r--src/corelib/io/qloggingcategory.cpp3
-rw-r--r--src/corelib/io/qprocess.cpp56
-rw-r--r--src/corelib/io/qprocess.h8
-rw-r--r--src/corelib/io/qresource.cpp2
-rw-r--r--src/corelib/io/qsettings.cpp34
-rw-r--r--src/corelib/io/qsettings.h8
-rw-r--r--src/corelib/io/qsettings_p.h6
-rw-r--r--src/corelib/io/qsettings_wasm.cpp286
-rw-r--r--src/corelib/io/qstandardpaths_android.cpp25
-rw-r--r--src/corelib/io/qstandardpaths_unix.cpp14
-rw-r--r--src/corelib/io/qstorageinfo_unix.cpp33
-rw-r--r--src/corelib/io/qtemporaryfile.cpp8
-rw-r--r--src/corelib/io/qurl.cpp61
-rw-r--r--src/corelib/io/qurlidna.cpp12
-rw-r--r--src/corelib/io/qurlquery.cpp4
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.cpp40
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.h2
-rw-r--r--src/corelib/itemmodels/qabstractproxymodel.cpp2
-rw-r--r--src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp4
-rw-r--r--src/corelib/itemmodels/qidentityproxymodel.cpp6
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel.cpp76
-rw-r--r--src/corelib/itemmodels/qsortfilterproxymodel.cpp72
-rw-r--r--src/corelib/itemmodels/qstringlistmodel.cpp8
-rw-r--r--src/corelib/itemmodels/qtransposeproxymodel.cpp4
-rw-r--r--src/corelib/kernel/qabstracteventdispatcher.cpp2
-rw-r--r--src/corelib/kernel/qabstracteventdispatcher.h3
-rw-r--r--src/corelib/kernel/qapplicationstatic.h2
-rw-r--r--src/corelib/kernel/qbasictimer.cpp12
-rw-r--r--src/corelib/kernel/qbasictimer.h7
-rw-r--r--src/corelib/kernel/qcfsocketnotifier.cpp2
-rw-r--r--src/corelib/kernel/qcore_mac.mm10
-rw-r--r--src/corelib/kernel/qcore_mac_p.h31
-rw-r--r--src/corelib/kernel/qcore_wasm.cpp45
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp178
-rw-r--r--src/corelib/kernel/qcoreapplication.h72
-rw-r--r--src/corelib/kernel/qcoreapplication_p.h2
-rw-r--r--src/corelib/kernel/qcoreapplication_platform.h8
-rw-r--r--src/corelib/kernel/qcoreglobaldata.cpp23
-rw-r--r--src/corelib/kernel/qcoreglobaldata_p.h39
-rw-r--r--src/corelib/kernel/qdeadlinetimer.h8
-rw-r--r--src/corelib/kernel/qeventdispatcher_glib.cpp8
-rw-r--r--src/corelib/kernel/qeventdispatcher_unix.cpp7
-rw-r--r--src/corelib/kernel/qeventdispatcher_wasm.cpp106
-rw-r--r--src/corelib/kernel/qeventdispatcher_wasm_p.h1
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp4
-rw-r--r--src/corelib/kernel/qfunctions_win.cpp64
-rw-r--r--src/corelib/kernel/qfunctions_win_p.h50
-rw-r--r--src/corelib/kernel/qiterable.cpp24
-rw-r--r--src/corelib/kernel/qjnihelpers.cpp4
-rw-r--r--src/corelib/kernel/qjnitypes.h77
-rw-r--r--src/corelib/kernel/qmath.h4
-rw-r--r--src/corelib/kernel/qmetaobject.cpp530
-rw-r--r--src/corelib/kernel/qmetaobject.h82
-rw-r--r--src/corelib/kernel/qmetaobject_p.h34
-rw-r--r--src/corelib/kernel/qmetaobjectbuilder.cpp2
-rw-r--r--src/corelib/kernel/qmetatype.cpp109
-rw-r--r--src/corelib/kernel/qmetatype.h64
-rw-r--r--src/corelib/kernel/qmimedata.cpp4
-rw-r--r--src/corelib/kernel/qobject.cpp70
-rw-r--r--src/corelib/kernel/qobject.h18
-rw-r--r--src/corelib/kernel/qobject_p.h5
-rw-r--r--src/corelib/kernel/qobjectdefs.h186
-rw-r--r--src/corelib/kernel/qobjectdefs_impl.h1
-rw-r--r--src/corelib/kernel/qpermissions.cpp556
-rw-r--r--src/corelib/kernel/qpermissions.h156
-rw-r--r--src/corelib/kernel/qpermissions_android.cpp137
-rw-r--r--src/corelib/kernel/qpermissions_darwin.mm88
-rw-r--r--src/corelib/kernel/qpermissions_p.h55
-rw-r--r--src/corelib/kernel/qpermissions_wasm.cpp278
-rw-r--r--src/corelib/kernel/qpoll.cpp5
-rw-r--r--src/corelib/kernel/qproperty.cpp519
-rw-r--r--src/corelib/kernel/qproperty.h96
-rw-r--r--src/corelib/kernel/qproperty_p.h42
-rw-r--r--src/corelib/kernel/qpropertyprivate.h5
-rw-r--r--src/corelib/kernel/qsharedmemory.cpp181
-rw-r--r--src/corelib/kernel/qsharedmemory.h19
-rw-r--r--src/corelib/kernel/qsharedmemory_android.cpp9
-rw-r--r--src/corelib/kernel/qsharedmemory_p.h30
-rw-r--r--src/corelib/kernel/qsharedmemory_unix.cpp16
-rw-r--r--src/corelib/kernel/qsharedmemory_win.cpp9
-rw-r--r--src/corelib/kernel/qsystemerror.cpp12
-rw-r--r--src/corelib/kernel/qsystemerror_p.h2
-rw-r--r--src/corelib/kernel/qsystemsemaphore.cpp2
-rw-r--r--src/corelib/kernel/qsystemsemaphore.h2
-rw-r--r--src/corelib/kernel/qsystemsemaphore_android.cpp6
-rw-r--r--src/corelib/kernel/qsystemsemaphore_p.h18
-rw-r--r--src/corelib/kernel/qsystemsemaphore_unix.cpp10
-rw-r--r--src/corelib/kernel/qsystemsemaphore_win.cpp5
-rw-r--r--src/corelib/kernel/qtimer.cpp31
-rw-r--r--src/corelib/kernel/qtimer.h10
-rw-r--r--src/corelib/kernel/qtimer_p.h39
-rw-r--r--src/corelib/kernel/qtimerinfo_unix.cpp31
-rw-r--r--src/corelib/kernel/qtimerinfo_unix_p.h2
-rw-r--r--src/corelib/kernel/qtmetamacros.h4
-rw-r--r--src/corelib/kernel/qtmochelpers.h3
-rw-r--r--src/corelib/kernel/qtranslator.cpp17
-rw-r--r--src/corelib/kernel/qvariant.cpp392
-rw-r--r--src/corelib/kernel/qvariant.h2
-rw-r--r--src/corelib/kernel/qwineventnotifier.h2
-rw-r--r--src/corelib/kernel/qwinregistry.cpp130
-rw-r--r--src/corelib/kernel/qwinregistry_p.h27
-rw-r--r--src/corelib/mimetypes/mime/generate.bat48
-rw-r--r--src/corelib/mimetypes/mime/generate.pl93
-rw-r--r--src/corelib/mimetypes/mimetypes_resources.cmake2
-rw-r--r--src/corelib/mimetypes/qmimedatabase.cpp8
-rw-r--r--src/corelib/mimetypes/qmimeglobpattern.cpp18
-rw-r--r--src/corelib/mimetypes/qmimemagicrule.cpp32
-rw-r--r--src/corelib/mimetypes/qmimeprovider.cpp16
-rw-r--r--src/corelib/mimetypes/qmimetype.cpp6
-rw-r--r--src/corelib/platform/android/qandroidextras.cpp150
-rw-r--r--src/corelib/platform/android/qandroidextras_p.h22
-rw-r--r--src/corelib/platform/android/qandroidnativeinterface.cpp2
-rw-r--r--src/corelib/platform/darwin/qdarwinpermissionplugin.mm90
-rw-r--r--src/corelib/platform/darwin/qdarwinpermissionplugin_bluetooth.mm84
-rw-r--r--src/corelib/platform/darwin/qdarwinpermissionplugin_calendar.mm57
-rw-r--r--src/corelib/platform/darwin/qdarwinpermissionplugin_camera.mm42
-rw-r--r--src/corelib/platform/darwin/qdarwinpermissionplugin_contacts.mm58
-rw-r--r--src/corelib/platform/darwin/qdarwinpermissionplugin_location.mm230
-rw-r--r--src/corelib/platform/darwin/qdarwinpermissionplugin_microphone.mm42
-rw-r--r--src/corelib/platform/darwin/qdarwinpermissionplugin_p.h58
-rw-r--r--src/corelib/platform/darwin/qdarwinpermissionplugin_p_p.h102
-rw-r--r--src/corelib/platform/wasm/qstdweb.cpp45
-rw-r--r--src/corelib/platform/wasm/qstdweb_p.h14
-rw-r--r--src/corelib/platform/windows/qfactorycacheregistration.cpp53
-rw-r--r--src/corelib/platform/windows/qfactorycacheregistration_p.h52
-rw-r--r--src/corelib/plugin/qcoffpeparser.cpp2
-rw-r--r--src/corelib/plugin/qelfparser_p.cpp13
-rw-r--r--src/corelib/plugin/qfactoryinterface.h2
-rw-r--r--src/corelib/plugin/qfactoryloader.cpp4
-rw-r--r--src/corelib/plugin/qlibrary.cpp50
-rw-r--r--src/corelib/plugin/qlibrary_unix.cpp2
-rw-r--r--src/corelib/plugin/qlibrary_win.cpp2
-rw-r--r--src/corelib/plugin/qplugin.h6
-rw-r--r--src/corelib/plugin/qplugin.qdoc8
-rw-r--r--src/corelib/plugin/qpluginloader.cpp6
-rw-r--r--src/corelib/plugin/qsystemlibrary.cpp40
-rw-r--r--src/corelib/plugin/qsystemlibrary_p.h17
-rw-r--r--src/corelib/plugin/quuid.h8
-rw-r--r--src/corelib/qt_cmdline.cmake3
-rw-r--r--src/corelib/serialization/qcborarray.cpp19
-rw-r--r--src/corelib/serialization/qcborcommon.cpp3
-rw-r--r--src/corelib/serialization/qcbormap.cpp19
-rw-r--r--src/corelib/serialization/qcborstreamreader.cpp15
-rw-r--r--src/corelib/serialization/qcborstreamwriter.cpp7
-rw-r--r--src/corelib/serialization/qcborvalue.cpp5
-rw-r--r--src/corelib/serialization/qcborvalue.h6
-rw-r--r--src/corelib/serialization/qdatastream.h4
-rw-r--r--src/corelib/serialization/qjsonarray.cpp36
-rw-r--r--src/corelib/serialization/qjsoncbor.cpp3
-rw-r--r--src/corelib/serialization/qjsondocument.cpp4
-rw-r--r--src/corelib/serialization/qjsondocument.h2
-rw-r--r--src/corelib/serialization/qjsonobject.cpp42
-rw-r--r--src/corelib/serialization/qjsonparser.cpp2
-rw-r--r--src/corelib/serialization/qjsonvalue.cpp3
-rw-r--r--src/corelib/serialization/qjsonwriter.cpp6
-rw-r--r--src/corelib/serialization/qtextstream.cpp4
-rw-r--r--src/corelib/serialization/qtextstream.h1
-rw-r--r--src/corelib/serialization/qtextstream_p.h4
-rw-r--r--src/corelib/serialization/qxmlstream.cpp73
-rw-r--r--src/corelib/serialization/qxmlstream_p.h30
-rw-r--r--src/corelib/text/qanystringview.h103
-rw-r--r--src/corelib/text/qanystringview.qdoc83
-rw-r--r--src/corelib/text/qbytearray.cpp394
-rw-r--r--src/corelib/text/qbytearray.h18
-rw-r--r--src/corelib/text/qbytearraylist.h6
-rw-r--r--src/corelib/text/qbytearraymatcher.h29
-rw-r--r--src/corelib/text/qbytearrayview.h13
-rw-r--r--src/corelib/text/qbytearrayview.qdoc50
-rw-r--r--src/corelib/text/qbytedata_p.h6
-rw-r--r--src/corelib/text/qchar.cpp39
-rw-r--r--src/corelib/text/qchar.h9
-rw-r--r--src/corelib/text/qcollator.cpp2
-rw-r--r--src/corelib/text/qlocale.cpp538
-rw-r--r--src/corelib/text/qlocale.h2
-rw-r--r--src/corelib/text/qlocale_mac.mm6
-rw-r--r--src/corelib/text/qlocale_p.h26
-rw-r--r--src/corelib/text/qlocale_tools.cpp170
-rw-r--r--src/corelib/text/qlocale_tools_p.h19
-rw-r--r--src/corelib/text/qlocale_win.cpp37
-rw-r--r--src/corelib/text/qregularexpression.cpp10
-rw-r--r--src/corelib/text/qstring.cpp616
-rw-r--r--src/corelib/text/qstring.h86
-rw-r--r--src/corelib/text/qstringalgorithms_p.h3
-rw-r--r--src/corelib/text/qstringbuilder.h9
-rw-r--r--src/corelib/text/qstringconverter.cpp120
-rw-r--r--src/corelib/text/qstringconverter_base.h2
-rw-r--r--src/corelib/text/qstringconverter_p.h22
-rw-r--r--src/corelib/text/qstringfwd.h6
-rw-r--r--src/corelib/text/qstringlist.cpp24
-rw-r--r--src/corelib/text/qstringlist.h2
-rw-r--r--src/corelib/text/qstringmatcher.cpp41
-rw-r--r--src/corelib/text/qstringview.cpp4
-rw-r--r--src/corelib/text/qstringview.h20
-rw-r--r--src/corelib/text/qt_attribution.json4
-rw-r--r--src/corelib/text/qtextboundaryfinder.cpp4
-rw-r--r--src/corelib/text/qunicodetables.cpp10872
-rw-r--r--src/corelib/text/qunicodetools.cpp47
-rw-r--r--src/corelib/text/qutf8stringview.h25
-rw-r--r--src/corelib/text/qutf8stringview.qdoc2
-rw-r--r--src/corelib/text/qvsnprintf.cpp2
-rw-r--r--src/corelib/thread/qatomic.cpp82
-rw-r--r--src/corelib/thread/qatomic.h39
-rw-r--r--src/corelib/thread/qatomic_bootstrap.h69
-rw-r--r--src/corelib/thread/qatomic_cxx11.h2
-rw-r--r--src/corelib/thread/qbasicatomic.h20
-rw-r--r--src/corelib/thread/qexception.cpp6
-rw-r--r--src/corelib/thread/qexception.h2
-rw-r--r--src/corelib/thread/qfutex_p.h2
-rw-r--r--src/corelib/thread/qfuture.h8
-rw-r--r--src/corelib/thread/qfuture.qdoc8
-rw-r--r--src/corelib/thread/qfuture_impl.h2
-rw-r--r--src/corelib/thread/qfutureinterface.cpp59
-rw-r--r--src/corelib/thread/qfutureinterface.h4
-rw-r--r--src/corelib/thread/qfutureinterface_p.h5
-rw-r--r--src/corelib/thread/qfuturesynchronizer.h4
-rw-r--r--src/corelib/thread/qlocking_p.h7
-rw-r--r--src/corelib/thread/qmutex.cpp4
-rw-r--r--src/corelib/thread/qmutex.h16
-rw-r--r--src/corelib/thread/qmutex_p.h9
-rw-r--r--src/corelib/thread/qmutex_win.cpp30
-rw-r--r--src/corelib/thread/qpromise.h3
-rw-r--r--src/corelib/thread/qresultstore.h10
-rw-r--r--src/corelib/thread/qsemaphore.cpp5
-rw-r--r--src/corelib/thread/qsemaphore.h2
-rw-r--r--src/corelib/thread/qthread.cpp10
-rw-r--r--src/corelib/thread/qthread.h6
-rw-r--r--src/corelib/thread/qthread_unix.cpp19
-rw-r--r--src/corelib/thread/qthread_win.cpp4
-rw-r--r--src/corelib/thread/qthreadpool.cpp12
-rw-r--r--src/corelib/thread/qthreadstorage.cpp6
-rw-r--r--src/corelib/thread/qwaitcondition.qdoc6
-rw-r--r--src/corelib/thread/qwaitcondition_p.h7
-rw-r--r--src/corelib/thread/qwaitcondition_win.cpp4
-rw-r--r--src/corelib/time/qdatetime.cpp279
-rw-r--r--src/corelib/time/qdatetime.h25
-rw-r--r--src/corelib/time/qdatetime_p.h1
-rw-r--r--src/corelib/time/qdatetimeparser.cpp86
-rw-r--r--src/corelib/time/qdatetimeparser_p.h4
-rw-r--r--src/corelib/time/qlocaltime.cpp67
-rw-r--r--src/corelib/time/qtimezone.cpp4
-rw-r--r--src/corelib/time/qtimezone.h2
-rw-r--r--src/corelib/time/qtimezoneprivate.cpp69
-rw-r--r--src/corelib/time/qtimezoneprivate_android.cpp49
-rw-r--r--src/corelib/time/qtimezoneprivate_data_p.h11
-rw-r--r--src/corelib/time/qtimezoneprivate_tz.cpp43
-rw-r--r--src/corelib/tools/qalgorithms.qdoc12
-rw-r--r--src/corelib/tools/qarraydataops.h11
-rw-r--r--src/corelib/tools/qatomicscopedvaluerollback_p.h1
-rw-r--r--src/corelib/tools/qcommandlineparser.cpp18
-rw-r--r--src/corelib/tools/qcontainerfwd.h2
-rw-r--r--src/corelib/tools/qcontainertools_impl.h40
-rw-r--r--src/corelib/tools/qcontiguouscache.h4
-rw-r--r--src/corelib/tools/qcryptographichash.cpp205
-rw-r--r--src/corelib/tools/qcryptographichash.h5
-rw-r--r--src/corelib/tools/qduplicatetracker_p.h4
-rw-r--r--src/corelib/tools/qeasingcurve.cpp24
-rw-r--r--src/corelib/tools/qflatmap_p.h36
-rw-r--r--src/corelib/tools/qfreelist_p.h3
-rw-r--r--src/corelib/tools/qhash.cpp45
-rw-r--r--src/corelib/tools/qhash.h18
-rw-r--r--src/corelib/tools/qhashfunctions.h32
-rw-r--r--src/corelib/tools/qiterator.qdoc8
-rw-r--r--src/corelib/tools/qlist.h6
-rw-r--r--src/corelib/tools/qlist.qdoc33
-rw-r--r--src/corelib/tools/qmap.h8
-rw-r--r--src/corelib/tools/qmap.qdoc33
-rw-r--r--src/corelib/tools/qmultimap.qdoc24
-rw-r--r--src/corelib/tools/qoffsetstringarray_p.h27
-rw-r--r--src/corelib/tools/qrect.h10
-rw-r--r--src/corelib/tools/qscopedpointer.cpp10
-rw-r--r--src/corelib/tools/qscopedpointer.h8
-rw-r--r--src/corelib/tools/qscopeguard.h2
-rw-r--r--src/corelib/tools/qset.h6
-rw-r--r--src/corelib/tools/qshareddata.h12
-rw-r--r--src/corelib/tools/qshareddata_impl.h4
-rw-r--r--src/corelib/tools/qtaggedpointer.h29
-rw-r--r--src/corelib/tools/qversionnumber.cpp13
461 files changed, 22637 insertions, 15662 deletions
diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt
index fac7680b19..c8f2f9003a 100644
--- a/src/corelib/CMakeLists.txt
+++ b/src/corelib/CMakeLists.txt
@@ -1,5 +1,5 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+# SPDX-License-Identifier: BSD-3-Clause
# Generated from corelib.pro.
@@ -28,12 +28,19 @@ if(WASM)
set(corelib_extra_cmake_files
"${CMAKE_CURRENT_SOURCE_DIR}/${QT_CMAKE_EXPORT_NAMESPACE}WasmMacros.cmake")
endif()
+
+qt_path_join(config_build_dir ${QT_CONFIG_BUILD_DIR} "${INSTALL_CMAKE_NAMESPACE}Core")
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/QtInstallPaths.cmake.in"
+ "${config_build_dir}/QtInstallPaths.cmake" @ONLY)
# special case end
#####################################################################
## Core Module:
#####################################################################
+set(core_version_tagging_files
+ global/qversiontagging.cpp
+ global/qversiontagging.h)
qt_internal_add_module(Core
QMAKE_MODULE_CONFIG moc resources
NO_GENERATE_METATYPES # metatypes are extracted manually below
@@ -51,18 +58,22 @@ qt_internal_add_module(Core
global/qcompare_impl.h
global/qcompare.h
global/qcompilerdetection.h
+ global/qconstructormacros.h
global/qcontainerinfo.h
+ global/qdarwinhelpers.h
global/qendian.cpp global/qendian.h global/qendian_p.h
- global/qenvironmentvariables.cpp global/qenvironmentvariables.h
+ global/qexceptionhandling.cpp global/qexceptionhandling.h
global/qflags.h
global/qfloat16.cpp global/qfloat16.h
global/qforeach.h
+ global/qfunctionpointer.h
global/qglobal.cpp global/qglobal.h global/qglobal_p.h
global/qglobalstatic.h
global/qhooks.cpp global/qhooks_p.h
global/qlibraryinfo.cpp global/qlibraryinfo.h global/qlibraryinfo_p.h
global/qlogging.cpp global/qlogging.h global/qlogging_p.h
- global/qmalloc.cpp
+ global/qmalloc.cpp global/qmalloc.h
+ global/qminmax.h
global/qnamespace.h # this header is specified on purpose so AUTOMOC processes it
global/qnativeinterface.h global/qnativeinterface_p.h
global/qnumeric.cpp global/qnumeric.h global/qnumeric_p.h
@@ -70,21 +81,30 @@ qt_internal_add_module(Core
global/qoverload.h
global/qprocessordetection.h
global/qrandom.cpp global/qrandom.h global/qrandom_p.h
- global/qsysinfo.h
+ global/qswap.h
+ global/qsysinfo.cpp global/qsysinfo.h
global/qsystemdetection.h
+ global/qtclasshelpermacros.h
+ global/qtconfigmacros.h
global/qtdeprecationmarkers.h
- global/qtnamespacemacros.h
+ global/qtenvironmentvariables.cpp global/qtenvironmentvariables.h
+ global/qtnoop.h
+ global/qtpreprocessorsupport.h
global/qtrace_p.h
- global/qtranslation.h
+ global/qtresource.h
+ global/qttranslation.h
+ global/qttypetraits.h
global/qtversionchecks.h
global/qtypeinfo.h
+ global/qtypes.cpp global/qtypes.h
+ ${core_version_tagging_files}
global/qvolatile_p.h
global/q20algorithm.h
global/q20functional.h
global/q23functional.h
- global/qxpfunctional.h
global/q20iterator.h
global/qxpfunctional.h
+ global/qxptype_traits.h
io/qabstractfileengine.cpp io/qabstractfileengine_p.h
io/qbuffer.cpp io/qbuffer.h
io/qdataurl.cpp io/qdataurl_p.h
@@ -129,7 +149,6 @@ qt_internal_add_module(Core
kernel/qcoreapplication_platform.h
kernel/qcorecmdlineargs_p.h
kernel/qcoreevent.cpp kernel/qcoreevent.h
- kernel/qcoreglobaldata.cpp kernel/qcoreglobaldata_p.h
kernel/qdeadlinetimer.cpp kernel/qdeadlinetimer.h kernel/qdeadlinetimer_p.h
kernel/qelapsedtimer.cpp kernel/qelapsedtimer.h
kernel/qeventloop.cpp kernel/qeventloop.h kernel/qeventloop_p.h
@@ -158,10 +177,11 @@ qt_internal_add_module(Core
kernel/qsystemerror.cpp kernel/qsystemerror_p.h
kernel/qsystemsemaphore.cpp kernel/qsystemsemaphore.h kernel/qsystemsemaphore_p.h
kernel/qtestsupport_core.cpp kernel/qtestsupport_core.h
- kernel/qtimer.cpp kernel/qtimer.h
+ kernel/qtimer.cpp kernel/qtimer.h kernel/qtimer_p.h
kernel/qtranslator.cpp kernel/qtranslator.h kernel/qtranslator_p.h
kernel/qvariant.cpp kernel/qvariant.h
kernel/qvariantmap.h kernel/qvarianthash.h kernel/qvariantlist.h
+ kernel/qwineventnotifier.h
plugin/qfactoryinterface.cpp plugin/qfactoryinterface.h
plugin/qfactoryloader.cpp plugin/qfactoryloader_p.h
plugin/qplugin.h plugin/qplugin_p.h
@@ -218,7 +238,6 @@ qt_internal_add_module(Core
text/qutf8stringview.h
text/qvsnprintf.cpp
thread/qatomic.h
- thread/qatomic_bootstrap.h
thread/qatomic_cxx11.h
thread/qbasicatomic.h
thread/qgenericatomic.h
@@ -310,6 +329,7 @@ qt_internal_add_module(Core
"${CMAKE_CURRENT_SOURCE_DIR}/Qt6CTestMacros.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/Qt6CoreConfigureFileTemplate.in"
"${CMAKE_CURRENT_SOURCE_DIR}/Qt6CoreDeploySupport.cmake"
+ "${config_build_dir}/QtInstallPaths.cmake"
${corelib_extra_cmake_files}
# special case end
)
@@ -361,7 +381,7 @@ set_source_files_properties(${qobject_moc_files} PROPERTIES HEADER_FILE_ONLY ON)
set(core_metatype_args MANUAL_MOC_JSON_FILES ${core_qobject_metatypes_json_list})
if(QT_WILL_INSTALL)
- set(metatypes_install_dir ${INSTALL_LIBDIR}/metatypes)
+ set(metatypes_install_dir ${INSTALL_ARCHDATADIR}/metatypes)
list(APPEND core_metatype_args
__QT_INTERNAL_INSTALL __QT_INTERNAL_INSTALL_DIR "${metatypes_install_dir}")
endif()
@@ -369,10 +389,15 @@ endif()
# additional json files.
qt6_extract_metatypes(Core ${core_metatype_args})
-set_property(TARGET Core APPEND PROPERTY
- PUBLIC_HEADER "${CMAKE_CURRENT_BINARY_DIR}/global/qconfig.h")
-set_property(TARGET Core APPEND PROPERTY
- PRIVATE_HEADER "${CMAKE_CURRENT_BINARY_DIR}/global/qconfig_p.h")
+target_sources(Core PRIVATE
+ "${CMAKE_CURRENT_BINARY_DIR}/global/qconfig.h"
+ "${CMAKE_CURRENT_BINARY_DIR}/global/qconfig_p.h"
+)
+set_source_files_properties(
+ "${CMAKE_CURRENT_BINARY_DIR}/global/qconfig.h"
+ "${CMAKE_CURRENT_BINARY_DIR}/global/qconfig_p.h"
+ PROPERTIES GENERATED TRUE
+)
# Find ELF interpreter and define a macro for that:
if ((LINUX OR HURD) AND NOT CMAKE_CROSSCOMPILING AND BUILD_SHARED_LIBS)
@@ -468,10 +493,13 @@ endif()
qt_internal_extend_target(Core
CONDITION ( TEST_architecture_arch STREQUAL i386 ) OR
- ( TEST_architecture_arch STREQUAL x86_64 )
+ ( TEST_architecture_arch STREQUAL x86_64 ) OR
+ ( CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" ) OR
+ ( CMAKE_OSX_ARCHITECTURES MATCHES "i386" ) OR
SOURCES
global/qsimd_x86_p.h
)
+
qt_internal_extend_target(Core CONDITION ANDROID
SOURCES
kernel/qsharedmemory_android.cpp
@@ -510,7 +538,6 @@ qt_internal_extend_target(Core CONDITION QT_FEATURE_animation
# from the wrong DLL at runtime and crash!
qt_internal_extend_target(Core CONDITION QT_FEATURE_thread AND WIN32
SOURCES
- thread/qmutex_win.cpp
thread/qwaitcondition_win.cpp
LIBRARIES
synchronization
@@ -531,10 +558,10 @@ qt_internal_extend_target(Core CONDITION WIN32
kernel/qcoreapplication_win.cpp
kernel/qelapsedtimer_win.cpp
kernel/qeventdispatcher_win.cpp kernel/qeventdispatcher_win_p.h
- kernel/qfunctions_winrt_p.h
+ kernel/qfunctions_win.cpp kernel/qfunctions_win_p.h kernel/qfunctions_winrt_p.h
kernel/qsharedmemory_win.cpp
kernel/qsystemsemaphore_win.cpp
- kernel/qwineventnotifier.cpp kernel/qwineventnotifier.h kernel/qwineventnotifier_p.h
+ kernel/qwineventnotifier.cpp kernel/qwineventnotifier_p.h
kernel/qwinregistry.cpp kernel/qwinregistry_p.h
plugin/qsystemlibrary.cpp plugin/qsystemlibrary_p.h
thread/qthread_win.cpp
@@ -556,6 +583,10 @@ qt_internal_extend_target(Core CONDITION WIN32
userenv
)
+qt_internal_extend_target(Core CONDITION WASM
+ SOURCES
+ kernel/qcore_wasm.cpp)
+
qt_internal_extend_target(Core CONDITION APPLE
SOURCES
global/qoperatingsystemversion_darwin.mm
@@ -635,9 +666,6 @@ qt_internal_extend_target(Core CONDITION QT_FEATURE_journald
PkgConfig::Libsystemd
)
-set(core_version_tagging_files global/qversiontagging.cpp global/qversiontagging.h)
-target_sources(Core PRIVATE ${core_version_tagging_files})
-
# Disable LTO, as the symbols disappear somehow under GCC
# (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48200)
if(GCC)
@@ -818,6 +846,11 @@ qt_internal_extend_target(Core CONDITION QT_FEATURE_regularexpression
WrapPCRE2::WrapPCRE2
)
+qt_internal_extend_target(Core CONDITION QT_FEATURE_openssl_linked AND QT_FEATURE_opensslv30
+ LIBRARIES
+ WrapOpenSSL::WrapOpenSSL
+)
+
qt_internal_extend_target(Core CONDITION QT_FEATURE_hijricalendar
SOURCES
time/qhijricalendar.cpp time/qhijricalendar_p.h
@@ -983,6 +1016,12 @@ qt_internal_extend_target(Core CONDITION ANDROID
platform/android/qandroidnativeinterface.cpp
)
+qt_internal_extend_target(Core CONDITION WIN32
+ SOURCES
+ platform/windows/qfactorycacheregistration_p.h
+ platform/windows/qfactorycacheregistration.cpp
+)
+
qt_internal_extend_target(Core CONDITION HAIKU AND NOT ANDROID
SOURCES
io/qstandardpaths_haiku.cpp
@@ -1053,7 +1092,7 @@ qt_internal_extend_target(Core CONDITION QT_FEATURE_library AND UNIX AND NOT APP
plugin/qlibrary_unix.cpp
)
-qt_internal_extend_target(Core CONDITION QT_FEATURE_dlopen AND QT_FEATURE_library
+qt_internal_extend_target(Core CONDITION QT_FEATURE_dlopen
LIBRARIES
${CMAKE_DL_LIBS}
)
@@ -1121,166 +1160,147 @@ qt_internal_extend_target(Core CONDITION QT_FEATURE_mimetype
mimetypes/qmimetypeparser.cpp mimetypes/qmimetypeparser_p.h
)
-#### Keys ignored in scope 171:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_mimetype:
-# MIME_DATABASE = "mimetypes/mime/packages/freedesktop.org.xml"
-# OTHER_FILES = "$$MIME_DATABASE"
+qt_internal_extend_target(Core CONDITION QT_FEATURE_permissions
+ SOURCES
+ kernel/qpermissions.cpp kernel/qpermissions.h kernel/qpermissions_p.h
+)
-# special case begin
-# qt_internal_extend_target(Core CONDITION QT_FEATURE_mimetype AND QT_FEATURE_mimetype_database
-# INCLUDE_DIRECTORIES
-# .rcc
-#)
-# special case end
+if(QT_FEATURE_permissions AND APPLE)
+ qt_internal_extend_target(Core
+ SOURCES
+ kernel/qpermissions_darwin.mm
+ platform/darwin/qdarwinpermissionplugin.mm
+ PLUGIN_TYPES
+ permissions
+ )
+
+ foreach(permission Camera Microphone Bluetooth Contacts Calendar Location)
+ qt_internal_add_darwin_permission_plugin("${permission}")
+ endforeach()
-#### Keys ignored in scope 172:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_mimetype_database:
-# QMAKE_EXTRA_COMPILERS = "mimedb"
-# mimedb.commands = "${QMAKE_FILE_IN}" ">" "${QMAKE_FILE_OUT}"
-# mimedb.depends = "$$PWD/mime/generate.pl"
-# mimedb.input = "MIME_DATABASE"
-# mimedb.output = "$$outpath/qmimeprovider_database.cpp"
-# mimedb.variable_out = "INCLUDED_SOURCES"
+ # Camera
+ qt_internal_extend_target(QDarwinCameraPermissionPlugin
+ LIBRARIES ${FWAVFoundation}
+ )
+ set_property(TARGET QDarwinCameraPermissionPlugin PROPERTY
+ _qt_darwin_permissison_separate_request TRUE
+ )
+
+ # Microphone
+ qt_internal_extend_target(QDarwinMicrophonePermissionPlugin
+ LIBRARIES ${FWAVFoundation}
+ )
+ set_property(TARGET QDarwinMicrophonePermissionPlugin PROPERTY
+ _qt_darwin_permissison_separate_request TRUE
+ )
+
+ # Bluetooth
+ qt_internal_extend_target(QDarwinBluetoothPermissionPlugin
+ LIBRARIES ${FWCoreBluetooth}
+ )
+ set_property(TARGET QDarwinBluetoothPermissionPlugin PROPERTY
+ _qt_info_plist_usage_descriptions "NSBluetoothAlwaysUsageDescription"
+ )
-#### Keys ignored in scope 173:.:mimetypes:mimetypes/mimetypes.pri:ANDROID:
-# outpath = "$$outpath/$${QT_ARCH}"
+ # Contacts
+ qt_internal_extend_target(QDarwinContactsPermissionPlugin
+ LIBRARIES ${FWContacts}
+ )
-#### Keys ignored in scope 175:.:mimetypes:mimetypes/mimetypes.pri:(CMAKE_BUILD_TYPE STREQUAL Debug):
-# outpath = "$$outpath/debug"
+ # Calendar
+ qt_internal_extend_target(QDarwinCalendarPermissionPlugin
+ LIBRARIES ${FWEventKit}
+ )
+ set_property(TARGET QDarwinCalendarPermissionPlugin PROPERTY
+ _qt_info_plist_usage_descriptions "NSCalendarsUsageDescription"
+ )
-#### Keys ignored in scope 176:.:mimetypes:mimetypes/mimetypes.pri:else:
-# outpath = "$$outpath/release"
+ # Location
+ qt_internal_extend_target(QDarwinLocationPermissionPlugin
+ LIBRARIES ${FWCoreLocation}
+ )
+ set_property(TARGET QDarwinLocationPermissionPlugin PROPERTY
+ _qt_info_plist_usage_descriptions
+ "NSLocationWhenInUseUsageDescription"
+ "NSLocationAlwaysUsageDescription"
+ )
+endif()
-#### Keys ignored in scope 177:.:mimetypes:mimetypes/mimetypes.pri:MAKEFILE_GENERATOR___equals___MSVC.NET OR MAKEFILE_GENERATOR___equals___MSBUILD OR QMAKE_SH_ISEMPTY:
-# mimedb.commands = "cmd" "/c" "$$shell_path($$PWD/mime/generate.bat)"
-# mimedb.depends = "$$PWD/mime/generate.bat" "$$PWD/mime/hexdump.ps1"
+qt_internal_extend_target(Core CONDITION QT_FEATURE_permissions AND ANDROID
+ SOURCES
+ kernel/qpermissions_android.cpp
+)
-#### Keys ignored in scope 178:.:mimetypes:mimetypes/mimetypes.pri:else:
-# mimedb.commands = "perl" "$${mimedb.depends}"
+qt_internal_extend_target(Core CONDITION QT_FEATURE_permissions AND WASM
+ SOURCES
+ kernel/qpermissions_wasm.cpp
+)
-#### Keys ignored in scope 179:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_zstd:
-# mimedb.commands = "--zstd"
-# Resources:
-# special case begin
-# We can't specify the resources directly as we have unit tests that
-# depend on these as well and we no longer support the use of hand
-# edited qrc files.
if(QT_FEATURE_mimetype AND QT_FEATURE_mimetype_database)
include(${CMAKE_CURRENT_SOURCE_DIR}/mimetypes/mimetypes_resources.cmake)
-# Generate qmimeprovider_database.cpp
- set(qmimeprovider_db_output_dir "${CMAKE_CURRENT_BINARY_DIR}/.rcc")
- set(qmimeprovider_db_output "${qmimeprovider_db_output_dir}/qmimeprovider_database.cpp")
if(CMAKE_VERSION VERSION_LESS 3.18 OR QT_AVOID_CMAKE_ARCHIVING_API)
- set(command_args "")
- set(mime_dir "${CMAKE_CURRENT_SOURCE_DIR}/mimetypes/mime")
- set(command_depends "${mime_dir}/generate.pl" "${corelib_mimetypes_resource_file}")
- if (MSVC)
- list(APPEND command_args "${mime_dir}/generate.bat")
- list(APPEND command_depends "${mime_dir}/generate.bat" "${mime_dir}/hexdump.ps1" )
- else()
- file(MAKE_DIRECTORY ${qmimeprovider_db_output_dir})
- list(APPEND command_args perl "${mime_dir}/generate.pl" )
- endif()
-
- if (QT_FEATURE_zstd)
- list(APPEND command_args "--zstd")
+ set(archiving_api "External")
+ else()
+ set(archiving_api "CMake")
+ if(QT_FEATURE_zstd AND NOT QT_CMAKE_ZSTD_SUPPORT)
+ message(FATAL_ERROR
+ "CMake was not built with zstd support. "
+ "Rebuild CMake or set QT_AVOID_CMAKE_ARCHIVING_API=ON.")
endif()
+ endif()
- list(APPEND command_args "${corelib_mimetypes_resource_file}" ">" "${qmimeprovider_db_output}")
-
- add_custom_command(OUTPUT "${qmimeprovider_db_output}"
- DEPENDS ${command_depends}
- COMMAND ${command_args}
- COMMENT "Generating ${qmimeprovider_db_output}"
- VERBATIM
- )
- else()
- if(QT_FEATURE_zstd)
- if(NOT QT_CMAKE_ZSTD_SUPPORT)
- message(FATAL_ERROR
- "CMake was not built with zstd support. "
- "Rebuild CMake or set QT_AVOID_CMAKE_ARCHIVING_API=ON.")
- endif()
- set(qmime_db_compression Zstd)
- string(APPEND qmime_db_content "#define MIME_DATABASE_IS_ZSTD\n")
+ if(DEFINED INPUT_mimetype_database_compression)
+ set(supported_compression_types zstd gzip none)
+ if(INPUT_mimetype_database_compression IN_LIST supported_compression_types)
+ set(compression_type ${INPUT_mimetype_database_compression})
else()
- set(qmime_db_compression GZip)
- string(APPEND qmime_db_content "#define MIME_DATABASE_IS_GZIP\n")
+ message(FATAL_ERROR "Unknown mime type database compression is set:"
+ " ${INPUT_mimetype_database_compression}\nSupported compression types:\n"
+ " ${supported_compression_types}")
endif()
-
- file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/.rcc")
- get_filename_component(mime_types_resource_file "${corelib_mimetypes_resource_file}" NAME)
-
- set(mimetypes_resource_file_minified "${CMAKE_CURRENT_BINARY_DIR}/.rcc/${mime_types_resource_file}")
-
- set(mimetypes_resfile_timestamp_file "${CMAKE_CURRENT_BINARY_DIR}/.rcc/${mime_types_resource_file}.timestamp")
- file(TIMESTAMP "${corelib_mimetypes_resource_file}" mimetypes_resfile_timestamp)
-
- set(compute_db_archive ON)
- if (EXISTS "${mimetypes_resfile_timestamp_file}")
- file(READ "${mimetypes_resfile_timestamp_file}" old_mimetypes_resfile_timestamp)
- if ("${mimetypes_resfile_timestamp}" STREQUAL "${old_mimetypes_resfile_timestamp}")
- set(compute_db_archive OFF)
- endif()
+ if(compression_type STREQUAL "zstd" AND NOT QT_FEATURE_zstd)
+ message(FATAL_ERROR
+ "zstd compression is selected for mime type database, but the 'zstd'"
+ " feature is disabled.")
endif()
+ elseif(QT_FEATURE_zstd)
+ set(compression_type "zstd")
+ else()
+ set(compression_type "gzip")
+ endif()
- if (compute_db_archive)
- find_program(xmlstarlet NAMES xmlstarlet xml)
- if (xmlstarlet)
- execute_process(
- COMMAND "${xmlstarlet}" sel -D -B -t -c / "${corelib_mimetypes_resource_file}"
- OUTPUT_FILE "${mimetypes_resource_file_minified}"
- RESULT_VARIABLE failed_to_minify
- )
- if (NOT failed_to_minify)
- set(corelib_mimetypes_resource_file "${mimetypes_resource_file_minified}")
- endif()
- else()
- message(STATUS "xmlstarlet command was not found. ${mime_types_resource_file} will not be minified.")
- endif()
-
- if (CMAKE_VERSION GREATER_EQUAL 3.19)
- set(additional_file_archive_create_parameters COMPRESSION_LEVEL 9)
- endif()
-
- file(ARCHIVE_CREATE OUTPUT "${qmimeprovider_db_output}.archive"
- PATHS "${corelib_mimetypes_resource_file}"
- FORMAT raw
- COMPRESSION ${qmime_db_compression}
- ${additional_file_archive_create_parameters}
- )
- file(READ "${qmimeprovider_db_output}.archive" qmime_db_archive HEX)
- file(SIZE "${qmimeprovider_db_output}.archive" qmime_db_archive_size)
- file(SIZE "${corelib_mimetypes_resource_file}" qmime_db_resource_size)
- file(REMOVE ${qmimeprovider_db_output}.archive)
-
- string(APPEND qmime_db_content "static const unsigned char mimetype_database[] = { ")
-
- string(REGEX MATCHALL "([a-f0-9][a-f0-9])" qmime_db_hex "${qmime_db_archive}")
-
- list(TRANSFORM qmime_db_hex PREPEND "0x")
- math(EXPR qmime_db_archive_size "${qmime_db_archive_size} - 1")
- foreach(index RANGE 0 ${qmime_db_archive_size} 12)
- list(APPEND index_list ${index})
- endforeach()
- list(TRANSFORM qmime_db_hex PREPEND "\n " AT ${index_list})
- list(JOIN qmime_db_hex ", " qmime_db_hex_joined)
-
- string(APPEND qmime_db_content "${qmime_db_hex_joined}")
- string(APPEND qmime_db_content "\n};\n")
- string(APPEND qmime_db_content "static constexpr size_t MimeTypeDatabaseOriginalSize = ${qmime_db_resource_size};\n")
-
- file(WRITE "${qmimeprovider_db_output}" "${qmime_db_content}")
-
- file(WRITE "${mimetypes_resfile_timestamp_file}" "${mimetypes_resfile_timestamp}")
- endif()
+ if(QT_INTERNAL_ENABLE_VERBOSE_MIME_DATABASE_COMPRESSION)
+ set(extra_mime_db_compressor_flags "--log-level=STATUS")
+ else()
+ set(extra_mime_db_compressor_flags "--log-level=NOTICE")
endif()
- target_sources(Core PRIVATE ${qmimeprovider_db_output})
- set_source_files_properties(${qmimeprovider_db_output} PROPERTIES HEADER_FILE_ONLY TRUE)
- target_include_directories(Core PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/.rcc")
-endif()
+ # Generate qmimeprovider_database.cpp
+ set(qmimeprovider_db_output "${CMAKE_CURRENT_BINARY_DIR}/.rcc/qmimeprovider_database.cpp")
+ add_custom_command(OUTPUT "${qmimeprovider_db_output}"
+ COMMAND ${CMAKE_COMMAND}
+ -DINPUT_FILE=${corelib_mimetypes_resource_file}
+ -DOUTPUT_FILE=${qmimeprovider_db_output}
+ -DARCHIVING_API=${archiving_api}
+ -DCOMPRESSION_TYPE=${compression_type}
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/QtCompressMimeDatabase.cmake"
+ ${extra_mime_db_compressor_flags}
+ DEPENDS
+ "${CMAKE_CURRENT_SOURCE_DIR}/QtCompressMimeDatabase.cmake"
+ "${corelib_mimetypes_resource_file}"
+ VERBATIM
+ )
-# special case end
+ qt_internal_extend_target(Core
+ SOURCES ${qmimeprovider_db_output}
+ INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/.rcc"
+ )
+ set_source_files_properties(${qmimeprovider_db_output} PROPERTIES
+ GENERATED TRUE
+ HEADER_FILE_ONLY TRUE
+ )
+endif()
qt_internal_extend_target(Core CONDITION WASM
SOURCES
@@ -1291,7 +1311,6 @@ qt_internal_extend_target(Core CONDITION WASM
set_source_files_properties(
thread/qmutex_mac.cpp
thread/qmutex_unix.cpp
- thread/qmutex_win.cpp
PROPERTIES HEADER_FILE_ONLY ON) # special case: These files are included by qmutex.cpp!
diff --git a/src/corelib/Qt6AndroidMacros.cmake b/src/corelib/Qt6AndroidMacros.cmake
index 1e27ca333e..46463c8f4f 100644
--- a/src/corelib/Qt6AndroidMacros.cmake
+++ b/src/corelib/Qt6AndroidMacros.cmake
@@ -1,5 +1,5 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+# SPDX-License-Identifier: BSD-3-Clause
# Generate deployment tool json
@@ -257,6 +257,9 @@ function(qt6_android_generate_deployment_settings target)
if(COMMAND _qt_internal_generate_android_qml_deployment_settings)
_qt_internal_generate_android_qml_deployment_settings(file_contents ${target})
+ else()
+ string(APPEND file_contents
+ " \"qml-skip-import-scanning\": true,\n")
endif()
# Override rcc binary path
@@ -391,9 +394,14 @@ function(qt6_android_add_apk_target target)
COMMENT "Copying ${target} binary to apk folder"
)
+ set(sign_apk "")
if(QT_ANDROID_SIGN_APK)
set(sign_apk "--sign")
endif()
+ set(sign_aab "")
+ if(QT_ANDROID_SIGN_AAB)
+ set(sign_aab "--sign")
+ endif()
set(extra_args "")
if(QT_INTERNAL_NO_ANDROID_RCC_BUNDLE_CLEANUP)
@@ -463,6 +471,7 @@ function(qt6_android_add_apk_target target)
--output ${apk_final_dir}
--apk ${apk_final_file_path}
--aab
+ ${sign_aab}
${extra_args}
COMMENT "Creating AAB for ${target}"
)
@@ -523,6 +532,7 @@ function(qt6_android_add_apk_target target)
set_property(GLOBAL APPEND PROPERTY _qt_apk_targets ${target})
_qt_internal_collect_apk_dependencies_defer()
+ _qt_internal_collect_apk_imported_dependencies_defer("${target}")
endfunction()
function(_qt_internal_create_global_android_targets)
@@ -548,8 +558,8 @@ endfunction()
# The function collects all known non-imported shared libraries that are created in the build tree.
# It uses the CMake DEFER CALL feature if the CMAKE_VERSION is greater
-# than or equal to 3.18.
-# Note: Users that use cmake version less that 3.18 need to call qt_finalize_project
+# than or equal to 3.19.
+# Note: Users that use cmake version less that 3.19 need to call qt_finalize_project
# in the end of a project's top-level CMakeLists.txt.
function(_qt_internal_collect_apk_dependencies_defer)
# User opted-out the functionality
@@ -563,13 +573,14 @@ function(_qt_internal_collect_apk_dependencies_defer)
endif()
set_property(GLOBAL PROPERTY _qt_is_collect_apk_dependencies_defer_called TRUE)
- if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.18")
+ if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.19")
cmake_language(EVAL CODE "cmake_language(DEFER DIRECTORY \"${CMAKE_SOURCE_DIR}\"
CALL _qt_internal_collect_apk_dependencies)")
else()
# User don't want to see the warning
if(NOT QT_NO_WARN_BUILD_TREE_APK_DEPS)
- message(WARNING "CMake version you use is less than 3.18. APK dependencies, that are a"
+ message(WARNING
+ "The CMake version you use is less than 3.19. APK dependencies, that are a"
" part of the project tree, might not be collected correctly."
" Please call qt_finalize_project in the end of a project's top-level"
" CMakeLists.txt file to make sure that all the APK dependencies are"
@@ -580,8 +591,8 @@ function(_qt_internal_collect_apk_dependencies_defer)
endif()
endfunction()
-# The function collects shared libraries from the build system tree, that might be dependencies for
-# the main apk targets.
+# The function collects project-built shared libraries that might be dependencies for
+# the main apk targets. It stores their locations in a global custom target property.
function(_qt_internal_collect_apk_dependencies)
# User opted-out the functionality
if(QT_NO_COLLECT_BUILD_TREE_APK_DEPS)
@@ -597,6 +608,7 @@ function(_qt_internal_collect_apk_dependencies)
get_property(apk_targets GLOBAL PROPERTY _qt_apk_targets)
_qt_internal_collect_buildsystem_shared_libraries(libs "${CMAKE_SOURCE_DIR}")
+ list(REMOVE_DUPLICATES libs)
if(NOT TARGET qt_internal_plugins)
add_custom_target(qt_internal_plugins)
@@ -624,8 +636,8 @@ function(_qt_internal_collect_apk_dependencies)
)
endfunction()
-# The function recursively goes through the project subfolders and collects targets that supposed to
-# be shared libraries of any kind.
+# This function recursively walks the current directory and its subdirectories to collect shared
+# library targets built in those directories.
function(_qt_internal_collect_buildsystem_shared_libraries out_var subdir)
set(result "")
get_directory_property(buildsystem_targets DIRECTORY ${subdir} BUILDSYSTEM_TARGETS)
@@ -646,6 +658,81 @@ function(_qt_internal_collect_buildsystem_shared_libraries out_var subdir)
set(${out_var} "${result}" PARENT_SCOPE)
endfunction()
+# This function collects all imported shared libraries that might be dependencies for
+# the main apk targets. The actual collection is deferred until the target's directory scope
+# is processed.
+# The function requires CMake 3.21 or later.
+function(_qt_internal_collect_apk_imported_dependencies_defer target)
+ # User opted-out of the functionality.
+ if(QT_NO_COLLECT_IMPORTED_TARGET_APK_DEPS)
+ return()
+ endif()
+
+ get_target_property(target_source_dir "${target}" SOURCE_DIR)
+ if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.21")
+ cmake_language(EVAL CODE "cmake_language(DEFER DIRECTORY \"${target_source_dir}\"
+ CALL _qt_internal_collect_apk_imported_dependencies \"${target}\")")
+ endif()
+endfunction()
+
+# This function collects imported shared libraries that might be dependencies for
+# the main apk targets. It stores their locations on a custom target property for the given target.
+# The function requires CMake 3.21 or later.
+function(_qt_internal_collect_apk_imported_dependencies target)
+ # User opted-out the functionality
+ if(QT_NO_COLLECT_IMPORTED_TARGET_APK_DEPS)
+ return()
+ endif()
+
+ get_target_property(target_source_dir "${target}" SOURCE_DIR)
+ _qt_internal_collect_imported_shared_libraries_recursive(libs "${target_source_dir}")
+ list(REMOVE_DUPLICATES libs)
+
+ foreach(lib IN LISTS libs)
+ list(APPEND extra_library_dirs "$<TARGET_FILE_DIR:${lib}>")
+ endforeach()
+
+ set_property(TARGET "${target}" APPEND PROPERTY
+ _qt_android_extra_library_dirs "${extra_library_dirs}"
+ )
+endfunction()
+
+# This function recursively walks the current directory and its parent directories to collect
+# imported shared library targets.
+# The recursion goes upwards instead of downwards because imported targets are usually not global,
+# and we can't call get_target_property() on a target which is not available in the current
+# directory or parent scopes.
+# We also can't cache parent directories because the imported targets in a parent directory
+# might change in-between collection calls.
+# The function requires CMake 3.21 or later.
+function(_qt_internal_collect_imported_shared_libraries_recursive out_var subdir)
+ set(result "")
+
+ get_directory_property(imported_targets DIRECTORY "${subdir}" IMPORTED_TARGETS)
+ foreach(imported_target IN LISTS imported_targets)
+ get_target_property(target_type "${imported_target}" TYPE)
+ if(target_type STREQUAL "SHARED_LIBRARY" OR target_type STREQUAL "MODULE_LIBRARY")
+ # If the target has the _qt_package_version property set, it means it's an
+ # 'official' qt target like a module or plugin, so we don't want to add it
+ # to the list of extra paths to scan for in androiddeployqt, because they are
+ # already handled via the regular 'qt' code path in the androiddeployqt.
+ # Thus this will pick up only non-qt 3rd party targets.
+ get_target_property(qt_package_version "${imported_target}" _qt_package_version)
+ if(NOT qt_package_version)
+ list(APPEND result "${imported_target}")
+ endif()
+ endif()
+ endforeach()
+
+ get_directory_property(parent_dir DIRECTORY "${subdir}" PARENT_DIRECTORY)
+ if(parent_dir)
+ _qt_internal_collect_imported_shared_libraries_recursive(result_inner "${parent_dir}")
+ endif()
+
+ list(APPEND result ${result_inner})
+ set(${out_var} "${result}" PARENT_SCOPE)
+endfunction()
+
# This function allows deciding whether apks should be built as part of the ALL target at first
# add_executable call point, rather than when the 'apk' target is created as part of the
# find_package(Core) call.
@@ -963,16 +1050,30 @@ function(_qt_internal_configure_android_multiabi_target target)
list(APPEND extra_cmake_args "-DANDROID_NDK_ROOT=${ANDROID_NDK}")
endif()
+ if(DEFINED QT_NO_PACKAGE_VERSION_CHECK)
+ list(APPEND extra_cmake_args "-DQT_NO_PACKAGE_VERSION_CHECK=${QT_NO_PACKAGE_VERSION_CHECK}")
+ endif()
+
+ if(DEFINED QT_HOST_PATH_CMAKE_DIR)
+ list(APPEND extra_cmake_args "-DQT_HOST_PATH_CMAKE_DIR=${QT_HOST_PATH_CMAKE_DIR}")
+ endif()
+
if(CMAKE_MAKE_PROGRAM)
list(APPEND extra_cmake_args "-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}")
endif()
if(CMAKE_C_COMPILER_LAUNCHER)
- list(APPEND extra_cmake_args "-DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}")
+ list(JOIN CMAKE_C_COMPILER_LAUNCHER "$<SEMICOLON>"
+ compiler_launcher)
+ list(APPEND extra_cmake_args
+ "-DCMAKE_C_COMPILER_LAUNCHER=${compiler_launcher}")
endif()
if(CMAKE_CXX_COMPILER_LAUNCHER)
- list(APPEND extra_cmake_args "-DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}")
+ list(JOIN CMAKE_CXX_COMPILER_LAUNCHER "$<SEMICOLON>"
+ compiler_launcher)
+ list(APPEND extra_cmake_args
+ "-DCMAKE_CXX_COMPILER_LAUNCHER=${compiler_launcher}")
endif()
set(missing_qt_abi_toolchains "")
@@ -998,13 +1099,17 @@ function(_qt_internal_configure_android_multiabi_target target)
ExternalProject_Add("qt_internal_android_${abi}"
SOURCE_DIR "${CMAKE_SOURCE_DIR}"
BINARY_DIR "${android_abi_build_dir}"
- CMAKE_ARGS
+ CONFIGURE_COMMAND
+ "${CMAKE_COMMAND}"
+ "-G${CMAKE_GENERATOR}"
"-DCMAKE_TOOLCHAIN_FILE=${qt_abi_toolchain_path}"
"-DQT_HOST_PATH=${QT_HOST_PATH}"
"-DQT_IS_ANDROID_MULTI_ABI_EXTERNAL_PROJECT=ON"
"-DQT_INTERNAL_ANDROID_MULTI_ABI_BINARY_DIR=${CMAKE_BINARY_DIR}"
"${config_arg}"
"${extra_cmake_args}"
+ "-B" "${android_abi_build_dir}"
+ "-S" "${CMAKE_SOURCE_DIR}"
EXCLUDE_FROM_ALL TRUE
BUILD_COMMAND "" # avoid top-level build of external project
)
diff --git a/src/corelib/Qt6CTestMacros.cmake b/src/corelib/Qt6CTestMacros.cmake
index 1b4a8cb19b..a34069054f 100644
--- a/src/corelib/Qt6CTestMacros.cmake
+++ b/src/corelib/Qt6CTestMacros.cmake
@@ -1,5 +1,5 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+# SPDX-License-Identifier: BSD-3-Clause
#
# W A R N I N G
@@ -11,13 +11,13 @@
#
# We mean it.
-message("CMAKE_VERSION: ${CMAKE_VERSION}")
-message("CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
-message("CMAKE_MODULES_UNDER_TEST: ${CMAKE_MODULES_UNDER_TEST}")
+message(STATUS "CMAKE_VERSION: ${CMAKE_VERSION}")
+message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
+message(STATUS "CMAKE_MODULES_UNDER_TEST: ${CMAKE_MODULES_UNDER_TEST}")
foreach(_mod ${CMAKE_MODULES_UNDER_TEST})
- message("CMAKE_${_mod}_MODULE_MAJOR_VERSION: ${CMAKE_${_mod}_MODULE_MAJOR_VERSION}")
- message("CMAKE_${_mod}_MODULE_MINOR_VERSION: ${CMAKE_${_mod}_MODULE_MINOR_VERSION}")
- message("CMAKE_${_mod}_MODULE_PATCH_VERSION: ${CMAKE_${_mod}_MODULE_PATCH_VERSION}")
+ message(STATUS "CMAKE_${_mod}_MODULE_MAJOR_VERSION: ${CMAKE_${_mod}_MODULE_MAJOR_VERSION}")
+ message(STATUS "CMAKE_${_mod}_MODULE_MINOR_VERSION: ${CMAKE_${_mod}_MODULE_MINOR_VERSION}")
+ message(STATUS "CMAKE_${_mod}_MODULE_PATCH_VERSION: ${CMAKE_${_mod}_MODULE_PATCH_VERSION}")
endforeach()
# Generate a shell script wrapper that calls ninja with -v parameter.
@@ -163,6 +163,13 @@ function(_qt_internal_get_cmake_test_configure_options out_var)
endfunction()
function(_qt_internal_set_up_test_run_environment testname)
+ set(no_value_options NO_PLUGIN_PATH)
+ set(single_value_options "")
+ set(multi_value_options "")
+ cmake_parse_arguments(PARSE_ARGV 1 arg
+ "${no_value_options}" "${single_value_options}" "${multi_value_options}"
+ )
+
# This is copy-pasted from qt_add_test and adapted to the standalone project case.
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
set(QT_PATH_SEPARATOR "\\;")
@@ -201,20 +208,20 @@ function(_qt_internal_set_up_test_run_environment testname)
set_property(TEST "${testname}" APPEND PROPERTY ENVIRONMENT "${test_env_path}")
set_property(TEST "${testname}" APPEND PROPERTY ENVIRONMENT "QT_TEST_RUNNING_IN_CTEST=1")
- # Add the install prefix to list of plugin paths when doing a prefix build
- if(NOT QT_INSTALL_DIR)
- foreach(install_prefix ${install_prefixes})
- list(APPEND plugin_paths "${install_prefix}/${INSTALL_PLUGINSDIR}")
- endforeach()
- endif()
-
- #TODO: Collect all paths from known repositories when performing a super
- # build.
- list(APPEND plugin_paths "${PROJECT_BINARY_DIR}/${INSTALL_PLUGINSDIR}")
- list(JOIN plugin_paths "${QT_PATH_SEPARATOR}" plugin_paths_joined)
- set_property(TEST "${testname}"
- APPEND PROPERTY ENVIRONMENT "QT_PLUGIN_PATH=${plugin_paths_joined}")
+ if(NOT arg_NO_PLUGIN_PATH)
+ # Add the install prefix to list of plugin paths when doing a prefix build
+ if(NOT QT_INSTALL_DIR)
+ foreach(install_prefix ${install_prefixes})
+ list(APPEND plugin_paths "${install_prefix}/${INSTALL_PLUGINSDIR}")
+ endforeach()
+ endif()
+ # TODO: Collect all paths from known repositories when performing a super build.
+ list(APPEND plugin_paths "${PROJECT_BINARY_DIR}/${INSTALL_PLUGINSDIR}")
+ list(JOIN plugin_paths "${QT_PATH_SEPARATOR}" plugin_paths_joined)
+ set_property(TEST "${testname}"
+ APPEND PROPERTY ENVIRONMENT "QT_PLUGIN_PATH=${plugin_paths_joined}")
+ endif()
endfunction()
# Checks if the test project can be built successfully. Arguments:
@@ -252,13 +259,18 @@ endfunction()
# TESTNAME: a custom test name to use instead of the one derived from the source directory name
#
# BUILD_OPTIONS: a list of -D style CMake definitions to pass to ctest's --build-options (which
-# are ultimately passed to the CMake invocation of the test project)
+# are ultimately passed to the CMake invocation of the test project). You may
+# escape semicolons inside the definitions using:
+# https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#bracket-argument
+# so the argument containing list will look as following:
+# -DLIST_ARGUMENT=item1[[;]]item2[[;]]...itemN.
macro(_qt_internal_test_expect_pass _dir)
set(_test_option_args
SIMULATE_IN_SOURCE
NO_CLEAN_STEP
NO_BUILD_PROJECT_ARG
NO_IOS_DEFAULT_ARGS
+ NO_RUN_ENVIRONMENT_PLUGIN_PATH
)
set(_test_single_args
BINARY
@@ -414,6 +426,8 @@ macro(_qt_internal_test_expect_pass _dir)
)
endif()
+ string(REPLACE "[[;]]" "\;" _ARGS_BUILD_OPTIONS "${_ARGS_BUILD_OPTIONS}")
+
_qt_internal_get_cmake_test_configure_options(option_list)
set(ctest_command_args
--build-and-test
@@ -425,23 +439,160 @@ macro(_qt_internal_test_expect_pass _dir)
--build-makeprogram "${make_program}"
${build_project}
--build-options "${option_list}"
- ${_ARGS_BUILD_OPTIONS} ${additional_configure_args}
+ "${_ARGS_BUILD_OPTIONS}" ${additional_configure_args}
${test_command}
)
add_test(${testname} ${CMAKE_CTEST_COMMAND} ${ctest_command_args})
if(_ARGS_SIMULATE_IN_SOURCE)
set_tests_properties(${testname} PROPERTIES
- FIXTURES_REQUIRED "${testname}SIMULATE_IN_SOURCE_FIXTURE")
+ FIXTURES_REQUIRED "${testname}SIMULATE_IN_SOURCE_FIXTURE"
+ )
endif()
+ set_tests_properties(${testname} PROPERTIES ENVIRONMENT "ASAN_OPTIONS=detect_leaks=0")
if(_ARGS_BINARY)
- _qt_internal_set_up_test_run_environment("${testname}")
+ set(run_env_args "")
+ if(_ARGS_NO_RUN_ENVIRONMENT_PLUGIN_PATH)
+ list(APPEND run_env_args NO_PLUGIN_PATH)
+ endif()
+ _qt_internal_set_up_test_run_environment("${testname}" ${run_env_args})
endif()
unset(__expect_pass_source_dir)
unset(__expect_pass_build_dir)
endmacro()
+# Checks if a qmake project can be built successfully. Arguments:
+#
+# TESTNAME: a custom test name to use instead of the one derived from the source directory name.
+# the name also applies to the generated build directory.
+#
+# QMAKE_OPTIONS: a list of variable assignments to pass to the qmake invocation.
+# e.g. CONFIG+=debug
+#
+# BUILD_ENVIRONMENT: a list of environment assignments to use when invoking the build tool
+function(_qt_internal_add_qmake_test dir_name)
+ set(test_option_args
+ )
+ set(test_single_args
+ TESTNAME
+ )
+ set(test_multi_args
+ QMAKE_OPTIONS
+ BUILD_ENVIRONMENT
+ )
+
+ # PARSE_ARGV parsing keeps ';' in ENVIRONMENT variables
+ cmake_parse_arguments(PARSE_ARGV 1 arg
+ "${test_option_args}"
+ "${test_single_args}"
+ "${test_multi_args}"
+ )
+
+ if(arg_TESTNAME)
+ set(testname "${arg_TESTNAME}")
+ else()
+ string(REGEX REPLACE "[/)(]" "_" testname "${dir_name}")
+ endif()
+
+ set(source_dir "${CMAKE_CURRENT_SOURCE_DIR}/${dir_name}")
+ if(arg_TESTNAME)
+ set(build_dir "${CMAKE_CURRENT_BINARY_DIR}/${arg_TESTNAME}")
+ else()
+ set(build_dir "${CMAKE_CURRENT_BINARY_DIR}/${dir_name}")
+ endif()
+
+ # Find the qmake binary or the wrapper qmake script when cross-compiling..
+ if(QtBase_BINARY_DIR AND NOT QT_BUILD_STANDALONE_TESTS)
+ set(qmake_dir "${QtBase_BINARY_DIR}/${INSTALL_BINDIR}")
+ else()
+ set(qmake_dir "${QT6_INSTALL_PREFIX}/${QT6_INSTALL_BINS}")
+ endif()
+
+ set(qmake_path "${qmake_dir}/qmake${CMAKE_EXECUTABLE_SUFFIX}")
+
+ set(qmake_args
+ "${source_dir}"
+ ${arg_QMAKE_OPTIONS}
+ )
+
+ # Try to choose an appropriate build tool.
+ if(ENV{QT_QMAKE_TEST_BUILD_TOOL})
+ set(build_tool "$ENV{QT_QMAKE_TEST_BUILD_TOOL}")
+ elseif(MSVC)
+ set(build_tool "nmake")
+ elseif(MINGW)
+ set(build_tool "mingw32-make")
+ else()
+ set(build_tool "make")
+ endif()
+
+ set(build_tool_args "")
+ if(ENV{QT_QMAKE_TEST_BUILD_TOOL_OPTIONS})
+ set(build_tool_args "$ENV{QT_QMAKE_TEST_BUILD_TOOL_OPTIONS}")
+ endif()
+
+ # Remove any stale build dir, and create a new one on each test rerun.
+ add_test(${testname}_remove_build_dir
+ ${CMAKE_COMMAND} -E remove_directory "${build_dir}"
+ )
+ set_tests_properties(${testname}_remove_build_dir PROPERTIES
+ FIXTURES_SETUP "${testname}_ensure_clean_build_dir"
+ )
+
+ add_test(${testname}_create_build_dir
+ ${CMAKE_COMMAND} -E make_directory "${build_dir}"
+ )
+ set_tests_properties(${testname}_create_build_dir PROPERTIES
+ FIXTURES_SETUP "${testname}_ensure_clean_build_dir"
+ )
+
+ set_tests_properties(${testname}_create_build_dir
+ PROPERTIES DEPENDS ${testname}_remove_build_dir)
+
+ # Add test to call qmake.
+ #
+ # We can't use the add_test(NAME) signature to set a working directory, because that breaks
+ # when calling ctest without a -C <config> using multi-config generators, and the CI calls
+ # ctest without -C, and we use Xcode when configuring tests for iOS, which is multi-config.
+ # The plain add_test signature does not have this issue.
+ # Work around this by using a wrapper script that sets a working directory and use the plain
+ # signature.
+ # Somewhat related issue https://gitlab.kitware.com/cmake/cmake/-/issues/20283
+ set(qmake_wrapper_file "${CMAKE_CURRENT_BINARY_DIR}/run_qmake_${testname}.cmake")
+ _qt_internal_create_command_script(
+ COMMAND "${qmake_path}" ${qmake_args}
+ COMMAND_ECHO STDOUT
+ OUTPUT_FILE "${qmake_wrapper_file}"
+ WORKING_DIRECTORY "${build_dir}"
+ )
+
+ add_test(${testname}_qmake "${CMAKE_COMMAND}" "-P" "${qmake_wrapper_file}")
+
+ set_tests_properties(${testname}_qmake PROPERTIES
+ DEPENDS ${testname}_create_build_dir
+ FIXTURES_REQUIRED "${testname}_ensure_clean_build_dir"
+ FIXTURES_SETUP "${testname}_configure_project"
+ )
+
+ # Add test to build the generated qmake project.
+ set(build_tool_wrapper_file "${CMAKE_CURRENT_BINARY_DIR}/run_build_${testname}.cmake")
+ _qt_internal_create_command_script(
+ COMMAND "${build_tool}" ${build_tool_args}
+ COMMAND_ECHO STDOUT
+ OUTPUT_FILE "${build_tool_wrapper_file}"
+ WORKING_DIRECTORY "${build_dir}"
+ ENVIRONMENT ${arg_BUILD_ENVIRONMENT}
+ )
+
+ add_test(${testname} "${CMAKE_COMMAND}" "-P" "${build_tool_wrapper_file}")
+
+ set_tests_properties(${testname} PROPERTIES
+ DEPENDS ${testname}_qmake
+ FIXTURES_REQUIRED "${testname}_ensure_clean_build_dir;${testname}_configure_project"
+ )
+endfunction()
+
# Checks if the build of the test project fails.
# This test passes if the test project fails either at the
# configuring or build steps.
diff --git a/src/corelib/Qt6CoreConfigExtras.cmake.in b/src/corelib/Qt6CoreConfigExtras.cmake.in
index 8b4d3164cf..16f2ea0068 100644
--- a/src/corelib/Qt6CoreConfigExtras.cmake.in
+++ b/src/corelib/Qt6CoreConfigExtras.cmake.in
@@ -28,25 +28,11 @@ endif()
set(CMAKE_AUTOMOC_MACRO_NAMES "Q_OBJECT" "Q_GADGET" "Q_GADGET_EXPORT" "Q_NAMESPACE" "Q_NAMESPACE_EXPORT")
-# install layout information, following what qmake -query provides
-get_filename_component(QT@PROJECT_VERSION_MAJOR@_INSTALL_PREFIX ${CMAKE_CURRENT_LIST_DIR}/../@QT_INVERSE_CONFIG_INSTALL_DIR@ ABSOLUTE)
-set(QT@PROJECT_VERSION_MAJOR@_INSTALL_ARCHDATA "@INSTALL_ARCHDATADIR@")
-set(QT@PROJECT_VERSION_MAJOR@_INSTALL_BINS "@INSTALL_BINDIR@")
-set(QT@PROJECT_VERSION_MAJOR@_INSTALL_CONFIGURATION "@INSTALL_SYSCONFDIR@")
-set(QT@PROJECT_VERSION_MAJOR@_INSTALL_DATA "@INSTALL_DATADIR@")
-set(QT@PROJECT_VERSION_MAJOR@_INSTALL_DOCS "@INSTALL_DOCDIR@")
-set(QT@PROJECT_VERSION_MAJOR@_INSTALL_EXAMPLES "@INSTALL_EXAMPLESDIR@")
-set(QT@PROJECT_VERSION_MAJOR@_INSTALL_HEADERS "@INSTALL_INCLUDEDIR@")
-set(QT@PROJECT_VERSION_MAJOR@_INSTALL_LIBS "@INSTALL_LIBDIR@")
-set(QT@PROJECT_VERSION_MAJOR@_INSTALL_LIBEXECS "@INSTALL_LIBEXECDIR@")
-set(QT@PROJECT_VERSION_MAJOR@_INSTALL_PLUGINS "@INSTALL_PLUGINSDIR@")
-set(QT@PROJECT_VERSION_MAJOR@_INSTALL_QML "@INSTALL_QMLDIR@")
-set(QT@PROJECT_VERSION_MAJOR@_INSTALL_TESTS "@INSTALL_TESTSDIR@")
-set(QT@PROJECT_VERSION_MAJOR@_INSTALL_TRANSLATIONS "@INSTALL_TRANSLATIONSDIR@")
+include("${CMAKE_CURRENT_LIST_DIR}/QtInstallPaths.cmake")
+
set(QT@PROJECT_VERSION_MAJOR@_IS_SHARED_LIBS_BUILD "@BUILD_SHARED_LIBS@")
-get_filename_component(_Qt6CoreConfigDir ${CMAKE_CURRENT_LIST_FILE} PATH)
-set(_Qt6CTestMacros "${_Qt6CoreConfigDir}/Qt6CTestMacros.cmake")
+set(_Qt6CTestMacros "${CMAKE_CURRENT_LIST_DIR}/Qt6CTestMacros.cmake")
_qt_internal_setup_deploy_support()
@@ -64,7 +50,17 @@ if(ANDROID_PLATFORM)
endif()
endif()
+if(QT_FEATURE_permissions AND APPLE)
+ if(NOT QT_NO_CREATE_TARGETS)
+ set_property(TARGET ${__qt_core_target} APPEND PROPERTY
+ INTERFACE_QT_EXECUTABLE_FINALIZERS
+ _qt_internal_darwin_permission_finalizer
+ )
+ endif()
+endif()
+
if(EMSCRIPTEN)
+ set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
include("${CMAKE_CURRENT_LIST_DIR}/@QT_CMAKE_EXPORT_NAMESPACE@WasmMacros.cmake")
endif()
diff --git a/src/corelib/Qt6CoreDeploySupport.cmake b/src/corelib/Qt6CoreDeploySupport.cmake
index 5c3d6d7a2a..d149796b21 100644
--- a/src/corelib/Qt6CoreDeploySupport.cmake
+++ b/src/corelib/Qt6CoreDeploySupport.cmake
@@ -1,5 +1,5 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+# SPDX-License-Identifier: BSD-3-Clause
# NOTE: This code should only ever be executed in script mode. It expects to be
# used either as part of an install(CODE) call or called by a script
@@ -105,6 +105,178 @@ if(NOT __QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
endfunction()
endif()
+# Copied from QtCMakeHelpers.cmake
+function(_qt_internal_re_escape out_var str)
+ string(REGEX REPLACE "([][+.*()^])" "\\\\\\1" regex "${str}")
+ set(${out_var} ${regex} PARENT_SCOPE)
+endfunction()
+
+function(_qt_internal_set_rpath)
+ if(NOT CMAKE_HOST_UNIX OR CMAKE_HOST_APPLE)
+ message(WARNING "_qt_internal_set_rpath is not implemented on this platform.")
+ return()
+ endif()
+
+ set(no_value_options "")
+ set(single_value_options FILE NEW_RPATH)
+ set(multi_value_options "")
+ cmake_parse_arguments(PARSE_ARGV 0 arg
+ "${no_value_options}" "${single_value_options}" "${multi_value_options}"
+ )
+ if(__QT_DEPLOY_USE_PATCHELF)
+ message(STATUS "Setting runtime path of '${arg_FILE}' to '${arg_NEW_RPATH}'.")
+ execute_process(
+ COMMAND ${__QT_DEPLOY_PATCHELF_EXECUTABLE} --set-rpath "${arg_NEW_RPATH}" "${arg_FILE}"
+ RESULT_VARIABLE process_result
+ )
+ if(NOT process_result EQUAL "0")
+ if(process_result MATCHES "^[0-9]+$")
+ message(FATAL_ERROR "patchelf failed with exit code ${process_result}.")
+ else()
+ message(FATAL_ERROR "patchelf failed: ${process_result}.")
+ endif()
+ endif()
+ else()
+ # Warning: file(RPATH_SET) is CMake-internal API.
+ file(RPATH_SET
+ FILE "${arg_FILE}"
+ NEW_RPATH "${arg_NEW_RPATH}"
+ )
+ endif()
+endfunction()
+
+# Store the platform-dependent $ORIGIN marker in out_var.
+function(_qt_internal_get_rpath_origin out_var)
+ if(__QT_DEPLOY_SYSTEM_NAME STREQUAL "Darwin")
+ set(rpath_origin "@loader_path")
+ else()
+ set(rpath_origin "$ORIGIN")
+ endif()
+ set(${out_var} ${rpath_origin} PARENT_SCOPE)
+endfunction()
+
+function(_qt_internal_generic_deployqt)
+ set(no_value_options
+ NO_TRANSLATIONS
+ VERBOSE
+ )
+ set(single_value_options
+ LIB_DIR
+ PLUGINS_DIR
+ )
+ set(file_GRD_options
+ EXECUTABLES
+ LIBRARIES
+ MODULES
+ PRE_INCLUDE_REGEXES
+ PRE_EXCLUDE_REGEXES
+ POST_INCLUDE_REGEXES
+ POST_EXCLUDE_REGEXES
+ POST_INCLUDE_FILES
+ POST_EXCLUDE_FILES
+ )
+ set(multi_value_options ${file_GRD_options})
+ cmake_parse_arguments(PARSE_ARGV 0 arg
+ "${no_value_options}" "${single_value_options}" "${multi_value_options}"
+ )
+
+ if(arg_VERBOSE OR __QT_DEPLOY_VERBOSE)
+ set(verbose TRUE)
+ endif()
+
+ # Make input file paths absolute
+ foreach(var IN ITEMS EXECUTABLES LIBRARIES MODULES)
+ string(PREPEND var arg_)
+ set(abspaths "")
+ foreach(path IN LISTS ${var})
+ get_filename_component(abspath "${path}" REALPATH BASE_DIR "${QT_DEPLOY_PREFIX}")
+ list(APPEND abspaths "${abspath}")
+ endforeach()
+ set(${var} "${abspaths}")
+ endforeach()
+
+ # We need to get the runtime dependencies of plugins too.
+ list(APPEND arg_MODULES ${__QT_DEPLOY_PLUGINS})
+
+ # Forward the arguments that are exactly the same for file(GET_RUNTIME_DEPENDENCIES).
+ set(file_GRD_args "")
+ foreach(var IN LISTS file_GRD_options)
+ if(NOT "${arg_${var}}" STREQUAL "")
+ list(APPEND file_GRD_args ${var} ${arg_${var}})
+ endif()
+ endforeach()
+
+ # Compile a list of regular expressions that represent ignored library directories.
+ if("${arg_POST_EXCLUDE_REGEXES}" STREQUAL "")
+ set(regexes "")
+ foreach(path IN LISTS QT_DEPLOY_IGNORED_LIB_DIRS)
+ _qt_internal_re_escape(path_rex "${path}")
+ list(APPEND regexes "^${path_rex}")
+ endforeach()
+ if(regexes)
+ list(APPEND file_GRD_args POST_EXCLUDE_REGEXES ${regexes})
+ endif()
+ endif()
+
+ # Get the runtime dependencies recursively.
+ file(GET_RUNTIME_DEPENDENCIES
+ ${file_GRD_args}
+ RESOLVED_DEPENDENCIES_VAR resolved
+ UNRESOLVED_DEPENDENCIES_VAR unresolved
+ CONFLICTING_DEPENDENCIES_PREFIX conflicting
+ )
+ if(verbose)
+ message("file(GET_RUNTIME_DEPENDENCIES ${file_args})")
+ foreach(file IN LISTS resolved)
+ message(" resolved: ${file}")
+ endforeach()
+ foreach(file IN LISTS unresolved)
+ message(" unresolved: ${file}")
+ endforeach()
+ foreach(file IN LISTS conflicting_FILENAMES)
+ message(" conflicting: ${file}")
+ message(" with ${conflicting_${file}}")
+ endforeach()
+ endif()
+
+ # Deploy the Qt libraries.
+ file(INSTALL ${resolved}
+ DESTINATION "${QT_DEPLOY_PREFIX}/${arg_LIB_DIR}"
+ FOLLOW_SYMLINK_CHAIN
+ )
+
+ # Determine the runtime path origin marker if necessary.
+ if(__QT_DEPLOY_MUST_ADJUST_PLUGINS_RPATH)
+ _qt_internal_get_rpath_origin(rpath_origin)
+ endif()
+
+ # Deploy the Qt plugins.
+ foreach(file_path IN LISTS __QT_DEPLOY_PLUGINS)
+ file(RELATIVE_PATH destination
+ "${__QT_DEPLOY_QT_INSTALL_PREFIX}/${__QT_DEPLOY_QT_INSTALL_PLUGINS}"
+ "${file_path}"
+ )
+ get_filename_component(destination "${destination}" DIRECTORY)
+ string(PREPEND destination "${QT_DEPLOY_PREFIX}/${arg_PLUGINS_DIR}/")
+ file(INSTALL ${file_path} DESTINATION ${destination})
+
+ if(__QT_DEPLOY_MUST_ADJUST_PLUGINS_RPATH)
+ get_filename_component(file_name ${file_path} NAME)
+ file(RELATIVE_PATH rel_lib_dir "${destination}"
+ "${QT_DEPLOY_PREFIX}/${QT_DEPLOY_LIB_DIR}")
+ _qt_internal_set_rpath(
+ FILE "${destination}/${file_name}"
+ NEW_RPATH "${rpath_origin}/${rel_lib_dir}"
+ )
+ endif()
+ endforeach()
+
+ # Deploy translations.
+ if(NOT arg_NO_TRANSLATIONS)
+ qt6_deploy_translations()
+ endif()
+endfunction()
+
# This function is currently in Technical Preview.
# Its signature and behavior might change.
function(qt6_deploy_runtime_dependencies)
@@ -118,6 +290,7 @@ function(qt6_deploy_runtime_dependencies)
VERBOSE
NO_OVERWRITE
NO_APP_STORE_COMPLIANCE # TODO: Might want a better name
+ NO_TRANSLATIONS
)
set(single_value_options
EXECUTABLE
@@ -126,6 +299,16 @@ function(qt6_deploy_runtime_dependencies)
PLUGINS_DIR
QML_DIR
)
+ set(file_GRD_options
+ # The following include/exclude options are only used if the "generic deploy tool" is
+ # used. The options are what file(GET_RUNTIME_DEPENDENCIES) supports.
+ PRE_INCLUDE_REGEXES
+ PRE_EXCLUDE_REGEXES
+ POST_INCLUDE_REGEXES
+ POST_EXCLUDE_REGEXES
+ POST_INCLUDE_FILES
+ POST_EXCLUDE_FILES
+ )
set(multi_value_options
# These ADDITIONAL_... options are based on what file(GET_RUNTIME_DEPENDENCIES)
# supports. We differentiate between the types of binaries so that we keep
@@ -135,6 +318,7 @@ function(qt6_deploy_runtime_dependencies)
ADDITIONAL_EXECUTABLES
ADDITIONAL_LIBRARIES
ADDITIONAL_MODULES
+ ${file_GRD_options}
)
cmake_parse_arguments(PARSE_ARGV 0 arg
"${no_value_options}" "${single_value_options}" "${multi_value_options}"
@@ -173,8 +357,8 @@ function(qt6_deploy_runtime_dependencies)
set(arg_EXECUTABLE "${CMAKE_MATCH_1}")
endif()
elseif(arg_GENERATE_QT_CONF)
- get_filename_component(exe_dir "${arg_EXECUTABLE}" DIRECTORY)
- if(exe_dir STREQUAL "")
+ set(exe_dir "${QT_DEPLOY_BIN_DIR}")
+ if(exe_dir STREQUAL "" OR exe_dir STREQUAL ".")
set(exe_dir ".")
set(prefix ".")
else()
@@ -202,6 +386,8 @@ function(qt6_deploy_runtime_dependencies)
list(APPEND tool_options --verbose 2)
elseif(__QT_DEPLOY_SYSTEM_NAME STREQUAL Darwin)
list(APPEND tool_options -verbose=3)
+ else()
+ list(APPEND tool_options VERBOSE)
endif()
endif()
@@ -214,6 +400,9 @@ function(qt6_deploy_runtime_dependencies)
if(NOT arg_NO_OVERWRITE)
list(APPEND tool_options --force)
endif()
+ if(arg_NO_TRANSLATIONS)
+ list(APPEND tool_options --no-translations)
+ endif()
elseif(__QT_DEPLOY_SYSTEM_NAME STREQUAL Darwin)
set(extra_binaries_option "-executable=")
if(NOT arg_NO_APP_STORE_COMPLIANCE)
@@ -228,10 +417,43 @@ function(qt6_deploy_runtime_dependencies)
# for debugging purposes. It may be removed at any time without warning.
list(APPEND tool_options ${__qt_deploy_tool_extra_options})
+ if(__QT_DEPLOY_TOOL STREQUAL "GRD")
+ message(STATUS "Running generic Qt deploy tool on ${arg_EXECUTABLE}")
+
+ # Construct the EXECUTABLES, LIBRARIES and MODULES arguments.
+ list(APPEND tool_options EXECUTABLES ${arg_EXECUTABLE})
+ if(NOT "${arg_ADDITIONAL_EXECUTABLES}" STREQUAL "")
+ list(APPEND tool_options ${arg_ADDITIONAL_EXECUTABLES})
+ endif()
+ foreach(file_type LIBRARIES MODULES)
+ if("${arg_ADDITIONAL_${file_type}}" STREQUAL "")
+ continue()
+ endif()
+ list(APPEND tool_options ${file_type} ${arg_ADDITIONAL_${file_type}})
+ endforeach()
+
+ # Forward the arguments that are exactly the same for file(GET_RUNTIME_DEPENDENCIES).
+ foreach(var IN LISTS file_GRD_options)
+ if(NOT "${arg_${var}}" STREQUAL "")
+ list(APPEND tool_options ${var} ${arg_${var}})
+ endif()
+ endforeach()
+
+ if(arg_NO_TRANSLATIONS)
+ list(APPEND tool_options NO_TRANSLATIONS)
+ endif()
+
+ _qt_internal_generic_deployqt(
+ EXECUTABLE "${arg_EXECUTABLE}"
+ LIB_DIR "${arg_LIB_DIR}"
+ PLUGINS_DIR "${arg_PLUGINS_DIR}"
+ ${tool_options}
+ )
+ return()
+ endif()
+
# Both windeployqt and macdeployqt don't differentiate between the different
# types of binaries, so we merge the lists and treat them all the same.
- # A purely CMake-based implementation would need to treat them differently
- # because of how file(GET_RUNTIME_DEPENDENCIES) works.
set(additional_binaries
${arg_ADDITIONAL_EXECUTABLES}
${arg_ADDITIONAL_LIBRARIES}
@@ -272,3 +494,147 @@ function(_qt_internal_show_skip_runtime_deploy_message qt_build_type_string)
"this target platform (${__QT_DEPLOY_SYSTEM_NAME}, ${qt_build_type_string})."
)
endfunction()
+
+# This function is currently in Technical Preview.
+# Its signature and behavior might change.
+function(qt6_deploy_translations)
+ set(no_value_options VERBOSE)
+ set(single_value_options
+ LCONVERT
+ )
+ set(multi_value_options
+ CATALOGS
+ LOCALES
+ )
+ cmake_parse_arguments(PARSE_ARGV 0 arg
+ "${no_value_options}" "${single_value_options}" "${multi_value_options}"
+ )
+
+ set(verbose OFF)
+ if(arg_VERBOSE OR __QT_DEPLOY_VERBOSE)
+ set(verbose ON)
+ endif()
+
+ if(arg_CATALOGS)
+ set(catalogs ${arg_CATALOGS})
+ else()
+ set(catalogs qt qtbase)
+
+ # Find the translations that belong to the Qt modules that are used by the project.
+ # "Used by the project" means just all modules that are pulled in via find_package for now.
+ set(modules ${__QT_DEPLOY_ALL_MODULES_FOUND_VIA_FIND_PACKAGE})
+
+ set(module_catalog_mapping
+ "Bluetooth|Nfc" qtconnectivity
+ "Help" qt_help
+ "Multimedia(Widgets|QuickPrivate)?" qtmultimedia
+ "Qml|Quick" qtdeclarative
+ "SerialPort" qtserialport
+ "WebEngine" qtwebengine
+ "WebSockets" qtwebsockets
+ )
+ list(LENGTH module_catalog_mapping max_i)
+ math(EXPR max_i "${max_i} - 1")
+ foreach(module IN LISTS modules)
+ foreach(i RANGE 0 ${max_i} 2)
+ list(GET module_catalog_mapping ${i} module_rex)
+ if(NOT module MATCHES "^${module_rex}")
+ continue()
+ endif()
+ math(EXPR k "${i} + 1")
+ list(GET module_catalog_mapping ${k} catalog)
+ list(APPEND catalogs ${catalog})
+ endforeach()
+ endforeach()
+ endif()
+
+ get_filename_component(qt_translations_dir "${__QT_DEPLOY_QT_INSTALL_TRANSLATIONS}" ABSOLUTE
+ BASE_DIR "${__QT_DEPLOY_QT_INSTALL_PREFIX}"
+ )
+ set(locales ${arg_LOCALES})
+ if(NOT locales)
+ file(GLOB locales RELATIVE "${qt_translations_dir}" "${qt_translations_dir}/*.qm")
+ list(TRANSFORM locales REPLACE "\\.qm$" "")
+ list(TRANSFORM locales REPLACE "^qt_help" "qt-help")
+ list(TRANSFORM locales REPLACE "^[^_]+" "")
+ list(TRANSFORM locales REPLACE "^_" "")
+ list(REMOVE_DUPLICATES locales)
+ endif()
+
+ # Ensure existence of the output directory.
+ set(output_dir "${QT_DEPLOY_PREFIX}/${QT_DEPLOY_TRANSLATIONS_DIR}")
+ if(NOT EXISTS "${output_dir}")
+ file(MAKE_DIRECTORY "${output_dir}")
+ endif()
+
+ # Locate lconvert.
+ if(arg_LCONVERT)
+ set(lconvert "${arg_LCONVERT}")
+ else()
+ set(lconvert "${__QT_DEPLOY_QT_INSTALL_PREFIX}/${__QT_DEPLOY_QT_INSTALL_BINS}/lconvert")
+ if(CMAKE_HOST_WIN32)
+ string(APPEND lconvert ".exe")
+ endif()
+ if(NOT EXISTS ${lconvert})
+ message(STATUS "lconvert was not found. Skipping deployment of translations.")
+ return()
+ endif()
+ endif()
+
+ # Find the .qm files for the selected locales
+ if(verbose)
+ message(STATUS "Looking for translations in ${qt_translations_dir}")
+ endif()
+ foreach(locale IN LISTS locales)
+ set(qm_files "")
+ foreach(catalog IN LISTS catalogs)
+ set(qm_file "${catalog}_${locale}.qm")
+ if(EXISTS "${qt_translations_dir}/${qm_file}")
+ list(APPEND qm_files ${qm_file})
+ endif()
+ endforeach()
+
+ if(NOT qm_files)
+ message(WARNING "No translations found for requested locale '${locale}'.")
+ continue()
+ endif()
+
+ if(verbose)
+ foreach(qm_file IN LISTS qm_files)
+ message(STATUS "found translation file: ${qm_file}")
+ endforeach()
+ endif()
+
+ # Merge the .qm files into one qt_${locale}.qm file.
+ set(output_file_name "qt_${locale}.qm")
+ set(output_file_path "${output_dir}/${output_file_name}")
+ message(STATUS "Creating: ${output_file_path}")
+ set(extra_options)
+ if(verbose)
+ list(APPEND extra_options COMMAND_ECHO STDOUT)
+ endif()
+ execute_process(
+ COMMAND ${lconvert} -if qm -o ${output_file_path} ${qm_files}
+ WORKING_DIRECTORY ${qt_translations_dir}
+ RESULT_VARIABLE process_result
+ ${extra_options}
+ )
+ if(NOT process_result EQUAL "0")
+ if(process_result MATCHES "^[0-9]+$")
+ message(WARNING "lconvert failed with exit code ${process_result}.")
+ else()
+ message(WARNING "lconvert failed: ${process_result}.")
+ endif()
+ endif()
+ endforeach()
+endfunction()
+
+if(NOT __QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ function(qt_deploy_translations)
+ if(__QT_DEFAULT_MAJOR_VERSION EQUAL 6)
+ qt6_deploy_translations(${ARGV})
+ else()
+ message(FATAL_ERROR "qt_deploy_translations() is only available in Qt 6.")
+ endif()
+ endfunction()
+endif()
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake
index 1612d23b10..a4b17eda99 100644
--- a/src/corelib/Qt6CoreMacros.cmake
+++ b/src/corelib/Qt6CoreMacros.cmake
@@ -1,6 +1,6 @@
# Copyright 2005-2011 Kitware, Inc.
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: (LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0) AND BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
######################################
#
@@ -8,8 +8,6 @@
#
######################################
-include(CMakeParseArguments)
-
set(__qt_core_macros_module_base_dir "${CMAKE_CURRENT_LIST_DIR}")
# macro used to create the names of output files preserving relative dirs
@@ -553,6 +551,7 @@ function(qt6_add_executable target)
_qt_internal_create_executable("${target}" ${arg_UNPARSED_ARGUMENTS})
target_link_libraries("${target}" PRIVATE Qt6::Core)
+ set_property(TARGET ${target} PROPERTY _qt_expects_finalization TRUE)
if(arg_MANUAL_FINALIZATION)
# Caller says they will call qt6_finalize_target() themselves later
@@ -650,6 +649,7 @@ function(_qt_internal_finalize_executable target)
if(EMSCRIPTEN)
_qt_internal_wasm_add_target_helpers("${target}")
+ _qt_internal_add_wasm_extra_exported_methods("${target}")
endif()
if(IOS)
_qt_internal_finalize_ios_app("${target}")
@@ -703,6 +703,7 @@ function(qt6_finalize_target target)
message(FATAL_ERROR "No target '${target}' found in current scope.")
endif()
+ _qt_internal_expose_deferred_files_to_ide(${target})
get_target_property(target_type ${target} TYPE)
get_target_property(is_android_executable "${target}" _qt_is_android_executable)
@@ -711,612 +712,28 @@ function(qt6_finalize_target target)
endif()
endfunction()
-function(_qt_internal_handle_ios_launch_screen target)
- # Check if user provided a launch screen path via a variable.
- set(launch_screen "")
-
- # Check if the project provided a launch screen path via a variable.
- # This variable is currently in Technical Preview.
- if(QT_IOS_LAUNCH_SCREEN)
- set(launch_screen "${QT_IOS_LAUNCH_SCREEN}")
- endif()
-
- # Check if the project provided a launch screen path via a target property, it takes precedence
- # over the variable.
- # This property is currently in Technical Preview.
- get_target_property(launch_screen_from_prop "${target}" QT_IOS_LAUNCH_SCREEN)
- if(launch_screen_from_prop)
- set(launch_screen "${launch_screen_from_prop}")
- endif()
-
- # If the project hasn't provided a launch screen file path, use a copy of the template
- # that qmake uses.
- # It needs to be a copy because configure_file can't handle all the escaped double quotes
- # present in the qmake template file.
- set(is_default_launch_screen FALSE)
- if(NOT launch_screen AND NOT QT_NO_SET_DEFAULT_IOS_LAUNCH_SCREEN)
- set(is_default_launch_screen TRUE)
- set(launch_screen
- "${__qt_internal_cmake_ios_support_files_path}/LaunchScreen.storyboard")
- endif()
-
- # Check that the launch screen exists.
- if(launch_screen)
- if(NOT IS_ABSOLUTE "${launch_screen}")
- message(FATAL_ERROR
- "Provided launch screen value should be an absolute path: '${launch_screen}'")
- endif()
-
- if(NOT EXISTS "${launch_screen}")
- message(FATAL_ERROR
- "Provided launch screen file does not exist: '${launch_screen}'")
- endif()
- endif()
-
- if(launch_screen AND NOT QT_NO_ADD_IOS_LAUNCH_SCREEN_TO_BUNDLE)
- get_filename_component(launch_screen_name "${launch_screen}" NAME)
-
- # Make a copy of the default launch screen template for this target and replace the
- # label inside the template with the target name.
- if(is_default_launch_screen)
- # Configure our default template and place it in the build dir.
- set(launch_screen_in_path "${launch_screen}")
-
- string(MAKE_C_IDENTIFIER "${target}" target_identifier)
- set(launch_screen_out_dir
- "${CMAKE_CURRENT_BINARY_DIR}/.qt/launch_screen_storyboards/${target_identifier}")
-
- set(launch_screen_out_path
- "${launch_screen_out_dir}/${launch_screen_name}")
-
- file(MAKE_DIRECTORY "${launch_screen_out_dir}")
-
- # Replaces the value in the default template.
- set(QT_IOS_LAUNCH_SCREEN_TEXT "${target}")
- configure_file(
- "${launch_screen_in_path}"
- "${launch_screen_out_path}"
- @ONLY
- )
-
- set(final_launch_screen_path "${launch_screen_out_path}")
- else()
- set(final_launch_screen_path "${launch_screen}")
- endif()
-
- # Add the launch screen storyboard file as a source file, otherwise CMake doesn't consider
- # it as a resource file and MACOSX_PACKAGE_LOCATION processing will be skipped.
- target_sources("${target}" PRIVATE "${final_launch_screen_path}")
-
- # Ensure Xcode compiles the storyboard file and installs the compiled storyboard .nib files
- # into the app bundle.
- # We use target_sources and the MACOSX_PACKAGE_LOCATION source file property for that
- # instead of the RESOURCE target property, becaues the latter could potentially end up
- # needlessly installing the source storyboard file.
- #
- # We can't rely on policy CMP0118 since user project controls it.
- set(scope_args)
- if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.18")
- set(scope_args TARGET_DIRECTORY ${target})
- endif()
- set_source_files_properties("${final_launch_screen_path}" ${scope_args}
- PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
-
- # Save the launch screen name, so its value is added as an UILaunchStoryboardName entry
- # in the Qt generated Info.plist file.
- set_target_properties("${target}" PROPERTIES
- _qt_ios_launch_screen_name "${launch_screen_name}"
- _qt_ios_launch_screen_path "${final_launch_screen_path}")
- endif()
-endfunction()
-
-function(_qt_internal_find_ios_development_team_id out_var)
- get_property(team_id GLOBAL PROPERTY _qt_internal_ios_development_team_id)
- get_property(team_id_computed GLOBAL PROPERTY _qt_internal_ios_development_team_id_computed)
- if(team_id_computed)
- # Just in case if the value is non-empty but still booly FALSE.
- if(NOT team_id)
- set(team_id "")
- endif()
- set("${out_var}" "${team_id}" PARENT_SCOPE)
+function(_qt_internal_darwin_permission_finalizer target)
+ get_target_property(plist_file "${target}" MACOSX_BUNDLE_INFO_PLIST)
+ if(NOT plist_file)
return()
endif()
-
- set_property(GLOBAL PROPERTY _qt_internal_ios_development_team_id_computed "TRUE")
-
- set(home_dir "$ENV{HOME}")
- set(xcode_preferences_path "${home_dir}/Library/Preferences/com.apple.dt.Xcode.plist")
-
- # Extract the first account name (email) from the user's Xcode preferences
- message(DEBUG "Trying to extract an Xcode development team id from '${xcode_preferences_path}'")
- execute_process(COMMAND "/usr/libexec/PlistBuddy"
- -x -c "print IDEProvisioningTeams" "${xcode_preferences_path}"
- OUTPUT_VARIABLE teams_xml
- ERROR_VARIABLE plist_error)
-
- # Parsing state.
- set(is_free "")
- set(current_team_id "")
- set(parsing_is_free FALSE)
- set(parsing_team_id FALSE)
- set(first_team_id "")
-
- # Parse the xml output and return the first encountered non-free team id. If no non-free team id
- # is found, return the first encountered free team id.
- # If no team is found, return an empty string.
- #
- # Example input:
- #<plist version="1.0">
- #<dict>
- # <key>marty@planet.local</key>
- # <array>
- # <dict>
- # <key>isFreeProvisioningTeam</key>
- # <false/>
- # <key>teamID</key>
- # <string>AAA</string>
- # ...
- # </dict>
- # <dict>
- # <key>isFreeProvisioningTeam</key>
- # <true/>
- # <key>teamID</key>
- # <string>BBB</string>
- # ...
- # </dict>
- # </array>
- #</dict>
- #</plist>
- if(teams_xml AND NOT plist_error)
- string(REPLACE "\n" ";" teams_xml_lines "${teams_xml}")
-
- foreach(xml_line ${teams_xml_lines})
- string(STRIP "${xml_line}" xml_line)
- if(xml_line STREQUAL "<dict>")
- # Clean any previously found values when a new team dict is matched.
- set(is_free "")
- set(current_team_id "")
-
- elseif(xml_line STREQUAL "<key>isFreeProvisioningTeam</key>")
- set(parsing_is_free TRUE)
-
- elseif(parsing_is_free)
- set(parsing_is_free FALSE)
-
- if(xml_line MATCHES "true")
- set(is_free TRUE)
- else()
- set(is_free FALSE)
- endif()
-
- elseif(xml_line STREQUAL "<key>teamID</key>")
- set(parsing_team_id TRUE)
-
- elseif(parsing_team_id)
- set(parsing_team_id FALSE)
- if(xml_line MATCHES "<string>([^<]+)</string>")
- set(current_team_id "${CMAKE_MATCH_1}")
- else()
- continue()
- endif()
-
- string(STRIP "${current_team_id}" current_team_id)
-
- # If this is the first team id we found so far, remember that, regardless if's free
- # or not.
- if(NOT first_team_id AND current_team_id)
- set(first_team_id "${current_team_id}")
- endif()
-
- # Break early if we found a non-free team id and use it, because we prefer
- # a non-free team for signing, just like qmake.
- if(NOT is_free AND current_team_id)
- set(first_team_id "${current_team_id}")
- break()
- endif()
- endif()
- endforeach()
- endif()
-
- if(NOT first_team_id)
- message(DEBUG "Failed to extract an Xcode development team id.")
- set("${out_var}" "" PARENT_SCOPE)
- else()
- message(DEBUG "Successfully extracted the first encountered Xcode development team id.")
- set_property(GLOBAL PROPERTY _qt_internal_ios_development_team_id "${first_team_id}")
- set("${out_var}" "${first_team_id}" PARENT_SCOPE)
- endif()
-endfunction()
-
-function(_qt_internal_get_ios_bundle_identifier_prefix out_var)
- get_property(prefix GLOBAL PROPERTY _qt_internal_ios_bundle_identifier_prefix)
- get_property(prefix_computed GLOBAL PROPERTY
- _qt_internal_ios_bundle_identifier_prefix_computed)
- if(prefix_computed)
- # Just in case if the value is non-empty but still booly FALSE.
- if(NOT prefix)
- set(prefix "")
- endif()
- set("${out_var}" "${prefix}" PARENT_SCOPE)
- return()
- endif()
-
- set_property(GLOBAL PROPERTY _qt_internal_ios_bundle_identifier_prefix_computed "TRUE")
-
- set(home_dir "$ENV{HOME}")
- set(xcode_preferences_path "${home_dir}/Library/Preferences/com.apple.dt.Xcode.plist")
-
- message(DEBUG "Trying to extract the default bundle identifier prefix from Xcode preferences.")
- execute_process(COMMAND "/usr/libexec/PlistBuddy"
- -c "print IDETemplateOptions:bundleIdentifierPrefix"
- "${xcode_preferences_path}"
- OUTPUT_VARIABLE prefix
- ERROR_VARIABLE prefix_error)
- if(prefix AND NOT prefix_error)
- message(DEBUG "Successfully extracted the default bundle identifier prefix.")
- string(STRIP "${prefix}" prefix)
- else()
- message(DEBUG "Failed to extract the default bundle identifier prefix.")
- endif()
-
- if(prefix AND NOT prefix_error)
- set_property(GLOBAL PROPERTY _qt_internal_ios_bundle_identifier_prefix "${prefix}")
- set("${out_var}" "${prefix}" PARENT_SCOPE)
- else()
- set("${out_var}" "" PARENT_SCOPE)
- endif()
-endfunction()
-
-function(_qt_internal_escape_rfc_1034_identifier value out_var)
- # According to https://datatracker.ietf.org/doc/html/rfc1034#section-3.5
- # we can only use letters, digits, dot (.) and hyphens (-).
- # Underscores are not allowed.
- string(REGEX REPLACE "[^A-Za-z0-9.]" "-" value "${value}")
-
- set("${out_var}" "${value}" PARENT_SCOPE)
-endfunction()
-
-function(_qt_internal_get_default_ios_bundle_identifier out_var)
- _qt_internal_get_ios_bundle_identifier_prefix(prefix)
- if(NOT prefix)
- set(prefix "com.yourcompany")
-
- # For a better out-of-the-box experience, try to create a unique prefix by appending
- # the sha1 of the team id, if one is found.
- _qt_internal_find_ios_development_team_id(team_id)
- if(team_id)
- string(SHA1 hash "${team_id}")
- string(SUBSTRING "${hash}" 0 8 infix)
- string(APPEND prefix ".${infix}")
- else()
- message(WARNING
- "No organization bundle identifier prefix could be retrieved from Xcode "
- "preferences. This can lead to code signing issues due to a non-unique bundle "
- "identifier. Please set up an organization prefix by creating a new project within "
- "Xcode, or consider providing a custom bundle identifier by specifying the "
- "XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER property."
- )
- endif()
- endif()
-
- # Escape the prefix according to rfc 1034, it's important for code-signing. If an invalid
- # identifier is used, calling xcodebuild on the command line says that no provisioning profile
- # could be found, with no additional error message. If one opens the generated project with
- # Xcode and clicks on 'Try again' to get a new profile, it shows a semi-useful error message
- # that the identifier is invalid.
- _qt_internal_escape_rfc_1034_identifier("${prefix}" prefix)
-
- set(identifier "${prefix}.\${PRODUCT_NAME:rfc1034identifier}")
- set("${out_var}" "${identifier}" PARENT_SCOPE)
-endfunction()
-
-function(_qt_internal_set_placeholder_apple_bundle_version target)
- # If user hasn't provided neither a bundle version nor a bundle short version string for the
- # app, set a placeholder value for both which will add them to the generated Info.plist file.
- # This is required so that the app launches in the simulator (but apparently not for running
- # on-device).
- get_target_property(bundle_version "${target}" MACOSX_BUNDLE_BUNDLE_VERSION)
- get_target_property(bundle_short_version "${target}" MACOSX_BUNDLE_SHORT_VERSION_STRING)
-
- if(NOT MACOSX_BUNDLE_BUNDLE_VERSION AND
- NOT MACOSX_BUNDLE_SHORT_VERSION_STRING AND
- NOT bundle_version AND
- NOT bundle_short_version AND
- NOT QT_NO_SET_XCODE_BUNDLE_VERSION
- )
- get_target_property(version "${target}" VERSION)
- if(NOT version)
- set(version "${PROJECT_VERSION}")
- if(NOT version)
- set(version "1.0.0")
- endif()
- endif()
-
- # Use x.y for short version and x.y.z for full version
- # Any versions longer than this will fail App Store
- # submission.
- string(REPLACE "." ";" version_list ${version})
- list(LENGTH version_list version_list_length)
- list(GET version_list 0 version_major)
- set(bundle_short_version "${version_major}")
- if(version_list_length GREATER 1)
- list(GET version_list 1 version_minor)
- string(APPEND bundle_short_version ".${version_minor}")
- endif()
- set(bundle_version "${bundle_short_version}")
- if(version_list_length GREATER 2)
- list(GET version_list 2 version_patch)
- string(APPEND bundle_version ".${version_patch}")
- endif()
-
-
- if(NOT CMAKE_XCODE_ATTRIBUTE_MARKETING_VERSION
- AND NOT QT_NO_SET_XCODE_ATTRIBUTE_MARKETING_VERSION
- AND NOT CMAKE_XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION
- AND NOT QT_NO_SET_XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION)
- get_target_property(marketing_version "${target}"
- XCODE_ATTRIBUTE_MARKETING_VERSION)
- get_target_property(current_project_version "${target}"
- XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION)
- if(NOT marketing_version AND NOT current_project_version)
+ foreach(plugin_target IN LISTS QT_ALL_PLUGINS_FOUND_BY_FIND_PACKAGE_permissions)
+ set(versioned_plugin_target "${QT_CMAKE_EXPORT_NAMESPACE}::${plugin_target}")
+ get_target_property(usage_descriptions
+ ${versioned_plugin_target}
+ _qt_info_plist_usage_descriptions)
+ foreach(usage_description_key IN LISTS usage_descriptions)
+ execute_process(COMMAND "/usr/libexec/PlistBuddy"
+ -c "print ${usage_description_key}" "${plist_file}"
+ OUTPUT_VARIABLE usage_description
+ ERROR_VARIABLE plist_error)
+ if(usage_description AND NOT plist_error)
set_target_properties("${target}"
- PROPERTIES
- XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION "${bundle_version}"
- XCODE_ATTRIBUTE_MARKETING_VERSION "${bundle_short_version}"
- )
- set(bundle_version "$(CURRENT_PROJECT_VERSION)")
- set(bundle_short_version "$(MARKETING_VERSION)")
+ PROPERTIES "_qt_has_${plugin_target}_usage_description" TRUE)
+ qt6_import_plugins(${target} INCLUDE ${versioned_plugin_target})
endif()
- endif()
-
- set_target_properties("${target}"
- PROPERTIES
- MACOSX_BUNDLE_BUNDLE_VERSION "${bundle_version}"
- MACOSX_BUNDLE_SHORT_VERSION_STRING "${bundle_short_version}"
- )
- endif()
-endfunction()
-
-function(_qt_internal_set_xcode_development_team_id target)
- # If user hasn't provided a development team id, try to find the first one specified
- # in the Xcode preferences.
- if(NOT CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM AND NOT QT_NO_SET_XCODE_DEVELOPMENT_TEAM_ID)
- get_target_property(existing_team_id "${target}" XCODE_ATTRIBUTE_DEVELOPMENT_TEAM)
- if(NOT existing_team_id)
- _qt_internal_find_ios_development_team_id(team_id)
- set_target_properties("${target}"
- PROPERTIES XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "${team_id}")
- endif()
- endif()
-endfunction()
-
-function(_qt_internal_set_xcode_bundle_identifier target)
- # Skip all logic if requested.
- if(QT_NO_SET_XCODE_BUNDLE_IDENTIFIER)
- return()
- endif()
-
- # There are two fields to consider: the CFBundleIdentifier key (CFBI) to be written to
- # Info.plist
- # and the PRODUCT_BUNDLE_IDENTIFIER (PBI) property to set in the Xcode project.
- # The following logic enables the best out-of-the-box experience combined with maximum
- # customization.
- # 1) If values for both fields are not provided, assign ${PRODUCT_BUNDLE_IDENTIFIER} to CFBI
- # (which is expanded by xcodebuild at build time and will use the value of PBI) and
- # auto-compute a default PBI from Xcode's ${PRODUCT_NAME}.
- # 2) If CFBI is set and PBI isn't, use given CFBI and keep PBI empty.
- # 3) If PBI is set and CFBI isn't, assign ${PRODUCT_BUNDLE_IDENTIFIER} to CFBI and use
- # the given PBI.
- # 4) If both are set, use both given values.
- # TLDR:
- # cfbi pbi -> result_cfbi result_pbi
- # unset unset computed computed
- # set unset given_val unset
- # unset set computed given_val
- # set set given_val given_val
-
- get_target_property(existing_cfbi "${target}" MACOSX_BUNDLE_GUI_IDENTIFIER)
- if(NOT MACOSX_BUNDLE_GUI_IDENTIFIER AND NOT existing_cfbi)
- set(is_cfbi_given FALSE)
- else()
- set(is_cfbi_given TRUE)
- endif()
-
- if(NOT is_cfbi_given)
- set_target_properties("${target}"
- PROPERTIES
- MACOSX_BUNDLE_GUI_IDENTIFIER "\${PRODUCT_BUNDLE_IDENTIFIER}")
- endif()
-
- get_target_property(existing_pbi "${target}" XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER)
- if(NOT CMAKE_XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER AND NOT existing_pbi)
- set(is_pbi_given FALSE)
- else()
- set(is_pbi_given TRUE)
- endif()
-
- if(NOT is_pbi_given AND NOT is_cfbi_given)
- _qt_internal_get_default_ios_bundle_identifier(bundle_id)
- set_target_properties("${target}"
- PROPERTIES
- XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${bundle_id}")
- endif()
-endfunction()
-
-function(_qt_internal_set_xcode_targeted_device_family target)
- if(NOT CMAKE_XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY
- AND NOT QT_NO_SET_XCODE_TARGETED_DEVICE_FAMILY)
- get_target_property(existing_device_family
- "${target}" XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY)
- if(NOT existing_device_family)
- set(device_family_iphone_and_ipad "1,2")
- set_target_properties("${target}"
- PROPERTIES
- XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY
- "${device_family_iphone_and_ipad}")
- endif()
- endif()
-endfunction()
-
-function(_qt_internal_set_xcode_code_sign_style target)
- if(NOT CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_STYLE
- AND NOT QT_NO_SET_XCODE_CODE_SIGN_STYLE)
- get_target_property(existing_code_style
- "${target}" XCODE_ATTRIBUTE_CODE_SIGN_STYLE)
- if(NOT existing_code_style)
- set(existing_code_style "Automatic")
- set_target_properties("${target}"
- PROPERTIES
- XCODE_ATTRIBUTE_CODE_SIGN_STYLE
- "${existing_code_style}")
- endif()
- endif()
-endfunction()
-
-# Workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/15183
-function(_qt_internal_set_xcode_install_path target)
- if(NOT CMAKE_XCODE_ATTRIBUTE_INSTALL_PATH
- AND NOT QT_NO_SET_XCODE_INSTALL_PATH)
- get_target_property(existing_install_path
- "${target}" XCODE_ATTRIBUTE_INSTALL_PATH)
- if(NOT existing_install_path)
- set_target_properties("${target}"
- PROPERTIES
- XCODE_ATTRIBUTE_INSTALL_PATH
- "$(inherited)")
- endif()
- endif()
-endfunction()
-
-function(_qt_internal_set_xcode_bundle_display_name target)
- # We want the value of CFBundleDisplayName to be ${PRODUCT_NAME}, but we can't put that
- # into the Info.plist.in template file directly, because the implicit configure_file(Info.plist)
- # done by CMake is not using the @ONLY option, so CMake would treat the assignment as
- # variable expansion. Escaping using backslashes does not help.
- # Work around it by assigning the dollar char to a separate cache var, and expand it, so that
- # the final value in the file will be ${PRODUCT_NAME}, to be evaluated at build time by Xcode.
- set(QT_INTERNAL_DOLLAR_VAR "$" CACHE STRING "")
-endfunction()
-
-function(_qt_internal_set_xcode_bitcode_enablement target)
- if(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE
- OR QT_NO_SET_XCODE_ENABLE_BITCODE)
- return()
- endif()
-
- get_target_property(existing_bitcode_enablement
- "${target}" XCODE_ATTRIBUTE_ENABLE_BITCODE)
- if(NOT existing_bitcode_enablement MATCHES "-NOTFOUND")
- return()
- endif()
-
- # Disable bitcode to match Xcode 14's new default
- set_target_properties("${target}"
- PROPERTIES
- XCODE_ATTRIBUTE_ENABLE_BITCODE
- "NO")
-endfunction()
-
-function(_qt_internal_generate_ios_info_plist target)
- # If the project already specifies a custom file, we don't override it.
- get_target_property(existing_plist "${target}" MACOSX_BUNDLE_INFO_PLIST)
- if(existing_plist)
- return()
- endif()
-
- set(info_plist_in "${__qt_internal_cmake_ios_support_files_path}/Info.plist.app.in")
-
- string(MAKE_C_IDENTIFIER "${target}" target_identifier)
- set(info_plist_out_dir
- "${CMAKE_CURRENT_BINARY_DIR}/.qt/info_plist/${target_identifier}")
- set(info_plist_out "${info_plist_out_dir}/Info.plist")
-
- # Check if we need to specify a custom launch screen storyboard entry.
- get_target_property(launch_screen_name "${target}" _qt_ios_launch_screen_name)
- if(launch_screen_name)
- set(qt_ios_launch_screen_plist_entry "${launch_screen_name}")
- endif()
-
- # Call configure_file to substitute Qt-specific @FOO@ values, not ${FOO} values.
- #
- # The output file will be another template file to be fed to CMake via the
- # MACOSX_BUNDLE_INFO_PLIST property. CMake will then call configure_file on it to provide
- # content for regular entries like CFBundleName, etc.
- #
- # We require this extra configure_file call so we can create unique Info.plist files for each
- # target in a project, while also providing a way to add Qt specific entries that CMake
- # does not support out of the box (e.g. a launch screen name).
- configure_file(
- "${info_plist_in}"
- "${info_plist_out}"
- @ONLY
- )
-
- set_target_properties("${target}" PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${info_plist_out}")
-endfunction()
-
-function(_qt_internal_set_ios_simulator_arch target)
- if(CMAKE_XCODE_ATTRIBUTE_ARCHS
- OR QT_NO_SET_XCODE_ARCHS)
- return()
- endif()
-
- get_target_property(existing_archs
- "${target}" XCODE_ATTRIBUTE_ARCHS)
- if(NOT existing_archs MATCHES "-NOTFOUND")
- return()
- endif()
-
- if(NOT x86_64 IN_LIST QT_OSX_ARCHITECTURES)
- return()
- endif()
-
- if(CMAKE_OSX_ARCHITECTURES AND NOT x86_64 IN_LIST CMAKE_OSX_ARCHITECTURES)
- return()
- endif()
-
- set_target_properties("${target}"
- PROPERTIES
- "XCODE_ATTRIBUTE_ARCHS[sdk=iphonesimulator*]"
- "x86_64")
-endfunction()
-
-function(_qt_internal_finalize_apple_app target)
- # Shared between macOS and iOS apps
- _qt_internal_set_xcode_development_team_id("${target}")
- _qt_internal_set_xcode_bundle_identifier("${target}")
- _qt_internal_set_xcode_code_sign_style("${target}")
- _qt_internal_set_xcode_bundle_display_name("${target}")
- _qt_internal_set_xcode_install_path("${target}")
- _qt_internal_set_placeholder_apple_bundle_version("${target}")
-endfunction()
-
-function(_qt_internal_finalize_ios_app target)
- _qt_internal_finalize_apple_app("${target}")
-
- _qt_internal_set_xcode_targeted_device_family("${target}")
- _qt_internal_set_xcode_bitcode_enablement("${target}")
- _qt_internal_handle_ios_launch_screen("${target}")
- _qt_internal_generate_ios_info_plist("${target}")
- _qt_internal_set_ios_simulator_arch("${target}")
-endfunction()
-
-function(_qt_internal_finalize_macos_app target)
- get_target_property(is_bundle ${target} MACOSX_BUNDLE)
- if(NOT is_bundle)
- return()
- endif()
-
- _qt_internal_finalize_apple_app("${target}")
-
- # Make sure the install rpath has at least the minimum needed if the app
- # has any non-static frameworks. We can't rigorously know if the app will
- # have any, even with a static Qt, so always add this. If there are no
- # frameworks, it won't do any harm.
- get_property(install_rpath TARGET ${target} PROPERTY INSTALL_RPATH)
- list(APPEND install_rpath "@executable_path/../Frameworks")
- list(REMOVE_DUPLICATES install_rpath)
- set_property(TARGET ${target} PROPERTY INSTALL_RPATH "${install_rpath}")
+ endforeach()
+ endforeach()
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
@@ -1459,6 +876,13 @@ if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
endfunction()
endif()
+function(_qt_internal_assign_to_internal_targets_folder target)
+ get_property(folder_name GLOBAL PROPERTY QT_TARGETS_FOLDER)
+ if(NOT "${folder_name}" STREQUAL "")
+ set_property(TARGET ${target} PROPERTY FOLDER "${folder_name}")
+ endif()
+endfunction()
+
function(qt6_extract_metatypes target)
get_target_property(existing_meta_types_file ${target} INTERFACE_QT_META_TYPES_BUILD_FILE)
@@ -1476,7 +900,7 @@ function(qt6_extract_metatypes target)
# TODO: Move this into a separate internal function, so it doesn't pollute the public one.
# Location where to install the metatypes file. Only used if
# __QT_INTERNAL_INSTALL is given. It defaults to the
- # ${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}/metatypes directory.
+ # ${CMAKE_INSTALL_PREFIX}/${INSTALL_ARCHDATADIR}/metatypes directory.
# Executable metatypes files are never installed.
__QT_INTERNAL_INSTALL_DIR
@@ -1586,6 +1010,7 @@ function(qt6_extract_metatypes target)
COMMAND_EXPAND_LISTS
)
add_dependencies(${target}_automoc_json_extraction ${target}_autogen)
+ _qt_internal_assign_to_internal_targets_folder(${target}_automoc_json_extraction)
else()
set(cmake_autogen_timestamp_file
"${target_binary_dir}/${target}_autogen/timestamp"
@@ -1715,10 +1140,11 @@ function(qt6_extract_metatypes target)
# Automatically fill default install args when not specified.
if(NOT arg___QT_INTERNAL_INSTALL_DIR)
- # INSTALL_LIBDIR is not set when QtBuildInternals is not loaded (when not doing a Qt build).
- # Default to a hardcoded location for user projects.
- if(INSTALL_LIBDIR)
- set(install_dir "${INSTALL_LIBDIR}/metatypes")
+ # INSTALL_ARCHDATADIR is not set when QtBuildInternals is not loaded
+ # (when not doing a Qt build). Default to a hardcoded location for user
+ # projects (will likely be wrong).
+ if(INSTALL_ARCHDATADIR)
+ set(install_dir "${INSTALL_ARCHDATADIR}/metatypes")
else()
set(install_dir "lib/metatypes")
endif()
@@ -1781,7 +1207,7 @@ function(_qt_internal_generate_win32_rc_file target)
endif()
if(MSVC)
- set(extra_rc_flags "/nologo")
+ set(extra_rc_flags "/c65001 /DWIN32 /nologo")
else()
set(extra_rc_flags)
endif()
@@ -2215,10 +1641,17 @@ function(__qt_propagate_generated_resource target resource_name generated_source
endif()
endfunction()
-# Creates fake targets and adds resource files to IDE's tree
-# FIXME: We shouldn't need to create a separate target for this, the files
-# should be added to the actual target instead.
+# Make file visible in IDEs.
+# Targets that are finalized add the file as HEADER_FILE_ONLY in the finalizer.
+# Targets that are not finalized add the file under a ${target}_other_files target.
function(_qt_internal_expose_source_file_to_ide target file)
+ get_target_property(target_expects_finalization ${target} _qt_expects_finalization)
+ if(target_expects_finalization AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.19")
+ set_property(TARGET ${target} APPEND PROPERTY _qt_deferred_files ${file})
+ return()
+ endif()
+
+ # Fallback for targets that are not finalized: Create fake target under which the file is added.
set(ide_target ${target}_other_files)
if(NOT TARGET ${ide_target})
add_custom_target(${ide_target} SOURCES "${file}")
@@ -2248,6 +1681,51 @@ function(_qt_internal_expose_source_file_to_ide target file)
endif()
endfunction()
+# Called by the target finalizer.
+# Adds the files that were added to _qt_deferred_files to SOURCES.
+# Sets HEADER_FILES_ONLY if they did not exist yet in SOURCES.
+function(_qt_internal_expose_deferred_files_to_ide target)
+ get_target_property(new_sources ${target} _qt_deferred_files)
+ if(NOT new_sources)
+ return()
+ endif()
+ set(new_sources_real "")
+ foreach(f IN LISTS new_sources)
+ get_filename_component(realf "${f}" REALPATH)
+ list(APPEND new_sources_real ${realf})
+ endforeach()
+
+ get_target_property(target_source_dir ${target} SOURCE_DIR)
+ get_filename_component(target_source_dir "${target_source_dir}" REALPATH)
+ get_target_property(existing_sources ${target} SOURCES)
+ if(existing_sources)
+ set(existing_sources_real "")
+ set(realf "")
+ foreach(f IN LISTS existing_sources)
+ get_filename_component(realf "${f}" REALPATH BASE_DIR ${target_source_dir})
+ list(APPEND existing_sources_real ${realf})
+ endforeach()
+ list(REMOVE_ITEM new_sources_real ${existing_sources_real})
+ endif()
+ if("${new_sources_real}" STREQUAL "")
+ return()
+ endif()
+ # Need to convert real paths back to relative paths because the use of absolute paths for these
+ # files causes invalid generation of build.ninja on Windows platforms.
+ set(new_sources "")
+ foreach(realf IN LISTS new_sources_real)
+ file(RELATIVE_PATH f "${target_source_dir}" "${realf}")
+ list(APPEND new_sources "${f}")
+ endforeach()
+
+ target_sources(${target} PRIVATE ${new_sources})
+ set(scope_args)
+ if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.18")
+ set(scope_args TARGET_DIRECTORY "${target}")
+ endif()
+ set_source_files_properties(${new_sources} ${scope_args} PROPERTIES HEADER_FILE_ONLY ON)
+endfunction()
+
#
# Process resources via file path instead of QRC files. Behind the
# scenes, it will generate a qrc file.
@@ -2267,22 +1745,22 @@ function(_qt_internal_process_resource target resourceName)
if("${rcc_OPTIONS}" MATCHES "-binary")
set(isBinary TRUE)
- if(arg_BIG_RESOURCES)
+ if(rcc_BIG_RESOURCES)
message(FATAL_ERROR "BIG_RESOURCES cannot be used together with the -binary option.")
endif()
endif()
- if(arg_BIG_RESOURCES AND CMAKE_GENERATOR STREQUAL "Xcode" AND IOS)
+ if(rcc_BIG_RESOURCES AND CMAKE_GENERATOR STREQUAL "Xcode" AND IOS)
message(WARNING
"Due to CMake limitations, the BIG_RESOURCES option can't be used when building "
"for iOS. "
"See https://bugreports.qt.io/browse/QTBUG-103497 for details. "
"Falling back to using regular resources. "
)
- set(arg_BIG_RESOURCES OFF)
+ set(rcc_BIG_RESOURCES OFF)
endif()
- if(arg_BIG_RESOURCES AND CMAKE_VERSION VERSION_LESS "3.17")
+ if(rcc_BIG_RESOURCES AND CMAKE_VERSION VERSION_LESS "3.17")
message(WARNING
"The BIG_RESOURCES option does not work reliably with CMake < 3.17. "
"Consider upgrading to a more recent CMake version or disable the BIG_RESOURCES "
@@ -2326,7 +1804,7 @@ function(_qt_internal_process_resource target resourceName)
if(NOT rcc_PREFIX)
get_target_property(rcc_PREFIX ${target} QT_RESOURCE_PREFIX)
if (NOT rcc_PREFIX)
- message(FATAL_ERROR "_qt_internal_process_resource() was called without a PREFIX and the target does not provide QT_RESOURCE_PREFIX. Please either add a PREFIX or make the target ${target} provide a default.")
+ set(rcc_PREFIX "/")
endif()
endif()
@@ -2342,9 +1820,8 @@ function(_qt_internal_process_resource target resourceName)
# <RCC><qresource ...>
set(qrcContents "<RCC>\n <qresource")
- if (rcc_PREFIX)
- string(APPEND qrcContents " prefix=\"${rcc_PREFIX}\"")
- endif()
+ string(APPEND qrcContents " prefix=\"${rcc_PREFIX}\"")
+
if (rcc_LANG)
string(APPEND qrcContents " lang=\"${rcc_LANG}\"")
endif()
@@ -2370,13 +1847,20 @@ function(_qt_internal_process_resource target resourceName)
endif()
get_source_file_property(
target_dependency ${file} ${scope_args} _qt_resource_target_dependency)
- if (NOT target_dependency)
- list(APPEND resource_dependencies ${file})
- else()
- if (NOT TARGET ${target_dependency})
- message(FATAL_ERROR "Target dependency on resource file ${file} is not a cmake target.")
+
+ # The target dependency code path does not take care of rebuilds when ${file}
+ # is touched. Limit its usage to the Xcode generator to avoid the Xcode common
+ # dependency issue.
+ # TODO: Figure out how to avoid the issue on Xcode, while also enabling proper
+ # dependency tracking when ${file} is touched.
+ if(target_dependency AND CMAKE_GENERATOR STREQUAL "Xcode")
+ if(NOT TARGET ${target_dependency})
+ message(FATAL_ERROR
+ "Target dependency on resource file ${file} is not a cmake target.")
endif()
list(APPEND resource_dependencies ${target_dependency})
+ else()
+ list(APPEND resource_dependencies ${file})
endif()
_qt_internal_expose_source_file_to_ide(${target} "${file}")
endforeach()
@@ -2529,6 +2013,7 @@ endmacro()
function(qt6_add_plugin target)
_qt_internal_get_add_plugin_keywords(opt_args single_args multi_args)
+ list(APPEND opt_args MANUAL_FINALIZATION)
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
@@ -2575,6 +2060,7 @@ function(qt6_add_plugin target)
endif()
_qt_internal_add_library(${target} ${type_to_create} ${arg_UNPARSED_ARGUMENTS})
+ set_property(TARGET ${target} PROPERTY _qt_expects_finalization TRUE)
get_target_property(target_type "${target}" TYPE)
if (target_type STREQUAL "STATIC_LIBRARY")
@@ -2648,9 +2134,27 @@ function(qt6_add_plugin target)
if(target_type STREQUAL "MODULE_LIBRARY")
if(NOT TARGET qt_internal_plugins)
add_custom_target(qt_internal_plugins)
+ _qt_internal_assign_to_internal_targets_folder(qt_internal_plugins)
endif()
add_dependencies(qt_internal_plugins ${target})
endif()
+
+ if(arg_MANUAL_FINALIZATION)
+ # Caller says they will call qt6_finalize_target() themselves later
+ return()
+ endif()
+
+ # Defer the finalization if we can. When the caller's project requires
+ # CMake 3.19 or later, this makes the calls to this function concise while
+ # still allowing target property modification before finalization.
+ if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.19)
+ # Need to wrap in an EVAL CODE or else ${target} won't be evaluated
+ # due to special behavior of cmake_language() argument handling
+ cmake_language(EVAL CODE "cmake_language(DEFER CALL qt6_finalize_target ${target})")
+ else()
+ set_target_properties("${target}" PROPERTIES _qt_is_immediately_finalized TRUE)
+ qt6_finalize_target("${target}")
+ endif()
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
@@ -2669,6 +2173,7 @@ function(qt6_add_library target)
cmake_parse_arguments(PARSE_ARGV 1 arg "MANUAL_FINALIZATION" "" "")
_qt_internal_add_library("${target}" ${arg_UNPARSED_ARGUMENTS})
+ set_property(TARGET ${target} PROPERTY _qt_expects_finalization TRUE)
if(arg_MANUAL_FINALIZATION)
# Caller says they will call qt6_finalize_target() themselves later
@@ -2802,30 +2307,6 @@ function(_qt_internal_apply_strict_cpp target)
endif()
endfunction()
-# Wraps a tool command with a script that contains the necessary environment for the tool to run
-# correctly.
-# _qt_internal_wrap_tool_command(var <SET|APPEND> <command> [args...])
-# Arguments:
-# APPEND Selects the 'append' mode for the out_variable argument.
-# SET Selects the 'set' mode for the out_variable argument.
-function(_qt_internal_wrap_tool_command out_variable action)
- set(append FALSE)
- if(action STREQUAL "APPEND")
- set(append TRUE)
- elseif(NOT action STREQUAL "SET")
- message(FATAL_ERROR "Invalid action specified ${action}. Supported actions: SET, APPEND")
- endif()
-
- set(cmd COMMAND ${QT_TOOL_COMMAND_WRAPPER_PATH} ${ARGN})
-
- if(append)
- list(APPEND ${out_variable} ${cmd})
- else()
- set(${out_variable} ${cmd})
- endif()
- set(${out_variable} "${${out_variable}}" PARENT_SCOPE)
-endfunction()
-
# Copies properties of the dependency to the target.
# Arguments:
# PROPERTIES list of properties to copy. If not specified the following properties are copied
@@ -2929,6 +2410,10 @@ endfunction()
# Sets up the commands for use at install/deploy time
function(_qt_internal_setup_deploy_support)
+ if(QT_SKIP_SETUP_DEPLOYMENT)
+ return()
+ endif()
+
get_property(cmake_role GLOBAL PROPERTY CMAKE_ROLE)
if(NOT cmake_role STREQUAL "PROJECT")
return()
@@ -2990,6 +2475,8 @@ function(_qt_internal_setup_deploy_support)
set(safe_target_file
"$<TARGET_FILE:$<IF:${have_deploy_tool},${target_if_exists},${target}>>")
set(__QT_DEPLOY_TOOL "$<IF:${have_deploy_tool},${safe_target_file},${fallback}>")
+ elseif(UNIX AND NOT APPLE AND NOT ANDROID AND NOT CMAKE_CROSSCOMPILING)
+ set(__QT_DEPLOY_TOOL "GRD")
else()
# Android is handled as a build target, not via this install-based approach.
# Therefore, we don't consider androiddeployqt here.
@@ -2998,6 +2485,51 @@ function(_qt_internal_setup_deploy_support)
_qt_internal_add_deploy_support("${CMAKE_CURRENT_LIST_DIR}/Qt6CoreDeploySupport.cmake")
+ set(deploy_ignored_lib_dirs "")
+ if(__QT_DEPLOY_TOOL STREQUAL "GRD" AND NOT "${QT6_INSTALL_PREFIX}" STREQUAL "")
+ # Set up the directories we want to ignore when running file(GET_RUNTIME_DEPENDENCIES).
+ # If the Qt prefix is the root of one of those directories, don't ignore that directory.
+ # For example, if Qt's installation prefix is /usr, then we don't want to ignore /usr/lib.
+ foreach(link_dir IN LISTS CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES)
+ file(RELATIVE_PATH relative_dir "${QT6_INSTALL_PREFIX}" "${link_dir}")
+ if(relative_dir STREQUAL "")
+ # The Qt prefix is exactly ${link_dir}.
+ continue()
+ endif()
+ if(IS_ABSOLUTE "${relative_dir}" OR relative_dir MATCHES "^\\.\\./")
+ # The Qt prefix is outside of ${link_dir}.
+ list(APPEND deploy_ignored_lib_dirs "${link_dir}")
+ endif()
+ endforeach()
+ endif()
+
+ # Check whether we will have to adjust the RPATH of plugins.
+ if("${QT_DEPLOY_FORCE_ADJUST_RPATHS}" STREQUAL "")
+ set(must_adjust_plugins_rpath "")
+ if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows"
+ AND NOT CMAKE_INSTALL_LIBDIR STREQUAL QT6_INSTALL_LIBS)
+ set(must_adjust_plugins_rpath ON)
+ endif()
+ else()
+ set(must_adjust_plugins_rpath "${QT_DEPLOY_FORCE_ADJUST_RPATHS}")
+ endif()
+
+ # Find the patchelf executable if necessary.
+ if(must_adjust_plugins_rpath)
+ if(CMAKE_VERSION VERSION_LESS "3.21")
+ set(QT_DEPLOY_USE_PATCHELF ON)
+ endif()
+ if(QT_DEPLOY_USE_PATCHELF)
+ find_program(QT_DEPLOY_PATCHELF_EXECUTABLE patchelf)
+ if(NOT QT_DEPLOY_PATCHELF_EXECUTABLE)
+ set(QT_DEPLOY_PATCHELF_EXECUTABLE "patchelf")
+ message(WARNING "The patchelf executable could not be located. "
+ "To use Qt's CMake deployment API, install patchelf or upgrade CMake to 3.21 "
+ "or newer.")
+ endif()
+ endif()
+ endif()
+
file(GENERATE OUTPUT "${QT_DEPLOY_SUPPORT}" CONTENT
"cmake_minimum_required(VERSION 3.16...3.21)
@@ -3015,12 +2547,18 @@ endif()
if(NOT QT_DEPLOY_QML_DIR)
set(QT_DEPLOY_QML_DIR \"qml\")
endif()
+if(NOT QT_DEPLOY_TRANSLATIONS_DIR)
+ set(QT_DEPLOY_TRANSLATIONS_DIR \"translations\")
+endif()
if(NOT QT_DEPLOY_PREFIX)
set(QT_DEPLOY_PREFIX \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}\")
endif()
if(QT_DEPLOY_PREFIX STREQUAL \"\")
set(QT_DEPLOY_PREFIX .)
endif()
+if(NOT QT_DEPLOY_IGNORED_LIB_DIRS)
+ set(QT_DEPLOY_IGNORED_LIB_DIRS \"${deploy_ignored_lib_dirs}\")
+endif()
# These are internal implementation details. They may be removed at any time.
set(__QT_DEPLOY_SYSTEM_NAME \"${CMAKE_SYSTEM_NAME}\")
@@ -3033,6 +2571,15 @@ set(__QT_DEPLOY_GENERATOR_IS_MULTI_CONFIG \"${is_multi_config}\")
set(__QT_DEPLOY_ACTIVE_CONFIG \"$<CONFIG>\")
set(__QT_NO_CREATE_VERSIONLESS_FUNCTIONS \"${QT_NO_CREATE_VERSIONLESS_FUNCTIONS}\")
set(__QT_DEFAULT_MAJOR_VERSION \"${QT_DEFAULT_MAJOR_VERSION}\")
+set(__QT_DEPLOY_QT_ADDITIONAL_PACKAGES_PREFIX_PATH \"${QT_ADDITIONAL_PACKAGES_PREFIX_PATH}\")
+set(__QT_DEPLOY_QT_INSTALL_PREFIX \"${QT6_INSTALL_PREFIX}\")
+set(__QT_DEPLOY_QT_INSTALL_BINS \"${QT6_INSTALL_BINS}\")
+set(__QT_DEPLOY_QT_INSTALL_PLUGINS \"${QT6_INSTALL_PLUGINS}\")
+set(__QT_DEPLOY_QT_INSTALL_TRANSLATIONS \"${QT6_INSTALL_TRANSLATIONS}\")
+set(__QT_DEPLOY_PLUGINS \"\")
+set(__QT_DEPLOY_MUST_ADJUST_PLUGINS_RPATH \"${must_adjust_plugins_rpath}\")
+set(__QT_DEPLOY_USE_PATCHELF \"${QT_DEPLOY_USE_PATCHELF}\")
+set(__QT_DEPLOY_PATCHELF_EXECUTABLE \"${QT_DEPLOY_PATCHELF_EXECUTABLE}\")
# Define the CMake commands to be made available during deployment.
set(__qt_deploy_support_files
@@ -3097,6 +2644,22 @@ macro(qt6_standard_project_setup)
set(CMAKE_AUTO${auto_set} TRUE)
endif()
endforeach()
+
+ # Enable folder support for IDEs. A future CMake version might enable this by default.
+ # See CMake issue #21695.
+ get_property(__qt_use_folders GLOBAL PROPERTY USE_FOLDERS)
+ if(__qt_use_folders OR "${__qt_use_folders}" STREQUAL "")
+ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
+ get_property(__qt_qt_targets_folder GLOBAL PROPERTY QT_TARGETS_FOLDER)
+ if("${__qt_qt_targets_folder}" STREQUAL "")
+ set(__qt_qt_targets_folder QtInternalTargets)
+ set_property(GLOBAL PROPERTY QT_TARGETS_FOLDER ${__qt_qt_targets_folder})
+ endif()
+ get_property(__qt_autogen_targets_folder GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDERS)
+ if("${__qt_autogen_targets_folder}" STREQUAL "")
+ set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER ${__qt_qt_targets_folder})
+ endif()
+ endif()
endif()
endmacro()
@@ -3108,19 +2671,13 @@ endif()
# This function is currently in Technical Preview.
# Its signature and behavior might change.
-function(qt6_generate_deploy_app_script)
- # We use a TARGET keyword option instead of taking the target as the first
- # positional argument. This is to keep open the possibility of deploying
- # an app for which we don't have a target (e.g. an application from a
- # third party project that the caller may want to include in their own
- # package). We would add an EXECUTABLE keyword for that, which would be
- # mutually exclusive with the TARGET keyword.
- set(no_value_options
- NO_UNSUPPORTED_PLATFORM_ERROR
- )
+function(qt6_generate_deploy_script)
+ set(no_value_options "")
set(single_value_options
- TARGET
+ CONTENT
FILENAME_VARIABLE
+ NAME
+ TARGET
)
set(multi_value_options "")
cmake_parse_arguments(PARSE_ARGV 0 arg
@@ -3129,34 +2686,135 @@ function(qt6_generate_deploy_app_script)
if(arg_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Unexpected arguments: ${arg_UNPARSED_ARGUMENTS}")
endif()
- if(NOT arg_TARGET)
- message(FATAL_ERROR "TARGET must be specified")
- endif()
if(NOT arg_FILENAME_VARIABLE)
message(FATAL_ERROR "FILENAME_VARIABLE must be specified")
endif()
+ if("${arg_CONTENT}" STREQUAL "")
+ message(FATAL_ERROR "CONTENT must be specified")
+ endif()
+
+ # Check whether manual finalization is needed.
+ if(CMAKE_VERSION VERSION_LESS "3.19")
+ get_target_property(is_immediately_finalized ${arg_TARGET} _qt_is_immediately_finalized)
+ if(is_immediately_finalized)
+ message(WARNING
+ "Deployment of plugins for target '${arg_TARGET}' will not work. "
+ "Either, upgrade CMake to version 3.19 or newer, or call "
+ "qt_finalize_target(${arg_TARGET}) after generating the deployment script."
+ )
+ endif()
+ endif()
+
+ # Mark the target as "to be deployed".
+ set_property(TARGET ${arg_TARGET} PROPERTY _qt_marked_for_deployment ON)
# Create a file name that will be unique for this target and the combination
# of arguments passed to this command. This allows the project to call us
# multiple times with different arguments for the same target (e.g. to
# create deployment scripts for different scenarios).
- string(MAKE_C_IDENTIFIER "${arg_TARGET}" target_id)
+ set(file_base_name "custom")
+ if(NOT "${arg_NAME}" STREQUAL "")
+ set(file_base_name "${arg_NAME}")
+ elseif(NOT "${arg_TARGET}" STREQUAL "")
+ set(file_base_name "${arg_TARGET}")
+ endif()
+ string(MAKE_C_IDENTIFIER "${file_base_name}" target_id)
string(SHA1 args_hash "${ARGV}")
string(SUBSTRING "${args_hash}" 0 10 short_hash)
_qt_internal_get_deploy_impl_dir(deploy_impl_dir)
set(file_name "${deploy_impl_dir}/deploy_${target_id}_${short_hash}")
get_cmake_property(is_multi_config GENERATOR_IS_MULTI_CONFIG)
if(is_multi_config)
- string(APPEND file_name "-$<CONFIG>")
+ set(config_infix "-$<CONFIG>")
+ else()
+ set(config_infix "")
endif()
+ string(APPEND file_name "${config_infix}.cmake")
set(${arg_FILENAME_VARIABLE} "${file_name}" PARENT_SCOPE)
+ set(boiler_plate "include(${QT_DEPLOY_SUPPORT})
+include(\"\${CMAKE_CURRENT_LIST_DIR}/${arg_TARGET}-plugins${config_infix}.cmake\" OPTIONAL)
+set(__QT_DEPLOY_ALL_MODULES_FOUND_VIA_FIND_PACKAGE \"${QT_ALL_MODULES_FOUND_VIA_FIND_PACKAGE}\")
+")
+ list(TRANSFORM arg_CONTENT REPLACE "\\$" "\$")
+ file(GENERATE OUTPUT ${file_name} CONTENT "${boiler_plate}${arg_CONTENT}")
+endfunction()
+
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ macro(qt_generate_deploy_script)
+ if(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
+ qt6_generate_deploy_script(${ARGV})
+ else()
+ message(FATAL_ERROR "qt_generate_deploy_script() is only available in Qt 6.")
+ endif()
+ endmacro()
+endif()
+
+# This function is currently in Technical Preview.
+# Its signature and behavior might change.
+function(qt6_generate_deploy_app_script)
+ # We use a TARGET keyword option instead of taking the target as the first
+ # positional argument. This is to keep open the possibility of deploying
+ # an app for which we don't have a target (e.g. an application from a
+ # third party project that the caller may want to include in their own
+ # package). We would add an EXECUTABLE keyword for that, which would be
+ # mutually exclusive with the TARGET keyword.
+ set(no_value_options
+ NO_TRANSLATIONS
+ NO_UNSUPPORTED_PLATFORM_ERROR
+ )
+ set(single_value_options
+ TARGET
+ FILENAME_VARIABLE
+ )
+ set(qt_deploy_runtime_dependencies_options
+ # These options are forwarded as is to qt_deploy_runtime_dependencies.
+ PRE_INCLUDE_REGEXES
+ PRE_EXCLUDE_REGEXES
+ POST_INCLUDE_REGEXES
+ POST_EXCLUDE_REGEXES
+ POST_INCLUDE_FILES
+ POST_EXCLUDE_FILES
+ )
+ set(multi_value_options
+ ${qt_deploy_runtime_dependencies_options}
+ )
+ cmake_parse_arguments(PARSE_ARGV 0 arg
+ "${no_value_options}" "${single_value_options}" "${multi_value_options}"
+ )
+ if(arg_UNPARSED_ARGUMENTS)
+ message(FATAL_ERROR "Unexpected arguments: ${arg_UNPARSED_ARGUMENTS}")
+ endif()
+ if(NOT arg_TARGET)
+ message(FATAL_ERROR "TARGET must be specified")
+ endif()
+ if(NOT arg_FILENAME_VARIABLE)
+ message(FATAL_ERROR "FILENAME_VARIABLE must be specified")
+ endif()
+
if(QT6_IS_SHARED_LIBS_BUILD)
set(qt_build_type_string "shared Qt libs")
else()
set(qt_build_type_string "static Qt libs")
endif()
+ set(generate_args
+ TARGET ${arg_TARGET}
+ FILENAME_VARIABLE file_name
+ )
+
+ set(common_deploy_args "")
+ if(arg_NO_TRANSLATIONS)
+ string(APPEND common_deploy_args " NO_TRANSLATIONS\n")
+ endif()
+
+ # Forward the arguments that are exactly the same for qt_deploy_runtime_dependencies.
+ foreach(var IN LISTS qt_deploy_runtime_dependencies_options)
+ if(NOT "${arg_${var}}" STREQUAL "")
+ list(APPEND common_deploy_args ${var} ${arg_${var}})
+ endif()
+ endforeach()
+
if(APPLE AND NOT IOS AND QT6_IS_SHARED_LIBS_BUILD)
# TODO: Handle non-bundle applications if possible.
get_target_property(is_bundle ${arg_TARGET} MACOSX_BUNDLE)
@@ -3166,20 +2824,30 @@ function(qt6_generate_deploy_app_script)
"on Apple platforms."
)
endif()
- file(GENERATE OUTPUT "${file_name}" CONTENT "
-include(${QT_DEPLOY_SUPPORT})
+ qt6_generate_deploy_script(${generate_args}
+ CONTENT "
qt6_deploy_runtime_dependencies(
EXECUTABLE $<TARGET_FILE_NAME:${arg_TARGET}>.app
-)
+${common_deploy_args})
")
elseif(WIN32 AND QT6_IS_SHARED_LIBS_BUILD)
- file(GENERATE OUTPUT "${file_name}" CONTENT "
-include(${QT_DEPLOY_SUPPORT})
+ qt6_generate_deploy_script(${generate_args}
+ CONTENT "
+qt6_deploy_runtime_dependencies(
+ EXECUTABLE $<TARGET_FILE:${arg_TARGET}>
+ GENERATE_QT_CONF
+${common_deploy_args})
+")
+
+ elseif(UNIX AND NOT APPLE AND NOT ANDROID AND QT6_IS_SHARED_LIBS_BUILD)
+ qt6_generate_deploy_script(${generate_args}
+ CONTENT "
qt6_deploy_runtime_dependencies(
- EXECUTABLE \${QT_DEPLOY_BIN_DIR}/$<TARGET_FILE_NAME:${arg_TARGET}>
+ EXECUTABLE $<TARGET_FILE:${arg_TARGET}>
GENERATE_QT_CONF
-)")
+${common_deploy_args})
+")
elseif(NOT arg_NO_UNSUPPORTED_PLATFORM_ERROR AND NOT QT_INTERNAL_NO_UNSUPPORTED_PLATFORM_ERROR)
# Currently we don't deploy runtime dependencies if cross-compiling or using a static Qt.
@@ -3192,12 +2860,13 @@ qt6_deploy_runtime_dependencies(
"this target platform (${CMAKE_SYSTEM_NAME}, ${qt_build_type_string})."
)
else()
- file(GENERATE OUTPUT "${file_name}" CONTENT "
-include(${QT_DEPLOY_SUPPORT})
+ qt6_generate_deploy_script(${generate_args}
+ CONTENT "
_qt_internal_show_skip_runtime_deploy_message(\"${qt_build_type_string}\")
")
endif()
+ set(${arg_FILENAME_VARIABLE} "${file_name}" PARENT_SCOPE)
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
diff --git a/src/corelib/Qt6WasmMacros.cmake b/src/corelib/Qt6WasmMacros.cmake
index dbc8a49392..8274a4216e 100644
--- a/src/corelib/Qt6WasmMacros.cmake
+++ b/src/corelib/Qt6WasmMacros.cmake
@@ -1,25 +1,63 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+# SPDX-License-Identifier: BSD-3-Clause
# Copy in Qt HTML/JS launch files for apps.
function(_qt_internal_wasm_add_target_helpers target)
+
+ _qt_test_emscripten_version()
get_target_property(targetType "${target}" TYPE)
if("${targetType}" STREQUAL "EXECUTABLE")
- set(APPNAME ${target})
-
if(QT6_INSTALL_PREFIX)
set(WASM_BUILD_DIR "${QT6_INSTALL_PREFIX}")
elseif(QT_BUILD_DIR)
set(WASM_BUILD_DIR "${QT_BUILD_DIR}")
endif()
- configure_file("${WASM_BUILD_DIR}/plugins/platforms/wasm_shell.html"
- "${target}.html")
- configure_file("${WASM_BUILD_DIR}/plugins/platforms/qtloader.js"
- qtloader.js COPYONLY)
- configure_file("${WASM_BUILD_DIR}/plugins/platforms/qtlogo.svg"
- qtlogo.svg COPYONLY)
+ get_target_property(output_name ${target} OUTPUT_NAME)
+ if(output_name)
+ set(_target_output_name "${output_name}")
+ else()
+ set(_target_output_name "${target}")
+ endif()
+
+ set(APPNAME ${_target_output_name})
+
+ get_target_property(target_output_directory ${target} RUNTIME_OUTPUT_DIRECTORY)
+
+ get_target_property(is_test ${target} _qt_is_test_executable)
+ if(is_test)
+ # Keep in sync with testrunner_files in testlib/CMakeLists.txt
+ configure_file("${WASM_BUILD_DIR}/libexec/batchedtestrunner.html"
+ "${target_output_directory}/${_target_output_name}.html" COPYONLY)
+ configure_file("${WASM_BUILD_DIR}/libexec/qtestoutputreporter.css"
+ "${target_output_directory}/qtestoutputreporter.css" COPYONLY)
+ configure_file("${WASM_BUILD_DIR}/libexec/batchedtestrunner.js"
+ "${target_output_directory}/batchedtestrunner.js" COPYONLY)
+ configure_file("${WASM_BUILD_DIR}/libexec/emrunadapter.js"
+ "${target_output_directory}/emrunadapter.js" COPYONLY)
+ configure_file("${WASM_BUILD_DIR}/libexec/qwasmjsruntime.js"
+ "${target_output_directory}/qwasmjsruntime.js" COPYONLY)
+ configure_file("${WASM_BUILD_DIR}/libexec/qwasmtestmain.js"
+ "${target_output_directory}/qwasmtestmain.js" COPYONLY)
+ configure_file("${WASM_BUILD_DIR}/libexec/qtestoutputreporter.js"
+ "${target_output_directory}/qtestoutputreporter.js" COPYONLY)
+ configure_file("${WASM_BUILD_DIR}/libexec/util.js"
+ "${target_output_directory}/util.js" COPYONLY)
+ else()
+ if(target_output_directory)
+ set(_target_directory "${target_output_directory}")
+ else()
+ set(_target_directory "${CMAKE_CURRENT_BINARY_DIR}")
+ endif()
+
+ configure_file("${WASM_BUILD_DIR}/plugins/platforms/wasm_shell.html"
+ "${_target_directory}/${_target_output_name}.html")
+ configure_file("${WASM_BUILD_DIR}/plugins/platforms/qtloader.js"
+ ${_target_directory}/qtloader.js COPYONLY)
+ configure_file("${WASM_BUILD_DIR}/plugins/platforms/qtlogo.svg"
+ ${_target_directory}/qtlogo.svg COPYONLY)
+ endif()
if(QT_FEATURE_thread)
set(POOL_SIZE 4)
@@ -33,30 +71,35 @@ function(_qt_internal_wasm_add_target_helpers target)
message(DEBUG "Setting PTHREAD_POOL_SIZE to ${POOL_SIZE} for ${target}")
endif()
- # Hardcode wasm memory size.
+ # Set initial memory size, either from user setting or to a minimum amount required by Qt.
get_target_property(_tmp_initialMemory "${target}" QT_WASM_INITIAL_MEMORY)
if(_tmp_initialMemory)
set(QT_WASM_INITIAL_MEMORY "${_tmp_initialMemory}")
elseif(NOT DEFINED QT_WASM_INITIAL_MEMORY)
- if(QT_FEATURE_thread)
- # Pthreads and ALLOW_MEMORY_GROWTH can cause javascript wasm memory access to
- # be slow and having to update HEAP* views. Instead, we specify the memory size
- # at build time. Further, browsers limit the maximum initial memory size to 1GB.
- # https://github.com/WebAssembly/design/issues/1271
- set(QT_WASM_INITIAL_MEMORY "1GB")
- else()
- # emscripten default is 16MB, we need slightly more sometimes
- set(QT_WASM_INITIAL_MEMORY "50MB")
- endif()
- endif()
-
- if(DEFINED QT_WASM_INITIAL_MEMORY)
- # QT_WASM_INITIAL_MEMORY must be a multiple of 65536
- target_link_options("${target}"
- PRIVATE "SHELL:-s INITIAL_MEMORY=${QT_WASM_INITIAL_MEMORY}")
- message(DEBUG "-- Setting INITIAL_MEMORY to ${QT_WASM_INITIAL_MEMORY} for ${target}")
+ set(QT_WASM_INITIAL_MEMORY "50MB")
endif()
+ target_link_options("${target}" PRIVATE "SHELL:-s INITIAL_MEMORY=${QT_WASM_INITIAL_MEMORY}")
endif()
endfunction()
+function(_qt_internal_add_wasm_extra_exported_methods target)
+ get_target_property(wasm_extra_exported_methods "${target}" QT_WASM_EXTRA_EXPORTED_METHODS)
+
+ set(wasm_default_exported_methods "UTF16ToString,stringToUTF16,JSEvents,specialHTMLTargets")
+
+ if(NOT wasm_extra_exported_methods)
+ set(wasm_extra_exported_methods ${QT_WASM_EXTRA_EXPORTED_METHODS})
+ endif()
+
+ if(wasm_extra_exported_methods)
+ target_link_options("${target}" PRIVATE
+ "SHELL:-s EXPORTED_RUNTIME_METHODS=${wasm_default_exported_methods},${wasm_extra_exported_methods}"
+ )
+ else()
+ # an errant dangling comma will break this
+ target_link_options("${target}" PRIVATE
+ "SHELL:-s EXPORTED_RUNTIME_METHODS=${wasm_default_exported_methods}"
+ )
+ endif()
+endfunction()
diff --git a/src/corelib/QtCompressMimeDatabase.cmake b/src/corelib/QtCompressMimeDatabase.cmake
new file mode 100644
index 0000000000..718d330f28
--- /dev/null
+++ b/src/corelib/QtCompressMimeDatabase.cmake
@@ -0,0 +1,156 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+cmake_minimum_required(VERSION 3.16)
+
+get_filename_component(output_directory "${OUTPUT_FILE}" DIRECTORY)
+file(MAKE_DIRECTORY "${output_directory}")
+
+find_program(xmlstarlet NAMES xmlstarlet xml)
+if(xmlstarlet)
+ set(XML_STARLET_COMMAND COMMAND "${xmlstarlet}" sel -D -B -t -c / "${INPUT_FILE}")
+else()
+ get_filename_component(mime_types_resource_filename "${INPUT_FILE}" NAME)
+ message(STATUS "xmlstarlet command was not found. ${mime_types_resource_filename}"
+ " will not be minified.")
+endif()
+
+# The function tries to minify 'input_file' using the globally defined 'XML_STARLET_COMMAND'.
+# Sets the full path of the output file to the 'out_var' argument. If 'XML_STARLET_COMMAND' fails
+# to minify the 'input_file', 'out_var' is set to 'input_file'.
+function(try_minify_xml out_var input_file output_directory)
+ get_filename_component(output_filename "${input_file}" NAME)
+ set(minified_output "${output_directory}/${output_filename}")
+
+ # Assume XML_STARLET_COMMAND is globally defined.
+ if(XML_STARLET_COMMAND)
+ execute_process(${XML_STARLET_COMMAND}
+ OUTPUT_FILE "${minified_output}"
+ RESULT_VARIABLE failed_to_minify
+ )
+ if(NOT failed_to_minify)
+ set(${out_var} "${minified_output}" PARENT_SCOPE)
+ return()
+ endif()
+ endif()
+ set(${out_var} "${input_file}" PARENT_SCOPE)
+endfunction()
+
+unset(archive_command)
+
+if(COMPRESSION_TYPE STREQUAL "none")
+ try_minify_xml(qmimeprovider_db_data_file "${INPUT_FILE}" "${output_directory}")
+else()
+ # CMake versions less than 3.26 don't support the value of the zstd compression level higher
+ # than 9. We want zstd to compress with level 19 if it's possible, so if zstd executable is
+ # found on a file system we prefer to use the 'External' archiving API instead of the CMake API.
+ # See for details: https://gitlab.kitware.com/cmake/cmake/-/issues/24160
+ if(COMPRESSION_TYPE STREQUAL "zstd" AND CMAKE_VERSION VERSION_LESS 3.26)
+ find_program(archive_command NAMES zstd zstd.exe)
+ if(archive_command)
+ set(ARCHIVING_API "External")
+ endif()
+ endif()
+
+ set(qmimeprovider_db_data_file "${OUTPUT_FILE}.archive")
+ if(ARCHIVING_API STREQUAL "External")
+ message(STATUS "Using external archive command to compress the mime type database")
+ if(COMPRESSION_TYPE STREQUAL "zstd")
+ find_program(archive_command NAMES zstd zstd.exe)
+ if(archive_command)
+ set(archive_command_args -cq19 -T1)
+ else()
+ message(WARNING
+ "Unable to use the preffered ${COMPRESSION_TYPE} compression for the mime type database."
+ " ${COMPRESSION_TYPE} binary is not found. Trying gzip.")
+ endif()
+ endif()
+ if(NOT archive_command)
+ # Trying to use gzip if zstd is binary is not found.
+ set(COMPRESSION_TYPE "gzip")
+ find_program(archive_command NAMES gzip gzip.exe)
+ set(archive_command_args -nc9)
+ endif()
+ if(archive_command)
+ if(NOT XML_STARLET_COMMAND)
+ set(intput_file_arg INPUT_FILE "${INPUT_FILE}")
+ endif()
+ execute_process(${XML_STARLET_COMMAND}
+ COMMAND ${archive_command}
+ ${archive_command_args}
+ ${intput_file_arg}
+ OUTPUT_FILE "${qmimeprovider_db_data_file}"
+ RESULTS_VARIABLE results
+ ERROR_VARIABLE error_string
+ )
+
+ foreach(result IN LISTS results)
+ if(NOT result EQUAL 0)
+ message(WARNING "Unable to compress mime type database: ${error_string}")
+ endif()
+ endforeach()
+ else()
+ message(WARNING "Unable to find ${COMPRESSION_TYPE} binary."
+ " Please make sure that the ${COMPRESSION_TYPE} binary is in PATH."
+ " Adding the uncompressed mime type database.")
+ set(COMPRESSION_TYPE "none")
+ set(qmimeprovider_db_data_file "${INPUT_FILE}")
+ endif()
+ else()
+ message(STATUS "Using CMake archive command to compress the mime type database")
+
+ try_minify_xml(mimetypes_resource_file_minified "${INPUT_FILE}" "${output_directory}")
+
+ if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.26 AND COMPRESSION_TYPE STREQUAL "zstd")
+ set(additional_file_archive_create_parameters COMPRESSION_LEVEL 19)
+ elseif(CMAKE_VERSION VERSION_GREATER_EQUAL 3.19)
+ set(additional_file_archive_create_parameters COMPRESSION_LEVEL 9)
+ endif()
+
+ if(COMPRESSION_TYPE STREQUAL "gzip")
+ set(cmake_compression_type "GZip")
+ elseif(COMPRESSION_TYPE STREQUAL "zstd")
+ set(cmake_compression_type "Zstd")
+ endif()
+
+ file(ARCHIVE_CREATE OUTPUT "${qmimeprovider_db_data_file}"
+ PATHS "${mimetypes_resource_file_minified}"
+ FORMAT raw
+ COMPRESSION ${cmake_compression_type}
+ ${additional_file_archive_create_parameters}
+ )
+ if(NOT mimetypes_resource_file_minified STREQUAL INPUT_FILE)
+ file(REMOVE "${mimetypes_resource_file_minified}")
+ endif()
+ endif()
+endif()
+file(READ "${qmimeprovider_db_data_file}" qmime_db_data HEX)
+file(SIZE "${qmimeprovider_db_data_file}" qmime_db_data_size)
+if(NOT qmimeprovider_db_data_file STREQUAL INPUT_FILE)
+ file(SIZE "${INPUT_FILE}" qmime_db_resource_size)
+ file(REMOVE "${qmimeprovider_db_data_file}")
+else()
+ set(qmime_db_resource_size ${qmime_db_data_size})
+endif()
+
+string(REGEX MATCHALL "([a-f0-9][a-f0-9])" qmime_db_hex "${qmime_db_data}")
+
+list(TRANSFORM qmime_db_hex PREPEND "0x")
+math(EXPR qmime_db_data_size "${qmime_db_data_size} - 1")
+foreach(index RANGE 0 ${qmime_db_data_size} 12)
+ list(APPEND index_list ${index})
+endforeach()
+list(TRANSFORM qmime_db_hex PREPEND "\n " AT ${index_list})
+list(JOIN qmime_db_hex ", " qmime_db_hex_joined)
+
+if(NOT COMPRESSION_TYPE STREQUAL "none")
+ string(TOUPPER "${COMPRESSION_TYPE}" compression_type_upper)
+ set(qmime_db_content "#define MIME_DATABASE_IS_${compression_type_upper}\n")
+endif()
+string(APPEND qmime_db_content
+ "static const unsigned char mimetype_database[] = {"
+ "${qmime_db_hex_joined}"
+ "\n};\n"
+ "static constexpr size_t MimeTypeDatabaseOriginalSize = ${qmime_db_resource_size};\n"
+)
+
+file(WRITE "${OUTPUT_FILE}" "${qmime_db_content}")
diff --git a/src/corelib/QtInstallPaths.cmake.in b/src/corelib/QtInstallPaths.cmake.in
new file mode 100644
index 0000000000..977fffd0e4
--- /dev/null
+++ b/src/corelib/QtInstallPaths.cmake.in
@@ -0,0 +1,16 @@
+# install layout information, following what qmake -query provides
+get_filename_component(QT@PROJECT_VERSION_MAJOR@_INSTALL_PREFIX
+ ${CMAKE_CURRENT_LIST_DIR}/../@QT_INVERSE_CONFIG_INSTALL_DIR@ ABSOLUTE)
+set(QT@PROJECT_VERSION_MAJOR@_INSTALL_ARCHDATA "@INSTALL_ARCHDATADIR@")
+set(QT@PROJECT_VERSION_MAJOR@_INSTALL_BINS "@INSTALL_BINDIR@")
+set(QT@PROJECT_VERSION_MAJOR@_INSTALL_CONFIGURATION "@INSTALL_SYSCONFDIR@")
+set(QT@PROJECT_VERSION_MAJOR@_INSTALL_DATA "@INSTALL_DATADIR@")
+set(QT@PROJECT_VERSION_MAJOR@_INSTALL_DOCS "@INSTALL_DOCDIR@")
+set(QT@PROJECT_VERSION_MAJOR@_INSTALL_EXAMPLES "@INSTALL_EXAMPLESDIR@")
+set(QT@PROJECT_VERSION_MAJOR@_INSTALL_HEADERS "@INSTALL_INCLUDEDIR@")
+set(QT@PROJECT_VERSION_MAJOR@_INSTALL_LIBS "@INSTALL_LIBDIR@")
+set(QT@PROJECT_VERSION_MAJOR@_INSTALL_LIBEXECS "@INSTALL_LIBEXECDIR@")
+set(QT@PROJECT_VERSION_MAJOR@_INSTALL_PLUGINS "@INSTALL_PLUGINSDIR@")
+set(QT@PROJECT_VERSION_MAJOR@_INSTALL_QML "@INSTALL_QMLDIR@")
+set(QT@PROJECT_VERSION_MAJOR@_INSTALL_TESTS "@INSTALL_TESTSDIR@")
+set(QT@PROJECT_VERSION_MAJOR@_INSTALL_TRANSLATIONS "@INSTALL_TRANSLATIONSDIR@")
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index d57ce4ef5f..46ed60d6d1 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -283,7 +283,7 @@ void QUnifiedTimer::updateAnimationTimers()
QScopedValueRollback<bool> guard(insideTick, true);
if (profilerCallback)
profilerCallback(delta);
- for (currentAnimationIdx = 0; currentAnimationIdx < animationTimers.count(); ++currentAnimationIdx) {
+ for (currentAnimationIdx = 0; currentAnimationIdx < animationTimers.size(); ++currentAnimationIdx) {
QAbstractAnimationTimer *animation = animationTimers.at(currentAnimationIdx);
animation->updateAnimationsTime(delta);
}
@@ -294,7 +294,7 @@ void QUnifiedTimer::updateAnimationTimers()
int QUnifiedTimer::runningAnimationCount()
{
int count = 0;
- for (int i = 0; i < animationTimers.count(); ++i)
+ for (int i = 0; i < animationTimers.size(); ++i)
count += animationTimers.at(i)->runningAnimationCount();
return count;
}
@@ -309,7 +309,7 @@ void QUnifiedTimer::localRestart()
if (insideRestart)
return;
- if (!pausedAnimationTimers.isEmpty() && (animationTimers.count() + animationTimersToStart.count() == pausedAnimationTimers.count())) {
+ if (!pausedAnimationTimers.isEmpty() && (animationTimers.size() + animationTimersToStart.size() == pausedAnimationTimers.size())) {
driver->stop();
int closestTimeToFinish = closestPausedAnimationTimerTimeToFinish();
// use a precise timer if the pause will be short
@@ -327,7 +327,7 @@ void QUnifiedTimer::restart()
{
{
QScopedValueRollback<bool> guard(insideRestart, true);
- for (int i = 0; i < animationTimers.count(); ++i)
+ for (int i = 0; i < animationTimers.size(); ++i)
animationTimers.at(i)->restartAnimationTimer();
}
@@ -568,7 +568,7 @@ void QAnimationTimer::updateAnimationsTime(qint64 delta)
//when the CPU load is high
if (delta) {
QScopedValueRollback<bool> guard(insideTick, true);
- for (currentAnimationIdx = 0; currentAnimationIdx < animations.count(); ++currentAnimationIdx) {
+ for (currentAnimationIdx = 0; currentAnimationIdx < animations.size(); ++currentAnimationIdx) {
QAbstractAnimation *animation = animations.at(currentAnimationIdx);
int elapsed = QAbstractAnimationPrivate::get(animation)->totalCurrentTime
+ (animation->direction() == QAbstractAnimation::Forward ? delta : -delta);
diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h
index 2b08ef7756..5be59543c8 100644
--- a/src/corelib/animation/qabstractanimation_p.h
+++ b/src/corelib/animation/qabstractanimation_p.h
@@ -247,7 +247,7 @@ public:
void updateAnimationsTime(qint64 delta) override;
//useful for profiling/debugging
- int runningAnimationCount() override { return animations.count(); }
+ int runningAnimationCount() override { return animations.size(); }
private Q_SLOTS:
void startAnimations();
diff --git a/src/corelib/animation/qanimationgroup.cpp b/src/corelib/animation/qanimationgroup.cpp
index 5502942302..e8ffd99dcb 100644
--- a/src/corelib/animation/qanimationgroup.cpp
+++ b/src/corelib/animation/qanimationgroup.cpp
@@ -138,7 +138,7 @@ int QAnimationGroup::indexOfAnimation(QAbstractAnimation *animation) const
void QAnimationGroup::addAnimation(QAbstractAnimation *animation)
{
Q_D(QAnimationGroup);
- insertAnimation(d->animations.count(), animation);
+ insertAnimation(d->animations.size(), animation);
}
/*!
@@ -261,7 +261,7 @@ void QAnimationGroupPrivate::clear(bool onDestruction)
const QList<QAbstractAnimation *> animationsCopy = animations; // taking a copy
animations.clear();
// Clearing backwards so the indices doesn't change while we remove animations.
- for (int i = animationsCopy.count() - 1; i >= 0; --i) {
+ for (int i = animationsCopy.size() - 1; i >= 0; --i) {
QAbstractAnimation *animation = animationsCopy.at(i);
animation->setParent(nullptr);
QAbstractAnimationPrivate::get(animation)->group = nullptr;
diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp
index 109358b389..985371d30f 100644
--- a/src/corelib/animation/qpropertyanimation.cpp
+++ b/src/corelib/animation/qpropertyanimation.cpp
@@ -22,6 +22,10 @@
\snippet code/src_corelib_animation_qpropertyanimation.cpp 0
+ \note You can also control an animation's lifespan by choosing a
+ \l{QAbstractAnimation::DeletionPolicy}{delete policy} while starting the
+ animation.
+
The property name and the QObject instance of which property
should be animated are passed to the constructor. You can then
specify the start and end value of the property. The procedure is
diff --git a/src/corelib/animation/qsequentialanimationgroup.cpp b/src/corelib/animation/qsequentialanimationgroup.cpp
index 25d6d1de37..8e99d9cee0 100644
--- a/src/corelib/animation/qsequentialanimationgroup.cpp
+++ b/src/corelib/animation/qsequentialanimationgroup.cpp
@@ -172,7 +172,7 @@ void QSequentialAnimationGroupPrivate::rewindForwards(const AnimationIndex &newA
// we need to force activation because setCurrentAnimation will have no effect
activateCurrentAnimation();
else
- setCurrentAnimation(animations.count() - 1, true);
+ setCurrentAnimation(animations.size() - 1, true);
}
// and now we need to fast rewind from the current position to
@@ -396,7 +396,7 @@ void QSequentialAnimationGroupPrivate::setCurrentAnimation(int index, bool inter
// currentAnimation.removeBindingUnlessInWrapper()
// is not necessary here, since it is read only
- index = qMin(index, animations.count() - 1);
+ index = qMin(index, animations.size() - 1);
if (index == -1) {
Q_ASSERT(animations.isEmpty());
@@ -517,7 +517,7 @@ void QSequentialAnimationGroupPrivate::animationRemoved(int index, QAbstractAnim
disconnectUncontrolledAnimation(currentAnimation);
- if (index < animations.count())
+ if (index < animations.size())
setCurrentAnimation(index); //let's try to take the next one
else if (index > 0)
setCurrentAnimation(index - 1);
diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp
index cd9a01a138..cf84200f2a 100644
--- a/src/corelib/animation/qvariantanimation.cpp
+++ b/src/corelib/animation/qvariantanimation.cpp
@@ -156,7 +156,7 @@ void QVariantAnimationPrivate::convertValues(int t)
{
auto type = QMetaType(t);
//this ensures that all the keyValues are of type t
- for (int i = 0; i < keyValues.count(); ++i) {
+ for (int i = 0; i < keyValues.size(); ++i) {
QVariantAnimation::KeyValue &pair = keyValues[i];
pair.second.convert(type);
}
@@ -190,7 +190,7 @@ void QVariantAnimationPrivate::updateInterpolator()
void QVariantAnimationPrivate::recalculateCurrentInterval(bool force/*=false*/)
{
// can't interpolate if we don't have at least 2 values
- if ((keyValues.count() + (defaultStartEndValue.isValid() ? 1 : 0)) < 2)
+ if ((keyValues.size() + (defaultStartEndValue.isValid() ? 1 : 0)) < 2)
return;
const qreal endProgress = (direction == QAbstractAnimation::Forward) ? qreal(1) : qreal(0);
@@ -207,7 +207,7 @@ void QVariantAnimationPrivate::recalculateCurrentInterval(bool force/*=false*/)
animationValueLessThan);
if (it == keyValues.constBegin()) {
//the item pointed to by it is the start element in the range
- if (it->first == 0 && keyValues.count() > 1) {
+ if (it->first == 0 && keyValues.size() > 1) {
currentInterval.start = *it;
currentInterval.end = *(it+1);
} else {
@@ -216,7 +216,7 @@ void QVariantAnimationPrivate::recalculateCurrentInterval(bool force/*=false*/)
}
} else if (it == keyValues.constEnd()) {
--it; //position the iterator on the last item
- if (it->first == 1 && keyValues.count() > 1) {
+ if (it->first == 1 && keyValues.size() > 1) {
//we have an end value (item with progress = 1)
currentInterval.start = *(it-1);
currentInterval.end = *it;
@@ -405,7 +405,7 @@ void QVariantAnimation::registerInterpolator(QVariantAnimation::Interpolator fun
// to continue causes the app to crash on exit with a SEGV
if (interpolators) {
const auto locker = qt_scoped_lock(registeredInterpolatorsMutex);
- if (interpolationType >= interpolators->count())
+ if (interpolationType >= interpolators->size())
interpolators->resize(interpolationType + 1);
interpolators->replace(interpolationType, func);
}
@@ -423,7 +423,7 @@ QVariantAnimation::Interpolator QVariantAnimationPrivate::getInterpolator(int in
QInterpolatorVector *interpolators = registeredInterpolators();
const auto locker = qt_scoped_lock(registeredInterpolatorsMutex);
QVariantAnimation::Interpolator ret = nullptr;
- if (interpolationType < interpolators->count()) {
+ if (interpolationType < interpolators->size()) {
ret = interpolators->at(interpolationType);
if (ret) return ret;
}
diff --git a/src/corelib/compat/removed_api.cpp b/src/corelib/compat/removed_api.cpp
index aa1a496f0f..aad7b58b36 100644
--- a/src/corelib/compat/removed_api.cpp
+++ b/src/corelib/compat/removed_api.cpp
@@ -173,24 +173,6 @@ QCalendar::QCalendar(QLatin1StringView name)
#include "qcollator.h" // inline function compare(ptr, n, ptr, n) (for MSVC)
-#if QT_CONFIG(future)
-
-#include "qfutureinterface.h"
-#include "private/qfutureinterface_p.h"
-
-void QFutureInterfaceBase::cleanContinuation()
-{
- if (!d)
- return;
-
- // This was called when the associated QPromise was being destroyed,
- // but isn't used anymore.
- QMutexLocker lock(&d->continuationMutex);
- d->continuation = nullptr;
-}
-
-#endif // QT_CONFIG(future)
-
#include "qhashfunctions.h"
size_t qHash(const QByteArray &key, size_t seed) noexcept
@@ -212,6 +194,8 @@ void QObject::setObjectName(const QString &name)
#include "qlocale.h" // uses QT_CORE_INLINE_SINCE
+#if QT_CONFIG(settings)
+
#include "qsettings.h"
void QSettings::beginGroup(const QString &prefix)
@@ -254,6 +238,7 @@ QVariant QSettings::value(const QString &key) const
return value(qToAnyStringViewIgnoringNull(key));
}
+#endif // QT_CONFIG(settings)
#include "qversionnumber.h"
@@ -285,7 +270,35 @@ QT_WARNING_POP
#if QT_CORE_REMOVED_SINCE(6, 5)
-#include "qenvironmentvariables.h"
+#include "qbasictimer.h"
+
+void QBasicTimer::start(int msec, QObject *obj)
+{
+ start(qint64(msec), obj);
+}
+
+void QBasicTimer::start(int msec, Qt::TimerType timerType, QObject *obj)
+{
+ start(qint64(msec), timerType, obj);
+}
+
+#include "qbuffer.h" // inline removed API
+
+#include "qdir.h"
+
+uint QDir::count() const
+{
+ return uint(count(QT6_CALL_NEW_OVERLOAD));
+}
+
+#if QT_POINTER_SIZE != 4
+QString QDir::operator[](int i) const
+{
+ return operator[](qsizetype{i});
+}
+#endif
+
+#include "qtenvironmentvariables.h"
bool qputenv(const char *varName, const QByteArray &value)
{
@@ -320,6 +333,8 @@ QVariant::QVariant(const QSize &s) : QVariant(QVariant::fromValue(s)) {}
QVariant::QVariant(const QSizeF &s) : QVariant(QVariant::fromValue(s)) {}
#endif
+#if QT_CONFIG(xmlstreamreader)
+
#include "qxmlstream.h"
QXmlStreamReader::QXmlStreamReader(const QByteArray &data)
@@ -351,4 +366,10 @@ void QXmlStreamReader::addData(const char *data)
addData(QAnyStringView(data));
}
+#endif // QT_CONFIG(xmlstreamreader)
+
+// inlined API
+#include "qfloat16.h"
+#include "qstring.h"
+
#endif // QT_CORE_REMOVED_SINCE(6, 5)
diff --git a/src/corelib/configure.cmake b/src/corelib/configure.cmake
index 8792755e69..112e9ec203 100644
--- a/src/corelib/configure.cmake
+++ b/src/corelib/configure.cmake
@@ -1,5 +1,5 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+# SPDX-License-Identifier: BSD-3-Clause
@@ -229,22 +229,6 @@ futimens(-1, 0);
/* END TEST: */
return 0;
}
-"# FIXME: qmake: ["# Block futimens() on Apple platforms unless it's available on ALL", '# deployment targets. This simplifies the logic at the call site', "# dramatically, as it isn't strictly needed compared to futimes().", 'darwin: QMAKE_CXXFLAGS += -Werror=unguarded-availability -Werror=unguarded-availability-new', 'CONFIG += warn_on']
-)
-
-# futimes
-qt_config_compile_test(futimes
- LABEL "futimes()"
- CODE
-"#include <sys/time.h>
-
-int main(void)
-{
- /* BEGIN TEST: */
-futimes(-1, 0);
- /* END TEST: */
- return 0;
-}
")
# getauxval
@@ -578,10 +562,6 @@ qt_feature("futimens" PRIVATE
LABEL "futimens()"
CONDITION NOT WIN32 AND TEST_futimens
)
-qt_feature("futimes" PRIVATE
- LABEL "futimes()"
- CONDITION NOT WIN32 AND NOT QT_FEATURE_futimens AND TEST_futimes
-)
qt_feature("getauxval" PRIVATE
LABEL "getauxval()"
CONDITION LINUX AND TEST_getauxval
@@ -746,7 +726,7 @@ qt_feature("xmlstream" PUBLIC
LABEL "XML Streaming APIs"
PURPOSE "Provides a simple streaming API for XML."
)
-qt_feature("cpp-winrt" PRIVATE
+qt_feature("cpp-winrt" PRIVATE PUBLIC
LABEL "cpp/winrt base"
PURPOSE "basic cpp/winrt language projection support"
CONDITION WIN32 AND TEST_cpp_winrt
@@ -961,6 +941,18 @@ qt_feature("cborstreamwriter" PUBLIC
LABEL "CBOR stream writing"
PURPOSE "Provides support for writing the CBOR binary format."
)
+qt_feature("poll-exit-on-error" PRIVATE
+ LABEL "Poll exit on error"
+ AUTODETECT OFF
+ CONDITION UNIX
+ PURPOSE "Exit on error instead of just printing the error code and continue."
+)
+qt_feature("permissions" PUBLIC
+ SECTION "Utilities"
+ LABEL "Application permissions"
+ PURPOSE "Provides support for requesting user permission to access restricted data or APIs"
+ CONDITION APPLE OR ANDROID OR WASM
+)
qt_configure_add_summary_section(NAME "Qt Core")
qt_configure_add_summary_entry(ARGS "backtrace")
qt_configure_add_summary_entry(ARGS "doubleconversion")
@@ -990,6 +982,7 @@ qt_configure_add_summary_entry(
ARGS "forkfd_pidfd"
CONDITION LINUX
)
+qt_configure_add_summary_entry(ARGS "permissions")
qt_configure_end_summary_section() # end of "Qt Core" section
qt_configure_add_report_entry(
TYPE NOTE
@@ -1019,5 +1012,5 @@ qt_configure_add_report_entry(
qt_configure_add_report_entry(
TYPE WARNING
MESSAGE "Basic cpp/winrt support missing. Some features might not be available."
- CONDITION MSVC AND NOT QT_FEATURE_cpp_winrt
+ CONDITION NOT QT_FEATURE_cpp_winrt
)
diff --git a/src/corelib/doc/include/QtCoreDoc b/src/corelib/doc/include/QtCoreDoc
index 3dc7ce46e5..f3c875e49a 100644
--- a/src/corelib/doc/include/QtCoreDoc
+++ b/src/corelib/doc/include/QtCoreDoc
@@ -1,2 +1,3 @@
#include <QtCore/QtCore>
#include "../../platform/android/qandroidextras_p.h"
+#include "../../kernel/qpermissions.h"
diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf
index 19e1fb23e5..f0a9fcc573 100644
--- a/src/corelib/doc/qtcore.qdocconf
+++ b/src/corelib/doc/qtcore.qdocconf
@@ -34,7 +34,8 @@ headerdirs += ..
sourcedirs += .. \
../../tools/androiddeployqt \
- ../../android/templates
+ ../../android/templates \
+ src/includes
exampledirs += \
../ \
diff --git a/src/corelib/doc/snippets/cmake-macros/deployment.cmake b/src/corelib/doc/snippets/cmake-macros/deployment.cmake
new file mode 100644
index 0000000000..c5979a9ff2
--- /dev/null
+++ b/src/corelib/doc/snippets/cmake-macros/deployment.cmake
@@ -0,0 +1,27 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+#! [qt_generate_deploy_script_example]
+cmake_minimum_required(VERSION 3.16...3.22)
+project(MyThings)
+
+find_package(Qt6 REQUIRED COMPONENTS Core)
+qt_standard_project_setup()
+
+qt_add_executable(MyApp main.cpp)
+
+install(TARGETS MyApp
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+)
+
+qt_generate_deploy_script(
+ TARGET MyApp
+ FILENAME_VARIABLE deploy_script
+ CONTENT "
+qt_deploy_runtime_dependencies(
+ EXECUTABLE $<TARGET_FILE_NAME:MyApp>
+)
+")
+install(SCRIPT ${deploy_script})
+#! [qt_generate_deploy_script_example]
diff --git a/src/corelib/doc/snippets/cmake-macros/examples.cmake b/src/corelib/doc/snippets/cmake-macros/examples.cmake
index 17d1d628f9..2ed094cb72 100644
--- a/src/corelib/doc/snippets/cmake-macros/examples.cmake
+++ b/src/corelib/doc/snippets/cmake-macros/examples.cmake
@@ -1,5 +1,5 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
#! [qt_wrap_cpp]
set(SOURCES myapp.cpp main.cpp)
diff --git a/src/corelib/doc/snippets/code/doc_src_containers.cpp b/src/corelib/doc/snippets/code/doc_src_containers.cpp
index 51d369d1d5..680a099f68 100644
--- a/src/corelib/doc/snippets/code/doc_src_containers.cpp
+++ b/src/corelib/doc/snippets/code/doc_src_containers.cpp
@@ -16,10 +16,30 @@ private:
};
//! [0]
+//! [range_for]
+QList<QString> list = {"A", "B", "C", "D"};
+for (const auto &item : list) {
+ ...
+}
+//! [range_for]
+
+//! [range_for_as_const]
+QList<QString> list = {"A", "B", "C", "D"};
+for (const auto &item : std::as_const(list)) {
+ ...
+}
+//! [range_for_as_const]
+
+//! [index]
+QList<QString> list = {"A", "B", "C", "D"};
+for (qsizetype i = 0; i < list.size(); ++i) {
+ const auto &item = list.at(i);
+ ...
+}
+//! [index]
//! [1]
-QList<QString> list;
-list << "A" << "B" << "C" << "D";
+QList<QString> list = {"A", "B", "C", "D"};
QListIterator<QString> i(list);
while (i.hasNext())
@@ -71,11 +91,12 @@ while (i.hasNext())
//! [7]
-QMap<QString, QString> map;
-map.insert("Paris", "France");
-map.insert("Guatemala City", "Guatemala");
-map.insert("Mexico City", "Mexico");
-map.insert("Moscow", "Russia");
+QMap<QString, QString> map = {
+ {"Paris", "France"},
+ {"Guatemala City", "Guatemala"},
+ {"Mexico City", "Mexico"},
+ {"Moscow", "Russia"}
+};
...
QMutableMapIterator<QString, QString> i(map);
@@ -106,28 +127,23 @@ while (i.findNext(widget))
//! [10]
-QList<QString> list;
-list << "A" << "B" << "C" << "D";
+QList<QString> list = {"A", "B", "C", "D"};
-QList<QString>::iterator i;
-for (i = list.begin(); i != list.end(); ++i)
+for (auto i = list.begin(), end = list.end(); i != end; ++i)
*i = (*i).toLower();
//! [10]
//! [11]
-QList<QString> list;
-list << "A" << "B" << "C" << "D";
+QList<QString> list = {"A", "B", "C", "D"};
-QList<QString>::reverse_iterator i;
-for (i = list.rbegin(); i != list.rend(); ++i)
+for (auto i = list.rbegin(), rend = list.rend(); i != rend; ++i)
*i = i->toLower();
//! [11]
//! [12]
-QList<QString>::const_iterator i;
-for (i = list.constBegin(); i != list.constEnd(); ++i)
+for (auto i = list.cbegin(), end = list.cend(); i != end; ++i)
qDebug() << *i;
//! [12]
@@ -135,8 +151,7 @@ for (i = list.constBegin(); i != list.constEnd(); ++i)
//! [13]
QMap<int, int> map;
...
-QMap<int, int>::const_iterator i;
-for (i = map.constBegin(); i != map.constEnd(); ++i)
+for (auto i = map.cbegin(), end = map.cend(); i != end; ++i)
qDebug() << i.key() << ':' << i.value();
//! [13]
@@ -144,13 +159,11 @@ for (i = map.constBegin(); i != map.constEnd(); ++i)
//! [14]
// RIGHT
const QList<int> sizes = splitter->sizes();
-QList<int>::const_iterator i;
-for (i = sizes.begin(); i != sizes.end(); ++i)
+for (auto i = sizes.begin(), end = sizes.end(); i != end; ++i)
...
// WRONG
-QList<int>::const_iterator i;
-for (i = splitter->sizes().begin();
+for (auto i = splitter->sizes().begin();
i != splitter->sizes().end(); ++i)
...
//! [14]
@@ -234,9 +247,9 @@ target_compile_definitions(my_app PRIVATE QT_NO_KEYWORDS)
QString onlyLetters(const QString &in)
{
QString out;
- for (int j = 0; j < in.size(); ++j) {
- if (in[j].isLetter())
- out += in[j];
+ for (qsizetype j = 0; j < in.size(); ++j) {
+ if (in.at(j).isLetter())
+ out += in.at(j);
}
return out;
}
@@ -273,15 +286,15 @@ int j = *i; // Undefined behavior!
//! [24]
//! [25]
-QList<int> list { 1, 2, 3, 4, 4, 5 };
-QSet<int> set(list.begin(), list.end());
+QList<int> list = {1, 2, 3, 4, 4, 5};
+QSet<int> set(list.cbegin(), list.cend());
/*
Will generate a QSet containing 1, 2, 3, 4, 5.
*/
//! [25]
//! [26]
-QList<int> list { 2, 3, 1 };
+QList<int> list = {2, 3, 1};
std::sort(list.begin(), list.end());
/*
diff --git a/src/corelib/doc/snippets/code/doc_src_qplugin.pro b/src/corelib/doc/snippets/code/doc_src_qplugin.pro
deleted file mode 100644
index 52fb9e3163..0000000000
--- a/src/corelib/doc/snippets/code/doc_src_qplugin.pro
+++ /dev/null
@@ -1,4 +0,0 @@
-#! [3]
-TEMPLATE = app
-QTPLUGIN += qjpeg qgif # image formats
-#! [3]
diff --git a/src/corelib/doc/snippets/code/src_corelib_animation_qpropertyanimation.cpp b/src/corelib/doc/snippets/code/src_corelib_animation_qpropertyanimation.cpp
index e50581a2c8..f8b74cd542 100644
--- a/src/corelib/doc/snippets/code/src_corelib_animation_qpropertyanimation.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_animation_qpropertyanimation.cpp
@@ -3,10 +3,94 @@
//! [0]
- QPropertyAnimation *animation = new QPropertyAnimation(myWidget, "geometry");
- animation->setDuration(10000);
- animation->setStartValue(QRect(0, 0, 100, 30));
- animation->setEndValue(QRect(250, 250, 100, 30));
+#include <QApplication>
+#include <QPushButton>
+#include <QPropertyAnimation>
+//! [1]
+class MyButtonWidget : public QWidget
+{
+public:
+ MyButtonWidget(QWidget *parent = nullptr);
+};
- animation->start();
+MyButtonWidget::MyButtonWidget(QWidget *parent) : QWidget(parent)
+{
+ QPushButton *button = new QPushButton(tr("Animated Button"), this);
+ QPropertyAnimation *anim = new QPropertyAnimation(button, "pos", this);
+ anim->setDuration(10000);
+ anim->setStartValue(QPoint(0, 0));
+ anim->setEndValue(QPoint(100, 250));
+ anim->start();
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ MyButtonWidget buttonAnimWidget;
+ buttonAnimWidget.resize(QSize(800, 600));
+ buttonAnimWidget.show();
+ return a.exec();
+}
+//! [1]
//! [0]
+
+
+//! [easing-curve]
+MyButtonWidget::MyButtonWidget(QWidget *parent) : QWidget(parent)
+{
+ QPushButton *button = new QPushButton(tr("Animated Button"), this);
+ QPropertyAnimation *anim = new QPropertyAnimation(button, "pos", this);
+ anim->setDuration(10000);
+ anim->setStartValue(QPoint(0, 0));
+ anim->setEndValue(QPoint(100, 250));
+ anim->setEasingCurve(QEasingCurve::OutBounce);
+ anim->start();
+}
+//! [easing-curve]
+
+
+//! [animation-group1]
+MyButtonWidget::MyButtonWidget(QWidget *parent) : QWidget(parent)
+{
+ QPushButton *bonnie = new QPushButton(tr("Bonnie"), this);
+ QPushButton *clyde = new QPushButton(tr("Clyde"), this);
+
+ QPropertyAnimation *anim1 = new QPropertyAnimation(bonnie, "pos", this);
+ anim1->setDuration(3000);
+ anim1->setStartValue(QPoint(0, 0));
+ anim1->setEndValue(QPoint(100, 250));
+
+ QPropertyAnimation *anim2 = new QPropertyAnimation(clyde, "pos", this);
+ anim2->setDuration(3000);
+ anim2->setStartValue(QPoint(100, 250));
+ anim2->setEndValue(QPoint(500, 500));
+
+ QParallelAnimationGroup *parallelAnim = new QParallelAnimationGroup;
+ parallelAnim->addAnimation(anim1);
+ parallelAnim->addAnimation(anim2);
+ parallelAnim->start();
+}
+//! [animation-group1]
+
+//! [animation-group2]
+MyButtonWidget::MyButtonWidget(QWidget *parent) : QWidget(parent)
+{
+ QPushButton *bonnie = new QPushButton(tr("Bonnie"), this);
+ QPushButton *clyde = new QPushButton(tr("Clyde"), this);
+
+ QPropertyAnimation *anim1 = new QPropertyAnimation(bonnie, "pos", this);
+ anim1->setDuration(3000);
+ anim1->setStartValue(QPoint(0, 0));
+ anim1->setEndValue(QPoint(100, 250));
+
+ QPropertyAnimation *anim2 = new QPropertyAnimation(clyde, "pos", this);
+ anim2->setDuration(3000);
+ anim2->setStartValue(QPoint(0, 0));
+ anim2->setEndValue(QPoint(200, 250));
+
+ QSequentialAnimationGroup *sequenceAnim = new QSequentialAnimationGroup;
+ sequenceAnim->addAnimation(anim1);
+ sequenceAnim->addAnimation(anim2);
+ sequenceAnim->start();
+}
+//! [animation-group2]
diff --git a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
index 4d6f566bf8..096e36dc72 100644
--- a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
@@ -667,6 +667,19 @@ bool readConfiguration(const QFile &file)
}
//! [qunreachable-switch]
+//! [qunreachable-return]
+ switch (shape) {
+ case Rectangle:
+ return rectangle();
+ case Triangle:
+ return triangle();
+ case Circle:
+ return circle();
+ case NumShapes:
+ Q_UNREACHABLE_RETURN(nullptr);
+ }
+//! [qunreachable-return]
+
//! [qt-version-check]
#include <QtGlobal>
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qmetaobject.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qmetaobject.cpp
index de291667ea..ec4646c520 100644
--- a/src/corelib/doc/snippets/code/src_corelib_kernel_qmetaobject.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qmetaobject.cpp
@@ -34,6 +34,21 @@ QMetaObject::invokeMethod(thread, "quit",
QMetaObject::invokeMethod: Unable to handle unregistered datatype 'MyType'
//! [3]
+//! [invokemethod-no-macro]
+QString retVal;
+QMetaObject::invokeMethod(obj, "compute", Qt::DirectConnection,
+ qReturnArg(retVal),
+ QString("sqrt"), 42, 9.7);
+//! [invokemethod-no-macro]
+
+
+//! [invokemethod-no-macro-other-types]
+QString retVal;
+QMetaObject::invokeMethod(obj, "compute", Qt::DirectConnection,
+ qReturnArg(retVal),
+ QStringView("sqrt"), qsizetype(42), 9.7f);
+//! [invokemethod-no-macro-other-types]
+
//! [4]
QString retVal;
@@ -83,6 +98,24 @@ method.invoke(pushButton, Qt::QueuedConnection);
QMetaMethod::invoke: Unable to handle unregistered datatype 'MyType'
//! [7]
+//! [invoke-no-macro]
+QString retVal;
+QByteArray normalizedSignature = QMetaObject::normalizedSignature("compute(QString, int, double)");
+int methodIndex = obj->metaObject()->indexOfMethod(normalizedSignature);
+QMetaMethod method = obj->metaObject()->method(methodIndex);
+method.invoke(obj, Qt::DirectConnection, qReturnArg(retVal),
+ QString("sqrt"), 42, 9.7);
+//! [invoke-no-macro]
+
+//! [invoke-no-macro-other-types]
+QString retVal;
+QByteArray normalizedSignature = QMetaObject::normalizedSignature("compute(QByteArray, qint64, long double)");
+int methodIndex = obj->metaObject()->indexOfMethod(normalizedSignature);
+QMetaMethod method = obj->metaObject()->method(methodIndex);
+method.invoke(obj, Qt::DirectConnection, qReturnArg(retVal),
+ QByteArray("sqrt"), qint64(42), 9.7L);
+//! [invoke-no-macro-other-types]
+
//! [8]
QString retVal;
QByteArray normalizedSignature = QMetaObject::normalizedSignature("compute(QString, int, double)");
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qmetatype.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qmetatype.cpp
index b66951357d..a213ccbca6 100644
--- a/src/corelib/doc/snippets/code/src_corelib_kernel_qmetatype.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qmetatype.cpp
@@ -35,12 +35,12 @@ MyStruct s2 = var.value<MyStruct>();
//! [3]
-int id = QMetaType::type("MyClass");
-if (id != QMetaType::UnknownType) {
- void *myClassPtr = QMetaType::create(id);
+QMetaType type = QMetaType::fromName("MyClass");
+if (type.isValid()) {
+ void *myClassPtr = type.create();
...
- QMetaType::destroy(id, myClassPtr);
- myClassPtr = 0;
+ type.destroy(myClassPtr);
+ myClassPtr = nullptr;
}
//! [3]
diff --git a/src/corelib/doc/snippets/code/src_corelib_text_qstring.cpp b/src/corelib/doc/snippets/code/src_corelib_text_qstring.cpp
index 2c195fd24f..efb529657a 100644
--- a/src/corelib/doc/snippets/code/src_corelib_text_qstring.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_text_qstring.cpp
@@ -30,6 +30,9 @@ if (str == QString("auto") || str == QString("extern")
}
//! [4]
+//! [4bis]
+str.append("Hello ").append("World");
+//! [4bis]
//! [5]
if (str == "auto"_L1
diff --git a/src/corelib/doc/snippets/code/src_corelib_text_qstringiterator.cpp b/src/corelib/doc/snippets/code/src_corelib_text_qstringiterator.cpp
index 6b04d23b97..10e6eb6276 100644
--- a/src/corelib/doc/snippets/code/src_corelib_text_qstringiterator.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_text_qstringiterator.cpp
@@ -16,7 +16,7 @@ QStringIterator i(string); // implicitly converted to QStringView
//! [1]
while (i.hasNext())
- uint c = i.next();
+ char32_t c = i.next();
//! [1]
}
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp
index f1be49c1d4..b7e56c5ec3 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp
@@ -297,11 +297,11 @@ inline size_t qHash(const std::unordered_set<int> &key, size_t seed = 0)
//! [31]
//! [32]
-size_t qHash(K key);
-size_t qHash(const K &key);
-
size_t qHash(K key, size_t seed);
size_t qHash(const K &key, size_t seed);
+
+size_t qHash(K key); // deprecated, do not use
+size_t qHash(const K &key); // deprecated, do not use
//! [32]
//! [33]
diff --git a/src/corelib/doc/snippets/code/src_gui_dialogs_qmessagebox.cpp b/src/corelib/doc/snippets/code/src_gui_dialogs_qmessagebox.cpp
index afa4c09873..0b307c33c4 100644
--- a/src/corelib/doc/snippets/code/src_gui_dialogs_qmessagebox.cpp
+++ b/src/corelib/doc/snippets/code/src_gui_dialogs_qmessagebox.cpp
@@ -77,8 +77,8 @@ msgBox.exec();
//! [6]
QMessageBox msgBox;
-msgBox.setText("The document has been modified.");
-msgBox.setInformativeText("Do you want to save your changes?");
+msgBox.setText("Do you want to save your changes?");
+msgBox.setInformativeText("The document has been modified. It was last saved 5 days ago.");
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Save);
int ret = msgBox.exec();
diff --git a/src/corelib/doc/snippets/fileinfo/main.cpp b/src/corelib/doc/snippets/fileinfo/main.cpp
index da6a2798f6..819bde3de5 100644
--- a/src/corelib/doc/snippets/fileinfo/main.cpp
+++ b/src/corelib/doc/snippets/fileinfo/main.cpp
@@ -31,14 +31,16 @@ int main(int argc, char *argv[])
qDebug() << fileInfo5.fileName();
qDebug() << fileInfo6.fileName();
+ QGroupBox *groupBox = new QGroupBox(QStringLiteral("QFileInfo::dir() test"));
+
+ QVBoxLayout *vbox = new QVBoxLayout(groupBox);
+
QPushButton* button1 = new QPushButton(fileInfo1.dir().path());
QPushButton* button2 = new QPushButton(fileInfo2.dir().path());
QPushButton* button3 = new QPushButton(fileInfo3.dir().path());
QPushButton* button4 = new QPushButton(fileInfo4.dir().path());
QPushButton* button5 = new QPushButton(fileInfo5.dir().path());
QPushButton* button6 = new QPushButton(fileInfo6.dir().path());
-
- QVBoxLayout* vbox = new QVBoxLayout;
vbox->addWidget(button1);
vbox->addWidget(button2);
vbox->addWidget(button3);
@@ -47,8 +49,6 @@ int main(int argc, char *argv[])
vbox->addWidget(button6);
vbox->addStretch(1);
- QGroupBox *groupBox = new QGroupBox("QFileInfo::dir() test");
- groupBox->setLayout(vbox);
groupBox->show();
return app.exec();
diff --git a/src/corelib/doc/snippets/qmetatype/registerConverters.cpp b/src/corelib/doc/snippets/qmetatype/registerConverters.cpp
index 5c5e76c7b0..f53d04b7a6 100644
--- a/src/corelib/doc/snippets/qmetatype/registerConverters.cpp
+++ b/src/corelib/doc/snippets/qmetatype/registerConverters.cpp
@@ -1,6 +1,7 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+#include <QJsonObject>
#include <QMetaType>
#include <QString>
@@ -50,5 +51,12 @@ int main() {
QMetaType::registerConverter<CustomStringType, QString>([](const CustomStringType &str) {
return QString::fromUtf8(str.data());
});
+ QMetaType::registerConverter<QJsonValue, QPointF>(
+ [](const QJsonValue &value) -> std::optional<QPointF> {
+ const auto object = value.toObject();
+ if (!object.contains("x") || !object.contains("y"))
+ return std::nullopt; // The conversion fails if the required properties are missing
+ return QPointF{object["x"].toDouble(), object["y"].toDouble()};
+ });
//! [unaryfunc]
}
diff --git a/src/corelib/doc/snippets/qsignalmapper/buttonwidget.cpp b/src/corelib/doc/snippets/qsignalmapper/buttonwidget.cpp
index 1d1f2b147c..235d8b27db 100644
--- a/src/corelib/doc/snippets/qsignalmapper/buttonwidget.cpp
+++ b/src/corelib/doc/snippets/qsignalmapper/buttonwidget.cpp
@@ -11,7 +11,7 @@ ButtonWidget::ButtonWidget(const QStringList &texts, QWidget *parent)
{
signalMapper = new QSignalMapper(this);
- QGridLayout *gridLayout = new QGridLayout;
+ QGridLayout *gridLayout = new QGridLayout(this);
for (int i = 0; i < texts.size(); ++i) {
QPushButton *button = new QPushButton(texts[i]);
connect(button, &QPushButton::clicked, signalMapper, &QSignalMapper::map);
@@ -23,8 +23,6 @@ ButtonWidget::ButtonWidget(const QStringList &texts, QWidget *parent)
connect(signalMapper, &QSignalMapper::mappedString,
//! [1] //! [2]
this, &ButtonWidget::clicked);
-
- setLayout(gridLayout);
}
//! [2]
@@ -32,13 +30,12 @@ ButtonWidget::ButtonWidget(const QStringList &texts, QWidget *parent)
ButtonWidget::ButtonWidget(const QStringList &texts, QWidget *parent)
: QWidget(parent)
{
- QGridLayout *gridLayout = new QGridLayout;
+ QGridLayout *gridLayout = new QGridLayout(this);
for (int i = 0; i < texts.size(); ++i) {
QString text = texts[i];
QPushButton *button = new QPushButton(text);
connect(button, &QPushButton::clicked, [this, text] { clicked(text); });
gridLayout->addWidget(button, i / 3, i % 3);
}
- setLayout(gridLayout);
}
//! [3]
diff --git a/src/corelib/doc/snippets/qstringlist/main.cpp b/src/corelib/doc/snippets/qstringlist/main.cpp
index fa3540d8ce..d2175aafb5 100644
--- a/src/corelib/doc/snippets/qstringlist/main.cpp
+++ b/src/corelib/doc/snippets/qstringlist/main.cpp
@@ -22,24 +22,6 @@ Widget::Widget(QWidget *parent)
fonts << "Courier" << "Verdana";
//! [0b]
-//! [1]
- for (int i = 0; i < fonts.size(); ++i)
- cout << fonts.at(i).toLocal8Bit().constData() << Qt::endl;
-//! [1]
-
-//! [2]
- QStringListIterator javaStyleIterator(fonts);
- while (javaStyleIterator.hasNext())
- cout << javaStyleIterator.next().toLocal8Bit().constData() << Qt::endl;
-//! [2]
-
-//! [3]
- QStringList::const_iterator constIterator;
- for (constIterator = fonts.constBegin(); constIterator != fonts.constEnd();
- ++constIterator)
- cout << (*constIterator).toLocal8Bit().constData() << Qt::endl;
-//! [3]
-
//! [4]
QString str = fonts.join(", ");
// str == "Arial, Helvetica, Times, Courier"
diff --git a/src/corelib/doc/snippets/resource-system/CMakeLists.txt b/src/corelib/doc/snippets/resource-system/CMakeLists.txt
index efb8aadfe7..267e9a59ad 100644
--- a/src/corelib/doc/snippets/resource-system/CMakeLists.txt
+++ b/src/corelib/doc/snippets/resource-system/CMakeLists.txt
@@ -1,5 +1,5 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+# SPDX-License-Identifier: BSD-3-Clause
project(my_app)
cmake_minimum_required(VERSION 3.16)
diff --git a/src/corelib/doc/src/animation.qdoc b/src/corelib/doc/src/animation.qdoc
index e09300010a..28f88c907a 100644
--- a/src/corelib/doc/src/animation.qdoc
+++ b/src/corelib/doc/src/animation.qdoc
@@ -22,153 +22,134 @@
\keyword Animation
- The animation framework aims to provide an easy way for creating animated
- and smooth GUIs. By animating Qt properties, the framework provides great
- freedom for animating widgets and other \l{QObject}s. The framework can
- also be used with the Graphics View framework. Many of the concepts
- available in the animation framework are also available in \l{Qt Quick},
- where it offers a declarative way of defining animations. Much of the
- knowledge acquired about the animation framework can be applied to
- \l{Qt Quick}.
-
- In this overview, we explain the basics of its architecture. We
- also show examples of the most common techniques that the
- framework allows for animating \l{QObject}s and graphics items.
+ The animation framework provides an easy way to animate your GUI elements.
+ It enables you to animate a Qt property value of a widget or QObject.
+ Most of the features offered by the framework are also available in
+ \l{Qt Quick}, where it's possible to define animations in a declarative way.
+
+ This overview explains the framework's architecture, with examples that
+ demonstrate the common techniques used for animating QObject and
+ GUI elements.
\tableofcontents
- \section1 The Animation Architecture
+ \section1 The Animation architecture
- We will in this section take a high-level look at the animation
- framework's architecture and how it is used to animate Qt
- properties. The following diagram shows the most important classes
- in the animation framework.
+ The following diagram shows the most important classes provided by the
+ framework:
\image animations-architecture.png
- The animation framework foundation consists of the base class
- QAbstractAnimation, and its two subclasses QVariantAnimation and
- QAnimationGroup. QAbstractAnimation is the ancestor of all
- animations. It represents basic properties that are common for all
- animations in the framework; notably, the ability to start, stop,
- and pause an animation. It is also receives the time change
- notifications.
-
- The animation framework further provides the QPropertyAnimation
- class, which inherits QVariantAnimation and performs animation of
- a Qt property, which is part of Qt's \l{Meta-Object
- System}{meta-object system}. The class performs an interpolation
- over the property using an easing curve. So when you want to
- animate a value, you can declare it as a property and make your
- class a QObject. Note that this gives us great freedom in
- animating already existing widgets and other \l{QObject}s.
+ It includes the QAbstractAnimation class, which provides the
+ necessary foundation for animations. This class defines the
+ generic properties for all animations supported by the framework.
+ For example, the ability to start, stop, and pause an animation. The
+ class also receives the time change notifications.
+
+ The framework further provides the QVariantAnimation and
+ QAnimationGroup classes, which build on their base case, QAbstractAnimation.
+ Next in the hierarchy is QPropertyAnimation, which is derived from
+ QVariantAnmiation, and it lets you animate a Qt property of a widget or
+ QObject. The class performs interpolation on the property value using an
+ easing curve. With these in place, you just need a QObject class with a
+ Qt property value that you can animate.
+
+ \note It is required that the target object you are animating is a QObject
+ or its subclass. This is necessary as the animation framework depends on the
+ \l{Meta-Object System}{meta-object system} for all the information about the
+ object it is animating.
Complex animations can be constructed by building a tree structure
- of \l{QAbstractAnimation}s. The tree is built by using
- \l{QAnimationGroup}s, which function as containers for other
- animations. Note also that the groups are subclasses of
- QAbstractAnimation, so groups can themselves contain other groups.
+ of \l{QAbstractAnimation}s, where the tree is a QAnimationGroup that
+ contains other animations. These animation groups can also contain
+ subgroups representing different groups or animations, such as
+ QParallelAnimationGroup and QSequentialAnimationGroup.
- Behind the scenes, the animations are controlled by a global
- timer, which sends \l{QAbstractAnimation::updateCurrentTime()}{updates} to
- all animations that are playing.
+ Behind the scenes, all animations are controlled by a global
+ timer, which sends \l{QAbstractAnimation::updateCurrentTime()}{updates} about
+ all animations that are running.
- For detailed descriptions of the classes' function and roles in
- the framework, please look up their class descriptions.
+ For detailed information of these individual classes' and their roles in
+ the framework, refer to their documentation.
- \section1 Classes in the Animation Framework
+ \section1 Classes offered by the framework
- These classes provide a framework for creating both simple and complex
- animations.
+ These classes provide the necessary infrastructure to create both simple and
+ complex animations.
\annotatedlist animation
- \section1 Animating Qt Properties
+ \section1 Animating Qt properties
- As mentioned in the previous section, the QPropertyAnimation class can
- interpolate over Qt properties. It is often this class that should be used
- for animation of values; in fact, its superclass, QVariantAnimation, has an
- empty implementation of \l{QVariantAnimation::}{updateCurrentValue()}, and
- does not change any value unless we change it ourselves on the
+ As the QPropertyAnimation class can interpolate on Qt properties, it is
+ used often. In fact, its superclass---QVariantAnimation---provides an
+ abstract implementation of \l{QVariantAnimation::}{updateCurrentValue()},
+ which does not change any value unless you change it on the
\l{QVariantAnimation::valueChanged()}{valueChanged signal}.
- A major reason we chose to animate Qt properties is that it
- presents us with freedom to animate already existing classes in
- the Qt API. Notably, the QWidget class (which we can also embed in
- a QGraphicsView) has properties for its bounds, colors, etc.
- Let's look at a small example:
-
- \code
- QPushButton button("Animated Button");
- button.show();
+ The framework lets you animate the Qt properties of the existing
+ classes in Qt. For example, the QWidget class---can be embedded in
+ a QGraphicsView---has properties for its bounds, colors, and so on.
+ The following example demonstrates how you can animate a QPushButton
+ widget:
- QPropertyAnimation animation(&button, "geometry");
- animation.setDuration(10000);
- animation.setStartValue(QRect(0, 0, 100, 30));
- animation.setEndValue(QRect(250, 250, 100, 30));
+ \snippet code/src_corelib_animation_qpropertyanimation.cpp 0
- animation.start();
- \endcode
+ The example animates the \c pos Qt property of a QPushButton, to move
+ it from the top--left corner of the screen to the end position (250, 250),
+ in 10 seconds (10000 milliseconds).
- This code will move \c button from the top left corner of the
- screen to the position (250, 250) in 10 seconds (10000 milliseconds).
-
- The example above will do a linear interpolation between the
- start and end value. It is also possible to set values
- situated between the start and end value. The interpolation
- will then go by these points.
+ It uses the linear interpolation method to control the speed of
+ animation between the start and end values. Try adding another value
+ in--between the start and end value to see how they are interpolated.
+ This time use the QPropertyAnimation::setKeyValueAt function to add
+ these values:
\code
- QPushButton button("Animated Button");
- button.show();
-
- QPropertyAnimation animation(&button, "geometry");
- animation.setDuration(10000);
-
- animation.setKeyValueAt(0, QRect(0, 0, 100, 30));
- animation.setKeyValueAt(0.8, QRect(250, 250, 100, 30));
- animation.setKeyValueAt(1, QRect(0, 0, 100, 30));
-
- animation.start();
+ ...
+ anim->setDuration(10000);
+ anim->setKeyValueAt(0, QPoint(0, 0));
+ anim->setKeyValueAt(0.8, QPoint(250, 250));
+ anim->setKeyValueAt(1, QPoint(0, 0));
+ ...
\endcode
- In this example, the animation will take the button to (250, 250)
- in 8 seconds, and then move it back to its original position in
- the remaining 2 seconds. The movement will be linearly
- interpolated between these points.
+ In this example, the animation moves the button to
+ (250, 250) in 8 seconds, and moves it back to its original position in
+ the remaining 2 seconds. The button's movement is linear-interpolated
+ between these points.
+
+ You can also animate a QObject's value that is not declared as a Qt
+ property, if the value has a setter method. In such cases, derive
+ a new class from the class that contains the value, and add a Qt property
+ for that value with the setter.
- You also have the possibility to animate values of a QObject
- that is not declared as a Qt property. The only requirement is
- that this value has a setter. You can then subclass the class
- containing the value and declare a property that uses this setter.
- Note that each Qt property requires a getter, so you will need to
- provide a getter yourself if this is not defined.
+ \note Each Qt property requires a getter also, so you should provide a
+ getter if that is not defined.
\code
class MyGraphicsRectItem : public QObject, public QGraphicsRectItem
{
Q_OBJECT
- Q_PROPERTY(QRectF geometry READ geometry WRITE setGeometry)
+ Q_PROPERTY(QPointF pos READ pos WRITE setPos)
};
\endcode
- In the above code example, we subclass QGraphicsRectItem and
- define a geometry property. We can now animate the widgets
- geometry even if QGraphicsRectItem does not provide the geometry
- property.
+ In this example, the \c MyGraphicsRectItem derives from
+ QGraphicsRectItem and QObject, and defines the \c pos property. You can
+ animate the item's \c pos even if QGraphicsRectItem does not provide
+ the \c pos property.
- For a general introduction to the Qt property system, see its
- \l{Qt's Property System}{overview}.
+ For a general introduction to the Qt property system, refer to
+ \l{Qt's Property System}.
\section1 Animations and the Graphics View Framework
- When you want to animate \l{QGraphicsItem}s, you also use
- QPropertyAnimation. However, QGraphicsItem does not inherit QObject.
- A good solution is to subclass the graphics item you wish to animate.
- This class will then also inherit QObject.
- This way, QPropertyAnimation can be used for \l{QGraphicsItem}s.
- The example below shows how this is done. Another possibility is
- to inherit QGraphicsWidget, which already is a QObject.
+ QPropertyAnimation can also be used to animate a QGraphicsItem, which does
+ not inherit QObject. In such cases, you derive a class from the graphics
+ item that you want to animate. This derived class should also inherit form
+ QObject to enable using QPropertyAnimation on a QGraphicsItem. The
+ following example shows how this is done:
\code
class Pixmap : public QObject, public QGraphicsPixmapItem
@@ -176,121 +157,78 @@
Q_OBJECT
Q_PROPERTY(QPointF pos READ pos WRITE setPos)
...
+ }
\endcode
- As described in the previous section, we need to define
- properties that we wish to animate.
+ \note You can also derive from QGraphicsWidget, which already is a
+ QObject.
- Note that QObject must be the first class inherited as the
- meta-object system demands this.
+ As described in the previous section, you need to define
+ properties that you want to animate. The derived class must inherit
+ from QObject first as the meta-object system requires it.
- \section1 Easing Curves
+ \section1 Easing curves
- As mentioned, QPropertyAnimation performs an interpolation between
- the start and end property value. In addition to adding more key
- values to the animation, you can also use an easing curve. Easing
- curves describe a function that controls how the speed of the
- interpolation between 0 and 1 should be, and are useful if you
- want to control the speed of an animation without changing the
- path of the interpolation.
+ A QPropertyAnimation performs linear interpolation
+ between the start and end property values. In addition to adding more key
+ values to the animation, you can also choose an easing curve to control the
+ speed of interpolation between 0 and 1, without changing the
+ path.
- \code
- QPushButton button("Animated Button");
- button.show();
- QPropertyAnimation animation(&button, "geometry");
- animation.setDuration(3000);
- animation.setStartValue(QRect(0, 0, 100, 30));
- animation.setEndValue(QRect(250, 250, 100, 30));
-
- animation.setEasingCurve(QEasingCurve::OutBounce);
-
- animation.start();
- \endcode
+ \snippet code/src_corelib_animation_qpropertyanimation.cpp easing-curve
- Here the animation will follow a curve that makes it bounce like a
- ball as if it was dropped from the start to the end position.
- QEasingCurve has a large collection of curves for you to choose
- from. These are defined by the QEasingCurve::Type enum. If you are
- in need of another curve, you can also implement one yourself, and
+ In this example, the animation follows a curve that makes the
+ \c button bounce like a ball. QEasingCurve offers a large collection of curves
+ to choose from the QEasingCurve::Type enum. If you want
+ to use another curve that is not available, implement one yourself and
register it with QEasingCurve.
- \omit Drop this for the first Lab release
- (Example of custom easing curve (without the actual impl of
- the function I expect)
- \endomit
+ \section1 Grouping animations
- \section1 Putting Animations Together
-
- An application will often contain more than one animation. For
- instance, you might want to move more than one graphics item
+ An application often contains more than one animation. For
+ example, it wants to move more than one graphics item
simultaneously or move them in sequence after each other.
- The subclasses of QAnimationGroup (QSequentialAnimationGroup and
- QParallelAnimationGroup) are containers for other animations so
+ The subclasses of QAnimationGroup---QSequentialAnimationGroup and
+ QParallelAnimationGroup---are containers for other animations so
that these animations can be animated either in sequence or
- parallel. The QAnimationGroup is an example of an animation that
- does not animate properties, but it gets notified of time changes
- periodically. This enables it to forward those time changes to its
- contained animations, and thereby controlling when its animations
- are played.
-
- Let's look at code examples that use both
- QSequentialAnimationGroup and QParallelAnimationGroup, starting
- off with the latter.
-
- \code
- QPushButton *bonnie = new QPushButton("Bonnie");
- bonnie->show();
+ parallel. The QAnimationGroup does not animate properties, but it
+ gets notified of time changes periodically. This enables it to
+ forward those time changes to the animation groups, which control when
+ their animations are played.
- QPushButton *clyde = new QPushButton("Clyde");
- clyde->show();
+ The two following examples demonstrate the use of both
+ QSequentialAnimationGroup and QParallelAnimationGroup:
- QPropertyAnimation *anim1 = new QPropertyAnimation(bonnie, "geometry");
- // Set up anim1
-
- QPropertyAnimation *anim2 = new QPropertyAnimation(clyde, "geometry");
- // Set up anim2
-
- QParallelAnimationGroup *group = new QParallelAnimationGroup;
- group->addAnimation(anim1);
- group->addAnimation(anim2);
-
- group->start();
- \endcode
+ \snippet code/src_corelib_animation_qpropertyanimation.cpp animation-group1
A parallel group plays more than one animation at the same time.
- Calling its \l{QAbstractAnimation::}{start()} function will start
- all animations it governs.
-
- \code
- QPushButton button("Animated Button");
- button.show();
+ Its \l{QAbstractAnimation::}{start()} function starts all
+ animations that are part of the group.
- QPropertyAnimation anim1(&button, "geometry");
- anim1.setDuration(3000);
- anim1.setStartValue(QRect(0, 0, 100, 30));
- anim1.setEndValue(QRect(500, 500, 100, 30));
+ \snippet code/src_corelib_animation_qpropertyanimation.cpp animation-group2
- QPropertyAnimation anim2(&button, "geometry");
- anim2.setDuration(3000);
- anim2.setStartValue(QRect(500, 500, 100, 30));
- anim2.setEndValue(QRect(1000, 500, 100, 30));
+ As the name suggests, a QSequentialAnimationGroup plays
+ its animations in sequence. It starts the next animation in
+ the list after the previous finishes.
- QSequentialAnimationGroup group;
+ A group is an animation itself, so you can add
+ it to another group. This way, building an animation tree, which define
+ when the animations are played in relation to each other.
- group.addAnimation(&anim1);
- group.addAnimation(&anim2);
+ \section1 Object ownership
- group.start();
- \endcode
+ A QPropertyAnimation should always have a parent that controls
+ its lifespan. A typical application may include several animations that
+ are grouped, where the animation group takes ownership of those animations.
+ An independent QProperyAnimation must be explicitly assigned a parent to
+ control its lifespan. In the following example, you can see that an
+ independent QPropertyAnimation has the QApplication instance as its
+ parent:
- As you no doubt have guessed, QSequentialAnimationGroup plays
- its animations in sequence. It starts the next animation in
- the list after the previous is finished.
+ \snippet code/src_corelib_animation_qpropertyanimation.cpp 0
- Since an animation group is an animation itself, you can add
- it to another group. This way, you can build a tree structure
- of animations which specifies when the animations are played
- in relation to each other.
+ \note You can also control the animation's lifespan by choosing a
+ \l{QAbstractAnimation::DeletionPolicy}{delete policy} while starting it.
*/
diff --git a/src/corelib/doc/src/cbor.qdoc b/src/corelib/doc/src/cbor.qdoc
new file mode 100644
index 0000000000..22252bbd88
--- /dev/null
+++ b/src/corelib/doc/src/cbor.qdoc
@@ -0,0 +1,78 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \group cbor
+ \title CBOR Support in Qt
+ \ingroup qt-basic-concepts
+ \brief An overview of CBOR support in Qt.
+
+ \ingroup frameworks-technologies
+
+ \keyword CBOR
+
+ Qt provides support for dealing with CBOR data. CBOR is a binary format to
+ store data that has a superset of the types available in JSON, but is more
+ compact.
+
+ The CBOR support in Qt provides an easy to use C++ API to parse,
+ modify and save CBOR data.
+
+ More details about the CBOR data format can be found in \l {RFC 7049}.
+
+ \tableofcontents
+
+ \section1 Overview
+
+ CBOR is a format to store structured data. It has three groups of built-in types:
+
+ \list
+ \li Basic types: integers, floating point, boolean, null, etc.
+ \li String-like types: strings and byte arrays
+ \li Containers: arrays and maps
+ \endlist
+
+ In addition, CBOR can add a "tag" to extend the meaning of the type. The
+ container types can contain basic types, string-like types and containers.
+
+ \sa {Cbordump Example}, {Convert Example}, {JSON Save Game Example}
+
+ \section1 The CBOR Classes
+
+ \section2 The QCborValue Class
+
+ The QCborValue class represents any CBOR type. It also has a simple API for
+ reading and writing to QCborStreamReader and QCborStreamWriter objects, as
+ well as manipulating such objects in memory, with the help of QCborArray
+ and QCborMap. The CborValue API is simplified from the full CBOR data type
+ and always represents all integers as \l qint64 and all floating-point as
+ \c double. This means QCborValue is unable to represent CBOR integer values
+ outside of the range of \l qint64 (-2^63 to 2^63-1). When creating a CBOR
+ stream, QCborValue::toCbor() can be configured to attempt to write the
+ shorter single- and half-precision floating-point representations.
+
+ \section2 The QCborArray Class
+
+ The QCborArray class is used to hold an array of QCborValue objects. A
+ QCborValue object can contain a QCborArray object. It has functions for
+ converting to and from QVariantList, QStringList, QJsonArray.
+
+ \section2 The QCborMap Class
+
+ The QCborMap class is used to hold an map of QCborValue objects. A
+ QCborValue object can contain a QCborMap object. It has functions for
+ converting to and from QVariantMap, QVariantMap, and QJsonObject, but it
+ can have keys of any type, not just QString.
+
+ \section2 The QCborStreamReader Class
+
+ The QCborStreamReader class is a low level API for reading CBOR data from a
+ QIODevice, a QByteArray, or a pointer to memory. It has an API similar to
+ the QXmlStreamReader class.
+
+ \section2 The QCborStreamWriter Class
+
+ The QCborStreamWriter class is a low level API for writing CBOR data to a
+ QIODevice or a QByteArray. It has an API similar to the QXmlStreamWriter
+ class.
+*/
diff --git a/src/corelib/doc/src/cmake/cmake-configure-variables.qdoc b/src/corelib/doc/src/cmake/cmake-configure-variables.qdoc
index 116e08fef4..9653800bc8 100644
--- a/src/corelib/doc/src/cmake/cmake-configure-variables.qdoc
+++ b/src/corelib/doc/src/cmake/cmake-configure-variables.qdoc
@@ -22,7 +22,7 @@ find_package(Qt6 REQUIRED COMPONENTS Core)
*/
*/*!
-\page cmake-variable-ANDROID_NDK_HOST_SYSTEM_NAME.html
+\page cmake-variable-android-ndk-host-system-name.html
\ingroup cmake-variables-qtcore
\title ANDROID_NDK_HOST_SYSTEM_NAME
@@ -41,7 +41,7 @@ part of the deployment settings for a target.
*/
/*!
-\page cmake-variable-ANDROID_SDK_ROOT.html
+\page cmake-variable-android-sdk-root.html
\ingroup cmake-variables-qtcore
\title ANDROID_SDK_ROOT
@@ -60,7 +60,7 @@ It is written out as part of the deployment settings for a target.
*/
/*!
-\page cmake-variable-QT_ANDROID_APPLICATION_ARGUMENTS.html
+\page cmake-variable-qt-android-application-arguments.html
\ingroup cmake-variables-qtcore
\title QT_ANDROID_APPLICATION_ARGUMENTS
@@ -79,7 +79,7 @@ out as part of the deployment settings for a target.
*/
/*!
-\page cmake-variable-QT_ANDROID_BUILD_ALL_ABIS.html
+\page cmake-variable-qt-android-build-all-abis.html
\ingroup cmake-variables-qtcore
\title QT_ANDROID_BUILD_ALL_ABIS
@@ -98,11 +98,11 @@ supplied by the Qt installer, with the corresponding naming of the directories.
The typical directory structure looks as below:
\badcode
/path/to/Qt/6.x.x
-    android_armv7
-    android_arm64_v8a
-    android_x86
-    android_x86_64
-    ...
+ android_armv7
+ android_arm64_v8a
+ android_x86
+ android_x86_64
+ ...
\endcode
The auto-detected paths can be customized using one of \c{QT_PATH_ANDROID_ABI_<ABI>} variables.
@@ -112,7 +112,7 @@ The variable is set to FALSE by default.
*/
/*!
-\page cmake-variable-QT_ANDROID_ABIS.html
+\page cmake-variable-qt-android-abis.html
\ingroup cmake-variables-qtcore
\title QT_ANDROID_ABIS
@@ -137,7 +137,7 @@ QT_ANDROID_ABIS logic.
*/
/*!
-\page cmake-variable-QT_PATH_ANDROID_ABI.html
+\page cmake-variable-qt-path-android-abi.html
\ingroup cmake-variables-qtcore
\title QT_PATH_ANDROID_ABI_<ABI>
@@ -156,7 +156,32 @@ Each variable can be used to specify the path to Qt for Android for the correspo
*/
/*!
-\page cmake-variable-QT_ANDROID_SIGN_APK.html
+\page cmake-variable-qt-android-sign-aab.html
+\ingroup cmake-variables-qtcore
+
+\title QT_ANDROID_SIGN_AAB
+\target cmake-variable-QT_ANDROID_SIGN_AAB
+
+\summary {Sign the .aab package with the specified keystore, alias and store password.}
+\cmakevariablesince 6.4
+\preliminarycmakevariable
+\cmakevariableandroidonly
+
+Sign the resulting package. The path of the keystore file, the alias of the key and passwords
+have to be specified by additional environment variables:
+\badcode
+ QT_ANDROID_KEYSTORE_PATH
+ QT_ANDROID_KEYSTORE_ALIAS
+ QT_ANDROID_KEYSTORE_STORE_PASS
+ QT_ANDROID_KEYSTORE_KEY_PASS
+\endcode
+Mentioned variables are used internally by \l{androiddeployqt}.
+
+\sa{androiddeployqt}
+*/
+
+/*!
+\page cmake-variable-qt-android-sign-apk.html
\ingroup cmake-variables-qtcore
\title QT_ANDROID_SIGN_APK
@@ -181,7 +206,56 @@ Mentioned variables are used internally by \l{androiddeployqt}.
*/
/*!
-\page cmake-variable-QT_HOST_PATH.html
+\page cmake-variable-qt-no-collect-build-tree-apk-deps.html
+\ingroup cmake-variables-qtcore
+
+\title QT_NO_COLLECT_BUILD_TREE_APK_DEPS
+\target cmake-variable-QT_NO_COLLECT_BUILD_TREE_APK_DEPS
+
+\summary {Prevents collecting of project-built shared library targets during Android deployment.}
+
+\cmakevariablesince 6.3
+\preliminarycmakevariable
+\cmakevariableandroidonly
+
+During project finalization, the build system collects the locations of
+all built shared library targets in the project.
+These locations are passed to \l androiddeployqt for deployment consideration when
+resolving dependencies between libraries.
+Set \c QT_NO_COLLECT_BUILD_TREE_APK_DEPS to \c TRUE to disable this behavior.
+
+\sa {qt6_finalize_project}{qt_finalize_project()}
+\sa {cmake-variable-QT_NO_COLLECT_IMPORTED_TARGET_APK_DEPS}{QT_NO_COLLECT_IMPORTED_TARGET_APK_DEPS}
+*/
+
+/*!
+\page cmake-variable-qt-no-collect-imported-target-apk-deps.html
+\ingroup cmake-variables-qtcore
+
+\title QT_NO_COLLECT_IMPORTED_TARGET_APK_DEPS
+\target cmake-variable-QT_NO_COLLECT_IMPORTED_TARGET_APK_DEPS
+
+\summary {Prevents collecting of imported targets during Android deployment.}
+
+\cmakevariablesince 6.5
+\preliminarycmakevariable
+\cmakevariableandroidonly
+
+When using CMake version 3.21 or later, the build system collects the locations of
+imported shared library targets that might be relevant for deployment.
+The collected targets are those that are reachable from the the directory scope
+of the currently processed executable target. That includes the target's source directory
+scope and its parents.
+The collected locations are passed to \l androiddeployqt for deployment consideration when
+resolving dependencies between libraries.
+Set \c QT_NO_COLLECT_IMPORTED_TARGET_APK_DEPS to \c TRUE to disable this behavior.
+
+\sa {qt6_finalize_project}{qt_finalize_project()}
+\sa {cmake-variable-QT_NO_COLLECT_BUILD_TREE_APK_DEPS}{QT_NO_COLLECT_BUILD_TREE_APK_DEPS}
+*/
+
+/*!
+\page cmake-variable-qt-host-path.html
\ingroup cmake-variables-qtcore
\title QT_HOST_PATH
@@ -190,7 +264,6 @@ Mentioned variables are used internally by \l{androiddeployqt}.
\summary {Location of the host Qt installation when cross-compiling.}
\cmakevariablesince 6.0
-\preliminarycmakevariable
When cross-compiling, this must be set to the install location of Qt for the host
platform. It is used to locate tools to be run on the host (\l{moc}, \l{rcc},
@@ -198,7 +271,7 @@ platform. It is used to locate tools to be run on the host (\l{moc}, \l{rcc},
*/
/*!
-\page cmake-variable-QT_NO_SET_XCODE_DEVELOPMENT_TEAM_ID.html
+\page cmake-variable-qt-no-set-xcode-development-team-id.html
\ingroup cmake-variables-qtcore
\title QT_NO_SET_XCODE_DEVELOPMENT_TEAM_ID
@@ -215,7 +288,7 @@ Set \c QT_NO_SET_XCODE_DEVELOPMENT_TEAM_ID to true if you want to prevent this.
*/
/*!
-\page cmake-variable-QT_NO_SET_XCODE_BUNDLE_IDENTIFIER.html
+\page cmake-variable-qt-no-set-xcode-bundle-identifier.html
\ingroup cmake-variables-qtcore
\title QT_NO_SET_XCODE_BUNDLE_IDENTIFIER
@@ -233,7 +306,7 @@ Set \c QT_NO_SET_XCODE_BUNDLE_IDENTIFIER to true if you want to prevent this.
*/
/*!
-\page cmake-variable-QT_ENABLE_VERBOSE_DEPLOYMENT.html
+\page cmake-variable-qt-enable-verbose-deployment.html
\ingroup cmake-variables-qtcore
\title QT_ENABLE_VERBOSE_DEPLOYMENT
@@ -253,7 +326,7 @@ must be set before the first \c{find_package(Qt6)} call to have that effect.
*/
/*!
-\page cmake-variable-QT_DEPLOY_SUPPORT.html
+\page cmake-variable-qt-deploy-support.html
\ingroup cmake-variables-qtcore
\title QT_DEPLOY_SUPPORT
@@ -280,7 +353,7 @@ an application, along with its runtime dependencies:
*/
/*!
-\page cmake-variable-QT_NO_STANDARD_PROJECT_SETUP.html
+\page cmake-variable-qt-no-standard-project-setup.html
\ingroup cmake-variables-qtcore
\title QT_NO_STANDARD_PROJECT_SETUP
@@ -289,7 +362,6 @@ an application, along with its runtime dependencies:
\summary {Prevents subsequent calls to qt_standard_project_setup() from making any changes.}
\cmakevariablesince 6.3
-\preliminarycmakevariable
The \l{qt6_standard_project_setup}{qt_standard_project_setup()} command is
typically called in the top level \c{CMakeLists.txt} file of a project. In some
@@ -302,3 +374,22 @@ methods provided by CMake.
\sa {qt6_standard_project_setup}{qt_standard_project_setup()}
*/
+
+/*!
+\page cmake-variable-qt-ios-launch-screen.html
+\ingroup cmake-variables-qtcore
+
+\title QT_IOS_LAUNCH_SCREEN
+\target cmake-variable-QT_IOS_LAUNCH_SCREEN
+
+\summary {Path to iOS launch screen storyboard used by all targets}
+
+\cmakevariablesince 6.4
+\preliminarycmakevariable
+\cmakevariableiosonly
+
+Specifies the path to an iOS launch screen storyboard file that will be used
+by all targets within a project.
+
+\sa {Launch Screens and Launch Images}
+*/
diff --git a/src/corelib/doc/src/cmake/cmake-deploy-variables.qdoc b/src/corelib/doc/src/cmake/cmake-deploy-variables.qdoc
index b10de9dc3b..a84b9bca6e 100644
--- a/src/corelib/doc/src/cmake/cmake-deploy-variables.qdoc
+++ b/src/corelib/doc/src/cmake/cmake-deploy-variables.qdoc
@@ -8,7 +8,7 @@
**/
/*!
-\page cmake-variable-QT_DEPLOY_PREFIX.html
+\page cmake-variable-qt-deploy-prefix.html
\ingroup cmake-variables-qtcore
\title QT_DEPLOY_PREFIX
@@ -49,11 +49,11 @@ install location and just use the prefix-relative \c{QT_DEPLOY_..._DIR}
variables.
\sa QT_DEPLOY_SUPPORT, QT_DEPLOY_BIN_DIR, QT_DEPLOY_LIB_DIR,
- QT_DEPLOY_PLUGINS_DIR, QT_DEPLOY_QML_DIR
+ QT_DEPLOY_PLUGINS_DIR, QT_DEPLOY_QML_DIR, QT_DEPLOY_TRANSLATIONS_DIR
*/
/*!
-\page cmake-variable-QT_DEPLOY_BIN_DIR.html
+\page cmake-variable-qt-deploy-bin-dir.html
\ingroup cmake-variables-qtcore
\title QT_DEPLOY_BIN_DIR
@@ -90,11 +90,11 @@ should not be used for that scenario.
\include cmake-deploy-runtime-dependencies.qdocinc
\sa QT_DEPLOY_SUPPORT, QT_DEPLOY_PREFIX, QT_DEPLOY_LIB_DIR,
- QT_DEPLOY_PLUGINS_DIR, QT_DEPLOY_QML_DIR
+ QT_DEPLOY_PLUGINS_DIR, QT_DEPLOY_QML_DIR, QT_DEPLOY_TRANSLATIONS_DIR
*/
/*!
-\page cmake-variable-QT_DEPLOY_LIB_DIR.html
+\page cmake-variable-qt-deploy-lib-dir.html
\ingroup cmake-variables-qtcore
\title QT_DEPLOY_LIB_DIR
@@ -132,11 +132,11 @@ should not be used for that scenario.
\include cmake-deploy-modified-variable-values.qdocinc
\sa QT_DEPLOY_SUPPORT, QT_DEPLOY_PREFIX, QT_DEPLOY_BIN_DIR,
- QT_DEPLOY_PLUGINS_DIR, QT_DEPLOY_QML_DIR
+ QT_DEPLOY_PLUGINS_DIR, QT_DEPLOY_QML_DIR, QT_DEPLOY_TRANSLATIONS_DIR
*/
/*!
-\page cmake-variable-QT_DEPLOY_PLUGINS_DIR.html
+\page cmake-variable-qt-deploy-plugins-dir.html
\ingroup cmake-variables-qtcore
\title QT_DEPLOY_PLUGINS_DIR
@@ -168,11 +168,11 @@ bundle contents.
\include cmake-deploy-modified-variable-values.qdocinc
\sa QT_DEPLOY_SUPPORT, QT_DEPLOY_PREFIX, QT_DEPLOY_BIN_DIR, QT_DEPLOY_LIB_DIR,
- QT_DEPLOY_QML_DIR
+ QT_DEPLOY_QML_DIR, QT_DEPLOY_TRANSLATIONS_DIR
*/
/*!
-\page cmake-variable-QT_DEPLOY_QML_DIR.html
+\page cmake-variable-qt-deploy-qml-dir.html
\ingroup cmake-variables-qtcore
\title QT_DEPLOY_QML_DIR
@@ -206,5 +206,67 @@ to be deployed to different locations within the app bundle.
\include cmake-deploy-modified-variable-values.qdocinc
\sa QT_DEPLOY_SUPPORT, QT_DEPLOY_PREFIX, QT_DEPLOY_BIN_DIR, QT_DEPLOY_LIB_DIR,
- QT_DEPLOY_PLUGINS_DIR
+ QT_DEPLOY_PLUGINS_DIR, QT_DEPLOY_TRANSLATIONS_DIR
+*/
+
+/*!
+\page cmake-variable-qt-deploy-translations-dir.html
+\ingroup cmake-variables-qtcore
+
+\title QT_DEPLOY_TRANSLATIONS_DIR
+\target cmake-variable-QT_DEPLOY_TRANSLATIONS_DIR
+
+\summary {Prefix-relative subdirectory for deploying Qt translations on some target platforms.}
+
+\include cmake-deploy-var-usage.qdocinc
+
+\cmakevariablesince 6.5
+\preliminarycmakevariable
+
+Projects should use \c QT_DEPLOY_TRANSLATIONS_DIR in their deploy scripts to
+avoid hard-coding a particular directory under which to deploy translations.
+
+\c QT_DEPLOY_TRANSLATIONS_DIR defaults to the value \c{translations}. To change
+the value of \c QT_DEPLOY_TRANSLATIONS_DIR, set it in the project deployment
+script before \c QT_DEPLOY_SUPPORT is included.
+
+The \c QT_DEPLOY_TRANSLATIONS_DIR path is relative to \l{QT_DEPLOY_PREFIX}.
+
+This variable is not meaningful when deploying on macOS or Windows.
+
+\section1 Example
+
+\include cmake-deploy-modified-variable-values.qdocinc
+
+\sa QT_DEPLOY_SUPPORT, QT_DEPLOY_PREFIX, QT_DEPLOY_BIN_DIR, QT_DEPLOY_LIB_DIR,
+ QT_DEPLOY_PLUGINS_DIR, QT_DEPLOY_QML_DIR
+*/
+
+/*!
+\page cmake-variable-qt-deploy-ignored-lib-dirs.html
+\ingroup cmake-variables-qtcore
+
+\title QT_DEPLOY_IGNORED_LIB_DIRS
+\target cmake-variable-QT_DEPLOY_IGNORED_LIB_DIRS
+
+\summary {Directories that are excluded from runtime dependencies search}
+
+\include cmake-deploy-var-usage.qdocinc
+
+\cmakevariablesince 6.5
+\preliminarycmakevariable
+
+This variable contains a list of directories that are not taken into account
+when searching for runtime dependencies with \l{qt_deploy_runtime_dependencies}.
+
+Projects may alter this variable before calling
+\l{qt_deploy_runtime_dependencies} to control from which directory runtime
+dependencies are deployed.
+
+This variable is ignored if the \c{POST_EXCLUDE_REGEXES} option is specified in
+the \l{qt_deploy_runtime_dependencies} call.
+
+This variable is not meaningful when deploying on macOS or Windows.
+
+\sa qt_deploy_runtime_dependencies
*/
diff --git a/src/corelib/doc/src/cmake/cmake-properties.qdoc b/src/corelib/doc/src/cmake/cmake-properties.qdoc
index bbb948aec2..3ade73b56b 100644
--- a/src/corelib/doc/src/cmake/cmake-properties.qdoc
+++ b/src/corelib/doc/src/cmake/cmake-properties.qdoc
@@ -12,7 +12,7 @@ target properties:
*/
/*!
-\page cmake-target-property-QT_ANDROID_DEPLOYMENT_DEPENDENCIES.html
+\page cmake-target-property-qt-android-deployment-dependencies.html
\ingroup cmake-properties-qtcore
\ingroup cmake-target-properties-qtcore
@@ -43,7 +43,7 @@ is listed before its dependencies, it will fail to load on some devices.
*/
/*!
-\page cmake-target-property-QT_ANDROID_EXTRA_LIBS.html
+\page cmake-target-property-qt-android-extra-libs.html
\ingroup cmake-properties-qtcore
\ingroup cmake-target-properties-qtcore
@@ -65,7 +65,7 @@ to enable OpenSSL in your application. For more information, see
*/
/*!
-\page cmake-target-property-QT_ANDROID_EXTRA_PLUGINS.html
+\page cmake-target-property-qt-android-extra-plugins.html
\ingroup cmake-properties-qtcore
\ingroup cmake-target-properties-qtcore
@@ -96,7 +96,7 @@ mangling is applied to the plugin library.
*/
/*!
-\page cmake-target-property-QT_ANDROID_MIN_SDK_VERSION.html
+\page cmake-target-property-qt-android-min-sdk-version.html
\ingroup cmake-properties-qtcore
\ingroup cmake-target-properties-qtcore
@@ -115,7 +115,7 @@ Specifies the minimum Android API level for the target.
*/
/*!
-\page cmake-target-property-QT_ANDROID_PACKAGE_SOURCE_DIR.html
+\page cmake-target-property-qt-android-package-source-dir.html
\ingroup cmake-properties-qtcore
\ingroup cmake-target-properties-qtcore
@@ -148,7 +148,7 @@ then place this directly into the directory specified by this variable.
*/
/*!
-\page cmake-target-property-QT_ANDROID_TARGET_SDK_VERSION.html
+\page cmake-target-property-qt-android-target-sdk-version.html
\ingroup cmake-properties-qtcore
\ingroup cmake-target-properties-qtcore
@@ -167,7 +167,7 @@ Specifies the target Android API level for the target.
*/
/*!
-\page cmake-target-property-QT_ANDROID_VERSION_CODE.html
+\page cmake-target-property-qt-android-version-code.html
\ingroup cmake-properties-qtcore
\ingroup cmake-target-properties-qtcore
@@ -189,7 +189,7 @@ For more information, see \l{Android: App Versioning}{Android App Versioning}.
*/
/*!
-\page cmake-target-property-QT_ANDROID_VERSION_NAME.html
+\page cmake-target-property-qt-android-version-name.html
\ingroup cmake-properties-qtcore
\ingroup cmake-target-properties-qtcore
@@ -211,7 +211,7 @@ For more information, see \l{Android: App Versioning}{Android App Versioning}.
*/
/*!
-\page cmake-target-property-QT_ANDROID_ABIS.html
+\page cmake-target-property-qt-android-abis.html
\ingroup cmake-properties-qtcore
\ingroup cmake-target-properties-qtcore
@@ -234,7 +234,7 @@ The property only affects targets created with
*/
/*!
-\page cmake-target-property-QT_QML_ROOT_PATH.html
+\page cmake-target-property-qt-qml-root-path.html
\ingroup cmake-properties-qtcore
\ingroup cmake-target-properties-qtcore
@@ -255,7 +255,7 @@ will be used instead.
*/
/*!
-\page cmake-target-property-QT_QML_IMPORT_PATH.html
+\page cmake-target-property-qt-qml-import-path.html
\ingroup cmake-properties-qtcore
\ingroup cmake-target-properties-qtcore
@@ -277,7 +277,7 @@ For application-specific QML imports, use
*/
/*!
-\page cmake-target-property-QT_ANDROID_DEPLOYMENT_SETTINGS_FILE.html
+\page cmake-target-property-qt-android-deployment-settings-file.html
\ingroup cmake-properties-qtcore
\ingroup cmake-target-properties-qtcore
@@ -297,7 +297,7 @@ and overwritten by that command.
*/
/*!
-\page cmake-target-property-QT_ANDROID_SYSTEM_LIBS_PREFIX.html
+\page cmake-target-property-qt-android-system-libs-prefix.html
\ingroup cmake-properties-qtcore
\ingroup cmake-target-properties-qtcore
@@ -314,7 +314,7 @@ when those libraries are installed outside app's native (JNI) library directory.
*/
/*!
-\page cmake-target-property-QT_ANDROID_NO_DEPLOY_QT_LIBS.html
+\page cmake-target-property-qt-android-no-deploy-qt-libs.html
\ingroup cmake-properties-qtcore
\ingroup cmake-target-properties-qtcore
@@ -336,7 +336,7 @@ instead.
*/
/*!
-\page cmake-target-property-qt_no_entrypoint.html
+\page cmake-target-property-qt-no-entrypoint.html
\ingroup cmake-properties-qtcore
\ingroup cmake-target-properties-qtcore
@@ -355,7 +355,7 @@ On targets that must provide their own entry point, set the property \c qt_no_en
*/
/*!
-\page cmake-target-property-qt_resource_prefix.html
+\page cmake-target-property-qt-resource-prefix.html
\ingroup cmake-properties-qtcore
\ingroup cmake-target-properties-qtcore
@@ -383,7 +383,7 @@ source file properties:
*/
/*!
-\page cmake-source-file-property-QT_RESOURCE_ALIAS.html
+\page cmake-source-file-property-qt-resource-alias.html
\ingroup cmake-source-file-properties-qtcore
\title QT_RESOURCE_ALIAS
@@ -401,7 +401,7 @@ the property value overrides the runtime path where the resource file is found.
*/
/*!
-\page cmake-target-property-QT_WASM_PTHREAD_POOL_SIZE.html
+\page cmake-target-property-qt-wasm-pthread-pool-size.html
\ingroup cmake-properties-qtcore
\ingroup cmake-target-properties-qtcore
@@ -425,7 +425,43 @@ For more information, see \l{https://emscripten.org/docs/porting/pthreads.html}{
*/
/*!
-\page cmake-target-property-QT_WASM_INITIAL_MEMORY.html
+\group cmake-global-properties-qtcore
+\title CMake Global Properties in Qt6 Core
+
+\l{CMake Commands in Qt6 Core}{CMake Commands} know about the following global
+CMake properties:
+
+\sa{CMake Property Reference}
+*/
+
+/*!
+\page cmake-global-property-qt-targets-folder.html
+\ingroup cmake-properties-qtcore
+\ingroup cmake-global-properties-qtcore
+
+\title QT_TARGETS_FOLDER
+\target cmake-global-property-QT_TARGETS_FOLDER
+
+\brief Sets the FOLDER property for Qt-internal targets.
+
+\cmakepropertysince 6.5
+\preliminarycmakeproperty
+
+Name of the \l FOLDER for internal targets that are added by Qt's CMake
+commands.
+
+By default, this property is not set.
+
+This property only has an effect if CMake's \l USE_FOLDERS property is \c{ON}.
+
+You can use the \l{qt6_standard_project_setup}{qt_standard_project_setup}
+function to enable folder support and initialize the \c{QT_TARGETS_FOLDER}.
+
+\sa{qt6_standard_project_setup}{qt_standard_project_setup}
+*/
+
+/*!
+\page cmake-target-property-qt-wasm-initial-memory.html
\ingroup cmake-properties-qtcore
\ingroup cmake-target-properties-qtcore
@@ -445,3 +481,22 @@ QT_WASM_INITIAL_MEMORY must be a multiple of 65536 bytes.
For more information, see \l{https://github.com/emscripten-core/emscripten/blob/main/src/settings.js}{Emscripten compiler settings}.
*/
+
+/*!
+\page cmake-target-property-qt-ios-launch-screen.html
+\ingroup cmake-properties-qtcore
+\ingroup cmake-target-properties-qtcore
+
+\title QT_IOS_LAUNCH_SCREEN
+\target cmake-target-property-QT_IOS_LAUNCH_SCREEN
+
+\summary {Path to iOS launch screen storyboard}
+
+\cmakepropertysince 6.4
+\preliminarycmakeproperty
+\cmakepropertyiosonly
+
+Specifies the path to an iOS launch screen storyboard file.
+
+\sa {Launch Screens and Launch Images}
+*/
diff --git a/src/corelib/doc/src/cmake/qt_add_big_resources.qdoc b/src/corelib/doc/src/cmake/qt_add_big_resources.qdoc
index 5ae7b9728b..72a00e6eef 100644
--- a/src/corelib/doc/src/cmake/qt_add_big_resources.qdoc
+++ b/src/corelib/doc/src/cmake/qt_add_big_resources.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_add_bigresources.html
+\page qt-add-bigresources.html
\ingroup cmake-commands-qtcore
\title qt_add_big_resources
diff --git a/src/corelib/doc/src/cmake/qt_add_binary_resources.qdoc b/src/corelib/doc/src/cmake/qt_add_binary_resources.qdoc
index a247b6d7c0..71ee8b894e 100644
--- a/src/corelib/doc/src/cmake/qt_add_binary_resources.qdoc
+++ b/src/corelib/doc/src/cmake/qt_add_binary_resources.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_add_binary_resources.html
+\page qt-add-binary-resources.html
\ingroup cmake-commands-qtcore
\title qt_add_binary_resources
diff --git a/src/corelib/doc/src/cmake/qt_add_executable.qdoc b/src/corelib/doc/src/cmake/qt_add_executable.qdoc
index a09ecc8dfd..6bdc6000e8 100644
--- a/src/corelib/doc/src/cmake/qt_add_executable.qdoc
+++ b/src/corelib/doc/src/cmake/qt_add_executable.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_add_executable.html
+\page qt-add-executable.html
\ingroup cmake-commands-qtcore
\title qt_add_executable
@@ -60,25 +60,34 @@ for you as a convenience.
After a target is created, further processing or \e{finalization} steps are
commonly needed. The steps to perform depend on the platform and on various
-properties of the target. The finalization processing is implemented by the
-\l{qt6_finalize_target}{qt_finalize_target()} command. You might need to also
-call the \l{qt6_finalize_project}{qt_finalize_project()} command at the end
-of top-level CMakeLists.txt to correctly resolve the dependencies between
-project targets.
-
-Finalization can occur either as part of this call or be deferred to sometime
-after this command returns (but it should still be in the same directory scope).
-When using CMake 3.19 or later, finalization is automatically deferred to the
+properties of the target.
+
+The finalization processing is implemented by two commands:
+\l{qt6_finalize_target}{qt_finalize_target()} and
+\l{qt6_finalize_project}{qt_finalize_project()}.
+
+Target finalization can occur either as part of calling \c{qt_add_executable}
+or be deferred to sometime after this command returns (but it should still be in
+the same directory scope).
+
+When using CMake 3.19 or later, target finalization is automatically deferred to the
end of the current directory scope. This gives the caller an opportunity to
modify properties of the created target before it is finalized. When using
CMake versions earlier than 3.19, automatic deferral isn't supported. In that
-case, finalization is performed immediately before this command returns.
+case, target finalization is performed immediately before this command returns.
Regardless of the CMake version, the \c{MANUAL_FINALIZATION} keyword can be given to
indicate that you will explicitly call \l{qt6_finalize_target}{qt_finalize_target()}
yourself instead at some later time. In general, \c MANUAL_FINALIZATION should
not be needed unless the project has to support CMake 3.18 or earlier.
+Project finalization occurs automatically when using CMake 3.19 or later.
+When using an older CMake version, you should call
+\l{qt6_finalize_project}{qt_finalize_project()} manually, at the end
+of the root \c CMakeLists.txt file.
+This is especially important when targeting Android, to collect dependencies
+between project targets for deployment purposes.
+
\sa {qt6_finalize_target}{qt_finalize_target()},
{qt6_set_finalizer_mode}{qt_set_finalizer_mode()},
{qt6_add_library}{qt_add_library()},
@@ -101,5 +110,5 @@ for finalizing the target by adding the \c{MANUAL_FINALIZATION} keyword.
\snippet cmake-macros/examples.cmake qt_add_executable_deferred
-\include cmake-android-qt-finalize-project-warning.cmake
+\include cmake-android-qt-finalize-project-warning.qdocinc
*/
diff --git a/src/corelib/doc/src/cmake/qt_add_library.qdoc b/src/corelib/doc/src/cmake/qt_add_library.qdoc
index 52b85d0476..6a5d17f0f9 100644
--- a/src/corelib/doc/src/cmake/qt_add_library.qdoc
+++ b/src/corelib/doc/src/cmake/qt_add_library.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_add_library.html
+\page qt-add-library.html
\ingroup cmake-commands-qtcore
\title qt_add_library
@@ -51,6 +51,7 @@ library created. The \c{qt_add_library()} command does not consider
Any \c{sources} provided will be passed through to the internal call to
\c{add_library()}.
+\target qt_add_library finalization
\section2 Finalization
After a target is created, further processing or \e{finalization} steps may be
diff --git a/src/corelib/doc/src/cmake/qt_add_plugin.qdoc b/src/corelib/doc/src/cmake/qt_add_plugin.qdoc
index e4bacc36a9..4341e22efb 100644
--- a/src/corelib/doc/src/cmake/qt_add_plugin.qdoc
+++ b/src/corelib/doc/src/cmake/qt_add_plugin.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_add_plugin.html
+\page qt-add-plugin.html
\ingroup cmake-commands-qtcore
\title qt_add_plugin
@@ -21,6 +21,7 @@ qt_add_plugin(target
[SHARED | STATIC]
[CLASS_NAME class_name]
[OUTPUT_TARGETS variable_name]
+ [MANUAL_FINALIZATION]
sources...
)
\endcode
@@ -67,4 +68,17 @@ project should also install these internal targets. The names of these targets
can be obtained by providing the \c OUTPUT_TARGETS option, followed by the name
of a variable in which to return the target list.
+\section2 Finalization
+
+After a target is created, further processing or \e{finalization} steps may be
+needed. The finalization processing is implemented by the
+\l{qt6_finalize_target}{qt_finalize_target()} command.
+
+For details and the meaning of the \c{MANUAL_FINALIZATION} option, refer to the
+\l{qt_add_library finalization}{finalization documentation} for
+\c{qt_add_library}.
+
+\sa {qt6_finalize_target}{qt_finalize_target()},
+ {qt6_add_executable}{qt_add_executable()}
+
*/
diff --git a/src/corelib/doc/src/cmake/qt_add_resources.qdoc b/src/corelib/doc/src/cmake/qt_add_resources.qdoc
index 8a61ec769e..982cf207af 100644
--- a/src/corelib/doc/src/cmake/qt_add_resources.qdoc
+++ b/src/corelib/doc/src/cmake/qt_add_resources.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_add_resources.html
+\page qt-add-resources.html
\ingroup cmake-commands-qtcore
\title qt_add_resources
@@ -57,7 +57,9 @@ See \l{The Qt Resource System} for a general description of Qt resources.
\c PREFIX specifies a path prefix under which all files of this resource are
accessible from C++ code. This corresponds to the XML attribute \c prefix of the
\c .qrc file format. If \c PREFIX is not given, the target property
-\l{cmake-target-property-QT_RESOURCE_PREFIX}{QT_RESOURCE_PREFIX} is used.
+\l{cmake-target-property-QT_RESOURCE_PREFIX}{QT_RESOURCE_PREFIX} is used. Since
+6.5, \c{PREFIX} is optional. If it is omitted and not specified by
+\c{QT_RESOURCE_PREFIX}, \c{"/"} will be used as the default path prefix.
\c LANG specifies the locale of this resource. This corresponds to the XML
attribute \c lang of the \c .qrc file format.
diff --git a/src/corelib/doc/src/cmake/qt_allow_non_utf8_sources.qdoc b/src/corelib/doc/src/cmake/qt_allow_non_utf8_sources.qdoc
index 8219380bd5..617baa0109 100644
--- a/src/corelib/doc/src/cmake/qt_allow_non_utf8_sources.qdoc
+++ b/src/corelib/doc/src/cmake/qt_allow_non_utf8_sources.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_allow_non_utf8_sources.html
+\page qt-allow-non-utf8-sources.html
\ingroup cmake-commands-qtcore
\title qt_allow_non_utf8_sources
diff --git a/src/corelib/doc/src/cmake/qt_android_add_apk_target.qdoc b/src/corelib/doc/src/cmake/qt_android_add_apk_target.qdoc
index 7818596c76..747849eabb 100644
--- a/src/corelib/doc/src/cmake/qt_android_add_apk_target.qdoc
+++ b/src/corelib/doc/src/cmake/qt_android_add_apk_target.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_android_add_apk_target.html
+\page qt-android-add-apk-target.html
\ingroup cmake-commands-qtcore
\title qt_android_add_apk_target
diff --git a/src/corelib/doc/src/cmake/qt_android_apply_arch_suffix.qdoc b/src/corelib/doc/src/cmake/qt_android_apply_arch_suffix.qdoc
index 5451a6727c..4d4585693d 100644
--- a/src/corelib/doc/src/cmake/qt_android_apply_arch_suffix.qdoc
+++ b/src/corelib/doc/src/cmake/qt_android_apply_arch_suffix.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_android_apply_arch_suffix.html
+\page qt-android-apply-arch-suffix.html
\ingroup cmake-commands-qtcore
\title qt_android_apply_arch_suffix
diff --git a/src/corelib/doc/src/cmake/qt_android_generate_deployment_settings.qdoc b/src/corelib/doc/src/cmake/qt_android_generate_deployment_settings.qdoc
index 4df3a32101..a717c80e7c 100644
--- a/src/corelib/doc/src/cmake/qt_android_generate_deployment_settings.qdoc
+++ b/src/corelib/doc/src/cmake/qt_android_generate_deployment_settings.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_android_generate_deployment_settings.html
+\page qt-android-generate-deployment-settings.html
\ingroup cmake-commands-qtcore
\title qt_android_generate_deployment_settings
diff --git a/src/corelib/doc/src/cmake/qt_deploy_qt_conf.qdoc b/src/corelib/doc/src/cmake/qt_deploy_qt_conf.qdoc
index 4f2b638835..fb3ee4796e 100644
--- a/src/corelib/doc/src/cmake/qt_deploy_qt_conf.qdoc
+++ b/src/corelib/doc/src/cmake/qt_deploy_qt_conf.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_deploy_qt_conf.html
+\page qt-deploy-qt-conf.html
\ingroup cmake-commands-qtcore
\title qt_deploy_qt_conf
@@ -64,10 +64,9 @@ as shown in the example below. This helps avoid hard-coding an absolute path.
\badcode
# The following script must only be executed at install time
-set(deploy_script "${CMAKE_CURRENT_BINARY_DIR}/deploy_custom.cmake")
-
-file(GENERATE OUTPUT ${deploy_script} CONTENT "
-include(\"${QT_DEPLOY_SUPPORT}\")
+qt_generate_deploy_script(
+ FILENAME_VARIABLE deploy_script
+ CONTENT "
qt_deploy_qt_conf(\"\${QT_DEPLOY_PREFIX}/\${QT_DEPLOY_BIN_DIR}/qt.conf\"
DATA_DIR \"./custom_data_dir\"
TRANSLATIONS_DIR \"./custom_translations_dir\"
diff --git a/src/corelib/doc/src/cmake/qt_deploy_runtime_dependencies.qdoc b/src/corelib/doc/src/cmake/qt_deploy_runtime_dependencies.qdoc
index 6f950b4020..7f6198d804 100644
--- a/src/corelib/doc/src/cmake/qt_deploy_runtime_dependencies.qdoc
+++ b/src/corelib/doc/src/cmake/qt_deploy_runtime_dependencies.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_deploy_runtime_dependencies.html
+\page qt-deploy-runtime-dependencies.html
\ingroup cmake-commands-qtcore
\title qt_deploy_runtime_dependencies
@@ -38,6 +38,13 @@ qt_deploy_runtime_dependencies(
[VERBOSE]
[NO_OVERWRITE]
[NO_APP_STORE_COMPLIANCE]
+ [NO_TRANSLATIONS]
+ [PRE_INCLUDE_REGEXES regexes...]
+ [PRE_EXCLUDE_REGEXES regexes...]
+ [POST_INCLUDE_REGEXES regexes...]
+ [POST_EXCLUDE_REGEXES regexes...]
+ [POST_INCLUDE_FILES files...]
+ [POST_EXCLUDE_FILES files...]
)
\endcode
@@ -58,11 +65,10 @@ see \l{qt_deploy_qml_imports()} for that.
The \c{EXECUTABLE} option must be provided.
-The \c{executable} argument should be a path to the executable file, relative to
-the base install location. For example, \c{bin/MyApp.exe}, or more dynamically
-\c{\${QT_DEPLOY_BIN_DIR}/$<TARGET_FILE_NAME:MyApp>}.
-Specifying raw target names not wrapped in a generator epxression like
-\c{<TARGET_FILE_NAME:>} is not supported.
+The \c{executable} argument should be the path to the executable file in the
+build directory. For example, \c{${CMAKE_CURRENT_BINARY_DIR}/MyApp.exe}, or more
+dynamically \c{$<TARGET_FILE:MyApp>}. Specifying raw target names not wrapped in
+a generator expression like \c{<TARGET_FILE:>} is not supported.
For macOS app bundles, the \c{executable} argument should be a path to the
bundle directory, relative to the base install location.
@@ -114,6 +120,25 @@ By default, if \c{executable} is a macOS app bundle, only Qt plugins and Qt
libraries that comply with Apple's app store requirements are deployed. The
\c{NO_APP_STORE_COMPLIANCE} option can be given to disable that constraint.
+On platforms other than macOS, Qt translations are automatically deployed. To
+inhibit this behavior, specify \c{NO_TRANSLATIONS}. Use
+\l{qt6_deploy_translations}{qt_deploy_translations} to deploy translations in a
+customized way.
+
+On Linux, deploying runtime dependencies is based on CMake's
+\c{file(GET_RUNTIME_DEPENDENCIES)} command. The options \c{PRE_INCLUDE_REGEXES},
+\c{PRE_EXCLUDE_REGEXES}, \c{POST_INCLUDE_REGEXES}, \c{POST_EXCLUDE_REGEXES},
+\c{POST_INCLUDE_FILES}, and \c{POST_EXCLUDE_FILES} are only meaningful in this
+context and are forwarded unaltered to \c{file(GET_RUNTIME_DEPENDENCIES)}. See
+the documentation of that command for details.
+
+On Linux, runtime dependencies that are located in system library directories
+are not deployed by default. If \c{POST_EXCLUDE_REGEXES} is specified, this
+automatic exclusion is not performed.
+
+The default value of \c{POST_EXCLUDE_REGEXES} is constructed from the value of
+\l{QT_DEPLOY_IGNORED_LIB_DIRS}.
+
\sa {qt6_generate_deploy_app_script}{qt_generate_deploy_app_script()},
qt_deploy_qt_conf(), qt_deploy_qml_imports()
diff --git a/src/corelib/doc/src/cmake/qt_deploy_translations.qdoc b/src/corelib/doc/src/cmake/qt_deploy_translations.qdoc
new file mode 100644
index 0000000000..7d175fd651
--- /dev/null
+++ b/src/corelib/doc/src/cmake/qt_deploy_translations.qdoc
@@ -0,0 +1,76 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+\page qt-deploy-translations.html
+\ingroup cmake-commands-qtcore
+
+\title qt_deploy_translations
+\target qt_deploy_translations
+
+\summary {Deploy Qt translations needed by an executable.}
+
+\include cmake-find-package-core.qdocinc
+
+Unlike most other CMake commands provided by Qt, \c{qt_deploy_translations()}
+can only be called from a deployment script. It cannot be called directly by the
+project during the configure stage.
+
+\cmakecommandsince 6.5
+\preliminarycmakecommand
+\note This command does not usually need to be called directly. It is used
+ internally by other higher level commands, but projects wishing to
+ implement more customized deployment logic may find it useful.
+
+\section1 Synopsis
+
+\badcode
+qt_deploy_translations(
+ [CATALOGS catalogs]
+ [LOCALES locales]
+ [LCONVERT lconvert_executable]
+ [VERBOSE]
+)
+\endcode
+
+\section1 Description
+
+When installing an application, it may be desirable to also install the
+translations that belong to the used Qt modules. The \c qt_deploy_translations
+command collects the necessary \c{.qm} file from the Qt installation and
+compiles them into one \c{qt_${language}.qm} file per language. The \c{.qm}
+files are installed into \c{QT_DEPLOY_TRANSLATIONS_DIR}.
+
+\section1 Arguments
+
+The \c LOCALES argument specifies for which locales translations should be
+deployed. This is a list of language/region combinations as described in
+\l{Changing the Target Locale}{Qt Linguist's manual for translators}. Examples
+for valid locales are: \c{de}, \c{pl}, or \c{pt_BR}.
+
+If \c LOCALES is omitted, then all available locales are deployed.
+
+The \c CATALOGS argument specifies a list of \l{Available
+Catalogs}{translation catalogs} to be deployed. If this argument is
+omitted, then all catalogs are deployed that belong to any Qt module
+that is used in the project via \c{find_package}.
+
+The \c LCONVERT argument specifies the \c lconvert executable that is used to
+combine the catalogs. By default, the Qt installation's \c lconvert is used.
+
+For debugging purposed, the \c VERBOSE argument can be set to turn on diagnostic
+messages.
+
+\sa QT_DEPLOY_TRANSLATIONS_DIR
+
+\section1 Example
+
+The following example deploys Danish and German translations of the Qt
+libraries.
+
+\badcode
+qt_deploy_translations(
+ LOCALES da de
+)
+\endcode
+*/
diff --git a/src/corelib/doc/src/cmake/qt_disable_unicode_defines.qdoc b/src/corelib/doc/src/cmake/qt_disable_unicode_defines.qdoc
index b056afea85..f4ad3c6426 100644
--- a/src/corelib/doc/src/cmake/qt_disable_unicode_defines.qdoc
+++ b/src/corelib/doc/src/cmake/qt_disable_unicode_defines.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_disable_unicode_defines.html
+\page qt-disable-unicode-defines.html
\ingroup cmake-commands-qtcore
\title qt_disable_unicode_defines
diff --git a/src/corelib/doc/src/cmake/qt_extract_metatypes.qdoc b/src/corelib/doc/src/cmake/qt_extract_metatypes.qdoc
index a430989036..837baa3f0c 100644
--- a/src/corelib/doc/src/cmake/qt_extract_metatypes.qdoc
+++ b/src/corelib/doc/src/cmake/qt_extract_metatypes.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_extract_metatypes.html
+\page qt-extract-metatypes.html
\ingroup cmake-commands-qtcore
\title qt_extract_metatypes
diff --git a/src/corelib/doc/src/cmake/qt_finalize_project.qdoc b/src/corelib/doc/src/cmake/qt_finalize_project.qdoc
index dc63e66cd6..56ab40055c 100644
--- a/src/corelib/doc/src/cmake/qt_finalize_project.qdoc
+++ b/src/corelib/doc/src/cmake/qt_finalize_project.qdoc
@@ -2,13 +2,13 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_finalize_project.html
+\page qt-finalize-project.html
\ingroup cmake-commands-qtcore
\title qt_finalize_project
\target qt6_finalize_project
-\summary {Handles various common platform-specific tasks associated with Qt project.}
+\summary {Handles various common platform-specific tasks associated with a Qt project.}
\preliminarycmakecommand
\include cmake-find-package-core.qdocinc
@@ -26,15 +26,19 @@ qt_finalize_project()
\section1 Description
Some targets that are created using Qt commands require additional actions
-at the end of CMake configuring phase. Depending on the platform the function
-typically walks through the build tree, resolves dependencies between targets
-created by the user, and applies extra deployment steps.
-
-With CMake versions 3.19 and higher, you don't need to call this command since
+at the end of CMake configuring phase.
+Depending on the platform, the function typically:
+\list
+ \li Walks the build tree.
+ \li Resolves dependencies.
+ \li Applies any extra deployment steps.
+\endlist
+
+With CMake version 3.19 or later, you don't need to call this command since
it consists of sub-commands that are ordinarily invoked at the end of
-\c CMAKE_SOURCE_DIR scope.
+\c CMAKE_SOURCE_DIR directory scope processing.
-\include cmake-android-qt-finalize-project-warning.cmake
+\include cmake-android-qt-finalize-project-warning.qdocinc
\section2 Examples
@@ -44,4 +48,6 @@ function:
\snippet cmake-macros/examples.cmake qt_finalize_project_manual
+\sa {cmake-variable-QT_NO_COLLECT_BUILD_TREE_APK_DEPS}{QT_NO_COLLECT_BUILD_TREE_APK_DEPS}
+\sa {cmake-variable-QT_NO_COLLECT_IMPORTED_TARGET_APK_DEPS}{QT_NO_COLLECT_IMPORTED_TARGET_APK_DEPS}
*/
diff --git a/src/corelib/doc/src/cmake/qt_finalize_target.qdoc b/src/corelib/doc/src/cmake/qt_finalize_target.qdoc
index 558e89991f..4b71248a1e 100644
--- a/src/corelib/doc/src/cmake/qt_finalize_target.qdoc
+++ b/src/corelib/doc/src/cmake/qt_finalize_target.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_finalize_target.html
+\page qt-finalize-target.html
\ingroup cmake-commands-qtcore
\title qt_finalize_target
@@ -61,7 +61,7 @@ CMake version earlier than 3.21.
\section2 WASM
Create \c{${target}.html} (a target-specific \c{wasm_shell.html} file),
-\c{qtloader.js} and \c{qtlogo.svg} files in the \c{CMAKE_CURRENT_BINARY_DIR}.
+\c{qtloader.js}, and \c{qtlogo.svg} files in the \c{CMAKE_CURRENT_BINARY_DIR}.
\section2 iOS
diff --git a/src/corelib/doc/src/cmake/qt_generate_deploy_app_script.qdoc b/src/corelib/doc/src/cmake/qt_generate_deploy_app_script.qdoc
index b3a3328098..6f6f96b8ae 100644
--- a/src/corelib/doc/src/cmake/qt_generate_deploy_app_script.qdoc
+++ b/src/corelib/doc/src/cmake/qt_generate_deploy_app_script.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_generate_deploy_app_script.html
+\page qt-generate-deploy-app-script.html
\ingroup cmake-commands-qtcore
\title qt_generate_deploy_app_script
@@ -22,7 +22,14 @@
qt_generate_deploy_app_script(
TARGET target
FILENAME_VARIABLE var_name
+ [NO_TRANSLATIONS]
[NO_UNSUPPORTED_PLATFORM_ERROR]
+ [PRE_INCLUDE_REGEXES regexes...]
+ [PRE_EXCLUDE_REGEXES regexes...]
+ [POST_INCLUDE_REGEXES regexes...]
+ [POST_EXCLUDE_REGEXES regexes...]
+ [POST_INCLUDE_FILES files...]
+ [POST_EXCLUDE_FILES files...]
)
\endcode
@@ -48,18 +55,37 @@ which should come after the application's target has been installed using
The deployment script will call \l{qt_deploy_runtime_dependencies()} with a
suitable set of options for the standard install layout.
-Currently, this is only implemented for macOS app bundles built on a macOS
-host and Windows executables built on a Windows host.
+Currently, this is only implemented for
+\list
+ \li macOS app bundles built on a macOS host,
+ \li Linux executables built on a Linux host,
+ \li and Windows executables built on a Windows host.
+\endlist
Cross-building a Windows executable on a Linux host, as well as similar
scenarios, are not currently supported.
Calling \c{qt_generate_deploy_app_script()} in such a case will result
in a fatal error, unless the \c{NO_UNSUPPORTED_PLATFORM_ERROR} option is given.
+On platforms other than macOS, Qt translations are automatically deployed. To
+inhibit this behavior, specify \c{NO_TRANSLATIONS}. Use
+\l{qt6_deploy_translations}{qt_deploy_translations} to deploy translations in a
+customized way.
+
For deploying a QML application, use
\l{qt6_generate_deploy_qml_app_script}{qt_generate_deploy_qml_app_script()}
instead.
+For generating a custom deployment script, use
+\l{qt6_generate_deploy_script}{qt_generate_deploy_script}.
+
+The options \c{PRE_INCLUDE_REGEXES}, \c{PRE_EXCLUDE_REGEXES},
+\c{POST_INCLUDE_REGEXES}, \c{POST_EXCLUDE_REGEXES}, \c{POST_INCLUDE_FILES}, and
+\c{POST_EXCLUDE_FILES} can be specified to control the deployment of runtime
+dependencies. These options do not apply to all platforms and are forwarded
+unmodified to \l{qt_deploy_runtime_dependencies()}.
+
\sa {qt6_standard_project_setup}{qt_standard_project_setup()},
+ {qt6_generate_deploy_script}{qt_generate_deploy_script()},
{qt6_generate_deploy_qml_app_script}{qt_generate_deploy_qml_app_script()}
\section1 Example
diff --git a/src/corelib/doc/src/cmake/qt_generate_deploy_script.qdoc b/src/corelib/doc/src/cmake/qt_generate_deploy_script.qdoc
new file mode 100644
index 0000000000..af0a6956d1
--- /dev/null
+++ b/src/corelib/doc/src/cmake/qt_generate_deploy_script.qdoc
@@ -0,0 +1,66 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+\page qt-generate-deploy-script.html
+\ingroup cmake-commands-qtcore
+
+\title qt_generate_deploy_script
+\target qt6_generate_deploy_script
+
+\summary {Generate a custom deployment script.}
+
+\include cmake-find-package-core.qdocinc
+
+\cmakecommandsince 6.5
+\preliminarycmakecommand
+
+\section1 Synopsis
+
+\badcode
+qt_generate_deploy_script(
+ FILENAME_VARIABLE var_name
+ [TARGET target]
+ [NAME script_name]
+ [CONTENT content]
+)
+\endcode
+
+\versionlessCMakeCommandsNote qt6_generate_deploy_script()
+
+\section1 Description
+
+The command generates a script whose full file path will be stored in the
+variable named by the \c{FILENAME_VARIABLE} option. That script is only written
+at CMake generation time. It is intended to be used with the \l{install(SCRIPT)}
+command, which should come after the application's target has been installed
+using \l{install(TARGETS)}.
+
+The command takes care of generating a file named suitably for multi-config
+generators. Necessary includes are added such that Qt's CMake deployment
+functions and variables are accessible.
+
+The \c TARGET argument specifies the target that will be deployed by the script.
+This affects the file name of the generated script, unless \c NAME is specified.
+
+The \c NAME argument controls an identifiable portion within the deployment
+script's automatically generated name. The \c NAME argument defaults to \c
+custom if neither \c NAME nor \c TARGET are given.
+
+The \c CONTENT argument specifies the code that is written to the deployment
+script. The content may contain generator expressions.
+
+This command is intended for generating custom deployment scripts that
+directly call functions of Qt's deployment API. For less complex
+deployment purposes, it is more convenient to use
+\l{qt6_generate_deploy_app_script}{qt_generate_deploy_app_script()} or
+\l{qt6_generate_deploy_qml_app_script}{qt_generate_deploy_qml_app_script()}.
+
+\sa {qt6_generate_deploy_app_script}{qt_generate_deploy_app_script()},
+ {qt6_generate_deploy_qml_app_script}{qt_generate_deploy_qml_app_script()}
+
+\section1 Example
+
+\snippet cmake-macros/deployment.cmake qt_generate_deploy_script_example
+
+*/
diff --git a/src/corelib/doc/src/cmake/qt_generate_moc.qdoc b/src/corelib/doc/src/cmake/qt_generate_moc.qdoc
index 4f60ae1ae2..55b6df9e7d 100644
--- a/src/corelib/doc/src/cmake/qt_generate_moc.qdoc
+++ b/src/corelib/doc/src/cmake/qt_generate_moc.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_generate_moc.html
+\page qt-generate-moc.html
\ingroup cmake-commands-qtcore
\title qt_generate_moc
diff --git a/src/corelib/doc/src/cmake/qt_import_plugins.qdoc b/src/corelib/doc/src/cmake/qt_import_plugins.qdoc
index cea6fc61f5..b9606654b0 100644
--- a/src/corelib/doc/src/cmake/qt_import_plugins.qdoc
+++ b/src/corelib/doc/src/cmake/qt_import_plugins.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_import_plugins.html
+\page qt-import-plugins.html
\ingroup cmake-commands-qtcore
\title qt_import_plugins
diff --git a/src/corelib/doc/src/cmake/qt_set_finalizer_mode.qdoc b/src/corelib/doc/src/cmake/qt_set_finalizer_mode.qdoc
index 476c63ccc0..f44a217544 100644
--- a/src/corelib/doc/src/cmake/qt_set_finalizer_mode.qdoc
+++ b/src/corelib/doc/src/cmake/qt_set_finalizer_mode.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_set_finalizer_mode.html
+\page qt-set-finalizer-mode.html
\ingroup cmake-commands-qtcore
\title qt_set_finalizer_mode
diff --git a/src/corelib/doc/src/cmake/qt_standard_project_setup.qdoc b/src/corelib/doc/src/cmake/qt_standard_project_setup.qdoc
index b94d688e49..6e91779fb9 100644
--- a/src/corelib/doc/src/cmake/qt_standard_project_setup.qdoc
+++ b/src/corelib/doc/src/cmake/qt_standard_project_setup.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_standard_project_setup.html
+\page qt-standard-project-setup.html
\ingroup cmake-commands-qtcore
\title qt_standard_project_setup
@@ -42,6 +42,9 @@ have been defined. It does the following things:
\c{${CMAKE_CURRENT_BINARY_DIR}}.
\li When target platforms other than Apple or Windows, \c{CMAKE_INSTALL_RPATH}
will be augmented as described below.
+\li CMake's \l USE_FOLDERS property is set to \c{ON}, and \l QT_TARGET_FOLDER is
+ set to \c{QtInternalTargets}. IDEs that support folders will display
+ Qt-internal targets in this folder.
\endlist
On platforms that support \c{RPATH} (other than Apple platforms), two values
@@ -57,6 +60,9 @@ will find their link-time dependencies, assuming projects install them to the
default locations the \l{install(TARGETS)} command uses when no destination is
explicitly provided.
+To disable folder support for IDEs, set \l USE_FOLDERS to \c OFF before or after
+the call to \c{qt_standard_project_setup}.
+
The \c{qt_standard_project_setup()} command can effectively be disabled by
setting the \l{QT_NO_STANDARD_PROJECT_SETUP} variable to true.
diff --git a/src/corelib/doc/src/cmake/qt_wrap_cpp.qdoc b/src/corelib/doc/src/cmake/qt_wrap_cpp.qdoc
index 8390b81cd3..c2a916c71c 100644
--- a/src/corelib/doc/src/cmake/qt_wrap_cpp.qdoc
+++ b/src/corelib/doc/src/cmake/qt_wrap_cpp.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_wrap_cpp.html
+\page qt-wrap-cpp.html
\ingroup cmake-commands-qtcore
\title qt_wrap_cpp
diff --git a/src/corelib/doc/src/containers.qdoc b/src/corelib/doc/src/containers.qdoc
index bed184de15..4a7d5dc1bb 100644
--- a/src/corelib/doc/src/containers.qdoc
+++ b/src/corelib/doc/src/containers.qdoc
@@ -39,7 +39,8 @@
\note Since Qt 5.14, range constructors are available for most of the
container classes. QMultiMap is a notable exception. Their use is
- encouraged in place of the various from/to methods. For example:
+ encouraged to replace of the various deprecated from/to methods of Qt 5.
+ For example:
\snippet code/doc_src_containers.cpp 25
@@ -191,7 +192,30 @@
the C++ language doesn't specify any initialization; in those
cases, Qt's containers automatically initialize the value to 0.
- \section1 The Iterator Classes
+ \section1 Iterating over Containers
+
+ \section2 Range-based for
+
+ Range-based \c for should preferably be used for containers:
+
+ \snippet code/doc_src_containers.cpp range_for
+
+ Note that when using a Qt container in a non-const context,
+ \l{implicit sharing} may perform an undesired detach of the container.
+ To prevent this, use \c std::as_const():
+
+ \snippet code/doc_src_containers.cpp range_for_as_const
+
+ For associative containers, this will loop over the values.
+
+ \section2 Index-based
+
+ For sequential containers that store their items contiguously in memory
+ (for example, QList), index-based iteration can be used:
+
+ \snippet code/doc_src_containers.cpp index
+
+ \section2 The Iterator Classes
Iterators provide a uniform means to access items in a container.
Qt's container classes provide two types of iterators: STL-style
@@ -200,7 +224,7 @@
from \l{Implicit Sharing}{implicitly shared copies} due to a call
to a non-const member function.
- \section2 STL-Style Iterators
+ \section3 STL-Style Iterators
STL-style iterators have been available since the release of Qt
2.0. They are compatible with Qt's and STL's \l{generic
@@ -262,12 +286,10 @@
In the code snippets so far, we used the unary \c * operator to
retrieve the item (of type QString) stored at a certain iterator
- position, and we then called QString::toLower() on it. Most C++
- compilers also allow us to write \c{i->toLower()}, but some
- don't.
+ position, and we then called QString::toLower() on it.
- For read-only access, you can use const_iterator, \l{QList::constBegin}{constBegin()},
- and \l{QList::constEnd()}{constEnd()}. For example:
+ For read-only access, you can use const_iterator, \l{QList::cbegin}{cbegin()},
+ and \l{QList::cend()}{cend()}. For example:
\snippet code/doc_src_containers.cpp 12
@@ -315,7 +337,7 @@
This problem doesn't occur with functions that return a const or
non-const reference to a container.
- \section3 Implicit sharing iterator problem
+ \section4 Implicit sharing iterator problem
\l{Implicit sharing} has another consequence on STL-style
iterators: you should avoid copying a container while
@@ -328,33 +350,11 @@
The above example only shows a problem with QList, but
the problem exists for all the implicitly shared Qt containers.
- \section2 Java-Style Iterators
+ \section3 Java-Style Iterators
\l{java-style-iterators}{Java-Style iterators} were introduced in Qt 4. Their API is modelled
on Java's iterator classes.
New code should should prefer \l{STL-Style Iterators}.
- \section1 Container keywords
-
- \target foreach
- \section2 The foreach Keyword
- \l{foreach-keyword}{The foreach keyword} is discouraged, new code should
- prefer C++11 range-based loops.
-
- \target forever
- \section2 The forever keyword.
- In addition to \c foreach, Qt also provides a \c forever
- pseudo-keyword for infinite loops:
-
- \snippet code/doc_src_containers.cpp 21
-
- If you're worried about namespace pollution, you can disable
- these macros by adding the following line to your \c .pro file:
-
- \snippet code/doc_src_containers.cpp 22
-
- \note The alternative macros Q_FOREACH and Q_FOREVER remain defined
- regardless.
-
\section1 Qt containers compared with std containers
\table
@@ -383,7 +383,7 @@
\li Similar to std::queue<T>, inherits from \l{QList}.
\row \li \l{QSet}<T>
- \li Similar to std::set<T>. Internally, \l{QSet} is implemented with a
+ \li Similar to std::unordered_set<T>. Internally, \l{QSet} is implemented with a
\l{QHash}.
\row \li \l{QMap}<Key, T>
@@ -393,16 +393,16 @@
\li Similar to std::multimap<T>.
\row \li \l{QHash}<Key, T>
- \li Most similar to std::map<T>.
+ \li Most similar to std::unordered_map<T>.
\row \li \l{QMultiHash}<Key, T>
- \li Most similar to std::multimap<T>.
+ \li Most similar to std::unordered_multimap<T>.
\endtable
\section1 Qt containers and std algorithms
- You can used Qt containers with functions from \c{#include <algorithm>}.
+ You can use Qt containers with functions from \c{#include <algorithm>}.
\snippet code/doc_src_containers.cpp 26
@@ -410,7 +410,7 @@
Qt includes other template classes that resemble containers in
some respects. These classes don't provide iterators and cannot
- be used with the \c foreach keyword.
+ be used with the \l foreach keyword.
\list
\li QCache<Key, T> provides a cache to store objects of a certain
diff --git a/src/corelib/doc/src/datastreamformat.qdoc b/src/corelib/doc/src/datastreamformat.qdoc
index c3e57a9adf..b1b2e6ba34 100644
--- a/src/corelib/doc/src/datastreamformat.qdoc
+++ b/src/corelib/doc/src/datastreamformat.qdoc
@@ -7,7 +7,7 @@
\brief List of data types that can be serialized by QDataStream.
The \l QDataStream class allows you to serialize the Qt data types
- listed in this section as of \l{QDataStream::setVersion()}{version 18}.
+ listed in this section.
It is always best to cast integers to a Qt integer type, such as
\l{qint16} or \l{quint32}, when reading and writing. This ensures that
@@ -67,5 +67,6 @@
\li QVector4D
\endlist
- \sa {JSON Support in Qt}
+ \sa {JSON Support in Qt}, {CBOR Support in Qt}
+
*/
diff --git a/src/corelib/doc/src/external-resources.qdoc b/src/corelib/doc/src/external-resources.qdoc
index 7e8977dbd9..ecda025820 100644
--- a/src/corelib/doc/src/external-resources.qdoc
+++ b/src/corelib/doc/src/external-resources.qdoc
@@ -121,3 +121,13 @@
\externalpage https://cmake.org/cmake/help/latest/module/FetchContent.html#command:fetchcontent_makeavailable
\title FetchContent_MakeAvailable()
*/
+
+/*!
+ \externalpage https://cmake.org/cmake/help/latest/prop_gbl/USE_FOLDERS.html
+ \title USE_FOLDERS
+*/
+
+/*!
+ \externalpage https://cmake.org/cmake/help/latest/prop_tgt/FOLDER.html
+ \title FOLDER
+*/
diff --git a/src/corelib/doc/src/includes/cmake-android-qt-finalize-project-warning.cmake b/src/corelib/doc/src/includes/cmake-android-qt-finalize-project-warning.qdocinc
index 2f18622ecf..3f2a4ab6ec 100644
--- a/src/corelib/doc/src/includes/cmake-android-qt-finalize-project-warning.cmake
+++ b/src/corelib/doc/src/includes/cmake-android-qt-finalize-project-warning.qdocinc
@@ -1,5 +1,5 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
\warning If your \e Android project is built using a CMake version lower than
3.19, make sure that you call \l{qt_finalize_project}{qt6_finalize_project()} at
diff --git a/src/corelib/doc/src/includes/cmake-deploy-runtime-dependencies.qdocinc b/src/corelib/doc/src/includes/cmake-deploy-runtime-dependencies.qdocinc
index 3c7fb8d5ee..26503ddece 100644
--- a/src/corelib/doc/src/includes/cmake-deploy-runtime-dependencies.qdocinc
+++ b/src/corelib/doc/src/includes/cmake-deploy-runtime-dependencies.qdocinc
@@ -23,13 +23,11 @@ endif()
qt_add_executable(HelperApp helper.cpp)
set(helper_app_path "\${QT_DEPLOY_BIN_DIR}/$<TARGET_FILE_NAME:HelperApp>")
-# The following script must only be executed at install time
-set(deploy_script "${CMAKE_CURRENT_BINARY_DIR}/deploy_MyApp.cmake")
-
-file(GENERATE OUTPUT ${deploy_script} CONTENT "
-# Including the file pointed to by QT_DEPLOY_SUPPORT ensures the generated
-# deployment script has access to qt_deploy_runtime_dependencies()
-include(\"${QT_DEPLOY_SUPPORT}\")
+# Generate a deployment script to be executed at install time
+qt_generate_deploy_script(
+ TARGET MyApp
+ FILENAME_VARIABLE deploy_script
+ CONTENT "
qt_deploy_runtime_dependencies(
EXECUTABLE \"${executable_path}\"
ADDITIONAL_EXECUTABLES \"${helper_app_path}\"
diff --git a/src/corelib/doc/src/includes/permissions.qdocinc b/src/corelib/doc/src/includes/permissions.qdocinc
new file mode 100644
index 0000000000..00bf848d37
--- /dev/null
+++ b/src/corelib/doc/src/includes/permissions.qdocinc
@@ -0,0 +1,51 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+//! [requestPermission-functor]
+ When the request is ready, \a functor will be called as
+ \c {functor(const QPermission &permission)}, with
+ \c permission describing the result of the request.
+//! [requestPermission-functor]
+
+//! [requestPermission-postamble]
+ If the user explicitly grants the application the requested \a permission,
+ or the \a permission is known to not require user authorization on the given
+ platform, the status will be Qt::PermissionStatus::Granted.
+
+ If the user explicitly denies the application the requested \a permission,
+ or the \a permission is known to not be accessible or applicable to applications
+ on the given platform, the status will be Qt::PermissionStatus::Denied.
+
+ The result of a request will never be Qt::PermissionStatus::Undetermined.
+
+ \note Permissions can only be requested from the main thread.
+//! [requestPermission-postamble]
+
+//! [permission-metadata]
+ \inmodule QtCore
+ \inheaderfile QPermissions
+ \ingroup permissions
+ \since 6.5
+ \sa QPermission,
+ QCoreApplication::requestPermission(),
+ QCoreApplication::checkPermission(),
+ {Application Permissions}
+//! [permission-metadata]
+
+//! [begin-usage-declarations]
+ To request this permission at runtime, the following platform
+ specific usage declarations have to be made at build time:
+
+ \table
+ \header
+ \li Platform
+ \li Type
+ \li
+//! [begin-usage-declarations]
+
+//! [end-usage-declarations]
+ \endtable
+
+ Please see the individual usage declaration types for how
+ to add them to your project.
+//! [end-usage-declarations]
diff --git a/src/corelib/doc/src/objectmodel/bindableproperties.qdoc b/src/corelib/doc/src/objectmodel/bindableproperties.qdoc
index f9f129df97..d6f96f6579 100644
--- a/src/corelib/doc/src/objectmodel/bindableproperties.qdoc
+++ b/src/corelib/doc/src/objectmodel/bindableproperties.qdoc
@@ -247,4 +247,18 @@
be called for the current value of the property, register your callback using
subscribe() instead.
+ \section1 Interaction with Q_PROPERTYs
+
+ A \l {The Property System}{Q_PROPERTY} that defines \c BINDABLE can be bound and
+ used in binding expressions. You can implement such properties using \l {QProperty},
+ \l {QObjectBindableProperty}, or \l {QObjectComputedProperty}.
+
+ Q_PROPERTYs without \c BINDABLE can also be bound and be used in binding expressions,
+ as long as they define a \c NOTIFY signal. You must wrap the property in a \l QBindable
+ using the \c {QBindable(QObject* obj, const char* property)} constructor. Then, the
+ property can be bound using \c \l QBindable::setBinding() or used in a binding
+ expression via \c \l QBindable::value(). You must use \c QBindable::value() in binding
+ expressions instead of the normal property \c READ function (or \c MEMBER) to enable
+ dependency tracking if the property is not \c BINDABLE.
+
*/
diff --git a/src/corelib/doc/src/qtcore-index.qdoc b/src/corelib/doc/src/qtcore-index.qdoc
index 377e199784..99cc114d64 100644
--- a/src/corelib/doc/src/qtcore-index.qdoc
+++ b/src/corelib/doc/src/qtcore-index.qdoc
@@ -75,6 +75,7 @@
\list
\li \l{The Animation Framework}
\li \l{JSON Support in Qt}
+ \li \l{CBOR Support in Qt}
\li \l{How to Create Qt Plugins}
\li \l{The Event System}
\endlist
diff --git a/src/corelib/global/archdetect.cpp b/src/corelib/global/archdetect.cpp
index a0ce5baa43..188ec2d176 100644
--- a/src/corelib/global/archdetect.cpp
+++ b/src/corelib/global/archdetect.cpp
@@ -17,12 +17,16 @@
# define ARCH_PROCESSOR "bfin"
#elif defined(Q_PROCESSOR_WASM)
# define ARCH_PROCESSOR "wasm"
+#elif defined(Q_PROCESSOR_HPPA)
+# define ARCH_PROCESSOR "hppa"
#elif defined(Q_PROCESSOR_X86_32)
# define ARCH_PROCESSOR "i386"
#elif defined(Q_PROCESSOR_X86_64)
# define ARCH_PROCESSOR "x86_64"
#elif defined(Q_PROCESSOR_IA64)
# define ARCH_PROCESSOR "ia64"
+#elif defined(Q_PROCESSOR_M68K)
+# define ARCH_PROCESSOR "m68k"
#elif defined(Q_PROCESSOR_MIPS_64)
# define ARCH_PROCESSOR "mips64"
#elif defined(Q_PROCESSOR_MIPS)
diff --git a/src/corelib/global/q20algorithm.h b/src/corelib/global/q20algorithm.h
index 2918a679e1..f670a5dbee 100644
--- a/src/corelib/global/q20algorithm.h
+++ b/src/corelib/global/q20algorithm.h
@@ -12,9 +12,9 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. Types and functions defined
-// in this file will behave exactly as their std counterparts. You
-// may use these definitions in your own code, but be aware that we
+// This file is not part of the Qt API. Types and functions defined in this
+// file can reliably be replaced by their std counterparts, once available.
+// You may use these definitions in your own code, but be aware that we
// will remove them once Qt depends on the C++ version that supports
// them in namespace std. There will be NO deprecation warning, the
// definitions will JUST go away.
@@ -27,11 +27,78 @@
QT_BEGIN_NAMESPACE
namespace q20 {
-// like std::is_sorted{,_until} (ie. constexpr)
+// like std::<algorithm> (ie. not ranged, but constexpr)
#ifdef __cpp_lib_constexpr_algorithms
+using std::copy;
+using std::copy_if;
+using std::copy_n;
+using std::fill;
+using std::fill_n;
using std::is_sorted_until;
using std::is_sorted;
+using std::transform;
#else
+template <typename InputIterator, typename OutputIterator>
+constexpr OutputIterator
+copy(InputIterator first, InputIterator last, OutputIterator dest)
+{
+ while (first != last) {
+ *dest = *first;
+ ++first;
+ ++dest;
+ }
+ return dest;
+}
+
+template <typename InputIterator, typename OutputIterator, typename UnaryPredicate>
+constexpr OutputIterator
+copy_if(InputIterator first, InputIterator last, OutputIterator dest, UnaryPredicate pred)
+{
+ while (first != last) {
+ if (pred(*first)) {
+ *dest = *first;
+ ++dest;
+ }
+ ++first;
+ }
+ return dest;
+}
+
+template <typename InputIterator, typename Size, typename OutputIterator>
+constexpr OutputIterator
+copy_n(InputIterator first, Size n, OutputIterator dest)
+{
+ while (n > Size{0}) {
+ *dest = *first;
+ ++first;
+ ++dest;
+ --n;
+ }
+ return dest;
+}
+
+template <typename ForwardIterator, typename Value>
+constexpr void
+fill(ForwardIterator first, ForwardIterator last, const Value &value)
+{
+ while (first != last) {
+ *first = value;
+ ++first;
+ }
+}
+
+template <typename OutputIterator, typename Size, typename Value>
+constexpr OutputIterator
+fill_n(OutputIterator first, Size n, const Value &value)
+{
+ while (n > Size{0}) {
+ *first = value;
+ ++first;
+ --n;
+ }
+ return first;
+}
+
template <typename ForwardIterator, typename BinaryPredicate = std::less<>>
constexpr ForwardIterator
is_sorted_until(ForwardIterator first, ForwardIterator last, BinaryPredicate p = {})
@@ -46,11 +113,27 @@ is_sorted_until(ForwardIterator first, ForwardIterator last, BinaryPredicate p =
}
return first;
}
+
template <typename ForwardIterator, typename BinaryPredicate = std::less<>>
constexpr bool is_sorted(ForwardIterator first, ForwardIterator last, BinaryPredicate p = {})
{
return q20::is_sorted_until(first, last, p) == last;
}
+
+template <typename InputIterator, typename OutputIterator, typename UnaryFunction>
+constexpr OutputIterator
+transform(InputIterator first, InputIterator last, OutputIterator dest, UnaryFunction op)
+{
+ while (first != last) {
+ *dest = op(*first);
+ ++first;
+ ++dest;
+ }
+ return dest;
+}
+
+// binary transform missing on purpose (no users)
+
#endif
}
diff --git a/src/corelib/global/q20functional.h b/src/corelib/global/q20functional.h
index 9584252663..7ba10bd4b1 100644
--- a/src/corelib/global/q20functional.h
+++ b/src/corelib/global/q20functional.h
@@ -11,9 +11,9 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. Types and functions defined
-// in this file will behave exactly as their std counterparts. You
-// may use these definitions in your own code, but be aware that we
+// This file is not part of the Qt API. Types and functions defined in this
+// file can reliably be replaced by their std counterparts, once available.
+// You may use these definitions in your own code, but be aware that we
// will remove them once Qt depends on the C++ version that supports
// them in namespace std. There will be NO deprecation warning, the
// definitions will JUST go away.
diff --git a/src/corelib/global/q20iterator.h b/src/corelib/global/q20iterator.h
index a7f1cf3cfc..23b6406b64 100644
--- a/src/corelib/global/q20iterator.h
+++ b/src/corelib/global/q20iterator.h
@@ -11,9 +11,9 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. Types and functions defined
-// in this file will behave exactly as their std counterparts. You
-// may use these definitions in your own code, but be aware that we
+// This file is not part of the Qt API. Types and functions defined in this
+// file can reliably be replaced by their std counterparts, once available.
+// You may use these definitions in your own code, but be aware that we
// will remove them once Qt depends on the C++ version that supports
// them in namespace std. There will be NO deprecation warning, the
// definitions will JUST go away.
diff --git a/src/corelib/global/q23functional.h b/src/corelib/global/q23functional.h
index 5f83df698e..ae8f78a3d0 100644
--- a/src/corelib/global/q23functional.h
+++ b/src/corelib/global/q23functional.h
@@ -10,9 +10,9 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. Types and functions defined
-// in this file will behave exactly as their std counterparts. You
-// may use these definitions in your own code, but be aware that we
+// This file is not part of the Qt API. Types and functions defined in this
+// file can reliably be replaced by their std counterparts, once available.
+// You may use these definitions in your own code, but be aware that we
// will remove them once Qt depends on the C++ version that supports
// them in namespace std. There will be NO deprecation warning, the
// definitions will JUST go away.
diff --git a/src/corelib/global/qassert.cpp b/src/corelib/global/qassert.cpp
index 758c11cc57..4165429d4b 100644
--- a/src/corelib/global/qassert.cpp
+++ b/src/corelib/global/qassert.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qassert.h"
@@ -195,7 +195,25 @@ void qBadAlloc()
In debug builds the condition is enforced by an assert to facilitate debugging.
- \sa Q_ASSERT(), Q_ASSUME(), qFatal()
+ \note Use the macro Q_UNREACHABLE_RETURN() to insert return statements for
+ compilers that need them, without causing warnings for compilers that
+ complain about its presence.
+
+ \sa Q_ASSERT(), Q_ASSUME(), qFatal(), Q_UNREACHABLE_RETURN()
*/
+/*!
+ \macro void Q_UNREACHABLE_RETURN(...)
+ \relates <QtAssert>
+ \since 6.5
+
+ This is equivalent to
+ \code
+ Q_UNREACHABLE();
+ return __VA_ARGS__;
+ \endcode
+ except it omits the return on compilers that would warn about it.
+
+ \sa Q_UNREACHABLE()
+*/
QT_END_NAMESPACE
diff --git a/src/corelib/global/qassert.h b/src/corelib/global/qassert.h
index c3696d10a8..28c6b6c8fc 100644
--- a/src/corelib/global/qassert.h
+++ b/src/corelib/global/qassert.h
@@ -5,7 +5,8 @@
#define QASSERT_H
#include <QtCore/qcompilerdetection.h>
-#include <QtCore/qtnamespacemacros.h>
+#include <QtCore/qtconfigmacros.h>
+#include <QtCore/qtcoreexports.h>
#if 0
#pragma qt_class(QtAssert)
@@ -14,6 +15,8 @@
QT_BEGIN_NAMESPACE
+#if defined(__cplusplus)
+
#ifndef Q_CC_MSVC
Q_NORETURN
#endif
@@ -67,12 +70,43 @@ inline T *q_check_ptr(T *p) { Q_CHECK_PTR(p); return p; }
Q_UNREACHABLE_IMPL();\
} while (false)
+#ifndef Q_UNREACHABLE_RETURN
+# ifdef Q_COMPILER_COMPLAINS_ABOUT_RETURN_AFTER_UNREACHABLE
+# define Q_UNREACHABLE_RETURN(...) Q_UNREACHABLE()
+# else
+# define Q_UNREACHABLE_RETURN(...) do { Q_UNREACHABLE(); return __VA_ARGS__; } while (0)
+# endif
+#endif
+
#define Q_ASSUME(Expr) \
[] (bool valueOfExpression) {\
Q_ASSERT_X(valueOfExpression, "Q_ASSUME()", "Assumption in Q_ASSUME(\"" #Expr "\") was not correct");\
Q_ASSUME_IMPL(valueOfExpression);\
}(Expr)
+// Don't use these in C++ mode, use static_assert directly.
+// These are here only to keep old code compiling.
+# define Q_STATIC_ASSERT(Condition) static_assert(bool(Condition), #Condition)
+# define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message)
+
+#elif defined(Q_COMPILER_STATIC_ASSERT)
+// C11 mode - using the _S version in case <assert.h> doesn't do the right thing
+# define Q_STATIC_ASSERT(Condition) _Static_assert(!!(Condition), #Condition)
+# define Q_STATIC_ASSERT_X(Condition, Message) _Static_assert(!!(Condition), Message)
+#else
+// C89 & C99 version
+# define Q_STATIC_ASSERT_PRIVATE_JOIN(A, B) Q_STATIC_ASSERT_PRIVATE_JOIN_IMPL(A, B)
+# define Q_STATIC_ASSERT_PRIVATE_JOIN_IMPL(A, B) A ## B
+# ifdef __COUNTER__
+# define Q_STATIC_ASSERT(Condition) \
+ typedef char Q_STATIC_ASSERT_PRIVATE_JOIN(q_static_assert_result, __COUNTER__) [(Condition) ? 1 : -1];
+# else
+# define Q_STATIC_ASSERT(Condition) \
+ typedef char Q_STATIC_ASSERT_PRIVATE_JOIN(q_static_assert_result, __LINE__) [(Condition) ? 1 : -1];
+# endif /* __COUNTER__ */
+# define Q_STATIC_ASSERT_X(Condition, Message) Q_STATIC_ASSERT(Condition)
+#endif // __cplusplus
+
QT_END_NAMESPACE
#endif // QASSERT_H
diff --git a/src/corelib/global/qcompare.qdoc b/src/corelib/global/qcompare.qdoc
index e822f40490..33b8f31000 100644
--- a/src/corelib/global/qcompare.qdoc
+++ b/src/corelib/global/qcompare.qdoc
@@ -26,7 +26,7 @@
object is equivalent to the second;
\li \c QPartialOrdering::Greater represents that the first object
- is equivalent to the second;
+ is greater than the second;
\li \c QPartialOrdering::Unordered represents that the first object
is \e{not ordered} with respect to the second.
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index 64154bc0c8..b0df663242 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -7,6 +7,7 @@
#endif
#if 0
+#pragma qt_class(QtCompilerDetection)
#pragma qt_sync_skip_header_check
#pragma qt_sync_stop_processing
#endif
@@ -14,9 +15,12 @@
#ifndef QCOMPILERDETECTION_H
#define QCOMPILERDETECTION_H
+#include <QtCore/qprocessordetection.h>
+
/*
The compiler, must be one of: (Q_CC_x)
+ COVERITY - Coverity cov-scan
SYM - Digital Mars C/C++ (used to be Symantec C++)
MSVC - Microsoft Visual C/C++, Intel C++ for Windows
BOR - Borland/Turbo C++
@@ -43,6 +47,11 @@
Should be sorted most to least authoritative.
*/
+#if defined(__COVERITY__)
+# define Q_CC_COVERITY
+# define Q_COMPILER_COMPLAINS_ABOUT_RETURN_AFTER_UNREACHABLE
+#endif
+
/* Symantec C++ is now Digital Mars */
#if defined(__DMC__) || defined(__SC__)
# define Q_CC_SYM
@@ -221,7 +230,6 @@
but it is not defined on older compilers like C Set 3.1 */
#elif defined(__xlC__)
# define Q_CC_XLC
-# define Q_FULL_TEMPLATE_INSTANTIATION
# if __xlC__ < 0x400
# error "Compiler not supported"
# elif __xlC__ >= 0x0600
@@ -437,13 +445,21 @@
# define __has_include_next(x) 0
#endif
-// Kept around until all submodules have transitioned
-#define QT_HAS_BUILTIN(x) __has_builtin(x)
-#define QT_HAS_FEATURE(x) __has_feature(x)
-#define QT_HAS_ATTRIBUTE(x) __has_attribute(x)
-#define QT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
-#define QT_HAS_INCLUDE(x) __has_include(x)
-#define QT_HAS_INCLUDE_NEXT(x) __has_include_next(x)
+/*
+ detecting ASAN can be helpful to disable slow tests
+ clang uses feature, gcc defines __SANITIZE_ADDRESS__
+ unconditionally check both in case other compilers mirror
+ either of those options
+ */
+#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
+# define QT_ASAN_ENABLED
+#endif
+
+#ifdef __cplusplus
+# if __has_include(<version>) /* remove this check once Integrity, QNX have caught up */
+# include <version>
+# endif
+#endif
/*
* C++11 support
@@ -485,10 +501,16 @@
* N1653 Q_COMPILER_VARIADIC_MACROS
* N2242 N2555 Q_COMPILER_VARIADIC_TEMPLATES __cpp_variadic_templates = 200704
*
- * For any future version of the C++ standard, we use only the SD-6 macro.
+ *
+ * For the C++ standards C++14 and C++17, we use only the SD-6 macro.
* For full listing, see
* http://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations
*
+ * For any future version of the C++ standard, we use only the C++20 feature test macro.
+ * For library features, we assume <version> is present (this header includes it).
+ * For full listing, see
+ * https://en.cppreference.com/w/User:D41D8CD98F/feature_testing_macros
+ *
* C++ extensions:
* Q_COMPILER_RESTRICTED_VLA variable-length arrays, prior to __cpp_runtime_arrays
*/
@@ -1032,7 +1054,7 @@
* "Weak overloads" - makes an otherwise confliciting overload weaker
* (by making it a template)
*/
-#ifndef Q_CLANG_QDOC
+#ifndef Q_QDOC
# define Q_WEAK_OVERLOAD template <typename = void>
#else
# define Q_WEAK_OVERLOAD
@@ -1056,7 +1078,7 @@
* The workaround: declare such functions as function templates.
* (Obviously a function template does not need this marker.)
*/
-#ifndef Q_CLANG_QDOC
+#ifndef Q_QDOC
# define QT_POST_CXX17_API_IN_EXPORTED_CLASS template <typename = void>
#else
# define QT_POST_CXX17_API_IN_EXPORTED_CLASS
@@ -1119,6 +1141,20 @@
QT_WARNING_POP
#endif
+// The body must be a statement:
+#define Q_CAST_IGNORE_ALIGN(body) QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wcast-align") body QT_WARNING_POP
+
+// This macro can be used to calculate member offsets for types with a non standard layout.
+// It uses the fact that offsetof() is allowed to support those types since C++17 as an optional
+// feature. All our compilers do support this, but some issue a warning, so we wrap the offsetof()
+// call in a macro that disables the compiler warning.
+#define Q_OFFSETOF(Class, member) \
+ []() -> size_t { \
+ QT_WARNING_PUSH QT_WARNING_DISABLE_INVALID_OFFSETOF \
+ return offsetof(Class, member); \
+ QT_WARNING_POP \
+ }()
+
/*
Proper for-scoping in MIPSpro CC
*/
@@ -1203,4 +1239,124 @@ static_assert(!std::is_convertible_v<std::nullptr_t, bool>,
"Compile your code with -fPIC (and not with -fPIE)."
#endif
+#ifdef Q_PROCESSOR_X86_32
+# if defined(Q_CC_GNU)
+# define QT_FASTCALL __attribute__((regparm(3)))
+# elif defined(Q_CC_MSVC)
+# define QT_FASTCALL __fastcall
+# else
+# define QT_FASTCALL
+# endif
+#else
+# define QT_FASTCALL
+#endif
+
+// enable gcc warnings for printf-style functions
+#if defined(Q_CC_GNU) && !defined(__INSURE__)
+# if defined(Q_CC_MINGW) && !defined(Q_CC_CLANG)
+# define Q_ATTRIBUTE_FORMAT_PRINTF(A, B) \
+ __attribute__((format(gnu_printf, (A), (B))))
+# else
+# define Q_ATTRIBUTE_FORMAT_PRINTF(A, B) \
+ __attribute__((format(printf, (A), (B))))
+# endif
+#else
+# define Q_ATTRIBUTE_FORMAT_PRINTF(A, B)
+#endif
+
+#ifdef Q_CC_MSVC
+# define Q_NEVER_INLINE __declspec(noinline)
+# define Q_ALWAYS_INLINE __forceinline
+#elif defined(Q_CC_GNU)
+# define Q_NEVER_INLINE __attribute__((noinline))
+# define Q_ALWAYS_INLINE inline __attribute__((always_inline))
+#else
+# define Q_NEVER_INLINE
+# define Q_ALWAYS_INLINE inline
+#endif
+
+//defines the type for the WNDPROC on windows
+//the alignment needs to be forced for sse2 to not crash with mingw
+#if defined(Q_OS_WIN)
+# if defined(Q_CC_MINGW) && defined(Q_PROCESSOR_X86_32)
+# define QT_ENSURE_STACK_ALIGNED_FOR_SSE __attribute__ ((force_align_arg_pointer))
+# else
+# define QT_ENSURE_STACK_ALIGNED_FOR_SSE
+# endif
+# define QT_WIN_CALLBACK CALLBACK QT_ENSURE_STACK_ALIGNED_FOR_SSE
+#endif
+
+#ifdef __cpp_conditional_explicit
+#define Q_IMPLICIT explicit(false)
+#else
+#define Q_IMPLICIT
+#endif
+
+#if defined(__cplusplus)
+
+#ifdef __cpp_constinit
+# if defined(Q_CC_MSVC) && !defined(Q_CC_CLANG)
+ // https://developercommunity.visualstudio.com/t/C:-constinit-for-an-optional-fails-if-/1406069
+# define Q_CONSTINIT
+# else
+# define Q_CONSTINIT constinit
+# endif
+#elif defined(__has_cpp_attribute) && __has_cpp_attribute(clang::require_constant_initialization)
+# define Q_CONSTINIT [[clang::require_constant_initialization]]
+#elif defined(Q_CC_GNU_ONLY) && Q_CC_GNU >= 1000
+# define Q_CONSTINIT __constinit
+#else
+# define Q_CONSTINIT
+#endif
+
+#ifndef Q_OUTOFLINE_TEMPLATE
+# define Q_OUTOFLINE_TEMPLATE
+#endif
+#ifndef Q_INLINE_TEMPLATE
+# define Q_INLINE_TEMPLATE inline
+#endif
+
+/*
+ Avoid some particularly useless warnings from some stupid compilers.
+ To get ALL C++ compiler warnings, define QT_CC_WARNINGS or comment out
+ the line "#define QT_NO_WARNINGS". See also QTBUG-26877.
+*/
+#if !defined(QT_CC_WARNINGS)
+# define QT_NO_WARNINGS
+#endif
+#if defined(QT_NO_WARNINGS)
+# if defined(Q_CC_MSVC)
+QT_WARNING_DISABLE_MSVC(4251) /* class 'type' needs to have dll-interface to be used by clients of class 'type2' */
+QT_WARNING_DISABLE_MSVC(4244) /* conversion from 'type1' to 'type2', possible loss of data */
+QT_WARNING_DISABLE_MSVC(4275) /* non - DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' */
+QT_WARNING_DISABLE_MSVC(4514) /* unreferenced inline function has been removed */
+QT_WARNING_DISABLE_MSVC(4800) /* 'type' : forcing value to bool 'true' or 'false' (performance warning) */
+QT_WARNING_DISABLE_MSVC(4097) /* typedef-name 'identifier1' used as synonym for class-name 'identifier2' */
+QT_WARNING_DISABLE_MSVC(4706) /* assignment within conditional expression */
+QT_WARNING_DISABLE_MSVC(4355) /* 'this' : used in base member initializer list */
+QT_WARNING_DISABLE_MSVC(4710) /* function not inlined */
+QT_WARNING_DISABLE_MSVC(4530) /* C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc */
+# elif defined(Q_CC_BOR)
+# pragma option -w-inl
+# pragma option -w-aus
+# pragma warn -inl
+# pragma warn -pia
+# pragma warn -ccc
+# pragma warn -rch
+# pragma warn -sig
+# endif
+#endif
+
+#if !defined(QT_NO_EXCEPTIONS)
+# if !defined(Q_MOC_RUN)
+# if defined(Q_CC_GNU) && !defined(__cpp_exceptions)
+# define QT_NO_EXCEPTIONS
+# endif
+# elif defined(QT_BOOTSTRAPPED)
+# define QT_NO_EXCEPTIONS
+# endif
+#endif
+
+#endif // __cplusplus
+
#endif // QCOMPILERDETECTION_H
diff --git a/src/corelib/global/qcompilerdetection.qdoc b/src/corelib/global/qcompilerdetection.qdoc
new file mode 100644
index 0000000000..377323a5eb
--- /dev/null
+++ b/src/corelib/global/qcompilerdetection.qdoc
@@ -0,0 +1,394 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \headerfile <QtCompilerDetection>
+ \inmodule QtCore
+ \title Compiler-specific Macro Definitions
+ \ingroup funclists
+
+ \brief The <QtCompilerDetection> header file includes various
+ compiler-specific macros.
+
+ The <QtCompilerDetection> header file provides a range of macros (Q_CC_*)
+ that are defined if the application is compiled using the specified
+ compiler. For example, the Q_CC_SUN macro is defined if the application is
+ compiled using Forte Developer, or Sun Studio C++.
+
+ The purpose of these macros is to enable programmers to add
+ compiler-specific code to their application.
+*/
+
+/*!
+ \macro Q_CC_SYM
+ \relates <QtCompilerDetection>
+
+ Defined if the application is compiled using Digital Mars C/C++
+ (used to be Symantec C++).
+*/
+
+/*!
+ \macro Q_CC_MSVC
+ \relates <QtCompilerDetection>
+
+ Defined if the application is compiled using Microsoft Visual
+ C/C++, Intel C++ for Windows.
+*/
+
+/*!
+ \macro Q_CC_CLANG
+ \relates <QtCompilerDetection>
+
+ Defined if the application is compiled using Clang.
+*/
+
+/*!
+ \macro Q_CC_BOR
+ \relates <QtCompilerDetection>
+
+ Defined if the application is compiled using Borland/Turbo C++.
+*/
+
+/*!
+ \macro Q_CC_WAT
+ \relates <QtCompilerDetection>
+
+ Defined if the application is compiled using Watcom C++.
+*/
+
+/*!
+ \macro Q_CC_GNU
+ \relates <QtCompilerDetection>
+
+ Defined if the application is compiled using GNU Compiler Collection (GCC).
+*/
+
+/*!
+ \macro Q_CC_COMEAU
+ \relates <QtCompilerDetection>
+
+ Defined if the application is compiled using Comeau C++.
+*/
+
+/*!
+ \macro Q_CC_EDG
+ \relates <QtCompilerDetection>
+
+ Defined if the application is compiled using Edison Design Group
+ C++.
+*/
+
+/*!
+ \macro Q_CC_OC
+ \relates <QtCompilerDetection>
+
+ Defined if the application is compiled using CenterLine C++.
+*/
+
+/*!
+ \macro Q_CC_SUN
+ \relates <QtCompilerDetection>
+
+ Defined if the application is compiled using Forte Developer, or
+ Sun Studio C++.
+*/
+
+/*!
+ \macro Q_CC_MIPS
+ \relates <QtCompilerDetection>
+
+ Defined if the application is compiled using MIPSpro C++.
+*/
+
+/*!
+ \macro Q_CC_DEC
+ \relates <QtCompilerDetection>
+
+ Defined if the application is compiled using DEC C++.
+*/
+
+/*!
+ \macro Q_CC_HPACC
+ \relates <QtCompilerDetection>
+
+ Defined if the application is compiled using HP aC++.
+*/
+
+/*!
+ \macro Q_CC_USLC
+ \relates <QtCompilerDetection>
+
+ Defined if the application is compiled using SCO OUDK and UDK.
+*/
+
+/*!
+ \macro Q_CC_CDS
+ \relates <QtCompilerDetection>
+
+ Defined if the application is compiled using Reliant C++.
+*/
+
+/*!
+ \macro Q_CC_KAI
+ \relates <QtCompilerDetection>
+
+ Defined if the application is compiled using KAI C++.
+*/
+
+/*!
+ \macro Q_CC_INTEL
+ \relates <QtCompilerDetection>
+ \obsolete
+
+ This macro used to be defined if the application was compiled with the old
+ Intel C++ compiler for Linux, macOS or Windows. The new oneAPI C++ compiler
+ is just a build of Clang and therefore does not define this macro.
+
+ \sa Q_CC_CLANG
+*/
+
+/*!
+ \macro Q_CC_HIGHC
+ \relates <QtCompilerDetection>
+
+ Defined if the application is compiled using MetaWare High C/C++.
+*/
+
+/*!
+ \macro Q_CC_PGI
+ \relates <QtCompilerDetection>
+
+ Defined if the application is compiled using Portland Group C++.
+*/
+
+/*!
+ \macro Q_CC_GHS
+ \relates <QtCompilerDetection>
+
+ Defined if the application is compiled using Green Hills
+ Optimizing C++ Compilers.
+*/
+
+/*!
+ \macro void Q_FALLTHROUGH()
+ \relates <QtCompilerDetection>
+ \since 5.8
+
+ Can be used in switch statements at the end of case block to tell the compiler
+ and other developers that that the lack of a break statement is intentional.
+
+ This is useful since a missing break statement is often a bug, and some
+ compilers can be configured to emit warnings when one is not found.
+
+ \sa Q_UNREACHABLE(), Q_UNREACHABLE_RETURN()
+*/
+
+/*!
+ \macro Q_LIKELY(expr)
+ \relates <QtCompilerDetection>
+ \since 4.8
+
+ \brief Hints to the compiler that the enclosed condition, \a expr, is
+ likely to evaluate to \c true.
+
+ Use of this macro can help the compiler to optimize the code.
+
+ Example:
+
+ \snippet code/src_corelib_global_qglobal.cpp qlikely
+
+ \sa Q_UNLIKELY(), Q_ASSUME()
+*/
+
+/*!
+ \macro Q_UNLIKELY(expr)
+ \relates <QtCompilerDetection>
+ \since 4.8
+
+ \brief Hints to the compiler that the enclosed condition, \a expr, is
+ likely to evaluate to \c false.
+
+ Use of this macro can help the compiler to optimize the code.
+
+ Example:
+
+ \snippet code/src_corelib_global_qglobal.cpp qunlikely
+
+ \sa Q_LIKELY()
+*/
+
+/*!
+ \macro Q_CONSTINIT
+ \relates <QtCompilerDetection>
+ \since 6.4
+
+ \brief Enforces constant initialization when supported by the compiler.
+
+ If the compiler supports the C++20 \c{constinit} keyword, Clang's
+ \c{[[clang::require_constant_initialization]]} or GCC's \c{__constinit},
+ then this macro expands to the first one of these that is available,
+ otherwise it expands to nothing.
+
+ Variables marked as \c{constinit} cause a compile-error if their
+ initialization would have to be performed at runtime.
+
+ \note Constant-initialized variables may still have load-time impact if
+ they have non-trivial destruction.
+
+ For constants, you can use \c{constexpr} since C++11, but \c{constexpr}
+ makes variables \c{const}, too, whereas \c{constinit} ensures constant
+ initialization, but doesn't make the variable \c{const}:
+
+ \table
+ \header \li Keyword \li Added \li immutable \li constant-initialized
+ \row \li \c{const} \li C++98 \li yes \li not required
+ \row \li \c{constexpr} \li C++11 \li yes \li required
+ \row \li \c{constinit} \li C++20 \li no \li required
+ \endtable
+*/
+
+/*!
+ \macro Q_DECL_EXPORT
+ \relates <QtCompilerDetection>
+
+ This macro marks a symbol for shared library export (see
+ \l{sharedlibrary.html}{Creating Shared Libraries}).
+
+ \sa Q_DECL_IMPORT
+*/
+
+/*!
+ \macro Q_DECL_IMPORT
+ \relates <QtCompilerDetection>
+
+ This macro declares a symbol to be an import from a shared library (see
+ \l{sharedlibrary.html}{Creating Shared Libraries}).
+
+ \sa Q_DECL_EXPORT
+*/
+
+/*!
+ \macro Q_DECL_CONSTEXPR
+ \relates <QtCompilerDetection>
+ \deprecated [6.4] Use the \c constexpr keyword instead.
+
+ This macro can be used to declare variable that should be constructed at compile-time,
+ or an inline function that can be computed at compile-time.
+
+ \sa Q_DECL_RELAXED_CONSTEXPR
+*/
+
+/*!
+ \macro Q_DECL_RELAXED_CONSTEXPR
+ \relates <QtCompilerDetection>
+ \deprecated [6.4] Use the \c constexpr keyword instead.
+
+ This macro can be used to declare an inline function that can be computed
+ at compile-time according to the relaxed rules from C++14.
+
+ \sa Q_DECL_CONSTEXPR
+*/
+
+/*!
+ \macro Q_DECL_NOTHROW
+ \relates <QtCompilerDetection>
+ \since 5.0
+ \deprecated [6.4] Use the \c noexcept keyword instead.
+
+ This macro marks a function as never throwing, under no
+ circumstances. If the function does nevertheless throw, the
+ behavior is undefined.
+
+ \sa Q_DECL_NOEXCEPT, Q_DECL_NOEXCEPT_EXPR()
+*/
+
+/*!
+ \macro Q_DECL_NOEXCEPT
+ \relates <QtCompilerDetection>
+ \since 5.0
+ \deprecated [6.4] Use the \c noexcept keyword instead.
+
+ This macro marks a function as never throwing. If the function
+ does nevertheless throw, the behavior is defined:
+ std::terminate() is called.
+
+
+ \sa Q_DECL_NOTHROW, Q_DECL_NOEXCEPT_EXPR()
+*/
+
+/*!
+ \macro Q_DECL_NOEXCEPT_EXPR(x)
+ \relates <QtCompilerDetection>
+ \since 5.0
+ \deprecated [6.4] Use the \c noexcept keyword instead.
+
+ This macro marks a function as non-throwing if \a x is \c true. If
+ the function does nevertheless throw, the behavior is defined:
+ std::terminate() is called.
+
+
+ \sa Q_DECL_NOTHROW, Q_DECL_NOEXCEPT
+*/
+
+/*!
+ \macro Q_DECL_OVERRIDE
+ \since 5.0
+ \deprecated
+ \relates <QtCompilerDetection>
+
+ This macro can be used to declare an overriding virtual
+ function. Use of this markup will allow the compiler to generate
+ an error if the overriding virtual function does not in fact
+ override anything.
+
+ It expands to "override".
+
+ The macro goes at the end of the function, usually after the
+ \c{const}, if any:
+ \snippet code/src_corelib_global_qglobal.cpp qdecloverride
+
+ \sa Q_DECL_FINAL
+*/
+
+/*!
+ \macro Q_DECL_FINAL
+ \since 5.0
+ \deprecated
+ \relates <QtCompilerDetection>
+
+ This macro can be used to declare an overriding virtual or a class
+ as "final", with Java semantics. Further-derived classes can then
+ no longer override this virtual function, or inherit from this
+ class, respectively.
+
+ It expands to "final".
+
+ The macro goes at the end of the function, usually after the
+ \c{const}, if any:
+ \snippet code/src_corelib_global_qglobal.cpp qdeclfinal-1
+
+ For classes, it goes in front of the \c{:} in the class
+ definition, if any:
+ \snippet code/src_corelib_global_qglobal.cpp qdeclfinal-2
+
+ \sa Q_DECL_OVERRIDE
+*/
+
+/*!
+ \macro const char* Q_FUNC_INFO()
+ \relates <QtCompilerDetection>
+
+ Expands to a string that describe the function the macro resides in. How this string looks
+ more specifically is compiler dependent. With GNU GCC it is typically the function signature,
+ while with other compilers it might be the line and column number.
+
+ Q_FUNC_INFO can be conveniently used with qDebug(). For example, this function:
+
+ \snippet code/src_corelib_global_qglobal.cpp 22
+
+ when instantiated with the integer type, will with the GCC compiler produce:
+
+ \tt{const TInputType& myMin(const TInputType&, const TInputType&) [with TInputType = int] was called with value1: 3 value2: 4}
+
+ If this macro is used outside a function, the behavior is undefined.
+*/
diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h
index 61fd6479b1..78d622f5e9 100644
--- a/src/corelib/global/qconfig-bootstrapped.h
+++ b/src/corelib/global/qconfig-bootstrapped.h
@@ -23,6 +23,8 @@
#ifdef QT_BOOTSTRAPPED
+#include <stdlib.h> // for __GLIBC_PREREQ
+
#ifndef QT_NO_EXCEPTIONS
#define QT_NO_EXCEPTIONS
#endif
@@ -61,7 +63,6 @@
#define QT_FEATURE_jalalicalendar -1
#define QT_FEATURE_journald -1
#define QT_FEATURE_futimens -1
-#define QT_FEATURE_futimes -1
#define QT_FEATURE_future -1
#define QT_FEATURE_itemmodel -1
#define QT_FEATURE_library -1
@@ -106,6 +107,7 @@
#define QT_FEATURE_commandlineparser 1
#define QT_FEATURE_settings -1
+#define QT_FEATURE_permissions -1
#define QT_NO_TEMPORARYFILE
diff --git a/src/corelib/global/qconstructormacros.h b/src/corelib/global/qconstructormacros.h
new file mode 100644
index 0000000000..21492ac31f
--- /dev/null
+++ b/src/corelib/global/qconstructormacros.h
@@ -0,0 +1,38 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#ifndef QCONSTRUCTORMACROS_H
+#define QCONSTRUCTORMACROS_H
+
+#if 0
+#pragma qt_class(QtConstructorMacros)
+#pragma qt_sync_stop_processing
+#endif
+
+#if defined(__cplusplus)
+
+#ifndef Q_CONSTRUCTOR_FUNCTION
+# define Q_CONSTRUCTOR_FUNCTION0(AFUNC) \
+ namespace { \
+ static const struct AFUNC ## _ctor_class_ { \
+ inline AFUNC ## _ctor_class_() { AFUNC(); } \
+ } AFUNC ## _ctor_instance_; \
+ }
+
+# define Q_CONSTRUCTOR_FUNCTION(AFUNC) Q_CONSTRUCTOR_FUNCTION0(AFUNC)
+#endif
+
+#ifndef Q_DESTRUCTOR_FUNCTION
+# define Q_DESTRUCTOR_FUNCTION0(AFUNC) \
+ namespace { \
+ static const struct AFUNC ## _dtor_class_ { \
+ inline AFUNC ## _dtor_class_() { } \
+ inline ~ AFUNC ## _dtor_class_() { AFUNC(); } \
+ } AFUNC ## _dtor_instance_; \
+ }
+# define Q_DESTRUCTOR_FUNCTION(AFUNC) Q_DESTRUCTOR_FUNCTION0(AFUNC)
+#endif
+
+#endif // __cplusplus
+
+#endif // QCONSTRUCTORMACROS_H
diff --git a/src/corelib/global/qdarwinhelpers.h b/src/corelib/global/qdarwinhelpers.h
new file mode 100644
index 0000000000..2ffc740d58
--- /dev/null
+++ b/src/corelib/global/qdarwinhelpers.h
@@ -0,0 +1,37 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#ifndef QTDARWINHELPERS_H
+#define QTDARWINHELPERS_H
+
+#if 0
+#pragma qt_class(QtDarwinHelpers)
+#pragma qt_sync_stop_processing
+#endif
+
+/*
+ Utility macros and inline functions
+*/
+
+#ifndef Q_FORWARD_DECLARE_OBJC_CLASS
+# ifdef __OBJC__
+# define Q_FORWARD_DECLARE_OBJC_CLASS(classname) @class classname
+# else
+# define Q_FORWARD_DECLARE_OBJC_CLASS(classname) class classname
+# endif
+#endif
+#ifndef Q_FORWARD_DECLARE_CF_TYPE
+# define Q_FORWARD_DECLARE_CF_TYPE(type) typedef const struct __ ## type * type ## Ref
+#endif
+#ifndef Q_FORWARD_DECLARE_MUTABLE_CF_TYPE
+# define Q_FORWARD_DECLARE_MUTABLE_CF_TYPE(type) typedef struct __ ## type * type ## Ref
+#endif
+#ifndef Q_FORWARD_DECLARE_CG_TYPE
+#define Q_FORWARD_DECLARE_CG_TYPE(type) typedef const struct type *type ## Ref;
+#endif
+#ifndef Q_FORWARD_DECLARE_MUTABLE_CG_TYPE
+#define Q_FORWARD_DECLARE_MUTABLE_CG_TYPE(type) typedef struct type *type ## Ref;
+#endif
+
+
+#endif // QTDARWINHELPERS_H
diff --git a/src/corelib/global/qdarwinhelpers.qdoc b/src/corelib/global/qdarwinhelpers.qdoc
new file mode 100644
index 0000000000..a827526634
--- /dev/null
+++ b/src/corelib/global/qdarwinhelpers.qdoc
@@ -0,0 +1,34 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \macro Q_FORWARD_DECLARE_OBJC_CLASS(classname)
+ \since 5.2
+ \relates <QtDarwinHelpers>
+
+ Forward-declares an Objective-C \a classname in a manner such that it can be
+ compiled as either Objective-C or C++.
+
+ This is primarily intended for use in header files that may be included by
+ both Objective-C and C++ source files.
+*/
+
+/*!
+ \macro Q_FORWARD_DECLARE_CF_TYPE(type)
+ \since 5.2
+ \relates <QtDarwinHelpers>
+
+ Forward-declares a Core Foundation \a type. This includes the actual
+ type and the ref type. For example, Q_FORWARD_DECLARE_CF_TYPE(CFString)
+ declares __CFString and CFStringRef.
+*/
+
+/*!
+ \macro Q_FORWARD_DECLARE_MUTABLE_CF_TYPE(type)
+ \since 5.2
+ \relates <QtDarwinHelpers>
+
+ Forward-declares a mutable Core Foundation \a type. This includes the actual
+ type and the ref type. For example, Q_FORWARD_DECLARE_MUTABLE_CF_TYPE(CFMutableString)
+ declares __CFMutableString and CFMutableStringRef.
+*/
diff --git a/src/corelib/global/qendian.cpp b/src/corelib/global/qendian.cpp
index 041562fe01..2fa7404507 100644
--- a/src/corelib/global/qendian.cpp
+++ b/src/corelib/global/qendian.cpp
@@ -399,28 +399,28 @@ QT_BEGIN_NAMESPACE
/*!
\fn template <typename T> QLEInteger &QLEInteger<T>::operator++()
- Performs a prefix ++ (increment) on this QLEInteger and returns a reference to
+ Performs a prefix \c{++} (increment) on this QLEInteger and returns a reference to
this object.
*/
/*!
\fn template <typename T> QLEInteger QLEInteger<T>::operator++(int)
- Performs a postfix ++ (increment) on this QLEInteger and returns a reference to
+ Performs a postfix \c{++} (increment) on this QLEInteger and returns a reference to
this object.
*/
/*!
\fn template <typename T> QLEInteger &QLEInteger<T>::operator--()
- Performs a prefix -- (decrement) on this QLEInteger and returns a reference to
+ Performs a prefix \c{--} (decrement) on this QLEInteger and returns a reference to
this object.
*/
/*!
\fn template <typename T> QLEInteger QLEInteger<T>::operator--(int)
- Performs a postfix -- (decrement) on this QLEInteger and returns a reference to
+ Performs a postfix \c{--} (decrement) on this QLEInteger and returns a reference to
this object.
*/
@@ -558,28 +558,28 @@ QT_BEGIN_NAMESPACE
/*!
\fn template <typename T> QBEInteger &QBEInteger<T>::operator++()
- Performs a prefix ++ (increment) on this QBEInteger and returns a reference to
+ Performs a prefix \c{++} (increment) on this QBEInteger and returns a reference to
this object.
*/
/*!
\fn template <typename T> QBEInteger QBEInteger<T>::operator++(int)
- Performs a postfix ++ (increment) on this QBEInteger and returns a reference to
+ Performs a postfix \c{++} (increment) on this QBEInteger and returns a reference to
this object.
*/
/*!
\fn template <typename T> QBEInteger &QBEInteger<T>::operator--()
- Performs a prefix -- (decrement) on this QBEInteger and returns a reference to
+ Performs a prefix \c{--} (decrement) on this QBEInteger and returns a reference to
this object.
*/
/*!
\fn template <typename T> QBEInteger QBEInteger<T>::operator--(int)
- Performs a postfix -- (decrement) on this QBEInteger and returns a reference to
+ Performs a postfix \c{--} (decrement) on this QBEInteger and returns a reference to
this object.
*/
diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h
index b803a27674..9cd0044cbc 100644
--- a/src/corelib/global/qendian.h
+++ b/src/corelib/global/qendian.h
@@ -302,7 +302,7 @@ public:
static constexpr T fromSpecial(T source) { return qFromBigEndian(source); }
};
-#ifdef Q_CLANG_QDOC
+#ifdef Q_QDOC
template<typename T>
class QLEInteger {
public:
diff --git a/src/corelib/global/qexceptionhandling.cpp b/src/corelib/global/qexceptionhandling.cpp
new file mode 100644
index 0000000000..f74eb49546
--- /dev/null
+++ b/src/corelib/global/qexceptionhandling.cpp
@@ -0,0 +1,20 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include "qexceptionhandling.h"
+
+#include <exception>
+
+QT_BEGIN_NAMESPACE
+
+/*
+ \internal
+ Allows you to call std::terminate() without including <exception>.
+ Called internally from QT_TERMINATE_ON_EXCEPTION
+*/
+Q_NORETURN void qTerminate() noexcept
+{
+ std::terminate();
+}
+
+QT_END_NAMESPACE
diff --git a/src/corelib/global/qexceptionhandling.h b/src/corelib/global/qexceptionhandling.h
new file mode 100644
index 0000000000..aca8de9003
--- /dev/null
+++ b/src/corelib/global/qexceptionhandling.h
@@ -0,0 +1,45 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#ifndef QEXCEPTIONHANDLING_H
+#define QEXCEPTIONHANDLING_H
+
+#include <QtCore/qtconfigmacros.h>
+#include <QtCore/qcompilerdetection.h>
+
+#if 0
+#pragma qt_class(QtExceptionHandling)
+#pragma qt_sync_stop_processing
+#endif
+
+QT_BEGIN_NAMESPACE
+
+/* These wrap try/catch so we can switch off exceptions later.
+
+ Beware - do not use more than one QT_CATCH per QT_TRY, and do not use
+ the exception instance in the catch block.
+ If you can't live with those constraints, don't use these macros.
+ Use the QT_NO_EXCEPTIONS macro to protect your code instead.
+*/
+Q_NORETURN Q_DECL_COLD_FUNCTION Q_CORE_EXPORT void qTerminate() noexcept;
+#ifdef QT_NO_EXCEPTIONS
+# define QT_TRY if (true)
+# define QT_CATCH(A) else
+# define QT_THROW(A) qt_noop()
+# define QT_RETHROW qt_noop()
+# define QT_TERMINATE_ON_EXCEPTION(expr) do { expr; } while (false)
+#else
+# define QT_TRY try
+# define QT_CATCH(A) catch (A)
+# define QT_THROW(A) throw A
+# define QT_RETHROW throw
+# ifdef Q_COMPILER_NOEXCEPT
+# define QT_TERMINATE_ON_EXCEPTION(expr) do { expr; } while (false)
+# else
+# define QT_TERMINATE_ON_EXCEPTION(expr) do { try { expr; } catch (...) { qTerminate(); } } while (false)
+# endif
+#endif
+
+QT_END_NAMESPACE
+
+#endif // QEXCEPTIONHANDLING_H
diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h
index a23dbb53cd..26a8e5c9cf 100644
--- a/src/corelib/global/qflags.h
+++ b/src/corelib/global/qflags.h
@@ -24,7 +24,7 @@ public:
// Microsoft Visual Studio has buggy behavior when it comes to
// unsigned enums: even if the enum is unsigned, the enum tags are
// always signed
-# if !defined(__LP64__) && !defined(Q_CLANG_QDOC)
+# if !defined(__LP64__) && !defined(Q_QDOC)
constexpr inline Q_IMPLICIT QFlag(long value) noexcept : i(int(value)) {}
constexpr inline Q_IMPLICIT QFlag(ulong value) noexcept : i(int(long(value))) {}
# endif
@@ -57,7 +57,7 @@ class QFlags
static_assert((std::is_enum<Enum>::value), "QFlags is only usable on enumeration types.");
public:
-#if defined(Q_CC_MSVC) || defined(Q_CLANG_QDOC)
+#if defined(Q_CC_MSVC) || defined(Q_QDOC)
// see above for MSVC
// the definition below is too complex for qdoc
typedef int Int;
@@ -179,26 +179,35 @@ typedef QFlags<Enum> Flags;
// These are opt-in, for backwards compatibility
#define QT_DECLARE_TYPESAFE_OPERATORS_FOR_FLAGS_ENUM(Flags) \
+[[maybe_unused]] \
constexpr inline Flags operator~(Flags::enum_type e) noexcept \
{ return ~Flags(e); } \
+[[maybe_unused]] \
constexpr inline void operator|(Flags::enum_type f1, int f2) noexcept = delete;
#else
#define QT_DECLARE_TYPESAFE_OPERATORS_FOR_FLAGS_ENUM(Flags) \
+[[maybe_unused]] \
constexpr inline QIncompatibleFlag operator|(Flags::enum_type f1, int f2) noexcept \
{ return QIncompatibleFlag(int(f1) | f2); }
#endif
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags) \
+[[maybe_unused]] \
constexpr inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, Flags::enum_type f2) noexcept \
{ return QFlags<Flags::enum_type>(f1) | f2; } \
+[[maybe_unused]] \
constexpr inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, QFlags<Flags::enum_type> f2) noexcept \
{ return f2 | f1; } \
+[[maybe_unused]] \
constexpr inline QFlags<Flags::enum_type> operator&(Flags::enum_type f1, Flags::enum_type f2) noexcept \
{ return QFlags<Flags::enum_type>(f1) & f2; } \
+[[maybe_unused]] \
constexpr inline QFlags<Flags::enum_type> operator&(Flags::enum_type f1, QFlags<Flags::enum_type> f2) noexcept \
{ return f2 & f1; } \
+[[maybe_unused]] \
constexpr inline QFlags<Flags::enum_type> operator^(Flags::enum_type f1, Flags::enum_type f2) noexcept \
{ return QFlags<Flags::enum_type>(f1) ^ f2; } \
+[[maybe_unused]] \
constexpr inline QFlags<Flags::enum_type> operator^(Flags::enum_type f1, QFlags<Flags::enum_type> f2) noexcept \
{ return f2 ^ f1; } \
constexpr inline void operator+(Flags::enum_type f1, Flags::enum_type f2) noexcept = delete; \
@@ -218,6 +227,7 @@ QT_DECLARE_TYPESAFE_OPERATORS_FOR_FLAGS_ENUM(Flags)
#if __cplusplus > 201702L // assume compilers don't warn if in C++17 mode
// in C++20 mode, provide user-defined operators to override the deprecated operations:
# define Q_DECLARE_MIXED_ENUM_OPERATOR(op, Ret, LHS, RHS) \
+ [[maybe_unused]] \
constexpr inline Ret operator op (LHS lhs, RHS rhs) noexcept \
{ return static_cast<Ret>(qToUnderlying(lhs) op qToUnderlying(rhs)); } \
/* end */
diff --git a/src/corelib/global/qflags.qdoc b/src/corelib/global/qflags.qdoc
new file mode 100644
index 0000000000..4542d99268
--- /dev/null
+++ b/src/corelib/global/qflags.qdoc
@@ -0,0 +1,459 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \class QFlag
+ \inmodule QtCore
+ \brief The QFlag class is a helper data type for QFlags.
+
+ It is equivalent to a plain \c int, except with respect to
+ function overloading and type conversions. You should never need
+ to use this class in your applications.
+
+ \sa QFlags
+*/
+
+/*!
+ \fn QFlag::QFlag(int value)
+
+ Constructs a QFlag object that stores the \a value.
+*/
+
+/*!
+ \fn QFlag::QFlag(uint value)
+ \since 5.3
+
+ Constructs a QFlag object that stores the \a value.
+*/
+
+/*!
+ \fn QFlag::QFlag(short value)
+ \since 5.3
+
+ Constructs a QFlag object that stores the \a value.
+*/
+
+/*!
+ \fn QFlag::QFlag(ushort value)
+ \since 5.3
+
+ Constructs a QFlag object that stores the \a value.
+*/
+
+/*!
+ \fn QFlag::operator int() const
+
+ Returns the value stored by the QFlag object.
+*/
+
+/*!
+ \fn QFlag::operator uint() const
+ \since 5.3
+
+ Returns the value stored by the QFlag object.
+*/
+
+/*!
+ \class QFlags
+ \inmodule QtCore
+ \brief The QFlags class provides a type-safe way of storing
+ OR-combinations of enum values.
+
+
+ \ingroup tools
+
+ The QFlags<Enum> class is a template class, where Enum is an enum
+ type. QFlags is used throughout Qt for storing combinations of
+ enum values.
+
+ The traditional C++ approach for storing OR-combinations of enum
+ values is to use an \c int or \c uint variable. The inconvenience
+ with this approach is that there's no type checking at all; any
+ enum value can be OR'd with any other enum value and passed on to
+ a function that takes an \c int or \c uint.
+
+ Qt uses QFlags to provide type safety. For example, the
+ Qt::Alignment type is simply a typedef for
+ QFlags<Qt::AlignmentFlag>. QLabel::setAlignment() takes a
+ Qt::Alignment parameter, which means that any combination of
+ Qt::AlignmentFlag values, or \c{{ }}, is legal:
+
+ \snippet code/src_corelib_global_qglobal.cpp 0
+
+ If you try to pass a value from another enum or just a plain
+ integer other than 0, the compiler will report an error. If you
+ need to cast integer values to flags in a untyped fashion, you can
+ use the explicit QFlags constructor as cast operator.
+
+ If you want to use QFlags for your own enum types, use
+ the Q_DECLARE_FLAGS() and Q_DECLARE_OPERATORS_FOR_FLAGS().
+
+ Example:
+
+ \snippet code/src_corelib_global_qglobal.cpp 1
+
+ You can then use the \c MyClass::Options type to store
+ combinations of \c MyClass::Option values.
+
+ \section1 Flags and the Meta-Object System
+
+ The Q_DECLARE_FLAGS() macro does not expose the flags to the meta-object
+ system, so they cannot be used by Qt Script or edited in Qt Designer.
+ To make the flags available for these purposes, the Q_FLAG() macro must
+ be used:
+
+ \snippet code/src_corelib_global_qglobal.cpp meta-object flags
+
+ \section1 Naming Convention
+
+ A sensible naming convention for enum types and associated QFlags
+ types is to give a singular name to the enum type (e.g., \c
+ Option) and a plural name to the QFlags type (e.g., \c Options).
+ When a singular name is desired for the QFlags type (e.g., \c
+ Alignment), you can use \c Flag as the suffix for the enum type
+ (e.g., \c AlignmentFlag).
+
+ \sa QFlag
+*/
+
+/*!
+ \typedef QFlags::Int
+ \since 5.0
+
+ Typedef for the integer type used for storage as well as for
+ implicit conversion. Either \c int or \c{unsigned int}, depending
+ on whether the enum's underlying type is signed or unsigned.
+*/
+
+/*!
+ \typedef QFlags::enum_type
+
+ Typedef for the Enum template type.
+*/
+
+/*!
+ \fn template<typename Enum> QFlags<Enum>::QFlags(const QFlags &other)
+
+ Constructs a copy of \a other.
+*/
+
+/*!
+ \fn template <typename Enum> QFlags<Enum>::QFlags(Enum flags)
+
+ Constructs a QFlags object storing the \a flags.
+*/
+
+/*!
+ \fn template <typename Enum> QFlags<Enum>::QFlags()
+ \since 5.15
+
+ Constructs a QFlags object with no flags set.
+*/
+
+/*!
+ \fn template <typename Enum> QFlags<Enum>::QFlags(QFlag flag)
+
+ Constructs a QFlags object initialized with the integer \a flag.
+
+ The QFlag type is a helper type. By using it here instead of \c
+ int, we effectively ensure that arbitrary enum values cannot be
+ cast to a QFlags, whereas untyped enum values (i.e., \c int
+ values) can.
+*/
+
+/*!
+ \fn template <typename Enum> QFlags<Enum>::QFlags(std::initializer_list<Enum> flags)
+ \since 5.4
+
+ Constructs a QFlags object initialized with all \a flags
+ combined using the bitwise OR operator.
+
+ \sa operator|=(), operator|()
+*/
+
+/*!
+ \fn template <typename Enum> QFlags &QFlags<Enum>::operator=(const QFlags &other)
+
+ Assigns \e other to this object and returns a reference to this
+ object.
+*/
+
+/*!
+ \fn template <typename Enum> QFlags &QFlags<Enum>::operator&=(int mask)
+
+ Performs a bitwise AND operation with \a mask and stores the
+ result in this QFlags object. Returns a reference to this object.
+
+ \sa operator&(), operator|=(), operator^=()
+*/
+
+/*!
+ \fn template <typename Enum> QFlags &QFlags<Enum>::operator&=(uint mask)
+
+ \overload
+*/
+
+/*!
+ \fn template <typename Enum> QFlags &QFlags<Enum>::operator&=(Enum mask)
+
+ \overload
+*/
+
+/*!
+ \fn template <typename Enum> QFlags &QFlags<Enum>::operator&=(QFlags mask)
+ \since 6.2
+
+ \overload
+*/
+
+/*!
+ \fn template <typename Enum> QFlags &QFlags<Enum>::operator|=(QFlags other)
+
+ Performs a bitwise OR operation with \a other and stores the
+ result in this QFlags object. Returns a reference to this object.
+
+ \sa operator|(), operator&=(), operator^=()
+*/
+
+/*!
+ \fn template <typename Enum> QFlags &QFlags<Enum>::operator|=(Enum other)
+
+ \overload
+*/
+
+/*!
+ \fn template <typename Enum> QFlags &QFlags<Enum>::operator^=(QFlags other)
+
+ Performs a bitwise XOR operation with \a other and stores the
+ result in this QFlags object. Returns a reference to this object.
+
+ \sa operator^(), operator&=(), operator|=()
+*/
+
+/*!
+ \fn template <typename Enum> QFlags &QFlags<Enum>::operator^=(Enum other)
+
+ \overload
+*/
+
+/*!
+ \fn template <typename Enum> QFlags<Enum>::operator Int() const
+
+ Returns the value stored in the QFlags object as an integer.
+
+ \sa Int
+*/
+
+/*!
+ \fn template <typename Enum> QFlags QFlags<Enum>::operator|(QFlags other) const
+
+ Returns a QFlags object containing the result of the bitwise OR
+ operation on this object and \a other.
+
+ \sa operator|=(), operator^(), operator&(), operator~()
+*/
+
+/*!
+ \fn template <typename Enum> QFlags QFlags<Enum>::operator|(Enum other) const
+
+ \overload
+*/
+
+/*!
+ \fn template <typename Enum> QFlags QFlags<Enum>::operator^(QFlags other) const
+
+ Returns a QFlags object containing the result of the bitwise XOR
+ operation on this object and \a other.
+
+ \sa operator^=(), operator&(), operator|(), operator~()
+*/
+
+/*!
+ \fn template <typename Enum> QFlags QFlags<Enum>::operator^(Enum other) const
+
+ \overload
+*/
+
+/*!
+ \fn template <typename Enum> QFlags QFlags<Enum>::operator&(int mask) const
+
+ Returns a QFlags object containing the result of the bitwise AND
+ operation on this object and \a mask.
+
+ \sa operator&=(), operator|(), operator^(), operator~()
+*/
+
+/*!
+ \fn template <typename Enum> QFlags QFlags<Enum>::operator&(uint mask) const
+
+ \overload
+*/
+
+/*!
+ \fn template <typename Enum> QFlags QFlags<Enum>::operator&(Enum mask) const
+
+ \overload
+*/
+
+/*!
+ \fn template <typename Enum> QFlags QFlags<Enum>::operator&(QFlags mask) const
+ \since 6.2
+
+ \overload
+*/
+
+/*!
+ \fn template <typename Enum> QFlags QFlags<Enum>::operator~() const
+
+ Returns a QFlags object that contains the bitwise negation of
+ this object.
+
+ \sa operator&(), operator|(), operator^()
+*/
+
+/*!
+ \fn template <typename Enum> bool QFlags<Enum>::operator!() const
+
+ Returns \c true if no flag is set (i.e., if the value stored by the
+ QFlags object is 0); otherwise returns \c false.
+*/
+
+/*!
+ \fn template <typename Enum> bool QFlags<Enum>::testFlag(Enum flag) const
+ \since 4.2
+
+ Returns \c true if the flag \a flag is set, otherwise \c false.
+
+ \note if \a flag contains multiple bits set to 1 (for instance, if
+ it's an enumerator equal to the bitwise-OR of other enumerators)
+ then this function will return \c true if and only if all the bits
+ are set in this flags object. On the other hand, if \a flag contains
+ no bits set to 1 (that is, its value as a integer is 0), then this
+ function will return \c true if and only if this flags object also
+ has no bits set to 1.
+
+ \sa testAnyFlag()
+*/
+
+/*!
+ \fn template <typename Enum> bool QFlags<Enum>::testFlags(QFlags flags) const noexcept
+ \since 6.2
+
+ Returns \c true if this flags object matches the given \a flags.
+
+ If \a flags has any flags set, this flags object matches precisely
+ if all flags set in \a flags are also set in this flags object.
+ Otherwise, when \a flags has no flags set, this flags object only
+ matches if it also has no flags set.
+
+ \sa testAnyFlags()
+*/
+
+/*!
+ \fn template <typename Enum> bool QFlags<Enum>::testAnyFlag(Enum flag) const noexcept
+ \since 6.2
+
+ Returns \c true if \b any flag set in \a flag is also set in this
+ flags object, otherwise \c false. If \a flag has no flags set, the
+ return will always be \c false.
+
+ \sa testFlag()
+*/
+
+/*!
+ \fn template <typename Enum> bool QFlags<Enum>::testAnyFlags(QFlags flags) const noexcept
+ \since 6.2
+
+ Returns \c true if \b any flag set in \a flags is also set in this
+ flags object, otherwise \c false. If \a flags has no flags set, the
+ return will always be \c false.
+
+ \sa testFlags()
+*/
+
+/*!
+ \fn template <typename Enum> QFlags QFlags<Enum>::setFlag(Enum flag, bool on)
+ \since 5.7
+
+ Sets the flag \a flag if \a on is \c true or unsets it if
+ \a on is \c false. Returns a reference to this object.
+*/
+
+/*!
+ \fn template <typename Enum> QFlags<Enum> QFlags<Enum>::fromInt(Int i) noexcept
+ \since 6.2
+
+ Constructs a QFlags object representing the integer value \a i.
+*/
+
+/*!
+ \fn template <typename Enum> Int QFlags<Enum>::toInt() const noexcept
+ \since 6.2
+
+ Returns the value stored in the QFlags object as an integer. Note
+ that the returned integer may be signed or unsigned, depending on
+ whether the enum's underlying type is signed or unsigned.
+
+ \sa Int
+*/
+
+/*!
+ \fn template <typename Enum> size_t qHash(QFlags<Enum> flags, size_t seed = 0) noexcept
+ \since 6.2
+ \relates QFlags
+
+ Calculates the hash for the flags \a flags, using \a seed
+ to seed the calculation.
+*/
+
+/*!
+ \fn template <typename Enum> bool operator==(QFlags<Enum> lhs, QFlags<Enum> rhs)
+ \fn template <typename Enum> bool operator==(QFlags<Enum> lhs, Enum rhs)
+ \fn template <typename Enum> bool operator==(Enum lhs, QFlags<Enum> rhs)
+ \since 6.2
+ \relates QFlags
+
+ Compares \a lhs and \a rhs for equality; the two arguments are
+ considered equal if they represent exactly the same value
+ (bitmask).
+*/
+
+/*!
+ \fn template <typename Enum> bool operator!=(QFlags<Enum> lhs, QFlags<Enum> rhs)
+ \fn template <typename Enum> bool operator!=(QFlags<Enum> lhs, Enum rhs)
+ \fn template <typename Enum> bool operator!=(Enum lhs, QFlags<Enum> rhs)
+ \since 6.2
+ \relates QFlags
+
+ Compares \a lhs and \a rhs for inequality; the two arguments are
+ considered different if they don't represent exactly the same value
+ (bitmask).
+*/
+
+/*!
+ \macro Q_DECLARE_FLAGS(Flags, Enum)
+ \relates QFlags
+
+ The Q_DECLARE_FLAGS() macro expands to
+
+ \snippet code/src_corelib_global_qglobal.cpp 2
+
+ \a Enum is the name of an existing enum type, whereas \a Flags is
+ the name of the QFlags<\e{Enum}> typedef.
+
+ See the QFlags documentation for details.
+
+ \sa Q_DECLARE_OPERATORS_FOR_FLAGS()
+*/
+
+/*!
+ \macro Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
+ \relates QFlags
+
+ The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global \c
+ operator|() functions for \a Flags, which is of type QFlags<T>.
+
+ See the QFlags documentation for details.
+
+ \sa Q_DECLARE_FLAGS()
+*/
diff --git a/src/corelib/global/qfloat16.cpp b/src/corelib/global/qfloat16.cpp
index b7f1a559b1..b8e7cbe928 100644
--- a/src/corelib/global/qfloat16.cpp
+++ b/src/corelib/global/qfloat16.cpp
@@ -7,7 +7,10 @@
#include <cmath> // for fpclassify()'s return values
#include <QtCore/qdatastream.h>
+#include <QtCore/qmetatype.h>
+#include <QtCore/qtextstream.h>
+QT_DECL_METATYPE_EXTERN(qfloat16, Q_CORE_EXPORT)
QT_BEGIN_NAMESPACE
QT_IMPL_METATYPE_EXTERN(qfloat16)
@@ -395,6 +398,19 @@ QDataStream &operator>>(QDataStream &ds, qfloat16 &f)
}
#endif
+QTextStream &operator>>(QTextStream &ts, qfloat16 &f16)
+{
+ float f;
+ ts >> f;
+ f16 = qfloat16(f);
+ return ts;
+}
+
+QTextStream &operator<<(QTextStream &ts, qfloat16 f)
+{
+ return ts << float(f);
+}
+
QT_END_NAMESPACE
#include "qfloat16tables.cpp"
diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h
index fc0d9e2702..89919f4e90 100644
--- a/src/corelib/global/qfloat16.h
+++ b/src/corelib/global/qfloat16.h
@@ -6,11 +6,16 @@
#define QFLOAT16_H
#include <QtCore/qglobal.h>
-#include <QtCore/qmetatype.h>
+#include <QtCore/qmath.h>
#include <QtCore/qnamespace.h>
#include <limits>
#include <string.h>
+#if defined(__STDCPP_FLOAT16_T__) && __has_include(<stdfloat>)
+// P1467 implementation - https://wg21.link/p1467
+# include <stdfloat>
+#endif
+
#if defined(QT_COMPILER_SUPPORTS_F16C) && defined(__AVX2__) && !defined(__F16C__)
// All processors that support AVX2 do support F16C too, so we could enable the
// feature unconditionally if __AVX2__ is defined. However, all currently
@@ -35,6 +40,7 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_DATASTREAM
class QDataStream;
#endif
+class QTextStream;
class qfloat16
{
@@ -45,11 +51,41 @@ class qfloat16
quint16 b16;
constexpr inline explicit Wrap(int value) : b16(quint16(value)) {}
};
+
public:
+#if defined(__STDCPP_FLOAT16_T__)
+# define QFLOAT16_IS_NATIVE 1
+ using NativeType = std::float16_t;
+#elif defined(Q_CC_CLANG) && defined(__FLT16_MAX__) && 0
+ // disabled due to https://github.com/llvm/llvm-project/issues/56963
+# define QFLOAT16_IS_NATIVE 1
+ using NativeType = decltype(__FLT16_MAX__);
+#elif defined(Q_CC_GNU_ONLY) && defined(__FLT16_MAX__)
+# define QFLOAT16_IS_NATIVE 1
+# ifdef __ARM_FP16_FORMAT_IEEE
+ using NativeType = __fp16;
+# else
+ using NativeType = _Float16;
+# endif
+#else
+# define QFLOAT16_IS_NATIVE 0
+ using NativeType = void;
+#endif
+ static constexpr bool IsNative = QFLOAT16_IS_NATIVE;
+ using NearestFloat = std::conditional_t<IsNative, NativeType, float>;
+
constexpr inline qfloat16() noexcept : b16(0) {}
explicit qfloat16(Qt::Initialization) noexcept { }
+
+#if QFLOAT16_IS_NATIVE
+ constexpr inline qfloat16(NativeType f) : f(f) {}
+ constexpr operator NativeType() const noexcept { return f; }
+#else
inline qfloat16(float f) noexcept;
inline operator float() const noexcept;
+#endif
+ template <typename T, typename = std::enable_if_t<std::is_arithmetic_v<T> && !std::is_same_v<T, NearestFloat>>>
+ explicit qfloat16(T value) noexcept : qfloat16(NearestFloat(value)) {}
// Support for qIs{Inf,NaN,Finite}:
bool isInf() const noexcept { return (b16 & 0x7fff) == 0x7c00; }
@@ -73,7 +109,18 @@ public:
inline constexpr bool isNormal() const noexcept
{ return (b16 & 0x7c00) && (b16 & 0x7c00) != 0x7c00; }
private:
- quint16 b16;
+ // ABI note: Qt 6's qfloat16 began with just a quint16 member so it ended
+ // up passed in general purpose registers in any function call taking
+ // qfloat16 by value (it has trivial copy constructors). This means the
+ // integer member in the anonymous union below must remain until a
+ // binary-incompatible version of Qt. If you remove it, on platforms using
+ // the System V ABI for C, the native type is passed in FP registers.
+ union {
+ quint16 b16;
+#if QFLOAT16_IS_NATIVE
+ NativeType f;
+#endif
+ };
constexpr inline explicit qfloat16(Wrap nibble) noexcept : b16(nibble.b16) {}
Q_CORE_EXPORT static const quint32 mantissatable[];
@@ -92,17 +139,17 @@ private:
return f;
}
- friend inline qfloat16 operator+(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast<float>(a) + static_cast<float>(b)); }
- friend inline qfloat16 operator-(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast<float>(a) - static_cast<float>(b)); }
- friend inline qfloat16 operator*(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast<float>(a) * static_cast<float>(b)); }
- friend inline qfloat16 operator/(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast<float>(a) / static_cast<float>(b)); }
+ friend inline qfloat16 operator+(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast<NearestFloat>(a) + static_cast<NearestFloat>(b)); }
+ friend inline qfloat16 operator-(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast<NearestFloat>(a) - static_cast<NearestFloat>(b)); }
+ friend inline qfloat16 operator*(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast<NearestFloat>(a) * static_cast<NearestFloat>(b)); }
+ friend inline qfloat16 operator/(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast<NearestFloat>(a) / static_cast<NearestFloat>(b)); }
#define QF16_MAKE_ARITH_OP_FP(FP, OP) \
friend inline FP operator OP(qfloat16 lhs, FP rhs) noexcept { return static_cast<FP>(lhs) OP rhs; } \
friend inline FP operator OP(FP lhs, qfloat16 rhs) noexcept { return lhs OP static_cast<FP>(rhs); }
#define QF16_MAKE_ARITH_OP_EQ_FP(FP, OP_EQ, OP) \
friend inline qfloat16& operator OP_EQ(qfloat16& lhs, FP rhs) noexcept \
- { lhs = qfloat16(float(static_cast<FP>(lhs) OP rhs)); return lhs; }
+ { lhs = qfloat16(NearestFloat(static_cast<FP>(lhs) OP rhs)); return lhs; }
#define QF16_MAKE_ARITH_OP(FP) \
QF16_MAKE_ARITH_OP_FP(FP, +) \
QF16_MAKE_ARITH_OP_FP(FP, -) \
@@ -116,6 +163,9 @@ private:
QF16_MAKE_ARITH_OP(long double)
QF16_MAKE_ARITH_OP(double)
QF16_MAKE_ARITH_OP(float)
+#if QFLOAT16_IS_NATIVE
+ QF16_MAKE_ARITH_OP(NativeType)
+#endif
#undef QF16_MAKE_ARITH_OP
#undef QF16_MAKE_ARITH_OP_FP
@@ -132,12 +182,12 @@ private:
QT_WARNING_PUSH
QT_WARNING_DISABLE_FLOAT_COMPARE
- friend inline bool operator>(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) > static_cast<float>(b); }
- friend inline bool operator<(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) < static_cast<float>(b); }
- friend inline bool operator>=(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) >= static_cast<float>(b); }
- friend inline bool operator<=(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) <= static_cast<float>(b); }
- friend inline bool operator==(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) == static_cast<float>(b); }
- friend inline bool operator!=(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) != static_cast<float>(b); }
+ friend inline bool operator>(qfloat16 a, qfloat16 b) noexcept { return static_cast<NearestFloat>(a) > static_cast<NearestFloat>(b); }
+ friend inline bool operator<(qfloat16 a, qfloat16 b) noexcept { return static_cast<NearestFloat>(a) < static_cast<NearestFloat>(b); }
+ friend inline bool operator>=(qfloat16 a, qfloat16 b) noexcept { return static_cast<NearestFloat>(a) >= static_cast<NearestFloat>(b); }
+ friend inline bool operator<=(qfloat16 a, qfloat16 b) noexcept { return static_cast<NearestFloat>(a) <= static_cast<NearestFloat>(b); }
+ friend inline bool operator==(qfloat16 a, qfloat16 b) noexcept { return static_cast<NearestFloat>(a) == static_cast<NearestFloat>(b); }
+ friend inline bool operator!=(qfloat16 a, qfloat16 b) noexcept { return static_cast<NearestFloat>(a) != static_cast<NearestFloat>(b); }
#define QF16_MAKE_BOOL_OP_FP(FP, OP) \
friend inline bool operator OP(qfloat16 lhs, FP rhs) noexcept { return static_cast<FP>(lhs) OP rhs; } \
@@ -157,8 +207,8 @@ QT_WARNING_DISABLE_FLOAT_COMPARE
#undef QF16_MAKE_BOOL_OP_FP
#define QF16_MAKE_BOOL_OP_INT(OP) \
- friend inline bool operator OP(qfloat16 a, int b) noexcept { return static_cast<float>(a) OP static_cast<float>(b); } \
- friend inline bool operator OP(int a, qfloat16 b) noexcept { return static_cast<float>(a) OP static_cast<float>(b); }
+ friend inline bool operator OP(qfloat16 a, int b) noexcept { return static_cast<NearestFloat>(a) OP static_cast<NearestFloat>(b); } \
+ friend inline bool operator OP(int a, qfloat16 b) noexcept { return static_cast<NearestFloat>(a) OP static_cast<NearestFloat>(b); }
QF16_MAKE_BOOL_OP_INT(>)
QF16_MAKE_BOOL_OP_INT(<)
@@ -174,6 +224,8 @@ QT_WARNING_POP
friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &ds, qfloat16 f);
friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &ds, qfloat16 &f);
#endif
+ friend Q_CORE_EXPORT QTextStream &operator<<(QTextStream &ts, qfloat16 f);
+ friend Q_CORE_EXPORT QTextStream &operator>>(QTextStream &ts, qfloat16 &f);
};
Q_DECLARE_TYPEINFO(qfloat16, Q_PRIMITIVE_TYPE);
@@ -188,6 +240,43 @@ Q_CORE_EXPORT void qFloatFromFloat16(float *, const qfloat16 *, qsizetype length
[[nodiscard]] inline int qFpClassify(qfloat16 f) noexcept { return f.fpClassify(); }
// [[nodiscard]] quint32 qFloatDistance(qfloat16 a, qfloat16 b);
+[[nodiscard]] inline qfloat16 qSqrt(qfloat16 f)
+{
+#if defined(__cpp_lib_extended_float) && defined(__STDCPP_FLOAT16_T__) && 0
+ // https://wg21.link/p1467 - disabled until tested
+ using namespace std;
+ return sqrt(f);
+#elif QFLOAT16_IS_NATIVE && defined(__HAVE_FLOAT16) && __HAVE_FLOAT16
+ // This C library (glibc) has sqrtf16().
+ return sqrtf16(f);
+#else
+ bool mathUpdatesErrno = true;
+# if defined(__NO_MATH_ERRNO__) || defined(_M_FP_FAST)
+ mathUpdatesErrno = false;
+# elif defined(math_errhandling)
+ mathUpdatesErrno = (math_errhandling & MATH_ERRNO);
+# endif
+
+ // We don't need to set errno to EDOM if (f >= 0 && f != -0 && !isnan(f))
+ // (or if we don't care about errno in the first place). We can merge the
+ // NaN check with by negating and inverting: !(0 > f), and leaving zero to
+ // sqrtf().
+ if (!mathUpdatesErrno || !(0 > f)) {
+# if defined(__AVX512FP16__)
+ __m128h v = _mm_set_sh(f);
+ v = _mm_sqrt_sh(v, v);
+ return _mm_cvtsh_h(v);
+# endif
+ }
+
+ // WG14's N2601 does not provide a way to tell which types an
+ // implementation supports, so we assume it doesn't and fall back to FP32
+ float f32 = float(f);
+ f32 = sqrtf(f32);
+ return qfloat16::NearestFloat(f32);
+#endif
+}
+
// The remainder of these utility functions complement qglobal.h
[[nodiscard]] inline int qRound(qfloat16 d) noexcept
{ return qRound(static_cast<float>(d)); }
@@ -197,8 +286,8 @@ Q_CORE_EXPORT void qFloatFromFloat16(float *, const qfloat16 *, qsizetype length
[[nodiscard]] inline bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
{
- float f1 = static_cast<float>(p1);
- float f2 = static_cast<float>(p2);
+ qfloat16::NearestFloat f1 = static_cast<qfloat16::NearestFloat>(p1);
+ qfloat16::NearestFloat f2 = static_cast<qfloat16::NearestFloat>(p2);
// The significand precision for IEEE754 half precision is
// 11 bits (10 explicitly stored), or approximately 3 decimal
// digits. In selecting the fuzzy comparison factor of 102.5f
@@ -222,9 +311,9 @@ Q_CORE_EXPORT void qFloatFromFloat16(float *, const qfloat16 *, qsizetype length
}
inline int qIntCast(qfloat16 f) noexcept
-{ return int(static_cast<float>(f)); }
+{ return int(static_cast<qfloat16::NearestFloat>(f)); }
-#ifndef Q_QDOC
+#if !defined(Q_QDOC) && !QFLOAT16_IS_NATIVE
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wc99-extensions")
QT_WARNING_DISABLE_GCC("-Wold-style-cast")
@@ -284,33 +373,52 @@ inline qfloat16::operator float() const noexcept
return f;
#endif
}
-#endif
+#endif // Q_QDOC and non-native
/*
qHypot compatibility; see ../kernel/qmath.h
*/
namespace QtPrivate {
-template <typename R>
-struct QHypotType<R, qfloat16> { using type = decltype(std::hypot(R(1), 1.0f)); };
-template <typename R>
-struct QHypotType<qfloat16, R> { using type = decltype(std::hypot(1.0f, R(1))); };
-template <> struct QHypotType<qfloat16, qfloat16> { using type = qfloat16; };
+template <> struct QHypotType<qfloat16, qfloat16>
+{
+ using type = qfloat16;
+};
+template <typename R> struct QHypotType<R, qfloat16>
+{
+ using type = std::conditional_t<std::is_floating_point_v<R>, R, double>;
+};
+template <typename R> struct QHypotType<qfloat16, R> : QHypotType<R, qfloat16>
+{
+};
}
+
// Avoid passing qfloat16 to std::hypot(), while ensuring return types
// consistent with the above:
-template<typename F, typename ...Fs> auto qHypot(F first, Fs... rest);
-template <typename T, typename std::enable_if<!std::is_same<qfloat16, T>::value, int>::type = 0>
-auto qHypot(T x, qfloat16 y) { return qHypot(x, float(y)); }
-template <typename T, typename std::enable_if<!std::is_same<qfloat16, T>::value, int>::type = 0>
-auto qHypot(qfloat16 x, T y) { return qHypot(float(x), y); }
-template <> inline auto qHypot(qfloat16 x, qfloat16 y)
+inline auto qHypot(qfloat16 x, qfloat16 y)
{
-#if (defined(QT_COMPILER_SUPPORTS_F16C) && defined(__F16C__)) || defined (__ARM_FP16_FORMAT_IEEE)
+#if defined(QT_COMPILER_SUPPORTS_F16C) && defined(__F16C__) || QFLOAT16_IS_NATIVE
return QtPrivate::QHypotHelper<qfloat16>(x).add(y).result();
#else
return qfloat16(qHypot(float(x), float(y)));
#endif
}
+
+// in ../kernel/qmath.h
+template<typename F, typename ...Fs> auto qHypot(F first, Fs... rest);
+
+template <typename T> typename QtPrivate::QHypotType<T, qfloat16>::type
+qHypot(T x, qfloat16 y)
+{
+ if constexpr (std::is_floating_point_v<T>)
+ return qHypot(x, float(y));
+ else
+ return qHypot(qfloat16(x), y);
+}
+template <typename T> auto qHypot(qfloat16 x, T y)
+{
+ return qHypot(y, x);
+}
+
#if defined(__cpp_lib_hypot) && __cpp_lib_hypot >= 201603L // Expected to be true
// If any are not qfloat16, convert each qfloat16 to float:
/* (The following splits the some-but-not-all-qfloat16 cases up, using
@@ -320,22 +428,22 @@ template <typename Ty, typename Tz,
typename std::enable_if<
// Ty, Tz aren't both qfloat16:
!(std::is_same_v<qfloat16, Ty> && std::is_same_v<qfloat16, Tz>), int>::type = 0>
-auto qHypot(qfloat16 x, Ty y, Tz z) { return qHypot(float(x), y, z); }
+auto qHypot(qfloat16 x, Ty y, Tz z) { return qHypot(qfloat16::NearestFloat(x), y, z); }
template <typename Tx, typename Tz,
typename std::enable_if<
// Tx isn't qfloat16:
!std::is_same_v<qfloat16, Tx>, int>::type = 0>
-auto qHypot(Tx x, qfloat16 y, Tz z) { return qHypot(x, float(y), z); }
+auto qHypot(Tx x, qfloat16 y, Tz z) { return qHypot(x, qfloat16::NearestFloat(y), z); }
template <typename Tx, typename Ty,
typename std::enable_if<
// Neither Tx nor Ty is qfloat16:
!std::is_same_v<qfloat16, Tx> && !std::is_same_v<qfloat16, Ty>, int>::type = 0>
-auto qHypot(Tx x, Ty y, qfloat16 z) { return qHypot(x, y, float(z)); }
+auto qHypot(Tx x, Ty y, qfloat16 z) { return qHypot(x, y, qfloat16::NearestFloat(z)); }
+
// If all are qfloat16, stay with qfloat16 (albeit via float, if no native support):
-template <>
inline auto qHypot(qfloat16 x, qfloat16 y, qfloat16 z)
{
-#if (defined(QT_COMPILER_SUPPORTS_F16C) && defined(__F16C__)) || defined (__ARM_FP16_FORMAT_IEEE)
+#if (defined(QT_COMPILER_SUPPORTS_F16C) && defined(__F16C__)) || QFLOAT16_IS_NATIVE
return QtPrivate::QHypotHelper<qfloat16>(x).add(y).add(z).result();
#else
return qfloat16(qHypot(float(x), float(y), float(z)));
@@ -345,8 +453,6 @@ inline auto qHypot(qfloat16 x, qfloat16 y, qfloat16 z)
QT_END_NAMESPACE
-QT_DECL_METATYPE_EXTERN(qfloat16, Q_CORE_EXPORT)
-
namespace std {
template<>
class numeric_limits<QT_PREPEND_NAMESPACE(qfloat16)> : public numeric_limits<float>
diff --git a/src/corelib/global/qforeach.h b/src/corelib/global/qforeach.h
index 95d68f31e4..ab0e20b989 100644
--- a/src/corelib/global/qforeach.h
+++ b/src/corelib/global/qforeach.h
@@ -1,12 +1,14 @@
-// Copyright (C) 2020 The Qt Company Ltd.
+// Copyright (C) 2022 The Qt Company Ltd.
// Copyright (C) 2019 Intel Corporation.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QFOREACH_H
#define QFOREACH_H
-#include <QtCore/qglobal.h>
+#include <QtCore/qtclasshelpermacros.h>
+#include <QtCore/qtconfigmacros.h>
#include <QtCore/qtdeprecationmarkers.h>
+#include <QtCore/qttypetraits.h>
QT_BEGIN_NAMESPACE
@@ -21,31 +23,13 @@ namespace QtPrivate {
template <typename T>
class QForeachContainer {
- Q_DISABLE_COPY(QForeachContainer)
+ Q_DISABLE_COPY_MOVE(QForeachContainer)
public:
- QForeachContainer(const T &t) : c(t), i(qAsConst(c).begin()), e(qAsConst(c).end()) {}
- QForeachContainer(T &&t) : c(std::move(t)), i(qAsConst(c).begin()), e(qAsConst(c).end()) {}
-
- QForeachContainer(QForeachContainer &&other)
- : c(std::move(other.c)),
- i(qAsConst(c).begin()),
- e(qAsConst(c).end()),
- control(std::move(other.control))
- {
- }
-
- QForeachContainer &operator=(QForeachContainer &&other)
- {
- c = std::move(other.c);
- i = qAsConst(c).begin();
- e = qAsConst(c).end();
- control = std::move(other.control);
- return *this;
- }
+ QForeachContainer(const T &t) : c(t), i(std::as_const(c).begin()), e(std::as_const(c).end()) {}
+ QForeachContainer(T &&t) : c(std::move(t)), i(std::as_const(c).begin()), e(std::as_const(c).end()) {}
T c;
typename T::const_iterator i, e;
- int control = 1;
};
// Containers that have a detach function are considered shared, and are OK in a foreach loop
diff --git a/src/corelib/global/qforeach.qdoc b/src/corelib/global/qforeach.qdoc
new file mode 100644
index 0000000000..e6abf0e29c
--- /dev/null
+++ b/src/corelib/global/qforeach.qdoc
@@ -0,0 +1,72 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \macro forever
+ \relates <QForeach>
+
+ This macro is provided for convenience for writing infinite
+ loops.
+
+ Example:
+
+ \snippet code/src_corelib_global_qglobal.cpp 31
+
+ It is equivalent to \c{for (;;)}.
+
+ If you're worried about namespace pollution, you can disable this
+ macro by adding the following line to your \c .pro file:
+
+ \snippet code/src_corelib_global_qglobal.cpp 32
+
+ If using other build systems, you can add \c QT_NO_KEYWORDS to the
+ list of pre-defined macros.
+
+ \sa Q_FOREVER
+*/
+
+/*!
+ \macro Q_FOREVER
+ \relates <QForeach>
+
+ Same as \l{forever}.
+
+ This macro is available even when \c no_keywords is specified
+ using the \c .pro file's \c CONFIG variable.
+
+ \sa foreach()
+*/
+
+/*!
+ \macro foreach(variable, container)
+ \relates <QForeach>
+
+ This macro is used to implement Qt's \c foreach loop. The \a
+ variable parameter is a variable name or variable definition; the
+ \a container parameter is a Qt container whose value type
+ corresponds to the type of the variable. See \l{The foreach
+ Keyword} for details.
+
+ If you're worried about namespace pollution, you can disable this
+ macro by adding the following line to your \c .pro file:
+
+ \snippet code/src_corelib_global_qglobal.cpp 33
+
+ \note Since Qt 5.7, the use of this macro is discouraged.
+ Use C++11 range-based \c for, possibly with \c {std::as_const()},
+ as needed.
+*/
+
+/*!
+ \macro Q_FOREACH(variable, container)
+ \relates <QForeach>
+
+ Same as foreach(\a variable, \a container).
+
+ This macro is available even when \c no_keywords is specified
+ using the \c .pro file's \c CONFIG variable.
+
+ \note Since Qt 5.7, the use of this macro is discouraged.
+ Use C++11 range-based \c for, possibly with \c {std::as_const()},
+ as needed.
+*/
diff --git a/src/corelib/global/qfunctionpointer.h b/src/corelib/global/qfunctionpointer.h
new file mode 100644
index 0000000000..3884954f89
--- /dev/null
+++ b/src/corelib/global/qfunctionpointer.h
@@ -0,0 +1,23 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#ifndef QFUNCTIONPOINTER_H
+#define QFUNCTIONPOINTER_H
+
+#include <QtCore/qtconfigmacros.h>
+
+#if 0
+#pragma qt_class(QFunctionPointer)
+#endif
+
+#if defined(__cplusplus)
+
+QT_BEGIN_NAMESPACE
+
+typedef void (*QFunctionPointer)();
+
+QT_END_NAMESPACE
+
+#endif // __cplusplus
+
+#endif // QFUNCTIONPOINTER_H
diff --git a/src/corelib/global/qfunctionpointer.qdoc b/src/corelib/global/qfunctionpointer.qdoc
new file mode 100644
index 0000000000..13f82bc011
--- /dev/null
+++ b/src/corelib/global/qfunctionpointer.qdoc
@@ -0,0 +1,9 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*! \typedef QFunctionPointer
+ \relates <QFunctionPointer>
+
+ This is a typedef for \c{void (*)()}, a pointer to a function that takes
+ no arguments and returns void.
+*/
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 2852beaaab..238b9cf4b4 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -8,26 +8,14 @@
#include "qlist.h"
#include "qdir.h"
#include "qdatetime.h"
-#include "qoperatingsystemversion.h"
-#include "qoperatingsystemversion_p.h"
-#if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
-# include "qoperatingsystemversion_win_p.h"
-# include "private/qwinregistry_p.h"
-#endif // Q_OS_WIN || Q_OS_CYGWIN
#include <private/qlocale_tools_p.h>
#include "qnativeinterface.h"
#include "qnativeinterface_p.h"
#include <stdlib.h>
-#include <limits.h>
#include <stdarg.h>
#include <string.h>
-#include <exception> // For std::terminate
-#ifndef QT_NO_EXCEPTIONS
-#include <new> // For std::bad_alloc
-#endif
-
#include <errno.h>
#if defined(Q_CC_MSVC)
# include <crtdbg.h>
@@ -41,28 +29,6 @@
# include <envLib.h>
#endif
-#ifdef Q_OS_ANDROID
-#include <qjniobject.h>
-#endif
-
-#if defined(Q_OS_SOLARIS)
-# include <sys/systeminfo.h>
-#endif
-
-#if defined(Q_OS_DARWIN) && __has_include(<IOKit/IOKitLib.h>)
-# include <IOKit/IOKitLib.h>
-# include <private/qcore_mac_p.h>
-#endif
-
-#ifdef Q_OS_UNIX
-#include <sys/utsname.h>
-#include <private/qcore_unix_p.h>
-#endif
-
-#ifdef Q_OS_BSD4
-#include <sys/sysctl.h>
-#endif
-
#if defined(Q_OS_INTEGRITY)
extern "C" {
// Function mmap resides in libshm_client.a. To be able to link with it one needs
@@ -76,8 +42,6 @@ extern "C" {
}
#endif
-#include "archdetect.cpp"
-
#ifdef qFatal
// the qFatal in this file are just redirections from elsewhere, so
// don't capture any context again
@@ -88,2922 +52,59 @@ QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
-// Statically check assumptions about the environment we're running
-// in. The idea here is to error or warn if otherwise implicit Qt
-// assumptions are not fulfilled on new hardware or compilers
-// (if this list becomes too long, consider factoring into a separate file)
-static_assert(UCHAR_MAX == 255, "Qt assumes that char is 8 bits");
-static_assert(sizeof(int) == 4, "Qt assumes that int is 32 bits");
-static_assert(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined incorrectly");
-static_assert(sizeof(float) == 4, "Qt assumes that float is 32 bits");
-static_assert(sizeof(char16_t) == 2, "Qt assumes that char16_t is 16 bits");
-static_assert(sizeof(char32_t) == 4, "Qt assumes that char32_t is 32 bits");
-#if defined(Q_OS_WIN)
-static_assert(sizeof(wchar_t) == sizeof(char16_t));
-#endif
-static_assert(std::numeric_limits<int>::radix == 2,
- "Qt assumes binary integers");
-static_assert((std::numeric_limits<int>::max() + std::numeric_limits<int>::lowest()) == -1,
- "Qt assumes two's complement integers");
-static_assert(sizeof(wchar_t) == sizeof(char32_t) || sizeof(wchar_t) == sizeof(char16_t),
- "Qt assumes wchar_t is compatible with either char32_t or char16_t");
-
-// While we'd like to check for __STDC_IEC_559__, as per ISO/IEC 9899:2011
-// Annex F (C11, normative for C++11), there are a few corner cases regarding
-// denormals where GHS compiler is relying hardware behavior that is not IEC
-// 559 compliant. So split the check in several subchecks.
-
-// On GHS the compiler reports std::numeric_limits<float>::is_iec559 as false.
-// This is all right according to our needs.
-#if !defined(Q_CC_GHS)
-static_assert(std::numeric_limits<float>::is_iec559,
- "Qt assumes IEEE 754 floating point");
-#endif
-
-// Technically, presence of NaN and infinities are implied from the above check,
-// but double checking our environment doesn't hurt...
-static_assert(std::numeric_limits<float>::has_infinity &&
- std::numeric_limits<float>::has_quiet_NaN,
- "Qt assumes IEEE 754 floating point");
-
-// is_iec559 checks for ISO/IEC/IEEE 60559:2011 (aka IEEE 754-2008) compliance,
-// but that allows for a non-binary radix. We need to recheck that.
-// Note how __STDC_IEC_559__ would instead check for IEC 60559:1989, aka
-// ANSI/IEEE 754−1985, which specifically implies binary floating point numbers.
-static_assert(std::numeric_limits<float>::radix == 2,
- "Qt assumes binary IEEE 754 floating point");
-
-// not required by the definition of size_t, but we depend on this
-static_assert(sizeof(size_t) == sizeof(void *), "size_t and a pointer don't have the same size");
-static_assert(sizeof(size_t) == sizeof(qsizetype)); // implied by the definition
-static_assert((std::is_same<qsizetype, qptrdiff>::value));
-
-// Check that our own typedefs are not broken.
-static_assert(sizeof(qint8) == 1, "Internal error, qint8 is misdefined");
-static_assert(sizeof(qint16)== 2, "Internal error, qint16 is misdefined");
-static_assert(sizeof(qint32) == 4, "Internal error, qint32 is misdefined");
-static_assert(sizeof(qint64) == 8, "Internal error, qint64 is misdefined");
-
-/*!
- \class QFlag
- \inmodule QtCore
- \brief The QFlag class is a helper data type for QFlags.
-
- It is equivalent to a plain \c int, except with respect to
- function overloading and type conversions. You should never need
- to use this class in your applications.
-
- \sa QFlags
-*/
-
-/*!
- \fn QFlag::QFlag(int value)
-
- Constructs a QFlag object that stores the \a value.
-*/
-
-/*!
- \fn QFlag::QFlag(uint value)
- \since 5.3
-
- Constructs a QFlag object that stores the \a value.
-*/
-
-/*!
- \fn QFlag::QFlag(short value)
- \since 5.3
-
- Constructs a QFlag object that stores the \a value.
-*/
-
-/*!
- \fn QFlag::QFlag(ushort value)
- \since 5.3
-
- Constructs a QFlag object that stores the \a value.
-*/
-
-/*!
- \fn QFlag::operator int() const
-
- Returns the value stored by the QFlag object.
-*/
-
-/*!
- \fn QFlag::operator uint() const
- \since 5.3
-
- Returns the value stored by the QFlag object.
-*/
-
-/*!
- \class QFlags
- \inmodule QtCore
- \brief The QFlags class provides a type-safe way of storing
- OR-combinations of enum values.
-
-
- \ingroup tools
-
- The QFlags<Enum> class is a template class, where Enum is an enum
- type. QFlags is used throughout Qt for storing combinations of
- enum values.
-
- The traditional C++ approach for storing OR-combinations of enum
- values is to use an \c int or \c uint variable. The inconvenience
- with this approach is that there's no type checking at all; any
- enum value can be OR'd with any other enum value and passed on to
- a function that takes an \c int or \c uint.
-
- Qt uses QFlags to provide type safety. For example, the
- Qt::Alignment type is simply a typedef for
- QFlags<Qt::AlignmentFlag>. QLabel::setAlignment() takes a
- Qt::Alignment parameter, which means that any combination of
- Qt::AlignmentFlag values, or \c{{ }}, is legal:
-
- \snippet code/src_corelib_global_qglobal.cpp 0
-
- If you try to pass a value from another enum or just a plain
- integer other than 0, the compiler will report an error. If you
- need to cast integer values to flags in a untyped fashion, you can
- use the explicit QFlags constructor as cast operator.
-
- If you want to use QFlags for your own enum types, use
- the Q_DECLARE_FLAGS() and Q_DECLARE_OPERATORS_FOR_FLAGS().
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp 1
-
- You can then use the \c MyClass::Options type to store
- combinations of \c MyClass::Option values.
-
- \section1 Flags and the Meta-Object System
-
- The Q_DECLARE_FLAGS() macro does not expose the flags to the meta-object
- system, so they cannot be used by Qt Script or edited in Qt Designer.
- To make the flags available for these purposes, the Q_FLAG() macro must
- be used:
-
- \snippet code/src_corelib_global_qglobal.cpp meta-object flags
-
- \section1 Naming Convention
-
- A sensible naming convention for enum types and associated QFlags
- types is to give a singular name to the enum type (e.g., \c
- Option) and a plural name to the QFlags type (e.g., \c Options).
- When a singular name is desired for the QFlags type (e.g., \c
- Alignment), you can use \c Flag as the suffix for the enum type
- (e.g., \c AlignmentFlag).
-
- \sa QFlag
-*/
-
-/*!
- \typedef QFlags::Int
- \since 5.0
-
- Typedef for the integer type used for storage as well as for
- implicit conversion. Either \c int or \c{unsigned int}, depending
- on whether the enum's underlying type is signed or unsigned.
-*/
-
-/*!
- \typedef QFlags::enum_type
-
- Typedef for the Enum template type.
-*/
-
-/*!
- \fn template<typename Enum> QFlags<Enum>::QFlags(const QFlags &other)
-
- Constructs a copy of \a other.
-*/
-
-/*!
- \fn template <typename Enum> QFlags<Enum>::QFlags(Enum flags)
-
- Constructs a QFlags object storing the \a flags.
-*/
-
-/*!
- \fn template <typename Enum> QFlags<Enum>::QFlags()
- \since 5.15
-
- Constructs a QFlags object with no flags set.
-*/
-
-/*!
- \fn template <typename Enum> QFlags<Enum>::QFlags(QFlag flag)
-
- Constructs a QFlags object initialized with the integer \a flag.
-
- The QFlag type is a helper type. By using it here instead of \c
- int, we effectively ensure that arbitrary enum values cannot be
- cast to a QFlags, whereas untyped enum values (i.e., \c int
- values) can.
-*/
-
-/*!
- \fn template <typename Enum> QFlags<Enum>::QFlags(std::initializer_list<Enum> flags)
- \since 5.4
-
- Constructs a QFlags object initialized with all \a flags
- combined using the bitwise OR operator.
-
- \sa operator|=(), operator|()
-*/
-
-/*!
- \fn template <typename Enum> QFlags &QFlags<Enum>::operator=(const QFlags &other)
-
- Assigns \e other to this object and returns a reference to this
- object.
-*/
-
-/*!
- \fn template <typename Enum> QFlags &QFlags<Enum>::operator&=(int mask)
-
- Performs a bitwise AND operation with \a mask and stores the
- result in this QFlags object. Returns a reference to this object.
-
- \sa operator&(), operator|=(), operator^=()
-*/
-
-/*!
- \fn template <typename Enum> QFlags &QFlags<Enum>::operator&=(uint mask)
-
- \overload
-*/
-
-/*!
- \fn template <typename Enum> QFlags &QFlags<Enum>::operator&=(Enum mask)
-
- \overload
-*/
-
-/*!
- \fn template <typename Enum> QFlags &QFlags<Enum>::operator&=(QFlags mask)
- \since 6.2
-
- \overload
-*/
-
-/*!
- \fn template <typename Enum> QFlags &QFlags<Enum>::operator|=(QFlags other)
-
- Performs a bitwise OR operation with \a other and stores the
- result in this QFlags object. Returns a reference to this object.
-
- \sa operator|(), operator&=(), operator^=()
-*/
-
-/*!
- \fn template <typename Enum> QFlags &QFlags<Enum>::operator|=(Enum other)
-
- \overload
-*/
-
-/*!
- \fn template <typename Enum> QFlags &QFlags<Enum>::operator^=(QFlags other)
-
- Performs a bitwise XOR operation with \a other and stores the
- result in this QFlags object. Returns a reference to this object.
-
- \sa operator^(), operator&=(), operator|=()
-*/
-
-/*!
- \fn template <typename Enum> QFlags &QFlags<Enum>::operator^=(Enum other)
-
- \overload
-*/
-
-/*!
- \fn template <typename Enum> QFlags<Enum>::operator Int() const
-
- Returns the value stored in the QFlags object as an integer.
-
- \sa Int
-*/
-
-/*!
- \fn template <typename Enum> QFlags QFlags<Enum>::operator|(QFlags other) const
-
- Returns a QFlags object containing the result of the bitwise OR
- operation on this object and \a other.
-
- \sa operator|=(), operator^(), operator&(), operator~()
-*/
-
-/*!
- \fn template <typename Enum> QFlags QFlags<Enum>::operator|(Enum other) const
-
- \overload
-*/
-
-/*!
- \fn template <typename Enum> QFlags QFlags<Enum>::operator^(QFlags other) const
-
- Returns a QFlags object containing the result of the bitwise XOR
- operation on this object and \a other.
-
- \sa operator^=(), operator&(), operator|(), operator~()
-*/
-
-/*!
- \fn template <typename Enum> QFlags QFlags<Enum>::operator^(Enum other) const
-
- \overload
-*/
-
-/*!
- \fn template <typename Enum> QFlags QFlags<Enum>::operator&(int mask) const
-
- Returns a QFlags object containing the result of the bitwise AND
- operation on this object and \a mask.
-
- \sa operator&=(), operator|(), operator^(), operator~()
-*/
-
-/*!
- \fn template <typename Enum> QFlags QFlags<Enum>::operator&(uint mask) const
-
- \overload
-*/
-
-/*!
- \fn template <typename Enum> QFlags QFlags<Enum>::operator&(Enum mask) const
-
- \overload
-*/
-
-/*!
- \fn template <typename Enum> QFlags QFlags<Enum>::operator&(QFlags mask) const
- \since 6.2
-
- \overload
-*/
-
-/*!
- \fn template <typename Enum> QFlags QFlags<Enum>::operator~() const
-
- Returns a QFlags object that contains the bitwise negation of
- this object.
-
- \sa operator&(), operator|(), operator^()
-*/
-
-/*!
- \fn template <typename Enum> bool QFlags<Enum>::operator!() const
-
- Returns \c true if no flag is set (i.e., if the value stored by the
- QFlags object is 0); otherwise returns \c false.
-*/
-
-/*!
- \fn template <typename Enum> bool QFlags<Enum>::testFlag(Enum flag) const
- \since 4.2
-
- Returns \c true if the flag \a flag is set, otherwise \c false.
-
- \note if \a flag contains multiple bits set to 1 (for instance, if
- it's an enumerator equal to the bitwise-OR of other enumerators)
- then this function will return \c true if and only if all the bits
- are set in this flags object. On the other hand, if \a flag contains
- no bits set to 1 (that is, its value as a integer is 0), then this
- function will return \c true if and only if this flags object also
- has no bits set to 1.
-
- \sa testAnyFlag()
-*/
-
-/*!
- \fn template <typename Enum> bool QFlags<Enum>::testFlags(QFlags flags) const noexcept
- \since 6.2
-
- Returns \c true if this flags object matches the given \a flags.
-
- If \a flags has any flags set, this flags object matches precisely
- if all flags set in \a flags are also set in this flags object.
- Otherwise, when \a flags has no flags set, this flags object only
- matches if it also has no flags set.
-
- \sa testAnyFlags()
-*/
-
-/*!
- \fn template <typename Enum> bool QFlags<Enum>::testAnyFlag(Enum flag) const noexcept
- \since 6.2
-
- Returns \c true if \b any flag set in \a flag is also set in this
- flags object, otherwise \c false. If \a flag has no flags set, the
- return will always be \c false.
-
- \sa testFlag()
-*/
-
-/*!
- \fn template <typename Enum> bool QFlags<Enum>::testAnyFlags(QFlags flags) const noexcept
- \since 6.2
-
- Returns \c true if \b any flag set in \a flags is also set in this
- flags object, otherwise \c false. If \a flags has no flags set, the
- return will always be \c false.
-
- \sa testFlags()
-*/
-
-/*!
- \fn template <typename Enum> QFlags QFlags<Enum>::setFlag(Enum flag, bool on)
- \since 5.7
-
- Sets the flag \a flag if \a on is \c true or unsets it if
- \a on is \c false. Returns a reference to this object.
-*/
-
-/*!
- \fn template <typename Enum> QFlags<Enum> QFlags<Enum>::fromInt(Int i) noexcept
- \since 6.2
-
- Constructs a QFlags object representing the integer value \a i.
-*/
-
-/*!
- \fn template <typename Enum> Int QFlags<Enum>::toInt() const noexcept
- \since 6.2
-
- Returns the value stored in the QFlags object as an integer. Note
- that the returned integer may be signed or unsigned, depending on
- whether the enum's underlying type is signed or unsigned.
-
- \sa Int
-*/
-
-/*!
- \fn template <typename Enum> size_t qHash(QFlags<Enum> flags, size_t seed = 0) noexcept
- \since 6.2
- \relates QFlags
-
- Calculates the hash for the flags \a flags, using \a seed
- to seed the calculation.
-*/
-
-/*!
- \fn template <typename Enum> bool operator==(QFlags<Enum> lhs, QFlags<Enum> rhs)
- \fn template <typename Enum> bool operator==(QFlags<Enum> lhs, Enum rhs)
- \fn template <typename Enum> bool operator==(Enum lhs, QFlags<Enum> rhs)
- \since 6.2
- \relates QFlags
-
- Compares \a lhs and \a rhs for equality; the two arguments are
- considered equal if they represent exactly the same value
- (bitmask).
-*/
-
-/*!
- \fn template <typename Enum> bool operator!=(QFlags<Enum> lhs, QFlags<Enum> rhs)
- \fn template <typename Enum> bool operator!=(QFlags<Enum> lhs, Enum rhs)
- \fn template <typename Enum> bool operator!=(Enum lhs, QFlags<Enum> rhs)
- \since 6.2
- \relates QFlags
-
- Compares \a lhs and \a rhs for inequality; the two arguments are
- considered different if they don't represent exactly the same value
- (bitmask).
-*/
-
-/*!
- \macro Q_DISABLE_COPY(Class)
- \relates QObject
-
- Disables the use of copy constructors and assignment operators
- for the given \a Class.
-
- Instances of subclasses of QObject should not be thought of as
- values that can be copied or assigned, but as unique identities.
- This means that when you create your own subclass of QObject
- (director or indirect), you should \e not give it a copy constructor
- or an assignment operator. However, it may not enough to simply
- omit them from your class, because, if you mistakenly write some code
- that requires a copy constructor or an assignment operator (it's easy
- to do), your compiler will thoughtfully create it for you. You must
- do more.
-
- The curious user will have seen that the Qt classes derived
- from QObject typically include this macro in a private section:
-
- \snippet code/src_corelib_global_qglobal.cpp 43
-
- It declares a copy constructor and an assignment operator in the
- private section, so that if you use them by mistake, the compiler
- will report an error.
-
- \snippet code/src_corelib_global_qglobal.cpp 44
-
- But even this might not catch absolutely every case. You might be
- tempted to do something like this:
-
- \snippet code/src_corelib_global_qglobal.cpp 45
-
- First of all, don't do that. Most compilers will generate code that
- uses the copy constructor, so the privacy violation error will be
- reported, but your C++ compiler is not required to generate code for
- this statement in a specific way. It could generate code using
- \e{neither} the copy constructor \e{nor} the assignment operator we
- made private. In that case, no error would be reported, but your
- application would probably crash when you called a member function
- of \c{w}.
-
- \sa Q_DISABLE_COPY_MOVE
-*/
-
-/*!
- \macro Q_DISABLE_COPY_MOVE(Class)
- \relates QObject
-
- A convenience macro that disables the use of copy constructors, assignment
- operators, move constructors and move assignment operators for the given
- \a Class.
-
- \sa Q_DISABLE_COPY
- \since 5.13
-*/
-
-/*!
- \macro Q_DECLARE_FLAGS(Flags, Enum)
- \relates QFlags
-
- The Q_DECLARE_FLAGS() macro expands to
-
- \snippet code/src_corelib_global_qglobal.cpp 2
-
- \a Enum is the name of an existing enum type, whereas \a Flags is
- the name of the QFlags<\e{Enum}> typedef.
-
- See the QFlags documentation for details.
-
- \sa Q_DECLARE_OPERATORS_FOR_FLAGS()
-*/
-
-/*!
- \macro Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
- \relates QFlags
-
- The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global \c
- operator|() functions for \a Flags, which is of type QFlags<T>.
-
- See the QFlags documentation for details.
-
- \sa Q_DECLARE_FLAGS()
-*/
-
/*!
\headerfile <QtGlobal>
\inmodule QtCore
\title Global Qt Declarations
\ingroup funclists
- \brief The <QtGlobal> header file includes the fundamental global
- declarations. It is included by most other Qt header files.
-
- The global declarations include \l{types}, \l{functions} and
- \l{macros}.
-
- The type definitions are partly convenience definitions for basic
- types (some of which guarantee certain bit-sizes on all platforms
- supported by Qt), partly types related to Qt message handling. The
- functions are related to generating messages, Qt version handling
- and comparing and adjusting object values. And finally, some of
- the declared macros enable programmers to add compiler or platform
- specific code to their applications, while others are convenience
- macros for larger operations.
-
- \section1 Types
-
- The header file declares several type definitions that guarantee a
- specified bit-size on all platforms supported by Qt for various
- basic types, for example \l qint8 which is a signed char
- guaranteed to be 8-bit on all platforms supported by Qt. The
- header file also declares the \l qlonglong type definition for \c
- {long long int } (\c __int64 on Windows).
-
- Several convenience type definitions are declared: \l qreal for \c
- double or \c float, \l uchar for \c unsigned char, \l uint for \c unsigned
- int, \l ulong for \c unsigned long and \l ushort for \c unsigned
- short.
-
- Finally, the QtMsgType definition identifies the various messages
- that can be generated and sent to a Qt message handler;
- QtMessageHandler is a type definition for a pointer to a function with
- the signature
- \c {void myMessageHandler(QtMsgType, const QMessageLogContext &, const char *)}.
- QMessageLogContext class contains the line, file, and function the
- message was logged at. This information is created by the QMessageLogger
- class.
-
- \section1 Functions
-
- The <QtGlobal> header file contains several functions comparing
- and adjusting an object's value. These functions take a template
- type as argument: You can retrieve the absolute value of an object
- using the qAbs() function, and you can bound a given object's
- value by given minimum and maximum values using the qBound()
- function. You can retrieve the minimum and maximum of two given
- objects using qMin() and qMax() respectively. All these functions
- return a corresponding template type; the template types can be
- replaced by any other type.
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp 3
-
- <QtGlobal> also contains functions that generate messages from the
- given string argument: qDebug(), qInfo(), qWarning(), qCritical(),
- and qFatal(). These functions call the message handler
- with the given message.
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp 4
-
- The remaining functions are qRound() and qRound64(), which both
- accept a \c double or \c float value as their argument returning
- the value rounded up to the nearest integer and 64-bit integer
- respectively, the qInstallMessageHandler() function which installs
- the given QtMessageHandler, and the qVersion() function which
- returns the version number of Qt at runtime as a string.
-
- \section1 Macros
-
- The <QtGlobal> header file provides a range of macros (Q_CC_*)
- that are defined if the application is compiled using the
- specified platforms. For example, the Q_CC_SUN macro is defined if
- the application is compiled using Forte Developer, or Sun Studio
- C++. The header file also declares a range of macros (Q_OS_*)
- that are defined for the specified platforms. For example,
- Q_OS_UNIX which is defined for the Unix-based systems.
-
- The purpose of these macros is to enable programmers to add
- compiler or platform specific code to their application.
-
- The remaining macros are convenience macros for larger operations:
- The QT_TR_NOOP(), QT_TRANSLATE_NOOP(), and QT_TRANSLATE_NOOP3()
- macros provide the possibility of marking strings for delayed
- translation. QT_TR_N_NOOP(), QT_TRANSLATE_N_NOOP(), and
- QT_TRANSLATE_N_NOOP3() are numerator dependent variants of these.
- The Q_ASSERT() and Q_ASSERT_X() enables warning messages of various
- level of refinement. The Q_FOREACH() and foreach() macros
- implement Qt's foreach loop.
-
- The Q_INT64_C() and Q_UINT64_C() macros wrap signed and unsigned
- 64-bit integer literals in a platform-independent way. The
- Q_CHECK_PTR() macro prints a warning containing the source code's
- file name and line number, saying that the program ran out of
- memory, if the pointer is \nullptr. The qPrintable() and qUtf8Printable()
- macros represent an easy way of printing text.
-
- The QT_POINTER_SIZE macro expands to the size of a pointer in bytes.
-
- The macros QT_VERSION and QT_VERSION_STR expand to a numeric value or a
- string, respectively. These identify the version of Qt that the application
- is compiled with.
-
- \sa <QtAlgorithms>, QSysInfo
-*/
-
-/*!
- \typedef qreal
- \relates <QtGlobal>
-
- Typedef for \c double unless Qt is configured with the
- \c{-qreal float} option.
-*/
-
-/*! \typedef uchar
- \relates <QtGlobal>
-
- Convenience typedef for \c{unsigned char}.
-*/
-
-/*! \typedef ushort
- \relates <QtGlobal>
-
- Convenience typedef for \c{unsigned short}.
-*/
-
-/*! \typedef uint
- \relates <QtGlobal>
-
- Convenience typedef for \c{unsigned int}.
-*/
-
-/*! \typedef ulong
- \relates <QtGlobal>
-
- Convenience typedef for \c{unsigned long}.
-*/
-
-/*! \typedef qint8
- \relates <QtGlobal>
-
- Typedef for \c{signed char}. This type is guaranteed to be 8-bit
- on all platforms supported by Qt.
-*/
-
-/*!
- \typedef quint8
- \relates <QtGlobal>
-
- Typedef for \c{unsigned char}. This type is guaranteed to
- be 8-bit on all platforms supported by Qt.
-*/
-
-/*! \typedef qint16
- \relates <QtGlobal>
-
- Typedef for \c{signed short}. This type is guaranteed to be
- 16-bit on all platforms supported by Qt.
-*/
-
-/*!
- \typedef quint16
- \relates <QtGlobal>
-
- Typedef for \c{unsigned short}. This type is guaranteed to
- be 16-bit on all platforms supported by Qt.
-*/
-
-/*! \typedef qint32
- \relates <QtGlobal>
-
- Typedef for \c{signed int}. This type is guaranteed to be 32-bit
- on all platforms supported by Qt.
-*/
-
-/*!
- \typedef quint32
- \relates <QtGlobal>
-
- Typedef for \c{unsigned int}. This type is guaranteed to
- be 32-bit on all platforms supported by Qt.
-*/
-
-/*! \typedef qint64
- \relates <QtGlobal>
-
- Typedef for \c{long long int}. This type is guaranteed to be 64-bit
- on all platforms supported by Qt.
-
- Literals of this type can be created using the Q_INT64_C() macro:
-
- \snippet code/src_corelib_global_qglobal.cpp 5
-
- \sa Q_INT64_C(), quint64, qlonglong
-*/
-
-/*!
- \typedef quint64
- \relates <QtGlobal>
-
- Typedef for \c{unsigned long long int}. This type is guaranteed to
- be 64-bit on all platforms supported by Qt.
-
- Literals of this type can be created using the Q_UINT64_C()
- macro:
-
- \snippet code/src_corelib_global_qglobal.cpp 6
-
- \sa Q_UINT64_C(), qint64, qulonglong
-*/
-
-/*!
- \typedef qintptr
- \relates <QtGlobal>
-
- Integral type for representing pointers in a signed integer (useful for
- hashing, etc.).
-
- Typedef for either qint32 or qint64. This type is guaranteed to
- be the same size as a pointer on all platforms supported by Qt. On
- a system with 32-bit pointers, qintptr is a typedef for qint32;
- on a system with 64-bit pointers, qintptr is a typedef for
- qint64.
-
- Note that qintptr is signed. Use quintptr for unsigned values.
-
- In order to print values of this type by using formatted-output
- facilities such as \c{printf()}, qDebug(), QString::asprintf() and
- so on, you can use the \c{PRIdQINTPTR} and \c{PRIiQINTPTR}
- macros as format specifiers. They will both print the value as a
- base 10 number.
-
- \code
- qintptr p = 123;
- printf("The pointer is %" PRIdQINTPTR "\n", p);
- \endcode
-
- \sa qptrdiff, qint32, qint64
-*/
-
-/*!
- \macro PRIdQINTPTR
- \macro PRIiQINTPTR
- \since 6.2
- \relates <QtGlobal>
-
- See qintptr.
-*/
-
-/*!
- \typedef quintptr
- \relates <QtGlobal>
-
- Integral type for representing pointers in an unsigned integer (useful for
- hashing, etc.).
-
- Typedef for either quint32 or quint64. This type is guaranteed to
- be the same size as a pointer on all platforms supported by Qt. On
- a system with 32-bit pointers, quintptr is a typedef for quint32;
- on a system with 64-bit pointers, quintptr is a typedef for
- quint64.
-
- Note that quintptr is unsigned. Use qptrdiff for signed values.
-
- In order to print values of this type by using formatted-output
- facilities such as \c{printf()}, qDebug(), QString::asprintf() and
- so on, you can use the following macros as format specifiers:
-
- \list
- \li \c{PRIuQUINTPTR}: prints the value as a base 10 number.
- \li \c{PRIoQUINTPTR}: prints the value as a base 8 number.
- \li \c{PRIxQUINTPTR}: prints the value as a base 16 number, using lowercase \c{a-f} letters.
- \li \c{PRIXQUINTPTR}: prints the value as a base 16 number, using uppercase \c{A-F} letters.
- \endlist
-
- \code
- quintptr p = 123u;
- printf("The pointer value is 0x%" PRIXQUINTPTR "\n", p);
- \endcode
-
- \sa qptrdiff, quint32, quint64
-*/
-
-/*!
- \macro PRIoQUINTPTR
- \macro PRIuQUINTPTR
- \macro PRIxQUINTPTR
- \macro PRIXQUINTPTR
- \since 6.2
- \relates <QtGlobal>
-
- See quintptr.
-*/
-
-/*!
- \typedef qptrdiff
- \relates <QtGlobal>
-
- Integral type for representing pointer differences.
-
- Typedef for either qint32 or qint64. This type is guaranteed to be
- the same size as a pointer on all platforms supported by Qt. On a
- system with 32-bit pointers, quintptr is a typedef for quint32; on
- a system with 64-bit pointers, quintptr is a typedef for quint64.
-
- Note that qptrdiff is signed. Use quintptr for unsigned values.
-
- In order to print values of this type by using formatted-output
- facilities such as \c{printf()}, qDebug(), QString::asprintf() and
- so on, you can use the \c{PRIdQPTRDIFF} and \c{PRIiQPTRDIFF}
- macros as format specifiers. They will both print the value as a
- base 10 number.
-
- \code
- qptrdiff d = 123;
- printf("The difference is %" PRIdQPTRDIFF "\n", d);
- \endcode
-
- \sa quintptr, qint32, qint64
-*/
-
-/*!
- \macro PRIdQPTRDIFF
- \macro PRIiQPTRDIFF
- \since 6.2
- \relates <QtGlobal>
-
- See qptrdiff.
-*/
-
-/*!
- \typedef qsizetype
- \relates <QtGlobal>
- \since 5.10
-
- Integral type providing Posix' \c ssize_t for all platforms.
-
- This type is guaranteed to be the same size as a \c size_t on all
- platforms supported by Qt.
-
- Note that qsizetype is signed. Use \c size_t for unsigned values.
-
- In order to print values of this type by using formatted-output
- facilities such as \c{printf()}, qDebug(), QString::asprintf() and
- so on, you can use the \c{PRIdQSIZETYPE} and \c{PRIiQSIZETYPE}
- macros as format specifiers. They will both print the value as a
- base 10 number.
-
- \code
- qsizetype s = 123;
- printf("The size is %" PRIdQSIZETYPE "\n", s);
- \endcode
-
- \sa qptrdiff
-*/
-
-/*!
- \macro PRIdQSIZETYPE
- \macro PRIiQSIZETYPE
- \since 6.2
- \relates <QtGlobal>
-
- See qsizetype.
-*/
-
-/*!
- \enum QtMsgType
- \relates <QtGlobal>
-
- This enum describes the messages that can be sent to a message
- handler (QtMessageHandler). You can use the enum to identify and
- associate the various message types with the appropriate
- actions.
-
- \value QtDebugMsg
- A message generated by the qDebug() function.
- \value QtInfoMsg
- A message generated by the qInfo() function.
- \value QtWarningMsg
- A message generated by the qWarning() function.
- \value QtCriticalMsg
- A message generated by the qCritical() function.
- \value QtFatalMsg
- A message generated by the qFatal() function.
- \value QtSystemMsg
-
- \c QtInfoMsg was added in Qt 5.5.
-
- \sa QtMessageHandler, qInstallMessageHandler()
-*/
-
-/*! \typedef QFunctionPointer
- \relates <QFunctionPointer>
-
- This is a typedef for \c{void (*)()}, a pointer to a function that takes
- no arguments and returns void.
-*/
-
-/*! \macro qint64 Q_INT64_C(literal)
- \relates <QtGlobal>
-
- Wraps the signed 64-bit integer \a literal in a
- platform-independent way.
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp 8
-
- \sa qint64, Q_UINT64_C()
-*/
-
-/*! \macro quint64 Q_UINT64_C(literal)
- \relates <QtGlobal>
-
- Wraps the unsigned 64-bit integer \a literal in a
- platform-independent way.
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp 9
-
- \sa quint64, Q_INT64_C()
-*/
-
-/*! \typedef qlonglong
- \relates <QtGlobal>
-
- Typedef for \c{long long int} (\c __int64 on Windows). This is
- the same as \l qint64.
-
- \sa qulonglong, qint64
-*/
-
-/*!
- \typedef qulonglong
- \relates <QtGlobal>
-
- Typedef for \c{unsigned long long int} (\c{unsigned __int64} on
- Windows). This is the same as \l quint64.
-
- \sa quint64, qlonglong
-*/
-
-/*! \fn template <typename T> T qAbs(const T &t)
- \relates <QtNumeric>
-
- Compares \a t to the 0 of type T and returns the absolute
- value. Thus if T is \e {double}, then \a t is compared to
- \e{(double) 0}.
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp 10
-*/
-
-/*! \fn int qRound(double d)
- \relates <QtNumeric>
-
- Rounds \a d to the nearest integer.
-
- Rounds half away from zero (e.g. 0.5 -> 1, -0.5 -> -1).
-
- \note This function does not guarantee correctness for high precisions.
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp 11A
-*/
-
-/*! \fn int qRound(float d)
- \relates <QtNumeric>
-
- Rounds \a d to the nearest integer.
-
- Rounds half away from zero (e.g. 0.5f -> 1, -0.5f -> -1).
-
- \note This function does not guarantee correctness for high precisions.
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp 11B
-*/
-
-/*! \fn qint64 qRound64(double d)
- \relates <QtNumeric>
-
- Rounds \a d to the nearest 64-bit integer.
-
- Rounds half away from zero (e.g. 0.5 -> 1, -0.5 -> -1).
-
- \note This function does not guarantee correctness for high precisions.
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp 12A
-*/
-
-/*! \fn qint64 qRound64(float d)
- \relates <QtNumeric>
-
- Rounds \a d to the nearest 64-bit integer.
-
- Rounds half away from zero (e.g. 0.5f -> 1, -0.5f -> -1).
-
- \note This function does not guarantee correctness for high precisions.
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp 12B
-*/
-
-/*! \fn template <typename T> const T &qMin(const T &a, const T &b)
- \relates <QtGlobal>
-
- Returns the minimum of \a a and \a b.
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp 13
-
- \sa qMax(), qBound()
-*/
-
-/*! \fn template <typename T> const T &qMax(const T &a, const T &b)
- \relates <QtGlobal>
-
- Returns the maximum of \a a and \a b.
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp 14
-
- \sa qMin(), qBound()
-*/
-
-/*! \fn template <typename T> const T &qBound(const T &min, const T &val, const T &max)
- \relates <QtGlobal>
-
- Returns \a val bounded by \a min and \a max. This is equivalent
- to qMax(\a min, qMin(\a val, \a max)).
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp 15
-
- \sa qMin(), qMax()
-*/
-
-/*!
- \macro QT_VERSION_STR
- \relates <QtGlobal>
-
- This macro expands to a string that specifies Qt's version number (for
- example, "6.1.2"). This is the version with which the application is
- compiled. This may be a different version than the version the application
- will find itself using at \e runtime.
-
- \sa qVersion(), QT_VERSION
-*/
-
-/*!
- \relates <QtGlobal>
-
- Returns the version number of Qt at runtime as a string (for example,
- "6.1.2"). This may be a different version than the version the application
- was \e compiled with.
-
- \sa QT_VERSION_STR, QLibraryInfo::version()
-*/
-
-const char *qVersion() noexcept
-{
- return QT_VERSION_STR;
-}
-
-bool qSharedBuild() noexcept
-{
-#ifdef QT_SHARED
- return true;
-#else
- return false;
-#endif
-}
-
-/*****************************************************************************
- System detection routines
- *****************************************************************************/
-
-/*!
- \class QSysInfo
- \inmodule QtCore
- \brief The QSysInfo class provides information about the system.
-
- \list
- \li \l WordSize specifies the size of a pointer for the platform
- on which the application is compiled.
- \li \l ByteOrder specifies whether the platform is big-endian or
- little-endian.
- \endlist
-
- Some constants are defined only on certain platforms. You can use
- the preprocessor symbols Q_OS_WIN and Q_OS_MACOS to test that
- the application is compiled under Windows or \macos.
-
- \sa QLibraryInfo
-*/
-
-/*!
- \enum QSysInfo::Sizes
-
- This enum provides platform-specific information about the sizes of data
- structures used by the underlying architecture.
-
- \value WordSize The size in bits of a pointer for the platform on which
- the application is compiled (32 or 64).
-*/
-
-/*!
- \enum QSysInfo::Endian
-
- \value BigEndian Big-endian byte order (also called Network byte order)
- \value LittleEndian Little-endian byte order
- \value ByteOrder Equals BigEndian or LittleEndian, depending on
- the platform's byte order.
-*/
-
-/*!
- \macro Q_OS_DARWIN
- \relates <QtGlobal>
-
- Defined on Darwin-based operating systems such as \macos, iOS, watchOS, and tvOS.
-*/
-
-/*!
- \macro Q_OS_MAC
- \relates <QtGlobal>
-
- Deprecated synonym for \c Q_OS_DARWIN. Do not use.
-*/
-
-/*!
- \macro Q_OS_OSX
- \relates <QtGlobal>
-
- Deprecated synonym for \c Q_OS_MACOS. Do not use.
-*/
-
-/*!
- \macro Q_OS_MACOS
- \relates <QtGlobal>
-
- Defined on \macos.
-*/
-
-/*!
- \macro Q_OS_IOS
- \relates <QtGlobal>
-
- Defined on iOS.
-*/
-
-/*!
- \macro Q_OS_WATCHOS
- \relates <QtGlobal>
-
- Defined on watchOS.
-*/
-
-/*!
- \macro Q_OS_TVOS
- \relates <QtGlobal>
-
- Defined on tvOS.
-*/
-
-/*!
- \macro Q_OS_WIN
- \relates <QtGlobal>
-
- Defined on all supported versions of Windows. That is, if
- \l Q_OS_WIN32 or \l Q_OS_WIN64 is defined.
-*/
-
-/*!
- \macro Q_OS_WINDOWS
- \relates <QtGlobal>
-
- This is a synonym for Q_OS_WIN.
-*/
-
-/*!
- \macro Q_OS_WIN32
- \relates <QtGlobal>
-
- Defined on 32-bit and 64-bit versions of Windows.
-*/
-
-/*!
- \macro Q_OS_WIN64
- \relates <QtGlobal>
-
- Defined on 64-bit versions of Windows.
-*/
-
-/*!
- \macro Q_OS_CYGWIN
- \relates <QtGlobal>
-
- Defined on Cygwin.
-*/
-
-/*!
- \macro Q_OS_SOLARIS
- \relates <QtGlobal>
-
- Defined on Sun Solaris.
-*/
-
-/*!
- \macro Q_OS_HPUX
- \relates <QtGlobal>
-
- Defined on HP-UX.
-*/
-
-/*!
- \macro Q_OS_LINUX
- \relates <QtGlobal>
-
- Defined on Linux.
-*/
-
-/*!
- \macro Q_OS_ANDROID
- \relates <QtGlobal>
-
- Defined on Android.
-*/
-
-/*!
- \macro Q_OS_FREEBSD
- \relates <QtGlobal>
-
- Defined on FreeBSD.
-*/
-
-/*!
- \macro Q_OS_NETBSD
- \relates <QtGlobal>
-
- Defined on NetBSD.
-*/
-
-/*!
- \macro Q_OS_OPENBSD
- \relates <QtGlobal>
-
- Defined on OpenBSD.
-*/
-
-/*!
- \macro Q_OS_AIX
- \relates <QtGlobal>
-
- Defined on AIX.
-*/
-
-/*!
- \macro Q_OS_HURD
- \relates <QtGlobal>
-
- Defined on GNU Hurd.
-*/
-
-/*!
- \macro Q_OS_QNX
- \relates <QtGlobal>
-
- Defined on QNX Neutrino.
-*/
-
-/*!
- \macro Q_OS_LYNX
- \relates <QtGlobal>
-
- Defined on LynxOS.
-*/
-
-/*!
- \macro Q_OS_BSD4
- \relates <QtGlobal>
-
- Defined on Any BSD 4.4 system.
-*/
-
-/*!
- \macro Q_OS_UNIX
- \relates <QtGlobal>
-
- Defined on Any UNIX BSD/SYSV system.
-*/
-
-/*!
- \macro Q_OS_WASM
- \relates <QtGlobal>
-
- Defined on Web Assembly.
-*/
-
-/*!
- \macro Q_CC_SYM
- \relates <QtGlobal>
-
- Defined if the application is compiled using Digital Mars C/C++
- (used to be Symantec C++).
-*/
-
-/*!
- \macro Q_CC_MSVC
- \relates <QtGlobal>
-
- Defined if the application is compiled using Microsoft Visual
- C/C++, Intel C++ for Windows.
-*/
-
-/*!
- \macro Q_CC_CLANG
- \relates <QtGlobal>
-
- Defined if the application is compiled using Clang.
-*/
-
-/*!
- \macro Q_CC_BOR
- \relates <QtGlobal>
-
- Defined if the application is compiled using Borland/Turbo C++.
-*/
-
-/*!
- \macro Q_CC_WAT
- \relates <QtGlobal>
-
- Defined if the application is compiled using Watcom C++.
-*/
-
-/*!
- \macro Q_CC_GNU
- \relates <QtGlobal>
-
- Defined if the application is compiled using GNU C++.
-*/
-
-/*!
- \macro Q_CC_COMEAU
- \relates <QtGlobal>
-
- Defined if the application is compiled using Comeau C++.
-*/
-
-/*!
- \macro Q_CC_EDG
- \relates <QtGlobal>
-
- Defined if the application is compiled using Edison Design Group
- C++.
-*/
-
-/*!
- \macro Q_CC_OC
- \relates <QtGlobal>
-
- Defined if the application is compiled using CenterLine C++.
-*/
-
-/*!
- \macro Q_CC_SUN
- \relates <QtGlobal>
-
- Defined if the application is compiled using Forte Developer, or
- Sun Studio C++.
-*/
-
-/*!
- \macro Q_CC_MIPS
- \relates <QtGlobal>
-
- Defined if the application is compiled using MIPSpro C++.
-*/
-
-/*!
- \macro Q_CC_DEC
- \relates <QtGlobal>
-
- Defined if the application is compiled using DEC C++.
-*/
-
-/*!
- \macro Q_CC_HPACC
- \relates <QtGlobal>
-
- Defined if the application is compiled using HP aC++.
-*/
-
-/*!
- \macro Q_CC_USLC
- \relates <QtGlobal>
-
- Defined if the application is compiled using SCO OUDK and UDK.
-*/
-
-/*!
- \macro Q_CC_CDS
- \relates <QtGlobal>
-
- Defined if the application is compiled using Reliant C++.
-*/
-
-/*!
- \macro Q_CC_KAI
- \relates <QtGlobal>
-
- Defined if the application is compiled using KAI C++.
-*/
-
-/*!
- \macro Q_CC_INTEL
- \relates <QtGlobal>
- \obsolete
-
- This macro used to be defined if the application was compiled with the old
- Intel C++ compiler for Linux, macOS or Windows. The new oneAPI C++ compiler
- is just a build of Clang and therefore does not define this macro.
-
- \sa Q_CC_CLANG
-*/
-
-/*!
- \macro Q_CC_HIGHC
- \relates <QtGlobal>
-
- Defined if the application is compiled using MetaWare High C/C++.
-*/
-
-/*!
- \macro Q_CC_PGI
- \relates <QtGlobal>
-
- Defined if the application is compiled using Portland Group C++.
-*/
-
-/*!
- \macro Q_CC_GHS
- \relates <QtGlobal>
-
- Defined if the application is compiled using Green Hills
- Optimizing C++ Compilers.
-*/
-
-/*!
- \macro Q_PROCESSOR_ALPHA
- \relates <QtGlobal>
-
- Defined if the application is compiled for Alpha processors.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-
-/*!
- \macro Q_PROCESSOR_ARM
- \relates <QtGlobal>
-
- Defined if the application is compiled for ARM processors. Qt currently
- supports three optional ARM revisions: \l Q_PROCESSOR_ARM_V5, \l
- Q_PROCESSOR_ARM_V6, and \l Q_PROCESSOR_ARM_V7.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-/*!
- \macro Q_PROCESSOR_ARM_V5
- \relates <QtGlobal>
-
- Defined if the application is compiled for ARMv5 processors. The \l
- Q_PROCESSOR_ARM macro is also defined when Q_PROCESSOR_ARM_V5 is defined.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-/*!
- \macro Q_PROCESSOR_ARM_V6
- \relates <QtGlobal>
-
- Defined if the application is compiled for ARMv6 processors. The \l
- Q_PROCESSOR_ARM and \l Q_PROCESSOR_ARM_V5 macros are also defined when
- Q_PROCESSOR_ARM_V6 is defined.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-/*!
- \macro Q_PROCESSOR_ARM_V7
- \relates <QtGlobal>
-
- Defined if the application is compiled for ARMv7 processors. The \l
- Q_PROCESSOR_ARM, \l Q_PROCESSOR_ARM_V5, and \l Q_PROCESSOR_ARM_V6 macros
- are also defined when Q_PROCESSOR_ARM_V7 is defined.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-
-/*!
- \macro Q_PROCESSOR_AVR32
- \relates <QtGlobal>
-
- Defined if the application is compiled for AVR32 processors.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-
-/*!
- \macro Q_PROCESSOR_BLACKFIN
- \relates <QtGlobal>
-
- Defined if the application is compiled for Blackfin processors.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-
-/*!
- \macro Q_PROCESSOR_IA64
- \relates <QtGlobal>
-
- Defined if the application is compiled for IA-64 processors. This includes
- all Itanium and Itanium 2 processors.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-
-/*!
- \macro Q_PROCESSOR_MIPS
- \relates <QtGlobal>
-
- Defined if the application is compiled for MIPS processors. Qt currently
- supports seven MIPS revisions: \l Q_PROCESSOR_MIPS_I, \l
- Q_PROCESSOR_MIPS_II, \l Q_PROCESSOR_MIPS_III, \l Q_PROCESSOR_MIPS_IV, \l
- Q_PROCESSOR_MIPS_V, \l Q_PROCESSOR_MIPS_32, and \l Q_PROCESSOR_MIPS_64.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-/*!
- \macro Q_PROCESSOR_MIPS_I
- \relates <QtGlobal>
-
- Defined if the application is compiled for MIPS-I processors. The \l
- Q_PROCESSOR_MIPS macro is also defined when Q_PROCESSOR_MIPS_I is defined.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-/*!
- \macro Q_PROCESSOR_MIPS_II
- \relates <QtGlobal>
-
- Defined if the application is compiled for MIPS-II processors. The \l
- Q_PROCESSOR_MIPS and \l Q_PROCESSOR_MIPS_I macros are also defined when
- Q_PROCESSOR_MIPS_II is defined.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-/*!
- \macro Q_PROCESSOR_MIPS_32
- \relates <QtGlobal>
-
- Defined if the application is compiled for MIPS32 processors. The \l
- Q_PROCESSOR_MIPS, \l Q_PROCESSOR_MIPS_I, and \l Q_PROCESSOR_MIPS_II macros
- are also defined when Q_PROCESSOR_MIPS_32 is defined.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-/*!
- \macro Q_PROCESSOR_MIPS_III
- \relates <QtGlobal>
-
- Defined if the application is compiled for MIPS-III processors. The \l
- Q_PROCESSOR_MIPS, \l Q_PROCESSOR_MIPS_I, and \l Q_PROCESSOR_MIPS_II macros
- are also defined when Q_PROCESSOR_MIPS_III is defined.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-/*!
- \macro Q_PROCESSOR_MIPS_IV
- \relates <QtGlobal>
-
- Defined if the application is compiled for MIPS-IV processors. The \l
- Q_PROCESSOR_MIPS, \l Q_PROCESSOR_MIPS_I, \l Q_PROCESSOR_MIPS_II, and \l
- Q_PROCESSOR_MIPS_III macros are also defined when Q_PROCESSOR_MIPS_IV is
- defined.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-/*!
- \macro Q_PROCESSOR_MIPS_V
- \relates <QtGlobal>
-
- Defined if the application is compiled for MIPS-V processors. The \l
- Q_PROCESSOR_MIPS, \l Q_PROCESSOR_MIPS_I, \l Q_PROCESSOR_MIPS_II, \l
- Q_PROCESSOR_MIPS_III, and \l Q_PROCESSOR_MIPS_IV macros are also defined
- when Q_PROCESSOR_MIPS_V is defined.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-/*!
- \macro Q_PROCESSOR_MIPS_64
- \relates <QtGlobal>
-
- Defined if the application is compiled for MIPS64 processors. The \l
- Q_PROCESSOR_MIPS, \l Q_PROCESSOR_MIPS_I, \l Q_PROCESSOR_MIPS_II, \l
- Q_PROCESSOR_MIPS_III, \l Q_PROCESSOR_MIPS_IV, and \l Q_PROCESSOR_MIPS_V
- macros are also defined when Q_PROCESSOR_MIPS_64 is defined.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-
-/*!
- \macro Q_PROCESSOR_POWER
- \relates <QtGlobal>
-
- Defined if the application is compiled for POWER processors. Qt currently
- supports two Power variants: \l Q_PROCESSOR_POWER_32 and \l
- Q_PROCESSOR_POWER_64.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-/*!
- \macro Q_PROCESSOR_POWER_32
- \relates <QtGlobal>
-
- Defined if the application is compiled for 32-bit Power processors. The \l
- Q_PROCESSOR_POWER macro is also defined when Q_PROCESSOR_POWER_32 is
- defined.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-/*!
- \macro Q_PROCESSOR_POWER_64
- \relates <QtGlobal>
-
- Defined if the application is compiled for 64-bit Power processors. The \l
- Q_PROCESSOR_POWER macro is also defined when Q_PROCESSOR_POWER_64 is
- defined.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-
-/*!
- \macro Q_PROCESSOR_RISCV
- \relates <QtGlobal>
- \since 5.13
-
- Defined if the application is compiled for RISC-V processors. Qt currently
- supports two RISC-V variants: \l Q_PROCESSOR_RISCV_32 and \l
- Q_PROCESSOR_RISCV_64.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-
-/*!
- \macro Q_PROCESSOR_RISCV_32
- \relates <QtGlobal>
- \since 5.13
-
- Defined if the application is compiled for 32-bit RISC-V processors. The \l
- Q_PROCESSOR_RISCV macro is also defined when Q_PROCESSOR_RISCV_32 is
- defined.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-
-/*!
- \macro Q_PROCESSOR_RISCV_64
- \relates <QtGlobal>
- \since 5.13
-
- Defined if the application is compiled for 64-bit RISC-V processors. The \l
- Q_PROCESSOR_RISCV macro is also defined when Q_PROCESSOR_RISCV_64 is
- defined.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-
-/*!
- \macro Q_PROCESSOR_S390
- \relates <QtGlobal>
-
- Defined if the application is compiled for S/390 processors. Qt supports
- one optional variant of S/390: Q_PROCESSOR_S390_X.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-/*!
- \macro Q_PROCESSOR_S390_X
- \relates <QtGlobal>
-
- Defined if the application is compiled for S/390x processors. The \l
- Q_PROCESSOR_S390 macro is also defined when Q_PROCESSOR_S390_X is defined.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-
-/*!
- \macro Q_PROCESSOR_SH
- \relates <QtGlobal>
-
- Defined if the application is compiled for SuperH processors. Qt currently
- supports one SuperH revision: \l Q_PROCESSOR_SH_4A.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-/*!
- \macro Q_PROCESSOR_SH_4A
- \relates <QtGlobal>
-
- Defined if the application is compiled for SuperH 4A processors. The \l
- Q_PROCESSOR_SH macro is also defined when Q_PROCESSOR_SH_4A is defined.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-
-/*!
- \macro Q_PROCESSOR_SPARC
- \relates <QtGlobal>
-
- Defined if the application is compiled for SPARC processors. Qt currently
- supports one optional SPARC revision: \l Q_PROCESSOR_SPARC_V9.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-/*!
- \macro Q_PROCESSOR_SPARC_V9
- \relates <QtGlobal>
-
- Defined if the application is compiled for SPARC V9 processors. The \l
- Q_PROCESSOR_SPARC macro is also defined when Q_PROCESSOR_SPARC_V9 is
- defined.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-
-/*!
- \macro Q_PROCESSOR_X86
- \relates <QtGlobal>
-
- Defined if the application is compiled for x86 processors. Qt currently
- supports two x86 variants: \l Q_PROCESSOR_X86_32 and \l Q_PROCESSOR_X86_64.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-/*!
- \macro Q_PROCESSOR_X86_32
- \relates <QtGlobal>
-
- Defined if the application is compiled for 32-bit x86 processors. This
- includes all i386, i486, i586, and i686 processors. The \l Q_PROCESSOR_X86
- macro is also defined when Q_PROCESSOR_X86_32 is defined.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-/*!
- \macro Q_PROCESSOR_X86_64
- \relates <QtGlobal>
-
- Defined if the application is compiled for 64-bit x86 processors. This
- includes all AMD64, Intel 64, and other x86_64/x64 processors. The \l
- Q_PROCESSOR_X86 macro is also defined when Q_PROCESSOR_X86_64 is defined.
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-
-/*!
- \macro QT_DISABLE_DEPRECATED_BEFORE
- \relates <QtGlobal>
-
- This macro can be defined in the project file to disable functions deprecated in
- a specified version of Qt or any earlier version. The default version number is 5.0,
- meaning that functions deprecated in or before Qt 5.0 will not be included.
-
- For instance, when preparing to upgrade to Qt 6.3, setting
- \c{QT_DISABLE_DEPRECATED_BEFORE=0x0602ff} will disable functions deprecated in
- Qt 6.2 and earlier, making it easy to find changes worth making before the
- upgrade. In any release, set \c{QT_DISABLE_DEPRECATED_BEFORE=0x000000} to
- enable all functions, including the ones deprecated in Qt 5.0 (although most
- of those have by now been removed entirely).
-
- \sa QT_DEPRECATED_WARNINGS
-*/
-
+ \brief The <QtGlobal> header file includes an assortment of other headers.
-/*!
- \macro QT_DEPRECATED_WARNINGS
- \relates <QtGlobal>
-
- Since Qt 5.13, this macro has no effect. In Qt 5.12 and before, if this macro
- is defined, the compiler will generate warnings if any API declared as
- deprecated by Qt is used.
-
- \sa QT_DISABLE_DEPRECATED_BEFORE, QT_NO_DEPRECATED_WARNINGS
-*/
-
-/*!
- \macro QT_NO_DEPRECATED_WARNINGS
- \relates <QtGlobal>
- \since 5.13
-
- This macro can be used to suppress deprecation warnings that would otherwise
- be generated when using deprecated APIs.
-
- \sa QT_DISABLE_DEPRECATED_BEFORE
-*/
-
-#if defined(Q_OS_MAC)
-
-QT_BEGIN_INCLUDE_NAMESPACE
-#include "private/qcore_mac_p.h"
-#include "qnamespace.h"
-QT_END_INCLUDE_NAMESPACE
-
-#ifdef Q_OS_DARWIN
-static const char *osVer_helper(QOperatingSystemVersion version = QOperatingSystemVersion::current())
-{
-#ifdef Q_OS_MACOS
- if (version.majorVersion() == 12)
- return "Monterey";
- // Compare against predefined constant to handle 10.16/11.0
- if (QOperatingSystemVersion::MacOSBigSur.version().isPrefixOf(version.version()))
- return "Big Sur";
- if (version.majorVersion() == 10) {
- switch (version.minorVersion()) {
- case 9:
- return "Mavericks";
- case 10:
- return "Yosemite";
- case 11:
- return "El Capitan";
- case 12:
- return "Sierra";
- case 13:
- return "High Sierra";
- case 14:
- return "Mojave";
- case 15:
- return "Catalina";
- }
- }
- // unknown, future version
-#else
- Q_UNUSED(version);
-#endif
- return nullptr;
-}
-#endif
-
-#elif defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
-
-QT_BEGIN_INCLUDE_NAMESPACE
-#include "qt_windows.h"
-QT_END_INCLUDE_NAMESPACE
-
-# ifndef QT_BOOTSTRAPPED
-class QWindowsSockInit
-{
-public:
- QWindowsSockInit();
- ~QWindowsSockInit();
- int version;
-};
-
-QWindowsSockInit::QWindowsSockInit()
-: version(0)
-{
- //### should we try for 2.2 on all platforms ??
- WSAData wsadata;
-
- // IPv6 requires Winsock v2.0 or better.
- if (WSAStartup(MAKEWORD(2, 0), &wsadata) != 0) {
- qWarning("QTcpSocketAPI: WinSock v2.0 initialization failed.");
- } else {
- version = 0x20;
- }
-}
-
-QWindowsSockInit::~QWindowsSockInit()
-{
- WSACleanup();
-}
-Q_GLOBAL_STATIC(QWindowsSockInit, winsockInit)
-# endif // QT_BOOTSTRAPPED
-
-static QString readVersionRegistryString(const wchar_t *subKey)
-{
- return QWinRegistryKey(HKEY_LOCAL_MACHINE, LR"(SOFTWARE\Microsoft\Windows NT\CurrentVersion)")
- .stringValue(subKey);
-}
-
-static inline QString windowsDisplayVersion()
-{
- // https://tickets.puppetlabs.com/browse/FACT-3058
- // The "ReleaseId" key stopped updating since Windows 10 20H2.
- if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows10_20H2)
- return readVersionRegistryString(L"DisplayVersion");
- else
- return readVersionRegistryString(L"ReleaseId");
-}
-
-static QString winSp_helper()
-{
- const auto osv = qWindowsVersionInfo();
- const qint16 major = osv.wServicePackMajor;
- if (major) {
- QString sp = QStringLiteral("SP ") + QString::number(major);
- const qint16 minor = osv.wServicePackMinor;
- if (minor)
- sp += u'.' + QString::number(minor);
-
- return sp;
- }
- return QString();
-}
-
-static const char *osVer_helper(QOperatingSystemVersion version = QOperatingSystemVersion::current())
-{
- Q_UNUSED(version);
- const OSVERSIONINFOEX osver = qWindowsVersionInfo();
- const bool workstation = osver.wProductType == VER_NT_WORKSTATION;
-
-#define Q_WINVER(major, minor) (major << 8 | minor)
- switch (Q_WINVER(osver.dwMajorVersion, osver.dwMinorVersion)) {
- case Q_WINVER(10, 0):
- if (workstation) {
- if (osver.dwBuildNumber >= 22000)
- return "11";
- return "10";
- }
- // else: Server
- if (osver.dwBuildNumber >= 20348)
- return "Server 2022";
- if (osver.dwBuildNumber >= 17763)
- return "Server 2019";
- return "Server 2016";
- }
-#undef Q_WINVER
- // unknown, future version
- return nullptr;
-}
-
-#endif
-#if defined(Q_OS_UNIX)
-# if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) || defined(Q_OS_FREEBSD)
-# define USE_ETC_OS_RELEASE
-struct QUnixOSVersion
-{
- // from /etc/os-release older /etc/lsb-release // redhat /etc/redhat-release // debian /etc/debian_version
- QString productType; // $ID $DISTRIB_ID // single line file containing: // Debian
- QString productVersion; // $VERSION_ID $DISTRIB_RELEASE // <Vendor_ID release Version_ID> // single line file <Release_ID/sid>
- QString prettyName; // $PRETTY_NAME $DISTRIB_DESCRIPTION
-};
-
-static QString unquote(const char *begin, const char *end)
-{
- // man os-release says:
- // Variable assignment values must be enclosed in double
- // or single quotes if they include spaces, semicolons or
- // other special characters outside of A–Z, a–z, 0–9. Shell
- // special characters ("$", quotes, backslash, backtick)
- // must be escaped with backslashes, following shell style.
- // All strings should be in UTF-8 format, and non-printable
- // characters should not be used. It is not supported to
- // concatenate multiple individually quoted strings.
- if (*begin == '"') {
- Q_ASSERT(end[-1] == '"');
- return QString::fromUtf8(begin + 1, end - begin - 2);
- }
- return QString::fromUtf8(begin, end - begin);
-}
-static QByteArray getEtcFileContent(const char *filename)
-{
- // we're avoiding QFile here
- int fd = qt_safe_open(filename, O_RDONLY);
- if (fd == -1)
- return QByteArray();
-
- QT_STATBUF sbuf;
- if (QT_FSTAT(fd, &sbuf) == -1) {
- qt_safe_close(fd);
- return QByteArray();
- }
-
- QByteArray buffer(sbuf.st_size, Qt::Uninitialized);
- buffer.resize(qt_safe_read(fd, buffer.data(), sbuf.st_size));
- qt_safe_close(fd);
- return buffer;
-}
-
-static bool readEtcFile(QUnixOSVersion &v, const char *filename,
- const QByteArray &idKey, const QByteArray &versionKey, const QByteArray &prettyNameKey)
-{
-
- QByteArray buffer = getEtcFileContent(filename);
- if (buffer.isEmpty())
- return false;
-
- const char *ptr = buffer.constData();
- const char *end = buffer.constEnd();
- const char *eol;
- QByteArray line;
- for (; ptr != end; ptr = eol + 1) {
- // find the end of the line after ptr
- eol = static_cast<const char *>(memchr(ptr, '\n', end - ptr));
- if (!eol)
- eol = end - 1;
- line.setRawData(ptr, eol - ptr);
-
- if (line.startsWith(idKey)) {
- ptr += idKey.length();
- v.productType = unquote(ptr, eol);
- continue;
- }
-
- if (line.startsWith(prettyNameKey)) {
- ptr += prettyNameKey.length();
- v.prettyName = unquote(ptr, eol);
- continue;
- }
-
- if (line.startsWith(versionKey)) {
- ptr += versionKey.length();
- v.productVersion = unquote(ptr, eol);
- continue;
- }
- }
-
- return true;
-}
-
-static bool readOsRelease(QUnixOSVersion &v)
-{
- QByteArray id = QByteArrayLiteral("ID=");
- QByteArray versionId = QByteArrayLiteral("VERSION_ID=");
- QByteArray prettyName = QByteArrayLiteral("PRETTY_NAME=");
-
- // man os-release(5) says:
- // The file /etc/os-release takes precedence over /usr/lib/os-release.
- // Applications should check for the former, and exclusively use its data
- // if it exists, and only fall back to /usr/lib/os-release if it is
- // missing.
- return readEtcFile(v, "/etc/os-release", id, versionId, prettyName) ||
- readEtcFile(v, "/usr/lib/os-release", id, versionId, prettyName);
-}
-
-static bool readEtcLsbRelease(QUnixOSVersion &v)
-{
- bool ok = readEtcFile(v, "/etc/lsb-release", QByteArrayLiteral("DISTRIB_ID="),
- QByteArrayLiteral("DISTRIB_RELEASE="), QByteArrayLiteral("DISTRIB_DESCRIPTION="));
- if (ok && (v.prettyName.isEmpty() || v.prettyName == v.productType)) {
- // some distributions have redundant information for the pretty name,
- // so try /etc/<lowercasename>-release
-
- // we're still avoiding QFile here
- QByteArray distrorelease = "/etc/" + v.productType.toLatin1().toLower() + "-release";
- int fd = qt_safe_open(distrorelease, O_RDONLY);
- if (fd != -1) {
- QT_STATBUF sbuf;
- if (QT_FSTAT(fd, &sbuf) != -1 && sbuf.st_size > v.prettyName.length()) {
- // file apparently contains interesting information
- QByteArray buffer(sbuf.st_size, Qt::Uninitialized);
- buffer.resize(qt_safe_read(fd, buffer.data(), sbuf.st_size));
- v.prettyName = QString::fromLatin1(buffer.trimmed());
- }
- qt_safe_close(fd);
- }
- }
-
- // some distributions have a /etc/lsb-release file that does not provide the values
- // we are looking for, i.e. DISTRIB_ID, DISTRIB_RELEASE and DISTRIB_DESCRIPTION.
- // Assuming that neither DISTRIB_ID nor DISTRIB_RELEASE were found, or contained valid values,
- // returning false for readEtcLsbRelease will allow further /etc/<lowercasename>-release parsing.
- return ok && !(v.productType.isEmpty() && v.productVersion.isEmpty());
-}
-
-#if defined(Q_OS_LINUX)
-static QByteArray getEtcFileFirstLine(const char *fileName)
-{
- QByteArray buffer = getEtcFileContent(fileName);
- if (buffer.isEmpty())
- return QByteArray();
-
- const char *ptr = buffer.constData();
- int eol = buffer.indexOf("\n");
- return QByteArray(ptr, eol).trimmed();
-}
-
-static bool readEtcRedHatRelease(QUnixOSVersion &v)
-{
- // /etc/redhat-release analysed should be a one line file
- // the format of its content is <Vendor_ID release Version>
- // i.e. "Red Hat Enterprise Linux Workstation release 6.5 (Santiago)"
- QByteArray line = getEtcFileFirstLine("/etc/redhat-release");
- if (line.isEmpty())
- return false;
-
- v.prettyName = QString::fromLatin1(line);
-
- const char keyword[] = "release ";
- int releaseIndex = line.indexOf(keyword);
- v.productType = QString::fromLatin1(line.mid(0, releaseIndex)).remove(u' ');
- int spaceIndex = line.indexOf(' ', releaseIndex + strlen(keyword));
- v.productVersion = QString::fromLatin1(line.mid(releaseIndex + strlen(keyword),
- spaceIndex > -1 ? spaceIndex - releaseIndex - int(strlen(keyword)) : -1));
- return true;
-}
-
-static bool readEtcDebianVersion(QUnixOSVersion &v)
-{
- // /etc/debian_version analysed should be a one line file
- // the format of its content is <Release_ID/sid>
- // i.e. "jessie/sid"
- QByteArray line = getEtcFileFirstLine("/etc/debian_version");
- if (line.isEmpty())
- return false;
+ Up to Qt 6.5, most Qt header files included <QtGlobal>. Before Qt 6.5,
+ <QtGlobal> defined an assortment of global declarations. Most of these
+ have moved, at Qt 6.5, to separate headers, so that source code can
+ include only what it needs, rather than the whole assortment. For now,
+ <QtGlobal> includes those other headers (see next section), but future
+ releases of Qt may remove some of these headers from <QtGlobal> or
+ condition their inclusion on a version check. Likewise, in future
+ releases, some Qt headers that currently include <QtGlobal> may stop
+ doing so. The hope is that this will improve compilation times by
+ avoiding global declarations when they are not used.
- v.productType = QStringLiteral("Debian");
- v.productVersion = QString::fromLatin1(line);
- return true;
-}
-#endif
-
-static bool findUnixOsVersion(QUnixOSVersion &v)
-{
- if (readOsRelease(v))
- return true;
- if (readEtcLsbRelease(v))
- return true;
-#if defined(Q_OS_LINUX)
- if (readEtcRedHatRelease(v))
- return true;
- if (readEtcDebianVersion(v))
- return true;
-#endif
- return false;
-}
-# endif // USE_ETC_OS_RELEASE
-#endif // Q_OS_UNIX
-
-#ifdef Q_OS_ANDROID
-static const char *osVer_helper(QOperatingSystemVersion)
-{
-/* Data:
-
-
-
-Cupcake
-Donut
-Eclair
-Eclair
-Eclair
-Froyo
-Gingerbread
-Gingerbread
-Honeycomb
-Honeycomb
-Honeycomb
-Ice Cream Sandwich
-Ice Cream Sandwich
-Jelly Bean
-Jelly Bean
-Jelly Bean
-KitKat
-KitKat
-Lollipop
-Lollipop
-Marshmallow
-Nougat
-Nougat
-Oreo
-*/
- static const char versions_string[] =
- "\0"
- "Cupcake\0"
- "Donut\0"
- "Eclair\0"
- "Froyo\0"
- "Gingerbread\0"
- "Honeycomb\0"
- "Ice Cream Sandwich\0"
- "Jelly Bean\0"
- "KitKat\0"
- "Lollipop\0"
- "Marshmallow\0"
- "Nougat\0"
- "Oreo\0"
- "\0";
-
- static const int versions_indices[] = {
- 0, 0, 0, 1, 9, 15, 15, 15,
- 22, 28, 28, 40, 40, 40, 50, 50,
- 69, 69, 69, 80, 80, 87, 87, 96,
- 108, 108, 115, -1
- };
-
- static const int versions_count = (sizeof versions_indices) / (sizeof versions_indices[0]);
-
- // https://source.android.com/source/build-numbers.html
- // https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels
- const int sdk_int = QJniObject::getStaticField<jint>("android/os/Build$VERSION", "SDK_INT");
- return &versions_string[versions_indices[qBound(0, sdk_int, versions_count - 1)]];
-}
-#endif
-
-/*!
- \since 5.4
-
- Returns the architecture of the CPU that Qt was compiled for, in text
- format. Note that this may not match the actual CPU that the application is
- running on if there's an emulation layer or if the CPU supports multiple
- architectures (like x86-64 processors supporting i386 applications). To
- detect that, use currentCpuArchitecture().
-
- Values returned by this function are stable and will not change over time,
- so applications can rely on the returned value as an identifier, except
- that new CPU types may be added over time.
-
- Typical returned values are (note: list not exhaustive):
- \list
- \li "arm"
- \li "arm64"
- \li "i386"
- \li "ia64"
- \li "mips"
- \li "mips64"
- \li "power"
- \li "power64"
- \li "sparc"
- \li "sparcv9"
- \li "x86_64"
- \endlist
-
- \sa QSysInfo::buildAbi(), QSysInfo::currentCpuArchitecture()
-*/
-QString QSysInfo::buildCpuArchitecture()
-{
- return QStringLiteral(ARCH_PROCESSOR);
-}
-
-/*!
- \since 5.4
-
- Returns the architecture of the CPU that the application is running on, in
- text format. Note that this function depends on what the OS will report and
- may not detect the actual CPU architecture if the OS hides that information
- or is unable to provide it. For example, a 32-bit OS running on a 64-bit
- CPU is usually unable to determine the CPU is actually capable of running
- 64-bit programs.
-
- Values returned by this function are mostly stable: an attempt will be made
- to ensure that they stay constant over time and match the values returned
- by QSysInfo::builldCpuArchitecture(). However, due to the nature of the
- operating system functions being used, there may be discrepancies.
-
- Typical returned values are (note: list not exhaustive):
- \list
- \li "arm"
- \li "arm64"
- \li "i386"
- \li "ia64"
- \li "mips"
- \li "mips64"
- \li "power"
- \li "power64"
- \li "sparc"
- \li "sparcv9"
- \li "x86_64"
- \endlist
-
- \sa QSysInfo::buildAbi(), QSysInfo::buildCpuArchitecture()
-*/
-QString QSysInfo::currentCpuArchitecture()
-{
-#if defined(Q_OS_WIN)
- // We don't need to catch all the CPU architectures in this function;
- // only those where the host CPU might be different than the build target
- // (usually, 64-bit platforms).
- SYSTEM_INFO info;
- GetNativeSystemInfo(&info);
- switch (info.wProcessorArchitecture) {
-# ifdef PROCESSOR_ARCHITECTURE_AMD64
- case PROCESSOR_ARCHITECTURE_AMD64:
- return QStringLiteral("x86_64");
-# endif
-# ifdef PROCESSOR_ARCHITECTURE_IA32_ON_WIN64
- case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64:
-# endif
- case PROCESSOR_ARCHITECTURE_IA64:
- return QStringLiteral("ia64");
- }
-#elif defined(Q_OS_DARWIN) && !defined(Q_OS_MACOS)
- // iOS-based OSes do not return the architecture on uname(2)'s result.
- return buildCpuArchitecture();
-#elif defined(Q_OS_UNIX)
- long ret = -1;
- struct utsname u;
-
-# if defined(Q_OS_SOLARIS)
- // We need a special call for Solaris because uname(2) on x86 returns "i86pc" for
- // both 32- and 64-bit CPUs. Reference:
- // http://docs.oracle.com/cd/E18752_01/html/816-5167/sysinfo-2.html#REFMAN2sysinfo-2
- // http://fxr.watson.org/fxr/source/common/syscall/systeminfo.c?v=OPENSOLARIS
- // http://fxr.watson.org/fxr/source/common/conf/param.c?v=OPENSOLARIS;im=10#L530
- if (ret == -1)
- ret = sysinfo(SI_ARCHITECTURE_64, u.machine, sizeof u.machine);
-# endif
-
- if (ret == -1)
- ret = uname(&u);
-
- // we could use detectUnixVersion() above, but we only need a field no other function does
- if (ret != -1) {
- // the use of QT_BUILD_INTERNAL here is simply to ensure all branches build
- // as we don't often build on some of the less common platforms
-# if defined(Q_PROCESSOR_ARM) || defined(QT_BUILD_INTERNAL)
- if (strcmp(u.machine, "aarch64") == 0)
- return QStringLiteral("arm64");
- if (strncmp(u.machine, "armv", 4) == 0)
- return QStringLiteral("arm");
-# endif
-# if defined(Q_PROCESSOR_POWER) || defined(QT_BUILD_INTERNAL)
- // harmonize "powerpc" and "ppc" to "power"
- if (strncmp(u.machine, "ppc", 3) == 0)
- return "power"_L1 + QLatin1StringView(u.machine + 3);
- if (strncmp(u.machine, "powerpc", 7) == 0)
- return "power"_L1 + QLatin1StringView(u.machine + 7);
- if (strcmp(u.machine, "Power Macintosh") == 0)
- return "power"_L1;
-# endif
-# if defined(Q_PROCESSOR_SPARC) || defined(QT_BUILD_INTERNAL)
- // Solaris sysinfo(2) (above) uses "sparcv9", but uname -m says "sun4u";
- // Linux says "sparc64"
- if (strcmp(u.machine, "sun4u") == 0 || strcmp(u.machine, "sparc64") == 0)
- return QStringLiteral("sparcv9");
- if (strcmp(u.machine, "sparc32") == 0)
- return QStringLiteral("sparc");
-# endif
-# if defined(Q_PROCESSOR_X86) || defined(QT_BUILD_INTERNAL)
- // harmonize all "i?86" to "i386"
- if (strlen(u.machine) == 4 && u.machine[0] == 'i'
- && u.machine[2] == '8' && u.machine[3] == '6')
- return QStringLiteral("i386");
- if (strcmp(u.machine, "amd64") == 0) // Solaris
- return QStringLiteral("x86_64");
-# endif
- return QString::fromLatin1(u.machine);
- }
-#endif
- return buildCpuArchitecture();
-}
-
-/*!
- \since 5.4
-
- Returns the full architecture string that Qt was compiled for. This string
- is useful for identifying different, incompatible builds. For example, it
- can be used as an identifier to request an upgrade package from a server.
-
- The values returned from this function are kept stable as follows: the
- mandatory components of the result will not change in future versions of
- Qt, but optional suffixes may be added.
-
- The returned value is composed of three or more parts, separated by dashes
- ("-"). They are:
+ \section1 List of Headers Extracted from <QtGlobal>
\table
- \header \li Component \li Value
- \row \li CPU Architecture \li The same as QSysInfo::buildCpuArchitecture(), such as "arm", "i386", "mips" or "x86_64"
- \row \li Endianness \li "little_endian" or "big_endian"
- \row \li Word size \li Whether it's a 32- or 64-bit application. Possible values are:
- "llp64" (Windows 64-bit), "lp64" (Unix 64-bit), "ilp32" (32-bit)
- \row \li (Optional) ABI \li Zero or more components identifying different ABIs possible in this architecture.
- Currently, Qt has optional ABI components for ARM and MIPS processors: one
- component is the main ABI (such as "eabi", "o32", "n32", "o64"); another is
- whether the calling convention is using hardware floating point registers ("hardfloat"
- is present).
-
- Additionally, if Qt was configured with \c{-qreal float}, the ABI option tag "qreal_float"
- will be present. If Qt was configured with another type as qreal, that type is present after
- "qreal_", with all characters other than letters and digits escaped by an underscore, followed
- by two hex digits. For example, \c{-qreal long double} becomes "qreal_long_20double".
+ \header \li Header \li Summary
+ \row \li <QFlags> \li Type-safe way of combining enum values
+ \row \li \l <QForeach> \li Qt's implementation of foreach and forever loops
+ \row \li \l <QFunctionPointer> \li Typedef for a pointer-to-function type
+ \row \li <QGlobalStatic> \li Thread-safe initialization of global static objects
+ \row \li \l <QOverload> \li Helpers for resolving member function overloads
+ \row \li <QSysInfo> \li A helper class to get system information
+ \row \li \l <QTypeInfo> \li Helpers to get type information
+ \row \li \l <QtAssert> \li Q_ASSERT and other runtime checks
+ \row \li \l <QtClassHelperMacros> \li Qt class helper macros
+ \row \li \l <QtCompilerDetection> \li Compiler-specific macro definitions
+ \row \li \l <QtDeprecationMarkers> \li Deprecation helper macros
+ \row \li \l <QtEnvironmentVariables> \li Helpers for working with environment variables
+ \row \li <QtExceptionHandling> \li Helpers for exception handling
+ \row \li \l <QtLogging> \li Qt logging helpers
+ \row \li <QtMalloc> \li Memory allocation helpers
+ \row \li \l <QtMinMax> \li Helpers for comparing values
+ \row \li \l <QtNumeric> \li Various numeric functions
+ \row \li \l <QtPreprocessorSupport> \li Helper preprocessor macros
+ \row \li \l <QtProcessorDetection> \li Architecture-specific macro definitions
+ \row \li \l <QtResource> \li Helpers for initializing and cleaning resources
+ \row \li \l <QtSwap> \li Implementation of qSwap()
+ \row \li \l <QtSystemDetection> \li Platform-specific macro definitions
+ \row \li \l <QtTranslation> \li Qt translation helpers
+ \row \li \l <QtTypeTraits> \li Qt type traits
+ \row \li \l <QtTypes> \li Qt fundamental type declarations
+ \row \li \l <QtVersionChecks> \li Qt Version related checks
\endtable
-
- \sa QSysInfo::buildCpuArchitecture()
-*/
-QString QSysInfo::buildAbi()
-{
- // ARCH_FULL is a concatenation of strings (incl. ARCH_PROCESSOR), which breaks
- // QStringLiteral on MSVC. Since the concatenation behavior we want is specified
- // the same C++11 paper as the Unicode strings, we'll use that macro and hope
- // that Microsoft implements the new behavior when they add support for Unicode strings.
- return QStringLiteral(ARCH_FULL);
-}
-
-static QString unknownText()
-{
- return QStringLiteral("unknown");
-}
-
-/*!
- \since 5.4
-
- Returns the type of the operating system kernel Qt was compiled for. It's
- also the kernel the application is running on, unless the host operating
- system is running a form of compatibility or virtualization layer.
-
- Values returned by this function are stable and will not change over time,
- so applications can rely on the returned value as an identifier, except
- that new OS kernel types may be added over time.
-
- On Windows, this function returns the type of Windows kernel, like "winnt".
- On Unix systems, it returns the same as the output of \c{uname
- -s} (lowercased).
-
- \note This function may return surprising values: it returns "linux"
- for all operating systems running Linux (including Android), "qnx" for all
- operating systems running QNX, "freebsd" for
- Debian/kFreeBSD, and "darwin" for \macos and iOS. For information on the type
- of product the application is running on, see productType().
-
- \sa QFileSelector, kernelVersion(), productType(), productVersion(), prettyProductName()
-*/
-QString QSysInfo::kernelType()
-{
-#if defined(Q_OS_WIN)
- return QStringLiteral("winnt");
-#elif defined(Q_OS_UNIX)
- struct utsname u;
- if (uname(&u) == 0)
- return QString::fromLatin1(u.sysname).toLower();
-#endif
- return unknownText();
-}
-
-/*!
- \since 5.4
-
- Returns the release version of the operating system kernel. On Windows, it
- returns the version of the NT kernel. On Unix systems, including
- Android and \macos, it returns the same as the \c{uname -r}
- command would return.
-
- If the version could not be determined, this function may return an empty
- string.
-
- \sa kernelType(), productType(), productVersion(), prettyProductName()
-*/
-QString QSysInfo::kernelVersion()
-{
-#ifdef Q_OS_WIN
- const auto osver = QOperatingSystemVersion::current();
- return QString::asprintf("%d.%d.%d",
- osver.majorVersion(), osver.minorVersion(), osver.microVersion());
-#else
- struct utsname u;
- if (uname(&u) == 0)
- return QString::fromLatin1(u.release);
- return QString();
-#endif
-}
-
-
-/*!
- \since 5.4
-
- Returns the product name of the operating system this application is
- running in. If the application is running on some sort of emulation or
- virtualization layer (such as WINE on a Unix system), this function will
- inspect the emulation / virtualization layer.
-
- Values returned by this function are stable and will not change over time,
- so applications can rely on the returned value as an identifier, except
- that new OS types may be added over time.
-
- \b{Linux and Android note}: this function returns "android" for Linux
- systems running Android userspace, notably when using the Bionic library.
- For all other Linux systems, regardless of C library being used, it tries
- to determine the distribution name and returns that. If determining the
- distribution name failed, it returns "unknown".
-
- \b{\macos note}: this function returns "macos" for all \macos systems,
- regardless of Apple naming convention. Previously, in Qt 5, it returned
- "osx", again regardless of Apple naming conventions.
-
- \b{Darwin, iOS, tvOS, and watchOS note}: this function returns "ios" for
- iOS systems, "tvos" for tvOS systems, "watchos" for watchOS systems, and
- "darwin" in case the system could not be determined.
-
- \b{FreeBSD note}: this function returns "debian" for Debian/kFreeBSD and
- "unknown" otherwise.
-
- \b{Windows note}: this function return "windows"
-
- For other Unix-type systems, this function usually returns "unknown".
-
- \sa QFileSelector, kernelType(), kernelVersion(), productVersion(), prettyProductName()
-*/
-QString QSysInfo::productType()
-{
- // similar, but not identical to QFileSelectorPrivate::platformSelectors
-#if defined(Q_OS_WIN)
- return QStringLiteral("windows");
-
-#elif defined(Q_OS_QNX)
- return QStringLiteral("qnx");
-
-#elif defined(Q_OS_ANDROID)
- return QStringLiteral("android");
-
-#elif defined(Q_OS_IOS)
- return QStringLiteral("ios");
-#elif defined(Q_OS_TVOS)
- return QStringLiteral("tvos");
-#elif defined(Q_OS_WATCHOS)
- return QStringLiteral("watchos");
-#elif defined(Q_OS_MACOS)
- return QStringLiteral("macos");
-#elif defined(Q_OS_DARWIN)
- return QStringLiteral("darwin");
-
-#elif defined(USE_ETC_OS_RELEASE) // Q_OS_UNIX
- QUnixOSVersion unixOsVersion;
- findUnixOsVersion(unixOsVersion);
- if (!unixOsVersion.productType.isEmpty())
- return unixOsVersion.productType;
-#endif
- return unknownText();
-}
-
-/*!
- \since 5.4
-
- Returns the product version of the operating system in string form. If the
- version could not be determined, this function returns "unknown".
-
- It will return the Android, iOS, \macos, Windows full-product
- versions on those systems.
-
- Typical returned values are (note: list not exhaustive):
- \list
- \li "12" (Android 12)
- \li "36" (Fedora 36)
- \li "15.5" (iOS 15.5)
- \li "12.4" (macOS Monterey)
- \li "22.04" (Ubuntu 22.04)
- \li "8.6" (watchOS 8.6)
- \li "11" (Windows 11)
- \li "Server 2022" (Windows Server 2022)
- \endlist
-
- On Linux systems, it will try to determine the distribution version and will
- return that. This is also done on Debian/kFreeBSD, so this function will
- return Debian version in that case.
-
- In all other Unix-type systems, this function always returns "unknown".
-
- \note The version string returned from this function is not guaranteed to
- be orderable. On Linux, the version of
- the distribution may jump unexpectedly, please refer to the distribution's
- documentation for versioning practices.
-
- \sa kernelType(), kernelVersion(), productType(), prettyProductName()
-*/
-QString QSysInfo::productVersion()
-{
-#if defined(Q_OS_ANDROID) || defined(Q_OS_DARWIN)
- const auto version = QOperatingSystemVersion::current();
- return QString::asprintf("%d.%d", version.majorVersion(), version.minorVersion());
-#elif defined(Q_OS_WIN)
- const char *version = osVer_helper();
- if (version) {
- const QLatin1Char spaceChar(' ');
- return QString::fromLatin1(version).remove(spaceChar).toLower() + winSp_helper().remove(spaceChar).toLower();
- }
- // fall through
-
-#elif defined(USE_ETC_OS_RELEASE) // Q_OS_UNIX
- QUnixOSVersion unixOsVersion;
- findUnixOsVersion(unixOsVersion);
- if (!unixOsVersion.productVersion.isEmpty())
- return unixOsVersion.productVersion;
-#endif
-
- // fallback
- return unknownText();
-}
-
-/*!
- \since 5.4
-
- Returns a prettier form of productType() and productVersion(), containing
- other tokens like the operating system type, codenames and other
- information. The result of this function is suitable for displaying to the
- user, but not for long-term storage, as the string may change with updates
- to Qt.
-
- If productType() is "unknown", this function will instead use the
- kernelType() and kernelVersion() functions.
-
- \sa kernelType(), kernelVersion(), productType(), productVersion()
-*/
-QString QSysInfo::prettyProductName()
-{
-#if defined(Q_OS_ANDROID) || defined(Q_OS_DARWIN) || defined(Q_OS_WIN)
- const auto version = QOperatingSystemVersion::current();
- const int majorVersion = version.majorVersion();
- const QString versionString = QString::asprintf("%d.%d", majorVersion, version.minorVersion());
- QString result = version.name() + u' ';
- const char *name = osVer_helper(version);
- if (!name)
- return result + versionString;
- result += QLatin1StringView(name);
-# if !defined(Q_OS_WIN)
- return result + " ("_L1 + versionString + u')';
-# else
- // (resembling winver.exe): Windows 10 "Windows 10 Version 1809"
- const auto displayVersion = windowsDisplayVersion();
- if (!displayVersion.isEmpty())
- result += " Version "_L1 + displayVersion;
- return result;
-# endif // Windows
-#elif defined(Q_OS_HAIKU)
- return "Haiku "_L1 + productVersion();
-#elif defined(Q_OS_UNIX)
-# ifdef USE_ETC_OS_RELEASE
- QUnixOSVersion unixOsVersion;
- findUnixOsVersion(unixOsVersion);
- if (!unixOsVersion.prettyName.isEmpty())
- return unixOsVersion.prettyName;
-# endif
- struct utsname u;
- if (uname(&u) == 0)
- return QString::fromLatin1(u.sysname) + u' ' + QString::fromLatin1(u.release);
-#endif
- return unknownText();
-}
-
-#ifndef QT_BOOTSTRAPPED
-/*!
- \since 5.6
-
- Returns this machine's host name, if one is configured. Note that hostnames
- are not guaranteed to be globally unique, especially if they were
- configured automatically.
-
- This function does not guarantee the returned host name is a Fully
- Qualified Domain Name (FQDN). For that, use QHostInfo to resolve the
- returned name to an FQDN.
-
- This function returns the same as QHostInfo::localHostName().
-
- \sa QHostInfo::localDomainName, machineUniqueId()
-*/
-QString QSysInfo::machineHostName()
-{
- // the hostname can change, so we can't cache it
-#if defined(Q_OS_LINUX)
- // gethostname(3) on Linux just calls uname(2), so do it ourselves
- // and avoid a memcpy
- struct utsname u;
- if (uname(&u) == 0)
- return QString::fromLocal8Bit(u.nodename);
- return QString();
-#else
-# ifdef Q_OS_WIN
- // Important: QtNetwork depends on machineHostName() initializing ws2_32.dll
- winsockInit();
-# endif
-
- char hostName[512];
- if (gethostname(hostName, sizeof(hostName)) == -1)
- return QString();
- hostName[sizeof(hostName) - 1] = '\0';
- return QString::fromLocal8Bit(hostName);
-#endif
-}
-#endif // QT_BOOTSTRAPPED
-
-enum {
- UuidStringLen = sizeof("00000000-0000-0000-0000-000000000000") - 1
-};
-
-/*!
- \since 5.11
-
- Returns a unique ID for this machine, if one can be determined. If no
- unique ID could be determined, this function returns an empty byte array.
- Unlike machineHostName(), the value returned by this function is likely
- globally unique.
-
- A unique ID is useful in network operations to identify this machine for an
- extended period of time, when the IP address could change or if this
- machine could have more than one IP address. For example, the ID could be
- used when communicating with a server or when storing device-specific data
- in shared network storage.
-
- Note that on some systems, this value will persist across reboots and on
- some it will not. Applications should not blindly depend on this fact
- without verifying the OS capabilities. In particular, on Linux systems,
- this ID is usually permanent and it matches the D-Bus machine ID, except
- for nodes without their own storage (replicated nodes).
-
- \sa machineHostName(), bootUniqueId()
-*/
-QByteArray QSysInfo::machineUniqueId()
-{
-#if defined(Q_OS_DARWIN) && __has_include(<IOKit/IOKitLib.h>)
- char uuid[UuidStringLen + 1];
- static const mach_port_t defaultPort = 0; // Effectively kIOMasterPortDefault/kIOMainPortDefault
- io_service_t service = IOServiceGetMatchingService(defaultPort, IOServiceMatching("IOPlatformExpertDevice"));
- QCFString stringRef = (CFStringRef)IORegistryEntryCreateCFProperty(service, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0);
- CFStringGetCString(stringRef, uuid, sizeof(uuid), kCFStringEncodingMacRoman);
- return QByteArray(uuid);
-#elif defined(Q_OS_BSD4) && defined(KERN_HOSTUUID)
- char uuid[UuidStringLen + 1];
- size_t uuidlen = sizeof(uuid);
- int name[] = { CTL_KERN, KERN_HOSTUUID };
- if (sysctl(name, sizeof name / sizeof name[0], &uuid, &uuidlen, nullptr, 0) == 0
- && uuidlen == sizeof(uuid))
- return QByteArray(uuid, uuidlen - 1);
-#elif defined(Q_OS_UNIX)
- // The modern name on Linux is /etc/machine-id, but that path is
- // unlikely to exist on non-Linux (non-systemd) systems. The old
- // path is more than enough.
- static const char fullfilename[] = "/usr/local/var/lib/dbus/machine-id";
- const char *firstfilename = fullfilename + sizeof("/usr/local") - 1;
- int fd = qt_safe_open(firstfilename, O_RDONLY);
- if (fd == -1 && errno == ENOENT)
- fd = qt_safe_open(fullfilename, O_RDONLY);
-
- if (fd != -1) {
- char buffer[32]; // 128 bits, hex-encoded
- qint64 len = qt_safe_read(fd, buffer, sizeof(buffer));
- qt_safe_close(fd);
-
- if (len != -1)
- return QByteArray(buffer, len);
- }
-#elif defined(Q_OS_WIN)
- // Let's poke at the registry
- const QString machineGuid = QWinRegistryKey(HKEY_LOCAL_MACHINE, LR"(SOFTWARE\Microsoft\Cryptography)")
- .stringValue(u"MachineGuid"_s);
- if (!machineGuid.isEmpty())
- return machineGuid.toLatin1();
-#endif
- return QByteArray();
-}
-
-/*!
- \since 5.11
-
- Returns a unique ID for this machine's boot, if one can be determined. If
- no unique ID could be determined, this function returns an empty byte
- array. This value is expected to change after every boot and can be
- considered globally unique.
-
- This function is currently only implemented for Linux and Apple operating
- systems.
-
- \sa machineUniqueId()
-*/
-QByteArray QSysInfo::bootUniqueId()
-{
-#ifdef Q_OS_LINUX
- // use low-level API here for simplicity
- int fd = qt_safe_open("/proc/sys/kernel/random/boot_id", O_RDONLY);
- if (fd != -1) {
- char uuid[UuidStringLen];
- qint64 len = qt_safe_read(fd, uuid, sizeof(uuid));
- qt_safe_close(fd);
- if (len == UuidStringLen)
- return QByteArray(uuid, UuidStringLen);
- }
-#elif defined(Q_OS_DARWIN)
- // "kern.bootsessionuuid" is only available by name
- char uuid[UuidStringLen + 1];
- size_t uuidlen = sizeof(uuid);
- if (sysctlbyname("kern.bootsessionuuid", uuid, &uuidlen, nullptr, 0) == 0
- && uuidlen == sizeof(uuid))
- return QByteArray(uuid, uuidlen - 1);
-#endif
- return QByteArray();
-};
-
-/*!
- \macro void Q_FALLTHROUGH()
- \relates <QtGlobal>
- \since 5.8
-
- Can be used in switch statements at the end of case block to tell the compiler
- and other developers that that the lack of a break statement is intentional.
-
- This is useful since a missing break statement is often a bug, and some
- compilers can be configured to emit warnings when one is not found.
-
- \sa Q_UNREACHABLE()
-*/
-
-/*!
- \macro const char* Q_FUNC_INFO()
- \relates <QtGlobal>
-
- Expands to a string that describe the function the macro resides in. How this string looks
- more specifically is compiler dependent. With GNU GCC it is typically the function signature,
- while with other compilers it might be the line and column number.
-
- Q_FUNC_INFO can be conveniently used with qDebug(). For example, this function:
-
- \snippet code/src_corelib_global_qglobal.cpp 22
-
- when instantiated with the integer type, will with the GCC compiler produce:
-
- \tt{const TInputType& myMin(const TInputType&, const TInputType&) [with TInputType = int] was called with value1: 3 value2: 4}
-
- If this macro is used outside a function, the behavior is undefined.
*/
/*
- \internal
- Allows you to call std::terminate() without including <exception>.
- Called internally from QT_TERMINATE_ON_EXCEPTION
-*/
-Q_NORETURN void qTerminate() noexcept
-{
- std::terminate();
-}
-
-/*
Dijkstra's bisection algorithm to find the square root of an integer.
Deliberately not exported as part of the Qt API, but used in both
qsimplerichtext.cpp and qgfxraster_qws.cpp
@@ -3064,314 +165,6 @@ void qAbort()
// localtime() -- but not localtime_r(), which we use when threaded
// strftime() -- not used (except in tests)
-/*!
- \macro forever
- \relates <QForeach>
-
- This macro is provided for convenience for writing infinite
- loops.
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp 31
-
- It is equivalent to \c{for (;;)}.
-
- If you're worried about namespace pollution, you can disable this
- macro by adding the following line to your \c .pro file:
-
- \snippet code/src_corelib_global_qglobal.cpp 32
-
- \sa Q_FOREVER
-*/
-
-/*!
- \macro Q_FOREVER
- \relates <QForeach>
-
- Same as \l{forever}.
-
- This macro is available even when \c no_keywords is specified
- using the \c .pro file's \c CONFIG variable.
-
- \sa foreach()
-*/
-
-/*!
- \macro foreach(variable, container)
- \relates <QForeach>
-
- This macro is used to implement Qt's \c foreach loop. The \a
- variable parameter is a variable name or variable definition; the
- \a container parameter is a Qt container whose value type
- corresponds to the type of the variable. See \l{The foreach
- Keyword} for details.
-
- If you're worried about namespace pollution, you can disable this
- macro by adding the following line to your \c .pro file:
-
- \snippet code/src_corelib_global_qglobal.cpp 33
-
- \note Since Qt 5.7, the use of this macro is discouraged. It will
- be removed in a future version of Qt. Please use C++11 range-for,
- possibly with qAsConst(), as needed.
-
- \sa qAsConst()
-*/
-
-/*!
- \macro Q_FOREACH(variable, container)
- \relates <QForeach>
-
- Same as foreach(\a variable, \a container).
-
- This macro is available even when \c no_keywords is specified
- using the \c .pro file's \c CONFIG variable.
-
- \note Since Qt 5.7, the use of this macro is discouraged. It will
- be removed in a future version of Qt. Please use C++11 range-for,
- possibly with qAsConst(), as needed.
-
- \sa qAsConst()
-*/
-
-/*!
- \fn template <typename T> typename std::add_const<T>::type &qAsConst(T &t)
- \relates <QtGlobal>
- \since 5.7
-
- Returns \a t cast to \c{const T}.
-
- This function is a Qt implementation of C++17's std::as_const(),
- a cast function like std::move(). But while std::move() turns
- lvalues into rvalues, this function turns non-const lvalues into
- const lvalues. Like std::as_const(), it doesn't work on rvalues,
- because it cannot be efficiently implemented for rvalues without
- leaving dangling references.
-
- Its main use in Qt is to prevent implicitly-shared Qt containers
- from detaching:
- \snippet code/src_corelib_global_qglobal.cpp as-const-0
-
- Of course, in this case, you could (and probably should) have declared
- \c s as \c const in the first place:
- \snippet code/src_corelib_global_qglobal.cpp as-const-1
- but often that is not easily possible.
-
- It is important to note that qAsConst() does not copy its argument,
- it just performs a \c{const_cast<const T&>(t)}. This is also the reason
- why it is designed to fail for rvalues: The returned reference would go
- stale too soon. So while this works (but detaches the returned object):
- \snippet code/src_corelib_global_qglobal.cpp as-const-2
-
- this would not:
- \snippet code/src_corelib_global_qglobal.cpp as-const-3
-
- To prevent this construct from compiling (and failing at runtime), qAsConst() has
- a second, deleted, overload which binds to rvalues.
-*/
-
-/*!
- \fn template <typename T> void qAsConst(const T &&t)
- \relates <QtGlobal>
- \since 5.7
- \overload
-
- This overload is deleted to prevent a dangling reference in code like
- \snippet code/src_corelib_global_qglobal.cpp as-const-4
-*/
-
-/*!
- \fn template <typename T, typename U = T> T qExchange(T &obj, U &&newValue)
- \relates <QtGlobal>
- \since 5.14
-
- Replaces the value of \a obj with \a newValue and returns the old value of \a obj.
-
- This is Qt's implementation of std::exchange(). It differs from std::exchange()
- only in that it is \c constexpr already in C++14, and available on all supported
- compilers.
-
- Here is how to use qExchange() to implement move constructors:
- \code
- MyClass(MyClass &&other)
- : m_pointer{qExchange(other.m_pointer, nullptr)},
- m_int{qExchange(other.m_int, 0)},
- m_vector{std::move(other.m_vector)},
- ...
- \endcode
-
- For members of class type, we can use std::move(), as their move-constructor will
- do the right thing. But for scalar types such as raw pointers or integer type, move
- is the same as copy, which, particularly for pointers, is not what we expect. So, we
- cannot use std::move() for such types, but we can use std::exchange()/qExchange() to
- make sure the source object's member is already reset by the time we get to the
- initialization of our next data member, which might come in handy if the constructor
- exits with an exception.
-
- Here is how to use qExchange() to write a loop that consumes the collection it
- iterates over:
- \code
- for (auto &e : qExchange(collection, {})
- doSomethingWith(e);
- \endcode
-
- Which is equivalent to the following, much more verbose code:
- \code
- {
- auto tmp = std::move(collection);
- collection = {}; // or collection.clear()
- for (auto &e : tmp)
- doSomethingWith(e);
- } // destroys 'tmp'
- \endcode
-
- This is perfectly safe, as the for-loop keeps the result of qExchange() alive for as
- long as the loop runs, saving the declaration of a temporary variable. Be aware, though,
- that qExchange() returns a non-const object, so Qt containers may detach.
-*/
-
-/*!
- \fn template <typename Enum> std::underlying_type_t<Enum> qToUnderlying(Enum e)
- \relates <QtGlobal>
- \since 6.2
-
- Converts the enumerator \a e to the equivalent value expressed in its
- enumeration's underlying type.
-*/
-
-/*!
- \macro Q_LIKELY(expr)
- \relates <QtGlobal>
- \since 4.8
-
- \brief Hints to the compiler that the enclosed condition, \a expr, is
- likely to evaluate to \c true.
-
- Use of this macro can help the compiler to optimize the code.
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp qlikely
-
- \sa Q_UNLIKELY(), Q_ASSUME()
-*/
-
-/*!
- \macro Q_UNLIKELY(expr)
- \relates <QtGlobal>
- \since 4.8
-
- \brief Hints to the compiler that the enclosed condition, \a expr, is
- likely to evaluate to \c false.
-
- Use of this macro can help the compiler to optimize the code.
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp qunlikely
-
- \sa Q_LIKELY()
-*/
-
-/*!
- \macro Q_CONSTINIT
- \relates <QtGlobal>
- \since 6.4
-
- \brief Enforces constant initialization when supported by the compiler.
-
- If the compiler supports the C++20 \c{constinit} keyword, Clang's
- \c{[[clang::require_constant_initialization]]} or GCC's \c{__constinit},
- then this macro expands to the first one of these that is available,
- otherwise it expands to nothing.
-
- Variables marked as \c{constinit} cause a compile-error if their
- initialization would have to be performed at runtime.
-
- For constants, you can use \c{constexpr} since C++11, but \c{constexpr}
- makes variables \c{const}, too, whereas \c{constinit} ensures constant
- initialization, but doesn't make the variable \c{const}:
-
- \table
- \header \li Keyword \li Added \li immutable \li constant-initialized
- \row \li \c{const} \li C++98 \li yes \li not required
- \row \li \c{constexpr} \li C++11 \li yes \li required
- \row \li \c{constinit} \li C++20 \li no \li required
- \endtable
-*/
-
-/*!
- \macro QT_POINTER_SIZE
- \relates <QtGlobal>
-
- Expands to the size of a pointer in bytes (4 or 8). This is
- equivalent to \c sizeof(void *) but can be used in a preprocessor
- directive.
-*/
-
-/*!
- \macro Q_DECLARE_TYPEINFO(Type, Flags)
- \relates <QtGlobal>
-
- You can use this macro to specify information about a custom type
- \a Type. With accurate type information, Qt's \l{Container Classes}
- {generic containers} can choose appropriate storage methods and
- algorithms.
-
- \a Flags can be one of the following:
-
- \list
- \li \c Q_PRIMITIVE_TYPE specifies that \a Type is a POD (plain old
- data) type with no constructor or destructor, and for which memcpy()ing
- creates a valid independent copy of the object.
- \li \c Q_RELOCATABLE_TYPE specifies that \a Type has a constructor
- and/or a destructor but can be moved in memory using \c
- memcpy().
- \li \c Q_MOVABLE_TYPE is the same as \c Q_RELOCATABLE_TYPE. Prefer to use
- \c Q_RELOCATABLE_TYPE in new code. Note: despite the name, this
- has nothing to do with move constructors or C++ move semantics.
- \li \c Q_COMPLEX_TYPE (the default) specifies that \a Type has
- constructors and/or a destructor and that it may not be moved
- in memory.
- \endlist
-
- Example of a "primitive" type:
-
- \snippet code/src_corelib_global_qglobal.cpp 38
-
- An example of a non-POD "primitive" type is QUuid: Even though
- QUuid has constructors (and therefore isn't POD), every bit
- pattern still represents a valid object, and memcpy() can be used
- to create a valid independent copy of a QUuid object.
-
- Example of a relocatable type:
-
- \snippet code/src_corelib_global_qglobal.cpp 39
-
- Qt will try to detect the class of a type using
- \l {https://en.cppreference.com/w/cpp/types/is_trivial} {std::is_trivial_v<T>}
- to identify primitive
- types and it will require both
- \l {https://en.cppreference.com/w/cpp/types/is_trivially_copyable} {std::is_trivially_copyable_v<T>}
- and
- \l {https://en.cppreference.com/w/cpp/types/is_destructible} {std::is_trivially_destructible_v<T>}
- to identify relocatable types.
- Use this macro to tune the behavior.
- For instance many types would be candidates for Q_RELOCATABLE_TYPE despite
- not being trivially-copyable.
-*/
-
-/*!
- \macro Q_UNUSED(name)
- \relates <QtGlobal>
-
- Indicates to the compiler that the parameter with the specified
- \a name is not used in the body of a function. This can be used to
- suppress compiler warnings while allowing functions to be defined
- with meaningful parameter names in their signatures.
-*/
-
struct QInternal_CallBackTable
{
QList<QList<qInternalCallback>> callbacks;
@@ -3420,57 +213,6 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
}
/*!
- \macro Q_BYTE_ORDER
- \relates <QtGlobal>
-
- This macro can be used to determine the byte order your system
- uses for storing data in memory. i.e., whether your system is
- little-endian or big-endian. It is set by Qt to one of the macros
- Q_LITTLE_ENDIAN or Q_BIG_ENDIAN. You normally won't need to worry
- about endian-ness, but you might, for example if you need to know
- which byte of an integer or UTF-16 character is stored in the
- lowest address. Endian-ness is important in networking, where
- computers with different values for Q_BYTE_ORDER must pass data
- back and forth.
-
- Use this macro as in the following examples.
-
- \snippet code/src_corelib_global_qglobal.cpp 40
-
- \sa Q_BIG_ENDIAN, Q_LITTLE_ENDIAN
-*/
-
-/*!
- \macro Q_LITTLE_ENDIAN
- \relates <QtGlobal>
-
- This macro represents a value you can compare to the macro
- Q_BYTE_ORDER to determine the endian-ness of your system. In a
- little-endian system, the least significant byte is stored at the
- lowest address. The other bytes follow in increasing order of
- significance.
-
- \snippet code/src_corelib_global_qglobal.cpp 41
-
- \sa Q_BYTE_ORDER, Q_BIG_ENDIAN
-*/
-
-/*!
- \macro Q_BIG_ENDIAN
- \relates <QtGlobal>
-
- This macro represents a value you can compare to the macro
- Q_BYTE_ORDER to determine the endian-ness of your system. In a
- big-endian system, the most significant byte is stored at the
- lowest address. The other bytes follow in decreasing order of
- significance.
-
- \snippet code/src_corelib_global_qglobal.cpp 42
-
- \sa Q_BYTE_ORDER, Q_LITTLE_ENDIAN
-*/
-
-/*!
\macro QT_NAMESPACE
\internal
@@ -3600,296 +342,6 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
*/
/*!
- \fn bool qFuzzyCompare(double p1, double p2)
- \relates <QtNumeric>
- \since 4.4
- \threadsafe
-
- Compares the floating point value \a p1 and \a p2 and
- returns \c true if they are considered equal, otherwise \c false.
-
- Note that comparing values where either \a p1 or \a p2 is 0.0 will not work,
- nor does comparing values where one of the values is NaN or infinity.
- If one of the values is always 0.0, use qFuzzyIsNull instead. If one of the
- values is likely to be 0.0, one solution is to add 1.0 to both values.
-
- \snippet code/src_corelib_global_qglobal.cpp 46
-
- The two numbers are compared in a relative way, where the
- exactness is stronger the smaller the numbers are.
-*/
-
-/*!
- \fn bool qFuzzyCompare(float p1, float p2)
- \relates <QtNumeric>
- \since 4.4
- \threadsafe
-
- Compares the floating point value \a p1 and \a p2 and
- returns \c true if they are considered equal, otherwise \c false.
-
- The two numbers are compared in a relative way, where the
- exactness is stronger the smaller the numbers are.
-*/
-
-/*!
- \fn bool qFuzzyIsNull(double d)
- \relates <QtNumeric>
- \since 4.4
- \threadsafe
-
- Returns true if the absolute value of \a d is within 0.000000000001 of 0.0.
-*/
-
-/*!
- \fn bool qFuzzyIsNull(float f)
- \relates <QtNumeric>
- \since 4.4
- \threadsafe
-
- Returns true if the absolute value of \a f is within 0.00001f of 0.0.
-*/
-
-/*!
- \macro QT_REQUIRE_VERSION(int argc, char **argv, const char *version)
- \relates <QtGlobal>
-
- This macro can be used to ensure that the application is run
- with a recent enough version of Qt. This is especially useful
- if your application depends on a specific bug fix introduced in a
- bug-fix release (for example, 6.1.2).
-
- The \a argc and \a argv parameters are the \c main() function's
- \c argc and \c argv parameters. The \a version parameter is a
- string literal that specifies which version of Qt the application
- requires (for example, "6.1.2").
-
- Example:
-
- \snippet code/src_gui_dialogs_qmessagebox.cpp 4
-*/
-
-/*!
- \macro Q_DECL_EXPORT
- \relates <QtGlobal>
-
- This macro marks a symbol for shared library export (see
- \l{sharedlibrary.html}{Creating Shared Libraries}).
-
- \sa Q_DECL_IMPORT
-*/
-
-/*!
- \macro Q_DECL_IMPORT
- \relates <QtGlobal>
-
- This macro declares a symbol to be an import from a shared library (see
- \l{sharedlibrary.html}{Creating Shared Libraries}).
-
- \sa Q_DECL_EXPORT
-*/
-
-/*!
- \macro Q_DECL_CONSTEXPR
- \relates <QtGlobal>
-
- This macro can be used to declare variable that should be constructed at compile-time,
- or an inline function that can be computed at compile-time.
-
- It expands to "constexpr" if your compiler supports that C++11 keyword, or to nothing
- otherwise.
-
- \sa Q_DECL_RELAXED_CONSTEXPR
-*/
-
-/*!
- \macro Q_DECL_RELAXED_CONSTEXPR
- \relates <QtGlobal>
-
- This macro can be used to declare an inline function that can be computed
- at compile-time according to the relaxed rules from C++14.
-
- It expands to "constexpr" if your compiler supports C++14 relaxed constant
- expressions, or to nothing otherwise.
-
- \sa Q_DECL_CONSTEXPR
-*/
-
-/*!
- \macro qDebug(const char *message, ...)
- \relates <QtGlobal>
- \threadsafe
-
- Calls the message handler with the debug message \a message. If no
- message handler has been installed, the message is printed to
- stderr. Under Windows the message is sent to the console, if it is a
- console application; otherwise, it is sent to the debugger. On QNX, the
- message is sent to slogger2. This function does nothing if \c QT_NO_DEBUG_OUTPUT
- was defined during compilation.
-
- If you pass the function a format string and a list of arguments,
- it works in similar way to the C printf() function. The format
- should be a Latin-1 string.
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp 24
-
- If you include \c <QtDebug>, a more convenient syntax is also
- available:
-
- \snippet code/src_corelib_global_qglobal.cpp 25
-
- With this syntax, the function returns a QDebug object that is
- configured to use the QtDebugMsg message type. It automatically
- puts a single space between each item, and outputs a newline at
- the end. It supports many C++ and Qt types.
-
- To suppress the output at runtime, install your own message handler
- with qInstallMessageHandler().
-
- \sa qInfo(), qWarning(), qCritical(), qFatal(), qInstallMessageHandler(),
- {Debugging Techniques}
-*/
-
-/*!
- \macro qInfo(const char *message, ...)
- \relates <QtGlobal>
- \threadsafe
- \since 5.5
-
- Calls the message handler with the informational message \a message. If no
- message handler has been installed, the message is printed to
- stderr. Under Windows, the message is sent to the console, if it is a
- console application; otherwise, it is sent to the debugger. On QNX the
- message is sent to slogger2. This function does nothing if \c QT_NO_INFO_OUTPUT
- was defined during compilation.
-
- If you pass the function a format string and a list of arguments,
- it works in similar way to the C printf() function. The format
- should be a Latin-1 string.
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp qInfo_printf
-
- If you include \c <QtDebug>, a more convenient syntax is also
- available:
-
- \snippet code/src_corelib_global_qglobal.cpp qInfo_stream
-
- With this syntax, the function returns a QDebug object that is
- configured to use the QtInfoMsg message type. It automatically
- puts a single space between each item, and outputs a newline at
- the end. It supports many C++ and Qt types.
-
- To suppress the output at runtime, install your own message handler
- using qInstallMessageHandler().
-
- \sa qDebug(), qWarning(), qCritical(), qFatal(), qInstallMessageHandler(),
- {Debugging Techniques}
-*/
-
-/*!
- \macro qWarning(const char *message, ...)
- \relates <QtGlobal>
- \threadsafe
-
- Calls the message handler with the warning message \a message. If no
- message handler has been installed, the message is printed to
- stderr. Under Windows, the message is sent to the debugger.
- On QNX the message is sent to slogger2. This
- function does nothing if \c QT_NO_WARNING_OUTPUT was defined
- during compilation; it exits if at the nth warning corresponding to the
- counter in environment variable \c QT_FATAL_WARNINGS. That is, if the
- environment variable contains the value 1, it will exit on the 1st message;
- if it contains the value 10, it will exit on the 10th message. Any
- non-numeric value is equivalent to 1.
-
- This function takes a format string and a list of arguments,
- similar to the C printf() function. The format should be a Latin-1
- string.
-
- Example:
- \snippet code/src_corelib_global_qglobal.cpp 26
-
- If you include <QtDebug>, a more convenient syntax is
- also available:
-
- \snippet code/src_corelib_global_qglobal.cpp 27
-
- This syntax inserts a space between each item, and
- appends a newline at the end.
-
- To suppress the output at runtime, install your own message handler
- with qInstallMessageHandler().
-
- \sa qDebug(), qInfo(), qCritical(), qFatal(), qInstallMessageHandler(),
- {Debugging Techniques}
-*/
-
-/*!
- \macro qCritical(const char *message, ...)
- \relates <QtGlobal>
- \threadsafe
-
- Calls the message handler with the critical message \a message. If no
- message handler has been installed, the message is printed to
- stderr. Under Windows, the message is sent to the debugger.
- On QNX the message is sent to slogger2.
-
- It exits if the environment variable QT_FATAL_CRITICALS is not empty.
-
- This function takes a format string and a list of arguments,
- similar to the C printf() function. The format should be a Latin-1
- string.
-
- Example:
- \snippet code/src_corelib_global_qglobal.cpp 28
-
- If you include <QtDebug>, a more convenient syntax is
- also available:
-
- \snippet code/src_corelib_global_qglobal.cpp 29
-
- A space is inserted between the items, and a newline is
- appended at the end.
-
- To suppress the output at runtime, install your own message handler
- with qInstallMessageHandler().
-
- \sa qDebug(), qInfo(), qWarning(), qFatal(), qInstallMessageHandler(),
- {Debugging Techniques}
-*/
-
-/*!
- \macro qFatal(const char *message, ...)
- \relates <QtGlobal>
-
- Calls the message handler with the fatal message \a message. If no
- message handler has been installed, the message is printed to
- stderr. Under Windows, the message is sent to the debugger.
- On QNX the message is sent to slogger2.
-
- If you are using the \b{default message handler} this function will
- abort to create a core dump. On Windows, for debug builds,
- this function will report a _CRT_ERROR enabling you to connect a debugger
- to the application.
-
- This function takes a format string and a list of arguments,
- similar to the C printf() function.
-
- Example:
- \snippet code/src_corelib_global_qglobal.cpp 30
-
- To suppress the output at runtime, install your own message handler
- with qInstallMessageHandler().
-
- \sa qDebug(), qInfo(), qWarning(), qCritical(), qInstallMessageHandler(),
- {Debugging Techniques}
-*/
-
-/*!
\macro qMove(x)
\relates <QtGlobal>
\deprecated
@@ -3902,25 +354,6 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
*/
/*!
- \macro Q_DECL_NOTHROW
- \relates <QtGlobal>
- \since 5.0
-
- This macro marks a function as never throwing, under no
- circumstances. If the function does nevertheless throw, the
- behaviour is undefined.
-
- The macro expands to either "throw()", if that has some benefit on
- the compiler, or to C++11 noexcept, if available, or to nothing
- otherwise.
-
- If you need C++11 noexcept semantics, don't use this macro, use
- Q_DECL_NOEXCEPT/Q_DECL_NOEXCEPT_EXPR instead.
-
- \sa Q_DECL_NOEXCEPT, Q_DECL_NOEXCEPT_EXPR()
-*/
-
-/*!
\macro QT_TERMINATE_ON_EXCEPTION(expr)
\relates <QtGlobal>
\internal
@@ -3950,126 +383,6 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
\sa Q_DECL_NOEXCEPT, Q_DECL_NOTHROW, qTerminate()
*/
-/*!
- \macro Q_DECL_NOEXCEPT
- \relates <QtGlobal>
- \since 5.0
-
- This macro marks a function as never throwing. If the function
- does nevertheless throw, the behaviour is defined:
- std::terminate() is called.
-
- The macro expands to C++11 noexcept, if available, or to nothing
- otherwise.
-
- If you need the operator version of C++11 noexcept, use
- Q_DECL_NOEXCEPT_EXPR(x).
-
- If you don't need C++11 noexcept semantics, e.g. because your
- function can't possibly throw, don't use this macro, use
- Q_DECL_NOTHROW instead.
-
- \sa Q_DECL_NOTHROW, Q_DECL_NOEXCEPT_EXPR()
-*/
-
-/*!
- \macro Q_DECL_NOEXCEPT_EXPR(x)
- \relates <QtGlobal>
- \since 5.0
-
- This macro marks a function as non-throwing if \a x is \c true. If
- the function does nevertheless throw, the behaviour is defined:
- std::terminate() is called.
-
- The macro expands to C++11 noexcept(x), if available, or to
- nothing otherwise.
-
- If you need the always-true version of C++11 noexcept, use
- Q_DECL_NOEXCEPT.
-
- If you don't need C++11 noexcept semantics, e.g. because your
- function can't possibly throw, don't use this macro, use
- Q_DECL_NOTHROW instead.
-
- \sa Q_DECL_NOTHROW, Q_DECL_NOEXCEPT
-*/
-
-/*!
- \macro Q_DECL_OVERRIDE
- \since 5.0
- \deprecated
- \relates <QtGlobal>
-
- This macro can be used to declare an overriding virtual
- function. Use of this markup will allow the compiler to generate
- an error if the overriding virtual function does not in fact
- override anything.
-
- It expands to "override".
-
- The macro goes at the end of the function, usually after the
- \c{const}, if any:
- \snippet code/src_corelib_global_qglobal.cpp qdecloverride
-
- \sa Q_DECL_FINAL
-*/
-
-/*!
- \macro Q_DECL_FINAL
- \since 5.0
- \deprecated
- \relates <QtGlobal>
-
- This macro can be used to declare an overriding virtual or a class
- as "final", with Java semantics. Further-derived classes can then
- no longer override this virtual function, or inherit from this
- class, respectively.
-
- It expands to "final".
-
- The macro goes at the end of the function, usually after the
- \c{const}, if any:
- \snippet code/src_corelib_global_qglobal.cpp qdeclfinal-1
-
- For classes, it goes in front of the \c{:} in the class
- definition, if any:
- \snippet code/src_corelib_global_qglobal.cpp qdeclfinal-2
-
- \sa Q_DECL_OVERRIDE
-*/
-
-/*!
- \macro Q_FORWARD_DECLARE_OBJC_CLASS(classname)
- \since 5.2
- \relates <QtGlobal>
-
- Forward-declares an Objective-C \a classname in a manner such that it can be
- compiled as either Objective-C or C++.
-
- This is primarily intended for use in header files that may be included by
- both Objective-C and C++ source files.
-*/
-
-/*!
- \macro Q_FORWARD_DECLARE_CF_TYPE(type)
- \since 5.2
- \relates <QtGlobal>
-
- Forward-declares a Core Foundation \a type. This includes the actual
- type and the ref type. For example, Q_FORWARD_DECLARE_CF_TYPE(CFString)
- declares __CFString and CFStringRef.
-*/
-
-/*!
- \macro Q_FORWARD_DECLARE_MUTABLE_CF_TYPE(type)
- \since 5.2
- \relates <QtGlobal>
-
- Forward-declares a mutable Core Foundation \a type. This includes the actual
- type and the ref type. For example, Q_FORWARD_DECLARE_MUTABLE_CF_TYPE(CFMutableString)
- declares __CFMutableString and CFMutableStringRef.
-*/
-
namespace QtPrivate {
Q_LOGGING_CATEGORY(lcNativeInterface, "qt.nativeinterface")
}
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 55ce173183..f78d7e9445 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -7,7 +7,6 @@
#if 0
#pragma qt_class(QtGlobal)
-#pragma qt_class(QIntegerForSize)
#endif
#ifdef __cplusplus
@@ -23,871 +22,25 @@
#endif
#include <QtCore/qtversionchecks.h>
-
-#ifdef QT_BOOTSTRAPPED
-#include <QtCore/qconfig-bootstrapped.h>
-#else
-#include <QtCore/qconfig.h>
-#include <QtCore/qtcore-config.h>
-#endif
-
-/*
- The Qt modules' export macros.
- The options are:
- - defined(QT_STATIC): Qt was built or is being built in static mode
- - defined(QT_SHARED): Qt was built or is being built in shared/dynamic mode
- If neither was defined, then QT_SHARED is implied. If Qt was compiled in static
- mode, QT_STATIC is defined in qconfig.h. In shared mode, QT_STATIC is implied
- for the bootstrapped tools.
-*/
-
-#ifdef QT_BOOTSTRAPPED
-# ifdef QT_SHARED
-# error "QT_SHARED and QT_BOOTSTRAPPED together don't make sense. Please fix the build"
-# elif !defined(QT_STATIC)
-# define QT_STATIC
-# endif
-#endif
-
-#if defined(QT_SHARED) || !defined(QT_STATIC)
-# ifdef QT_STATIC
-# error "Both QT_SHARED and QT_STATIC defined, please make up your mind"
-# endif
-# ifndef QT_SHARED
-# define QT_SHARED
-# endif
-#endif
-
+#include <QtCore/qtconfigmacros.h>
#include <QtCore/qtcoreexports.h>
-/*
- The QT_CONFIG macro implements a safe compile time check for features of Qt.
- Features can be in three states:
- 0 or undefined: This will lead to a compile error when testing for it
- -1: The feature is not available
- 1: The feature is available
-*/
-#define QT_CONFIG(feature) (1/QT_FEATURE_##feature == 1)
-#define QT_REQUIRE_CONFIG(feature) Q_STATIC_ASSERT_X(QT_FEATURE_##feature == 1, "Required feature " #feature " for file " __FILE__ " not available.")
-
-/*
- helper macros to make some simple code work active in Qt 6 or Qt 7 only,
- like:
- struct QT6_ONLY(Q_CORE_EXPORT) QTrivialClass
- {
- void QT7_ONLY(Q_CORE_EXPORT) void operate();
- }
-*/
-#if QT_VERSION_MAJOR == 7
-# define QT7_ONLY(...) __VA_ARGS__
-# define QT6_ONLY(...)
-#elif QT_VERSION_MAJOR == 6
-# define QT7_ONLY(...)
-# define QT6_ONLY(...) __VA_ARGS__
-#else
-# error Qt major version not 6 or 7
-#endif
-
-/* Macro and tag type to help overload resolution on functions
- that are, e.g., QT_REMOVED_SINCE'ed. Example use:
-
- #if QT_CORE_REMOVED_SINCE(6, 4)
- int size() const;
- #endif
- qsizetype size(QT6_DECL_NEW_OVERLOAD) const;
-
- in the normal cpp file:
-
- qsizetype size(QT6_IMPL_NEW_OVERLOAD) const {
- ~~~
- }
-
- in removed_api.cpp:
+#include <QtCore/qtpreprocessorsupport.h>
- int size() const { return int(size(QT6_CALL_NEW_OVERLOAD)); }
-*/
-#ifdef Q_CLANG_QDOC
-# define QT6_DECL_NEW_OVERLOAD
-# define QT6_DECL_NEW_OVERLOAD_TAIL
-# define QT6_IMPL_NEW_OVERLOAD
-# define QT6_IMPL_NEW_OVERLOAD_TAIL
-# define QT6_CALL_NEW_OVERLOAD
-# define QT6_CALL_NEW_OVERLOAD_TAIL
-#else
-# define QT6_DECL_NEW_OVERLOAD QT6_ONLY(Qt::Disambiguated_t = Qt::Disambiguated)
-# define QT6_DECL_NEW_OVERLOAD_TAIL QT6_ONLY(, QT6_DECL_NEW_OVERLOAD)
-# define QT6_IMPL_NEW_OVERLOAD QT6_ONLY(Qt::Disambiguated_t)
-# define QT6_IMPL_NEW_OVERLOAD_TAIL QT6_ONLY(, QT6_IMPL_NEW_OVERLOAD)
-# define QT6_CALL_NEW_OVERLOAD QT6_ONLY(Qt::Disambiguated)
-# define QT6_CALL_NEW_OVERLOAD_TAIL QT6_ONLY(, QT6_CALL_NEW_OVERLOAD)
-#endif
-
-/* These two macros makes it possible to turn the builtin line expander into a
- * string literal. */
-#define QT_STRINGIFY2(x) #x
-#define QT_STRINGIFY(x) QT_STRINGIFY2(x)
+#include <QtCore/qtnoop.h>
#include <QtCore/qsystemdetection.h>
#include <QtCore/qprocessordetection.h>
#include <QtCore/qcompilerdetection.h>
-#if defined (__ELF__)
-# define Q_OF_ELF
-#endif
-#if defined (__MACH__) && defined (__APPLE__)
-# define Q_OF_MACH_O
-#endif
-
-/*
- Avoid "unused parameter" warnings
-*/
-#define Q_UNUSED(x) (void)x;
-
-#if defined(__cplusplus)
-// Don't use these in C++ mode, use static_assert directly.
-// These are here only to keep old code compiling.
-# define Q_STATIC_ASSERT(Condition) static_assert(bool(Condition), #Condition)
-# define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message)
-#elif defined(Q_COMPILER_STATIC_ASSERT)
-// C11 mode - using the _S version in case <assert.h> doesn't do the right thing
-# define Q_STATIC_ASSERT(Condition) _Static_assert(!!(Condition), #Condition)
-# define Q_STATIC_ASSERT_X(Condition, Message) _Static_assert(!!(Condition), Message)
-#else
-// C89 & C99 version
-# define Q_STATIC_ASSERT_PRIVATE_JOIN(A, B) Q_STATIC_ASSERT_PRIVATE_JOIN_IMPL(A, B)
-# define Q_STATIC_ASSERT_PRIVATE_JOIN_IMPL(A, B) A ## B
-# ifdef __COUNTER__
-# define Q_STATIC_ASSERT(Condition) \
- typedef char Q_STATIC_ASSERT_PRIVATE_JOIN(q_static_assert_result, __COUNTER__) [(Condition) ? 1 : -1];
-# else
-# define Q_STATIC_ASSERT(Condition) \
- typedef char Q_STATIC_ASSERT_PRIVATE_JOIN(q_static_assert_result, __LINE__) [(Condition) ? 1 : -1];
-# endif /* __COUNTER__ */
-# define Q_STATIC_ASSERT_X(Condition, Message) Q_STATIC_ASSERT(Condition)
-#endif
+#include <QtCore/qassert.h>
+#include <QtCore/qtypes.h>
+#include <QtCore/qtclasshelpermacros.h>
-# include <QtCore/qtnamespacemacros.h>
#ifndef __ASSEMBLER__
-QT_BEGIN_NAMESPACE
-
-/*
- Size-dependent types (architechture-dependent byte order)
-
- Make sure to update QMetaType when changing these typedefs
-*/
-
-typedef signed char qint8; /* 8 bit signed */
-typedef unsigned char quint8; /* 8 bit unsigned */
-typedef short qint16; /* 16 bit signed */
-typedef unsigned short quint16; /* 16 bit unsigned */
-typedef int qint32; /* 32 bit signed */
-typedef unsigned int quint32; /* 32 bit unsigned */
-// Unlike LL / ULL in C++, for historical reasons, we force the
-// result to be of the requested type.
-#ifdef __cplusplus
-# define Q_INT64_C(c) static_cast<long long>(c ## LL) /* signed 64 bit constant */
-# define Q_UINT64_C(c) static_cast<unsigned long long>(c ## ULL) /* unsigned 64 bit constant */
-#else
-# define Q_INT64_C(c) ((long long)(c ## LL)) /* signed 64 bit constant */
-# define Q_UINT64_C(c) ((unsigned long long)(c ## ULL)) /* unsigned 64 bit constant */
-#endif
-typedef long long qint64; /* 64 bit signed */
-typedef unsigned long long quint64; /* 64 bit unsigned */
-
-typedef qint64 qlonglong;
-typedef quint64 qulonglong;
-
-#ifndef __cplusplus
-// In C++ mode, we define below using QIntegerForSize template
-Q_STATIC_ASSERT_X(sizeof(ptrdiff_t) == sizeof(size_t), "Weird ptrdiff_t and size_t definitions");
-typedef ptrdiff_t qptrdiff;
-typedef ptrdiff_t qsizetype;
-typedef ptrdiff_t qintptr;
-typedef size_t quintptr;
-
-#define PRIdQPTRDIFF "td"
-#define PRIiQPTRDIFF "ti"
-
-#define PRIdQSIZETYPE "td"
-#define PRIiQSIZETYPE "ti"
-
-#define PRIdQINTPTR "td"
-#define PRIiQINTPTR "ti"
-
-#define PRIuQUINTPTR "zu"
-#define PRIoQUINTPTR "zo"
-#define PRIxQUINTPTR "zx"
-#define PRIXQUINTPTR "zX"
-#endif
-
-/*
- Useful type definitions for Qt
-*/
-
-QT_BEGIN_INCLUDE_NAMESPACE
-typedef unsigned char uchar;
-typedef unsigned short ushort;
-typedef unsigned int uint;
-typedef unsigned long ulong;
-QT_END_INCLUDE_NAMESPACE
-
-#if defined(QT_COORD_TYPE)
-typedef QT_COORD_TYPE qreal;
-#else
-typedef double qreal;
-#endif
-
-/*
- Some classes do not permit copies to be made of an object. These
- classes contains a private copy constructor and assignment
- operator to disable copying (the compiler gives an error message).
-*/
-#define Q_DISABLE_COPY(Class) \
- Class(const Class &) = delete;\
- Class &operator=(const Class &) = delete;
-
-#define Q_DISABLE_COPY_MOVE(Class) \
- Q_DISABLE_COPY(Class) \
- Class(Class &&) = delete; \
- Class &operator=(Class &&) = delete;
-
-/*
- Implementing a move assignment operator using an established
- technique (move-and-swap, pure swap) is just boilerplate.
- Here's a couple of *private* macros for convenience.
-
- To know which one to use:
-
- * if you don't have a move constructor (*) => use pure swap;
- * if you have a move constructor, then
- * if your class holds just memory (no file handles, no user-defined
- datatypes, etc.) => use pure swap;
- * use move and swap.
-
- The preference should always go for the move-and-swap one, as it
- will deterministically destroy the data previously held in *this,
- and not "dump" it in the moved-from object (which may then be alive
- for longer).
-
- The requirement for either macro is the presence of a member swap(),
- which any value class that defines its own special member functions
- should have anyhow.
-
- (*) Many value classes in Qt do not have move constructors; mostly,
- the implicitly shared classes using QSharedDataPointer and friends.
- The reason is mostly historical: those classes require either an
- out-of-line move constructor, which we could not provide before we
- made C++11 mandatory (and that we don't like anyhow), or
- an out-of-line dtor for the Q(E)DSP<Private> member (cf. QPixmap).
-
- If you can however add a move constructor to a class lacking it,
- consider doing so, then reevaluate which macro to choose.
-*/
-#define QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(Class) \
- Class &operator=(Class &&other) noexcept { \
- Class moved(std::move(other)); \
- swap(moved); \
- return *this; \
- }
-
-#define QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(Class) \
- Class &operator=(Class &&other) noexcept { \
- swap(other); \
- return *this; \
- }
-
-/*
- No, this is not an evil backdoor. QT_BUILD_INTERNAL just exports more symbols
- for Qt's internal unit tests. If you want slower loading times and more
- symbols that can vanish from version to version, feel free to define QT_BUILD_INTERNAL.
-*/
-#if defined(QT_BUILD_INTERNAL) && defined(QT_BUILDING_QT) && defined(QT_SHARED)
-# define Q_AUTOTEST_EXPORT Q_DECL_EXPORT
-#elif defined(QT_BUILD_INTERNAL) && defined(QT_SHARED)
-# define Q_AUTOTEST_EXPORT Q_DECL_IMPORT
-#else
-# define Q_AUTOTEST_EXPORT
-#endif
-
-#define Q_INIT_RESOURCE(name) \
- do { extern int QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); \
- QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); } while (false)
-#define Q_CLEANUP_RESOURCE(name) \
- do { extern int QT_MANGLE_NAMESPACE(qCleanupResources_ ## name) (); \
- QT_MANGLE_NAMESPACE(qCleanupResources_ ## name) (); } while (false)
-
-/*
- * If we're compiling C++ code:
- * - and this is a non-namespace build, declare qVersion as extern "C"
- * - and this is a namespace build, declare it as a regular function
- * (we're already inside QT_BEGIN_NAMESPACE / QT_END_NAMESPACE)
- * If we're compiling C code, simply declare the function. If Qt was compiled
- * in a namespace, qVersion isn't callable anyway.
- */
-#if !defined(QT_NAMESPACE) && defined(__cplusplus) && !defined(Q_QDOC)
-extern "C"
-#endif
-Q_CORE_EXPORT Q_DECL_CONST_FUNCTION const char *qVersion(void) Q_DECL_NOEXCEPT;
-
#if defined(__cplusplus)
-#ifndef Q_CONSTRUCTOR_FUNCTION
-# define Q_CONSTRUCTOR_FUNCTION0(AFUNC) \
- namespace { \
- static const struct AFUNC ## _ctor_class_ { \
- inline AFUNC ## _ctor_class_() { AFUNC(); } \
- } AFUNC ## _ctor_instance_; \
- }
-
-# define Q_CONSTRUCTOR_FUNCTION(AFUNC) Q_CONSTRUCTOR_FUNCTION0(AFUNC)
-#endif
-
-#ifndef Q_DESTRUCTOR_FUNCTION
-# define Q_DESTRUCTOR_FUNCTION0(AFUNC) \
- namespace { \
- static const struct AFUNC ## _dtor_class_ { \
- inline AFUNC ## _dtor_class_() { } \
- inline ~ AFUNC ## _dtor_class_() { AFUNC(); } \
- } AFUNC ## _dtor_instance_; \
- }
-# define Q_DESTRUCTOR_FUNCTION(AFUNC) Q_DESTRUCTOR_FUNCTION0(AFUNC)
-#endif
-
-/*
- quintptr and qptrdiff is guaranteed to be the same size as a pointer, i.e.
-
- sizeof(void *) == sizeof(quintptr)
- && sizeof(void *) == sizeof(qptrdiff)
-
- size_t and qsizetype are not guaranteed to be the same size as a pointer, but
- they usually are. We actually check for that in qglobal.cpp.
-*/
-template <int> struct QIntegerForSize;
-template <> struct QIntegerForSize<1> { typedef quint8 Unsigned; typedef qint8 Signed; };
-template <> struct QIntegerForSize<2> { typedef quint16 Unsigned; typedef qint16 Signed; };
-template <> struct QIntegerForSize<4> { typedef quint32 Unsigned; typedef qint32 Signed; };
-template <> struct QIntegerForSize<8> { typedef quint64 Unsigned; typedef qint64 Signed; };
-#if defined(Q_CC_GNU) && defined(__SIZEOF_INT128__)
-template <> struct QIntegerForSize<16> { __extension__ typedef unsigned __int128 Unsigned; __extension__ typedef __int128 Signed; };
-#endif
-template <class T> struct QIntegerForSizeof: QIntegerForSize<sizeof(T)> { };
-typedef QIntegerForSize<Q_PROCESSOR_WORDSIZE>::Signed qregisterint;
-typedef QIntegerForSize<Q_PROCESSOR_WORDSIZE>::Unsigned qregisteruint;
-typedef QIntegerForSizeof<void *>::Unsigned quintptr;
-typedef QIntegerForSizeof<void *>::Signed qptrdiff;
-typedef qptrdiff qintptr;
-using qsizetype = QIntegerForSizeof<std::size_t>::Signed;
-
-// These custom definitions are necessary as we're not defining our
-// datatypes in terms of the language ones, but in terms of integer
-// types that have the sime size. For instance, on a 32-bit platform,
-// qptrdiff is int, while ptrdiff_t may be aliased to long; therefore
-// using %td to print a qptrdiff would be wrong (and raise -Wformat
-// warnings), although both int and long have same bit size on that
-// platform.
-//
-// We know that sizeof(size_t) == sizeof(void *) == sizeof(qptrdiff).
-#if SIZE_MAX == 4294967295ULL
-#define PRIuQUINTPTR "u"
-#define PRIoQUINTPTR "o"
-#define PRIxQUINTPTR "x"
-#define PRIXQUINTPTR "X"
-
-#define PRIdQPTRDIFF "d"
-#define PRIiQPTRDIFF "i"
-
-#define PRIdQINTPTR "d"
-#define PRIiQINTPTR "i"
-
-#define PRIdQSIZETYPE "d"
-#define PRIiQSIZETYPE "i"
-#elif SIZE_MAX == 18446744073709551615ULL
-#define PRIuQUINTPTR "llu"
-#define PRIoQUINTPTR "llo"
-#define PRIxQUINTPTR "llx"
-#define PRIXQUINTPTR "llX"
-
-#define PRIdQPTRDIFF "lld"
-#define PRIiQPTRDIFF "lli"
-
-#define PRIdQINTPTR "lld"
-#define PRIiQINTPTR "lli"
-
-#define PRIdQSIZETYPE "lld"
-#define PRIiQSIZETYPE "lli"
-#else
-#error Unsupported platform (unknown value for SIZE_MAX)
-#endif
-
-/* moc compats (signals/slots) */
-#ifndef QT_MOC_COMPAT
-# define QT_MOC_COMPAT
-#else
-# undef QT_MOC_COMPAT
-# define QT_MOC_COMPAT
-#endif
-
-#ifdef QT_ASCII_CAST_WARNINGS
-# define QT_ASCII_CAST_WARN \
- Q_DECL_DEPRECATED_X("Use fromUtf8, QStringLiteral, or QLatin1StringView")
-#else
-# define QT_ASCII_CAST_WARN
-#endif
-
-#ifdef Q_PROCESSOR_X86_32
-# if defined(Q_CC_GNU)
-# define QT_FASTCALL __attribute__((regparm(3)))
-# elif defined(Q_CC_MSVC)
-# define QT_FASTCALL __fastcall
-# else
-# define QT_FASTCALL
-# endif
-#else
-# define QT_FASTCALL
-#endif
-
-// enable gcc warnings for printf-style functions
-#if defined(Q_CC_GNU) && !defined(__INSURE__)
-# if defined(Q_CC_MINGW) && !defined(Q_CC_CLANG)
-# define Q_ATTRIBUTE_FORMAT_PRINTF(A, B) \
- __attribute__((format(gnu_printf, (A), (B))))
-# else
-# define Q_ATTRIBUTE_FORMAT_PRINTF(A, B) \
- __attribute__((format(printf, (A), (B))))
-# endif
-#else
-# define Q_ATTRIBUTE_FORMAT_PRINTF(A, B)
-#endif
-
-#ifdef Q_CC_MSVC
-# define Q_NEVER_INLINE __declspec(noinline)
-# define Q_ALWAYS_INLINE __forceinline
-#elif defined(Q_CC_GNU)
-# define Q_NEVER_INLINE __attribute__((noinline))
-# define Q_ALWAYS_INLINE inline __attribute__((always_inline))
-#else
-# define Q_NEVER_INLINE
-# define Q_ALWAYS_INLINE inline
-#endif
-
-//defines the type for the WNDPROC on windows
-//the alignment needs to be forced for sse2 to not crash with mingw
-#if defined(Q_OS_WIN)
-# if defined(Q_CC_MINGW) && defined(Q_PROCESSOR_X86_32)
-# define QT_ENSURE_STACK_ALIGNED_FOR_SSE __attribute__ ((force_align_arg_pointer))
-# else
-# define QT_ENSURE_STACK_ALIGNED_FOR_SSE
-# endif
-# define QT_WIN_CALLBACK CALLBACK QT_ENSURE_STACK_ALIGNED_FOR_SSE
-#endif
-
-/*
- Utility macros and inline functions
-*/
-
-#ifndef Q_FORWARD_DECLARE_OBJC_CLASS
-# ifdef __OBJC__
-# define Q_FORWARD_DECLARE_OBJC_CLASS(classname) @class classname
-# else
-# define Q_FORWARD_DECLARE_OBJC_CLASS(classname) class classname
-# endif
-#endif
-#ifndef Q_FORWARD_DECLARE_CF_TYPE
-# define Q_FORWARD_DECLARE_CF_TYPE(type) typedef const struct __ ## type * type ## Ref
-#endif
-#ifndef Q_FORWARD_DECLARE_MUTABLE_CF_TYPE
-# define Q_FORWARD_DECLARE_MUTABLE_CF_TYPE(type) typedef struct __ ## type * type ## Ref
-#endif
-#ifndef Q_FORWARD_DECLARE_CG_TYPE
-#define Q_FORWARD_DECLARE_CG_TYPE(type) typedef const struct type *type ## Ref;
-#endif
-#ifndef Q_FORWARD_DECLARE_MUTABLE_CG_TYPE
-#define Q_FORWARD_DECLARE_MUTABLE_CG_TYPE(type) typedef struct type *type ## Ref;
-#endif
-
-#ifdef Q_OS_DARWIN
-# define QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios, tvos, watchos) \
- ((defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && macos != __MAC_NA && __MAC_OS_X_VERSION_MAX_ALLOWED >= macos) || \
- (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && ios != __IPHONE_NA && __IPHONE_OS_VERSION_MAX_ALLOWED >= ios) || \
- (defined(__TV_OS_VERSION_MAX_ALLOWED) && tvos != __TVOS_NA && __TV_OS_VERSION_MAX_ALLOWED >= tvos) || \
- (defined(__WATCH_OS_VERSION_MAX_ALLOWED) && watchos != __WATCHOS_NA && __WATCH_OS_VERSION_MAX_ALLOWED >= watchos))
-
-# define QT_DARWIN_DEPLOYMENT_TARGET_BELOW(macos, ios, tvos, watchos) \
- ((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && macos != __MAC_NA && __MAC_OS_X_VERSION_MIN_REQUIRED < macos) || \
- (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && ios != __IPHONE_NA && __IPHONE_OS_VERSION_MIN_REQUIRED < ios) || \
- (defined(__TV_OS_VERSION_MIN_REQUIRED) && tvos != __TVOS_NA && __TV_OS_VERSION_MIN_REQUIRED < tvos) || \
- (defined(__WATCH_OS_VERSION_MIN_REQUIRED) && watchos != __WATCHOS_NA && __WATCH_OS_VERSION_MIN_REQUIRED < watchos))
-
-# define QT_MACOS_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios) \
- QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios, __TVOS_NA, __WATCHOS_NA)
-# define QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(macos) \
- QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, __IPHONE_NA, __TVOS_NA, __WATCHOS_NA)
-# define QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(ios) \
- QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, ios, __TVOS_NA, __WATCHOS_NA)
-# define QT_TVOS_PLATFORM_SDK_EQUAL_OR_ABOVE(tvos) \
- QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, __IPHONE_NA, tvos, __WATCHOS_NA)
-# define QT_WATCHOS_PLATFORM_SDK_EQUAL_OR_ABOVE(watchos) \
- QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, __IPHONE_NA, __TVOS_NA, watchos)
-
-# define QT_MACOS_IOS_DEPLOYMENT_TARGET_BELOW(macos, ios) \
- QT_DARWIN_DEPLOYMENT_TARGET_BELOW(macos, ios, __TVOS_NA, __WATCHOS_NA)
-# define QT_MACOS_DEPLOYMENT_TARGET_BELOW(macos) \
- QT_DARWIN_DEPLOYMENT_TARGET_BELOW(macos, __IPHONE_NA, __TVOS_NA, __WATCHOS_NA)
-# define QT_IOS_DEPLOYMENT_TARGET_BELOW(ios) \
- QT_DARWIN_DEPLOYMENT_TARGET_BELOW(__MAC_NA, ios, __TVOS_NA, __WATCHOS_NA)
-# define QT_TVOS_DEPLOYMENT_TARGET_BELOW(tvos) \
- QT_DARWIN_DEPLOYMENT_TARGET_BELOW(__MAC_NA, __IPHONE_NA, tvos, __WATCHOS_NA)
-# define QT_WATCHOS_DEPLOYMENT_TARGET_BELOW(watchos) \
- QT_DARWIN_DEPLOYMENT_TARGET_BELOW(__MAC_NA, __IPHONE_NA, __TVOS_NA, watchos)
-
-// Compatibility synonyms, do not use
-# define QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(osx, ios) QT_MACOS_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(osx, ios)
-# define QT_MAC_DEPLOYMENT_TARGET_BELOW(osx, ios) QT_MACOS_IOS_DEPLOYMENT_TARGET_BELOW(osx, ios)
-# define QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(osx) QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(osx)
-# define QT_OSX_DEPLOYMENT_TARGET_BELOW(osx) QT_MACOS_DEPLOYMENT_TARGET_BELOW(osx)
-
-// Implemented in qcore_mac_objc.mm
-class Q_CORE_EXPORT QMacAutoReleasePool
-{
-public:
- QMacAutoReleasePool();
- ~QMacAutoReleasePool();
-private:
- Q_DISABLE_COPY(QMacAutoReleasePool)
- void *pool;
-};
-
-#else
-
-#define QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios, tvos, watchos) (0)
-#define QT_MACOS_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios) (0)
-#define QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(macos) (0)
-#define QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(ios) (0)
-#define QT_TVOS_PLATFORM_SDK_EQUAL_OR_ABOVE(tvos) (0)
-#define QT_WATCHOS_PLATFORM_SDK_EQUAL_OR_ABOVE(watchos) (0)
-
-#define QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(osx, ios) (0)
-#define QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(osx) (0)
-
-#endif // Q_OS_DARWIN
-
-inline void qt_noop(void) {}
-
-/* These wrap try/catch so we can switch off exceptions later.
-
- Beware - do not use more than one QT_CATCH per QT_TRY, and do not use
- the exception instance in the catch block.
- If you can't live with those constraints, don't use these macros.
- Use the QT_NO_EXCEPTIONS macro to protect your code instead.
-*/
-
-#if !defined(QT_NO_EXCEPTIONS)
-# if !defined(Q_MOC_RUN)
-# if (defined(Q_CC_CLANG) && !__has_feature(cxx_exceptions)) || \
- (defined(Q_CC_GNU) && !defined(__EXCEPTIONS))
-# define QT_NO_EXCEPTIONS
-# endif
-# elif defined(QT_BOOTSTRAPPED)
-# define QT_NO_EXCEPTIONS
-# endif
-#endif
-
-Q_NORETURN Q_DECL_COLD_FUNCTION Q_CORE_EXPORT void qTerminate() noexcept;
-#ifdef QT_NO_EXCEPTIONS
-# define QT_TRY if (true)
-# define QT_CATCH(A) else
-# define QT_THROW(A) qt_noop()
-# define QT_RETHROW qt_noop()
-# define QT_TERMINATE_ON_EXCEPTION(expr) do { expr; } while (false)
-#else
-# define QT_TRY try
-# define QT_CATCH(A) catch (A)
-# define QT_THROW(A) throw A
-# define QT_RETHROW throw
-# ifdef Q_COMPILER_NOEXCEPT
-# define QT_TERMINATE_ON_EXCEPTION(expr) do { expr; } while (false)
-# else
-# define QT_TERMINATE_ON_EXCEPTION(expr) do { try { expr; } catch (...) { qTerminate(); } } while (false)
-# endif
-#endif
-
-Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qSharedBuild() noexcept;
-
-#ifndef Q_OUTOFLINE_TEMPLATE
-# define Q_OUTOFLINE_TEMPLATE
-#endif
-#ifndef Q_INLINE_TEMPLATE
-# define Q_INLINE_TEMPLATE inline
-#endif
-
-/*
- Debugging and error handling
-*/
-
-#if !defined(QT_NO_DEBUG) && !defined(QT_DEBUG)
-# define QT_DEBUG
-#endif
-
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <QtCore/qassert.h>
-QT_END_INCLUDE_NAMESPACE
-
-#if 0
-#pragma qt_class(QFunctionPointer)
-#endif
-typedef void (*QFunctionPointer)();
-
-#if !defined(Q_UNIMPLEMENTED)
-# define Q_UNIMPLEMENTED() qWarning("Unimplemented code.")
-#endif
-
-namespace QTypeTraits {
-
-namespace detail {
-template<typename T, typename U,
- typename = std::enable_if_t<std::is_arithmetic_v<T> && std::is_arithmetic_v<U> &&
- std::is_floating_point_v<T> == std::is_floating_point_v<U> &&
- std::is_signed_v<T> == std::is_signed_v<U> &&
- !std::is_same_v<T, bool> && !std::is_same_v<U, bool> &&
- !std::is_same_v<T, char> && !std::is_same_v<U, char>>>
-struct Promoted
-{
- using type = decltype(T() + U());
-};
-}
-
-template <typename T, typename U>
-using Promoted = typename detail::Promoted<T, U>::type;
-
-}
-
-template <typename T>
-constexpr inline const T &qMin(const T &a, const T &b) { return (a < b) ? a : b; }
-template <typename T>
-constexpr inline const T &qMax(const T &a, const T &b) { return (a < b) ? b : a; }
-template <typename T>
-constexpr inline const T &qBound(const T &min, const T &val, const T &max)
-{
- Q_ASSERT(!(max < min));
- return qMax(min, qMin(max, val));
-}
-template <typename T, typename U>
-constexpr inline QTypeTraits::Promoted<T, U> qMin(const T &a, const U &b)
-{
- using P = QTypeTraits::Promoted<T, U>;
- P _a = a;
- P _b = b;
- return (_a < _b) ? _a : _b;
-}
-template <typename T, typename U>
-constexpr inline QTypeTraits::Promoted<T, U> qMax(const T &a, const U &b)
-{
- using P = QTypeTraits::Promoted<T, U>;
- P _a = a;
- P _b = b;
- return (_a < _b) ? _b : _a;
-}
-template <typename T, typename U>
-constexpr inline QTypeTraits::Promoted<T, U> qBound(const T &min, const U &val, const T &max)
-{
- Q_ASSERT(!(max < min));
- return qMax(min, qMin(max, val));
-}
-template <typename T, typename U>
-constexpr inline QTypeTraits::Promoted<T, U> qBound(const T &min, const T &val, const U &max)
-{
- using P = QTypeTraits::Promoted<T, U>;
- Q_ASSERT(!(P(max) < P(min)));
- return qMax(min, qMin(max, val));
-}
-template <typename T, typename U>
-constexpr inline QTypeTraits::Promoted<T, U> qBound(const U &min, const T &val, const T &max)
-{
- using P = QTypeTraits::Promoted<T, U>;
- Q_ASSERT(!(P(max) < P(min)));
- return qMax(min, qMin(max, val));
-}
-
-/*
- Compilers which follow outdated template instantiation rules
- require a class to have a comparison operator to exist when
- a QList of this type is instantiated. It's not actually
- used in the list, though. Hence the dummy implementation.
- Just in case other code relies on it we better trigger a warning
- mandating a real implementation.
-*/
-
-#ifdef Q_FULL_TEMPLATE_INSTANTIATION
-# define Q_DUMMY_COMPARISON_OPERATOR(C) \
- bool operator==(const C&) const { \
- qWarning(#C"::operator==(const "#C"&) was called"); \
- return false; \
- }
-#else
-
-# define Q_DUMMY_COMPARISON_OPERATOR(C)
-#endif
-
-QT_WARNING_PUSH
-// warning: noexcept-expression evaluates to 'false' because of a call to 'void swap(..., ...)'
-QT_WARNING_DISABLE_GCC("-Wnoexcept")
-
-namespace QtPrivate
-{
-namespace SwapExceptionTester { // insulate users from the "using std::swap" below
- using std::swap; // import std::swap
- template <typename T>
- void checkSwap(T &t)
- noexcept(noexcept(swap(t, t)));
- // declared, but not implemented (only to be used in unevaluated contexts (noexcept operator))
-}
-} // namespace QtPrivate
-
-// Documented in ../tools/qalgorithm.qdoc
-template <typename T>
-constexpr void qSwap(T &value1, T &value2)
- noexcept(noexcept(QtPrivate::SwapExceptionTester::checkSwap(value1)))
-{
- using std::swap;
- swap(value1, value2);
-}
-
-// pure compile-time micro-optimization for our own headers, so not documented:
-template <typename T>
-constexpr inline void qt_ptr_swap(T* &lhs, T* &rhs) noexcept
-{
- T *tmp = lhs;
- lhs = rhs;
- rhs = tmp;
-}
-
-QT_WARNING_POP
-
-Q_CORE_EXPORT void *qMallocAligned(size_t size, size_t alignment) Q_ALLOC_SIZE(1);
-Q_CORE_EXPORT void *qReallocAligned(void *ptr, size_t size, size_t oldsize, size_t alignment) Q_ALLOC_SIZE(2);
-Q_CORE_EXPORT void qFreeAligned(void *ptr);
-
-
-/*
- Avoid some particularly useless warnings from some stupid compilers.
- To get ALL C++ compiler warnings, define QT_CC_WARNINGS or comment out
- the line "#define QT_NO_WARNINGS".
-*/
-#if !defined(QT_CC_WARNINGS)
-# define QT_NO_WARNINGS
-#endif
-#if defined(QT_NO_WARNINGS)
-# if defined(Q_CC_MSVC)
-QT_WARNING_DISABLE_MSVC(4251) /* class 'type' needs to have dll-interface to be used by clients of class 'type2' */
-QT_WARNING_DISABLE_MSVC(4244) /* conversion from 'type1' to 'type2', possible loss of data */
-QT_WARNING_DISABLE_MSVC(4275) /* non - DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' */
-QT_WARNING_DISABLE_MSVC(4514) /* unreferenced inline function has been removed */
-QT_WARNING_DISABLE_MSVC(4800) /* 'type' : forcing value to bool 'true' or 'false' (performance warning) */
-QT_WARNING_DISABLE_MSVC(4097) /* typedef-name 'identifier1' used as synonym for class-name 'identifier2' */
-QT_WARNING_DISABLE_MSVC(4706) /* assignment within conditional expression */
-QT_WARNING_DISABLE_MSVC(4355) /* 'this' : used in base member initializer list */
-QT_WARNING_DISABLE_MSVC(4710) /* function not inlined */
-QT_WARNING_DISABLE_MSVC(4530) /* C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc */
-# elif defined(Q_CC_BOR)
-# pragma option -w-inl
-# pragma option -w-aus
-# pragma warn -inl
-# pragma warn -pia
-# pragma warn -ccc
-# pragma warn -rch
-# pragma warn -sig
-# endif
-#endif
-
-// this adds const to non-const objects (like std::as_const)
-template <typename T>
-constexpr typename std::add_const<T>::type &qAsConst(T &t) noexcept { return t; }
-// prevent rvalue arguments:
-template <typename T>
-void qAsConst(const T &&) = delete;
-
-// like std::exchange
-template <typename T, typename U = T>
-constexpr T qExchange(T &t, U &&newValue)
-noexcept(std::conjunction_v<std::is_nothrow_move_constructible<T>, std::is_nothrow_assignable<T &, U>>)
-{
- T old = std::move(t);
- t = std::forward<U>(newValue);
- return old;
-}
-
-// like std::to_underlying
-template <typename Enum>
-constexpr std::underlying_type_t<Enum> qToUnderlying(Enum e) noexcept
-{
- return static_cast<std::underlying_type_t<Enum>>(e);
-}
-
-#ifdef __cpp_conditional_explicit
-#define Q_IMPLICIT explicit(false)
-#else
-#define Q_IMPLICIT
-#endif
-
-#ifdef __cpp_constinit
-# if defined(Q_CC_MSVC) && !defined(Q_CC_CLANG)
- // https://developercommunity.visualstudio.com/t/C:-constinit-for-an-optional-fails-if-/1406069
-# define Q_CONSTINIT
-# else
-# define Q_CONSTINIT constinit
-# endif
-#elif defined(__has_cpp_attribute) && __has_cpp_attribute(clang::require_constant_initialization)
-# define Q_CONSTINIT [[clang::require_constant_initialization]]
-#elif defined(Q_CC_GNU_ONLY) && Q_CC_GNU >= 1000
-# define Q_CONSTINIT __constinit
-#else
-# define Q_CONSTINIT
-#endif
-
-template <typename T> inline T *qGetPtrHelper(T *ptr) noexcept { return ptr; }
-template <typename Ptr> inline auto qGetPtrHelper(Ptr &ptr) noexcept -> decltype(ptr.get())
-{ static_assert(noexcept(ptr.get()), "Smart d pointers for Q_DECLARE_PRIVATE must have noexcept get()"); return ptr.get(); }
-
-// The body must be a statement:
-#define Q_CAST_IGNORE_ALIGN(body) QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wcast-align") body QT_WARNING_POP
-#define Q_DECLARE_PRIVATE(Class) \
- inline Class##Private* d_func() noexcept \
- { Q_CAST_IGNORE_ALIGN(return reinterpret_cast<Class##Private *>(qGetPtrHelper(d_ptr));) } \
- inline const Class##Private* d_func() const noexcept \
- { Q_CAST_IGNORE_ALIGN(return reinterpret_cast<const Class##Private *>(qGetPtrHelper(d_ptr));) } \
- friend class Class##Private;
-
-#define Q_DECLARE_PRIVATE_D(Dptr, Class) \
- inline Class##Private* d_func() noexcept \
- { Q_CAST_IGNORE_ALIGN(return reinterpret_cast<Class##Private *>(qGetPtrHelper(Dptr));) } \
- inline const Class##Private* d_func() const noexcept \
- { Q_CAST_IGNORE_ALIGN(return reinterpret_cast<const Class##Private *>(qGetPtrHelper(Dptr));) } \
- friend class Class##Private;
-
-#define Q_DECLARE_PUBLIC(Class) \
- inline Class* q_func() noexcept { return static_cast<Class *>(q_ptr); } \
- inline const Class* q_func() const noexcept { return static_cast<const Class *>(q_ptr); } \
- friend class Class;
-
-#define Q_D(Class) Class##Private * const d = d_func()
-#define Q_Q(Class) Class * const q = q_func()
-
-#define QT_MODULE(x)
-
-// This macro can be used to calculate member offsets for types with a non standard layout.
-// It uses the fact that offsetof() is allowed to support those types since C++17 as an optional
-// feature. All our compilers do support this, but some issue a warning, so we wrap the offsetof()
-// call in a macro that disables the compiler warning.
-#define Q_OFFSETOF(Class, member) \
- []() -> size_t { \
- QT_WARNING_PUSH QT_WARNING_DISABLE_INVALID_OFFSETOF \
- return offsetof(Class, member); \
- QT_WARNING_POP \
- }()
-
-QT_END_NAMESPACE
-
// We need to keep QTypeInfo, QSysInfo, QFlags, qDebug & family in qglobal.h for compatibility with Qt 4.
// Be careful when changing the order of these files.
#include <QtCore/qtypeinfo.h>
@@ -897,13 +50,22 @@ QT_END_NAMESPACE
#include <QtCore/qflags.h>
#include <QtCore/qatomic.h>
-#include <QtCore/qenvironmentvariables.h>
+#include <QtCore/qconstructormacros.h>
+#include <QtCore/qdarwinhelpers.h>
+#include <QtCore/qexceptionhandling.h>
#include <QtCore/qforeach.h>
+#include <QtCore/qfunctionpointer.h>
#include <QtCore/qglobalstatic.h>
+#include <QtCore/qmalloc.h>
+#include <QtCore/qminmax.h>
#include <QtCore/qnumeric.h>
#include <QtCore/qoverload.h>
+#include <QtCore/qswap.h>
#include <QtCore/qtdeprecationmarkers.h>
-#include <QtCore/qtranslation.h>
+#include <QtCore/qtenvironmentvariables.h>
+#include <QtCore/qtresource.h>
+#include <QtCore/qttranslation.h>
+#include <QtCore/qttypetraits.h>
#include <QtCore/qversiontagging.h>
#endif /* __cplusplus */
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index d931dfac48..64fc9fff01 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -236,6 +236,19 @@ QLibraryInfo::isDebugBuild() noexcept
}
/*!
+ \since 6.5
+ Returns \c true if this is a shared (dynamic) build of Qt.
+*/
+bool QLibraryInfo::isSharedBuild() noexcept
+{
+#ifdef QT_SHARED
+ return true;
+#else
+ return false;
+#endif
+}
+
+/*!
\since 5.8
Returns the version of the Qt library.
@@ -534,7 +547,7 @@ QString QLibraryInfoPrivate::path(QLibraryInfo::LibraryPath p, UsageMode usageMo
startIndex = ret.indexOf(u'$', startIndex);
if (startIndex < 0)
break;
- if (ret.length() < startIndex + 3)
+ if (ret.size() < startIndex + 3)
break;
if (ret.at(startIndex + 1) != u'(') {
startIndex++;
@@ -546,7 +559,7 @@ QString QLibraryInfoPrivate::path(QLibraryInfo::LibraryPath p, UsageMode usageMo
auto envVarName = QStringView{ret}.mid(startIndex + 2, endIndex - startIndex - 2);
QString value = QString::fromLocal8Bit(qgetenv(envVarName.toLocal8Bit().constData()));
ret.replace(startIndex, endIndex - startIndex + 1, value);
- startIndex += value.length();
+ startIndex += value.size();
}
config->endGroup();
@@ -646,6 +659,42 @@ QStringList QLibraryInfo::platformPluginArguments(const QString &platformName)
\deprecated Use LibraryPath with QLibraryInfo::path() instead.
*/
+/*!
+ \macro QT_VERSION_STR
+ \relates <QLibraryInfo>
+
+ This macro expands to a string that specifies Qt's version number (for
+ example, "6.1.2"). This is the version with which the application is
+ compiled. This may be a different version than the version the application
+ will find itself using at \e runtime.
+
+ \sa qVersion(), QT_VERSION
+*/
+
+/*!
+ \relates <QLibraryInfo>
+
+ Returns the version number of Qt at runtime as a string (for example,
+ "6.1.2"). This is the version of the Qt library in use at \e runtime,
+ which need not be the version the application was \e compiled with.
+
+ \sa QT_VERSION_STR, QLibraryInfo::version()
+*/
+
+const char *qVersion() noexcept
+{
+ return QT_VERSION_STR;
+}
+
+#if QT_DEPRECATED_SINCE(6, 9)
+
+bool qSharedBuild() noexcept
+{
+ return QLibraryInfo::isSharedBuild();
+}
+
+#endif // QT_DEPRECATED_SINCE(6, 9)
+
QT_END_NAMESPACE
#if defined(Q_CC_GNU) && defined(ELF_INTERPRETER)
diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h
index e0f2273787..71d9a01308 100644
--- a/src/corelib/global/qlibraryinfo.h
+++ b/src/corelib/global/qlibraryinfo.h
@@ -4,18 +4,25 @@
#ifndef QLIBRARYINFO_H
#define QLIBRARYINFO_H
+#if defined(__cplusplus)
#include <QtCore/qstring.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qversionnumber.h>
+#else
+#include <QtCore/qglobal.h>
+#endif
QT_BEGIN_NAMESPACE
+#if defined(__cplusplus)
+
class Q_CORE_EXPORT QLibraryInfo
{
public:
static const char *build() noexcept;
- static bool isDebugBuild() noexcept Q_DECL_CONST_FUNCTION;
+ [[nodiscard]] static bool isDebugBuild() noexcept Q_DECL_CONST_FUNCTION;
+ [[nodiscard]] static bool isSharedBuild() noexcept Q_DECL_CONST_FUNCTION;
#ifndef QT_BOOTSTRAPPED
static QVersionNumber version() noexcept Q_DECL_CONST_FUNCTION;
@@ -53,6 +60,28 @@ private:
QLibraryInfo();
};
+#if QT_DEPRECATED_SINCE(6, 9)
+
+QT_DEPRECATED_VERSION_X_6_9("Use QLibraryInfo::isSharedBuild() instead.")
+Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qSharedBuild() noexcept;
+
+#endif
+
+#endif // __cplusplus
+
+/*
+ * If we're compiling C++ code:
+ * - and this is a non-namespace build, declare qVersion as extern "C"
+ * - and this is a namespace build, declare it as a regular function
+ * (we're already inside QT_BEGIN_NAMESPACE / QT_END_NAMESPACE)
+ * If we're compiling C code, simply declare the function. If Qt was compiled
+ * in a namespace, qVersion isn't callable anyway.
+ */
+#if !defined(QT_NAMESPACE) && defined(__cplusplus) && !defined(Q_QDOC)
+extern "C"
+#endif
+Q_CORE_EXPORT Q_DECL_CONST_FUNCTION const char *qVersion(void) Q_DECL_NOEXCEPT;
+
QT_END_NAMESPACE
#endif // QLIBRARYINFO_H
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index 94ec78f382..1ce55c3f14 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -129,6 +129,36 @@ QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
+/*!
+ \headerfile <QtLogging>
+ \inmodule QtCore
+ \title Qt Logging Types
+
+ \brief The <QtLogging> header file defines Qt logging types, functions
+ and macros.
+
+ The <QtLogging> header file contains several types, functions and
+ macros for logging.
+
+ The QtMsgType enum identifies the various messages that can be generated
+ and sent to a Qt message handler; QtMessageHandler is a type definition for
+ a pointer to a function with the signature
+ \c {void myMessageHandler(QtMsgType, const QMessageLogContext &, const char *)}.
+ qInstallMessageHandler() function can be used to install the given
+ QtMessageHandler. QMessageLogContext class contains the line, file, and
+ function the message was logged at. This information is created by the
+ QMessageLogger class.
+
+ <QtLogging> also contains functions that generate messages from the
+ given string argument: qDebug(), qInfo(), qWarning(), qCritical(),
+ and qFatal(). These functions call the message handler
+ with the given message.
+
+ Example:
+
+ \snippet code/src_corelib_global_qglobal.cpp 4
+*/
+
#if !defined(Q_CC_MSVC)
Q_NORETURN
#endif
@@ -862,7 +892,7 @@ Q_AUTOTEST_EXPORT QByteArray qCleanupFuncinfo(QByteArray info)
if (info.isEmpty())
return info;
- int pos;
+ qsizetype pos;
// Skip trailing [with XXX] for templates (gcc), but make
// sure to not affect Objective-C message names.
@@ -909,7 +939,7 @@ Q_AUTOTEST_EXPORT QByteArray qCleanupFuncinfo(QByteArray info)
info.truncate(++pos);
if (info.at(pos - 1) == ')') {
- if (info.indexOf(operator_call) == pos - (int)strlen(operator_call))
+ if (info.indexOf(operator_call) == pos - qsizetype(strlen(operator_call)))
break;
// this function returns a pointer to a function
@@ -932,19 +962,19 @@ Q_AUTOTEST_EXPORT QByteArray qCleanupFuncinfo(QByteArray info)
if (pos > -1) {
switch (info.at(pos)) {
case ')':
- if (info.indexOf(operator_call) == pos - (int)strlen(operator_call) + 1)
+ if (info.indexOf(operator_call) == pos - qsizetype(strlen(operator_call)) + 1)
pos -= 2;
break;
case '<':
- if (info.indexOf(operator_lessThan) == pos - (int)strlen(operator_lessThan) + 1)
+ if (info.indexOf(operator_lessThan) == pos - qsizetype(strlen(operator_lessThan)) + 1)
--pos;
break;
case '>':
- if (info.indexOf(operator_greaterThan) == pos - (int)strlen(operator_greaterThan) + 1)
+ if (info.indexOf(operator_greaterThan) == pos - qsizetype(strlen(operator_greaterThan)) + 1)
--pos;
break;
case '=': {
- int operatorLength = (int)strlen(operator_lessThanEqual);
+ auto operatorLength = qsizetype(strlen(operator_lessThanEqual));
if (info.indexOf(operator_lessThanEqual) == pos - operatorLength + 1)
pos -= 2;
else if (info.indexOf(operator_greaterThanEqual) == pos - operatorLength + 1)
@@ -988,7 +1018,7 @@ Q_AUTOTEST_EXPORT QByteArray qCleanupFuncinfo(QByteArray info)
break;
// find the matching close
- int end = pos;
+ qsizetype end = pos;
templatecount = 1;
--pos;
while (pos && templatecount) {
@@ -1151,9 +1181,9 @@ void QMessagePattern::setPattern(const QString &pattern)
tokens[i] = qthreadptrTokenC;
else if (lexeme.startsWith(QLatin1StringView(timeTokenC))) {
tokens[i] = timeTokenC;
- int spaceIdx = lexeme.indexOf(QChar::fromLatin1(' '));
+ qsizetype spaceIdx = lexeme.indexOf(QChar::fromLatin1(' '));
if (spaceIdx > 0)
- timeArgs.append(lexeme.mid(spaceIdx + 1, lexeme.length() - spaceIdx - 2));
+ timeArgs.append(lexeme.mid(spaceIdx + 1, lexeme.size() - spaceIdx - 2));
else
timeArgs.append(QString());
} else if (lexeme.startsWith(QLatin1StringView(backtraceTokenC))) {
@@ -1302,7 +1332,7 @@ static QStringList backtraceFramesForLogMessage(int frameCount)
// use dladdr() instead of backtrace_symbols()
QString cachedLibrary;
const char *cachedFname = nullptr;
- auto decodeFrame = [&](const void *addr) -> DecodedFrame {
+ auto decodeFrame = [&](void *addr) -> DecodedFrame {
Dl_info info;
if (!dladdr(addr, &info))
return {};
@@ -1396,7 +1426,7 @@ static QString formatBacktraceForLogMessage(const QMessagePattern::BacktracePara
Q_GLOBAL_STATIC(QMessagePattern, qMessagePattern)
/*!
- \relates <QtGlobal>
+ \relates <QtLogging>
\since 5.4
Generates a formatted string out of the \a type, \a context, \a str arguments.
@@ -1959,7 +1989,7 @@ void qErrnoWarning(int code, const char *msg, ...)
/*!
\typedef QtMessageHandler
- \relates <QtGlobal>
+ \relates <QtLogging>
\since 5.0
This is a typedef for a pointer to a function with the following
@@ -1972,7 +2002,7 @@ void qErrnoWarning(int code, const char *msg, ...)
/*!
\fn QtMessageHandler qInstallMessageHandler(QtMessageHandler handler)
- \relates <QtGlobal>
+ \relates <QtLogging>
\since 5.0
Installs a Qt message \a handler which has been defined
@@ -2007,7 +2037,7 @@ void qErrnoWarning(int code, const char *msg, ...)
/*!
\fn void qSetMessagePattern(const QString &pattern)
- \relates <QtGlobal>
+ \relates <QtLogging>
\since 5.0
\brief Changes the output of the default message handler.
@@ -2040,9 +2070,12 @@ void qErrnoWarning(int code, const char *msg, ...)
\row \li \c{%{backtrace [depth=N] [separator="..."]}} \li A backtrace with the number of frames
specified by the optional \c depth parameter (defaults to 5), and separated by the optional
\c separator parameter (defaults to "|").
+
This expansion is available only on some platforms (currently only platfoms using glibc).
Names are only known for exported functions. If you want to see the name of every function
- in your application, use \c{QMAKE_LFLAGS += -rdynamic}.
+ in your application, make sure your application is compiled and linked with \c{-rdynamic},
+ or an equivalent of it.
+
When reading backtraces, take into account that frames might be missing due to inlining or
tail call optimization.
\endtable
@@ -2155,4 +2188,204 @@ QMessageLogContext &QMessageLogContext::copyContextFrom(const QMessageLogContext
\a lineNumber, in function \a functionName, and category \a categoryName.
*/
+/*!
+ \macro qDebug(const char *message, ...)
+ \relates <QtLogging>
+ \threadsafe
+
+ Calls the message handler with the debug message \a message. If no
+ message handler has been installed, the message is printed to
+ stderr. Under Windows the message is sent to the console, if it is a
+ console application; otherwise, it is sent to the debugger. On QNX, the
+ message is sent to slogger2. This function does nothing if \c QT_NO_DEBUG_OUTPUT
+ was defined during compilation.
+
+ If you pass the function a format string and a list of arguments,
+ it works in similar way to the C printf() function. The format
+ should be a Latin-1 string.
+
+ Example:
+
+ \snippet code/src_corelib_global_qglobal.cpp 24
+
+ If you include \c <QtDebug>, a more convenient syntax is also
+ available:
+
+ \snippet code/src_corelib_global_qglobal.cpp 25
+
+ With this syntax, the function returns a QDebug object that is
+ configured to use the QtDebugMsg message type. It automatically
+ puts a single space between each item, and outputs a newline at
+ the end. It supports many C++ and Qt types.
+
+ To suppress the output at runtime, install your own message handler
+ with qInstallMessageHandler().
+
+ \sa qInfo(), qWarning(), qCritical(), qFatal(), qInstallMessageHandler(),
+ {Debugging Techniques}
+*/
+
+/*!
+ \macro qInfo(const char *message, ...)
+ \relates <QtLogging>
+ \threadsafe
+ \since 5.5
+
+ Calls the message handler with the informational message \a message. If no
+ message handler has been installed, the message is printed to
+ stderr. Under Windows, the message is sent to the console, if it is a
+ console application; otherwise, it is sent to the debugger. On QNX the
+ message is sent to slogger2. This function does nothing if \c QT_NO_INFO_OUTPUT
+ was defined during compilation.
+
+ If you pass the function a format string and a list of arguments,
+ it works in similar way to the C printf() function. The format
+ should be a Latin-1 string.
+
+ Example:
+
+ \snippet code/src_corelib_global_qglobal.cpp qInfo_printf
+
+ If you include \c <QtDebug>, a more convenient syntax is also
+ available:
+
+ \snippet code/src_corelib_global_qglobal.cpp qInfo_stream
+
+ With this syntax, the function returns a QDebug object that is
+ configured to use the QtInfoMsg message type. It automatically
+ puts a single space between each item, and outputs a newline at
+ the end. It supports many C++ and Qt types.
+
+ To suppress the output at runtime, install your own message handler
+ using qInstallMessageHandler().
+