Adds fix for Qt bug where Qt fails to recognise a default font. In that case set the default font to Sans serif (#229)

This commit is contained in:
Atul R 2019-11-27 09:48:16 +01:00 committed by GitHub
parent 3a404d24a1
commit 0ed44e458e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 0 deletions

View File

@ -23,4 +23,5 @@ void safeDelete(QPointer<T>& component) {
delete component;
}
}
void initAppSettings();
} // namespace extrautils

View File

@ -1,5 +1,7 @@
#include "Extras/Utils/nutils.h"
#include <QApplication>
#include <QFont>
#include <QMetaType>
#include <QWidget>
#include <string>
@ -84,4 +86,12 @@ void* extrautils::configureQWidget(QWidget* widget, YGNodeRef node,
bool isLeafNode) {
flexutils::configureFlexNode(widget, node, isLeafNode);
return configureQObject(widget);
}
void extrautils::initAppSettings() {
QFont f = QApplication::font();
if (f.defaultFamily().isEmpty()) {
f.setFamily("Sans-Serif");
QApplication::setFont(f);
}
}

View File

@ -35,6 +35,7 @@
#include "core/FlexLayout/flexlayout_wrap.h"
// These cant be instantiated in JS Side
void InitPrivateHelpers(Napi::Env env) {
extrautils::initAppSettings();
QLayoutWrap::init(env); // Abstact class wrapper for pointing to any layout
}