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


plotjuggler
Author(s): Davide Faconti
autogenerated on Sat Jul 6 2019 03:44:17