summaryrefslogtreecommitdiffstats
path: root/src/gui/doc/snippets/code/src_gui_text_qfontmetrics.cpp
blob: 4650ad8d8f1d8acf4b8798df92c1441fe574359a (plain)
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
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QFont>
#include <QFontMetrics>

namespace src_gui_text_qfontmetrics {

void wrapper0() {
//! [0]
QFont font("times", 24);
QFontMetrics fm(font);
int pixelsWide = fm.horizontalAdvance("What's the advance width of this text?");
int pixelsHigh = fm.height();
//! [0]

Q_UNUSED(pixelsWide);
Q_UNUSED(pixelsHigh);
} // wrapper0


void wrapper1() {
//! [1]
QFont font("times", 24);
QFontMetricsF fm(font);
qreal pixelsWide = fm.horizontalAdvance("What's the advance width of this text?");
qreal pixelsHigh = fm.height();
//! [1]

Q_UNUSED(pixelsWide);
Q_UNUSED(pixelsHigh);
} // wrapper1

} //src_gui_text_qfontmetrics