Enable High-DPI scaling by default in all my Qt applications
This commit is contained in:
parent
abfcd9f8be
commit
56cf474231
|
@ -9,7 +9,7 @@ set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
|
|||
set(META_APP_DESCRIPTION
|
||||
"Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models")
|
||||
set(META_VERSION_MAJOR 6)
|
||||
set(META_VERSION_MINOR 1)
|
||||
set(META_VERSION_MINOR 2)
|
||||
set(META_VERSION_PATCH 0)
|
||||
set(META_APP_VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH})
|
||||
|
||||
|
|
|
@ -298,4 +298,18 @@ bool hasCoreApp()
|
|||
}
|
||||
} // namespace ApplicationInstances
|
||||
|
||||
/*!
|
||||
* \brief Sets Qt application attributes which are commonly used within my Qt applications.
|
||||
* \remarks
|
||||
* - So far this enables High-DPI support.
|
||||
* - The exact attributes are unspecified and might change to whatever makes sense in the future.
|
||||
*/
|
||||
void setupCommonQtApplicationAttributes()
|
||||
{
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
|
||||
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
|
||||
}
|
||||
|
||||
// namespace ApplicationInstances
|
||||
|
||||
} // namespace QtUtilities
|
||||
|
|
|
@ -12,14 +12,16 @@ QT_FORWARD_DECLARE_CLASS(QStringList)
|
|||
QT_FORWARD_DECLARE_CLASS(QSettings)
|
||||
|
||||
/*!
|
||||
* \brief Sets the application meta data in the QCoreApplication singleton.
|
||||
* \brief Sets the application meta data in the QCoreApplication singleton and attributes commonly used
|
||||
* within my applications.
|
||||
* \sa ::QtUtilities::setupCommonQtApplicationAttributes()
|
||||
*/
|
||||
#define SET_QT_APPLICATION_INFO \
|
||||
QCoreApplication::setOrganizationName(QStringLiteral(APP_AUTHOR)); \
|
||||
QCoreApplication::setOrganizationDomain(QStringLiteral(APP_DOMAIN)); \
|
||||
QCoreApplication::setApplicationName(QStringLiteral(APP_NAME)); \
|
||||
QCoreApplication::setApplicationVersion(QStringLiteral(APP_VERSION)); \
|
||||
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true)
|
||||
::QtUtilities::setupCommonQtApplicationAttributes()
|
||||
|
||||
/*!
|
||||
* \brief Loads translations for Qt, other dependencies and the application.
|
||||
|
@ -59,6 +61,8 @@ QT_UTILITIES_EXPORT bool hasGuiApp();
|
|||
QT_UTILITIES_EXPORT bool hasCoreApp();
|
||||
} // namespace ApplicationInstances
|
||||
|
||||
QT_UTILITIES_EXPORT void setupCommonQtApplicationAttributes();
|
||||
|
||||
} // namespace QtUtilities
|
||||
|
||||
#endif // APPLICATION_UTILITIES_RESOURCES_H
|
||||
|
|
Loading…
Reference in New Issue