menubar.cpp
Go to the documentation of this file.
1 #include "menubar.h"
2 #include <QDebug>
3 #include <QFontDatabase>
4 #include <QFont>
5 #include <QColor>
6 #include <QFontMetrics>
7 
8 MenuBar::MenuBar(QWidget* parent) : QMenuBar(parent)
9 {
10  int font_id = QFontDatabase::addApplicationFont("://resources/DejaVuSans-ExtraLight.ttf");
11  QString family = QFontDatabase::applicationFontFamilies(font_id).at(0);
12 
13  _font.setFamily(family);
14  _font.setStyleStrategy(QFont::PreferAntialias);
15  _font.setPixelSize(18);
16 
17  QFontMetrics fm(_font);
18  _width_plot = fm.width("Plot");
19  _width_juggler = fm.width("Juggler");
20 }
21 
22 //void MenuBar::paintEvent(QPaintEvent* event)
23 //{
24 // QMenuBar::paintEvent(event);
25 // QPainter painter(this);
26 // painter.setFont(_font);
27 
28 // int text_width = _width_plot + _width_juggler;
29 // {
30 // QPoint topleft(this->rect().width() - text_width - 12, 0);
31 // QSize rect_size(_width_plot, this->rect().height());
32 // painter.setPen(QColor("#dd22dd"));
33 // painter.drawText(QRect(topleft, rect_size), Qt::AlignHCenter | Qt::AlignVCenter, "Plot");
34 // }
35 // {
36 // QPoint topleft(this->rect().width() - _width_juggler - 10, 0);
37 // QSize rect_size(_width_juggler, this->rect().height());
38 // painter.setPen(QColor("#2288ff"));
39 // painter.drawText(QRect(topleft, rect_size), Qt::AlignHCenter | Qt::AlignVCenter, "Juggler");
40 // }
41 //}
int _width_juggler
Definition: menubar.h:17
int _width_plot
Definition: menubar.h:16
QFont _font
Definition: menubar.h:15
MenuBar(QWidget *parent)
Definition: menubar.cpp:8


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 03:48:09