forked from psemiletov/tea-qt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fontbox.cpp
55 lines (39 loc) · 1.13 KB
/
fontbox.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
this code is Public Domain
*/
#include <QVBoxLayout>
#include <QDebug>
#include <QSpinBox>
#include <QFont>
#include <QFontComboBox>
#include "fontbox.h"
CFontBox::CFontBox (QWidget *parent): QWidget (parent)
{
QVBoxLayout *h_box = new QVBoxLayout;
setLayout (h_box);
QFontComboBox *cf = new QFontComboBox();
QSpinBox *spb_font_size = new QSpinBox (this);
spb_font_size->setRange (6, 64);
spb_font_size->setValue (12);
connect (spb_font_size, SIGNAL(valueChanged (int)), this, SLOT(slot_font_size_changed (int )));
h_box->addWidget (cf);
h_box->addWidget (spb_font_size);
h_box->addWidget (&edit);
edit.setPlainText (tr("Example string"));
connect (cf, SIGNAL(currentIndexChanged (const QString &)),
this, SLOT(slot_fontname_changed(const QString &)));
setWindowTitle (tr("Font gallery"));
setAttribute(Qt::WA_DeleteOnClose, true);
}
void CFontBox::slot_fontname_changed (const QString &text)
{
QFont f = edit.font();
f.setFamily (text);
edit.setFont (f);
}
void CFontBox::slot_font_size_changed (int i)
{
QFont f = edit.font();
f.setPointSize (i);
edit.setFont (f);
}