mirror of
https://github.com/lubosz/overte.git
synced 2025-04-08 01:22:08 +02:00
Add more comments to UIUtil::scaleWidgetFontSizes
This commit is contained in:
parent
a8999964f6
commit
4a8e3193a9
1 changed files with 8 additions and 0 deletions
|
@ -37,6 +37,12 @@ int UIUtil::getWindowTitleBarHeight(const QWidget* window) {
|
|||
// font sizes need to be scaled based on the system DPI.
|
||||
// This function will scale the font size of widget and all
|
||||
// of its children recursively.
|
||||
//
|
||||
// When creating widgets, if a font size isn't explicitly set Qt will choose a
|
||||
// reasonable, but often different font size across platforms. This means
|
||||
// YOU SHOUD EXPLICITLY SET ALL FONT SIZES and call this function OR not use
|
||||
// this function at all. If you mix both you will end up with inconsistent results
|
||||
// across platforms.
|
||||
void UIUtil::scaleWidgetFontSizes(QWidget* widget) {
|
||||
auto glCanvas = DependencyManager::get<GLCanvas>();
|
||||
|
||||
|
@ -57,6 +63,8 @@ void UIUtil::scaleWidgetFontSizes(QWidget* widget) {
|
|||
internalScaleWidgetFontSizes(widget, fontScale);
|
||||
}
|
||||
|
||||
// Depth-first traversal through widget hierarchy. It is important to do a depth-first
|
||||
// traversal because modifying the font size of a parent node can affect children.
|
||||
void UIUtil::internalScaleWidgetFontSizes(QWidget* widget, float scale) {
|
||||
for (auto child : widget->findChildren<QWidget*>()) {
|
||||
if (child->parent() == widget) {
|
||||
|
|
Loading…
Reference in a new issue