diff options
| author | Iain R. Learmonth <irl@debian.org> | 2015-10-18 18:51:00 +0100 |
|---|---|---|
| committer | Iain R. Learmonth <irl@debian.org> | 2015-10-18 18:51:00 +0100 |
| commit | d63dd8d081a6fcd0715cd13f26df59fb831769d2 (patch) | |
| tree | b9c1f6245147a310aac3762630bad389bbb57335 /qt_helpers.cpp | |
| parent | c720a3d55c5ec832c29cb7ce50b6fb4b70c55b11 (diff) | |
Imported Upstream version 1.5.0upstream/1.5.0
Diffstat (limited to 'qt_helpers.cpp')
| -rw-r--r-- | qt_helpers.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/qt_helpers.cpp b/qt_helpers.cpp new file mode 100644 index 00000000..62def121 --- /dev/null +++ b/qt_helpers.cpp @@ -0,0 +1,37 @@ +#include "qt_helpers.hpp" + +#include <QString> +#include <QFont> +#include <QWidget> +#include <QStyle> +#include <QVariant> + +QString font_as_stylesheet (QFont const& font) +{ + QString font_weight; + switch (font.weight ()) + { + case QFont::Light: font_weight = "light"; break; + case QFont::Normal: font_weight = "normal"; break; + case QFont::DemiBold: font_weight = "demibold"; break; + case QFont::Bold: font_weight = "bold"; break; + case QFont::Black: font_weight = "black"; break; + } + return QString { + " font-family: %1;\n" + " font-size: %2pt;\n" + " font-style: %3;\n" + " font-weight: %4;\n"} + .arg (font.family ()) + .arg (font.pointSize ()) + .arg (font.styleName ()) + .arg (font_weight); +} + +void update_dynamic_property (QWidget * widget, char const * property, QVariant const& value) +{ + widget->setProperty (property, value); + widget->style ()->unpolish (widget); + widget->style ()->polish (widget); + widget->update (); +} |
