Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
src_gui_text_qfont.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
#
include
<
QFont
>
4
#
include
<
QFontInfo
>
5
#
include
<
QFontMetrics
>
6
7
namespace
src_gui_text_qfont
{
8
9
void
wrapper0
() {
10
//! [0]
11
QFont serifFont(
"Times"
, 10, QFont::Bold);
12
QFont sansFont(
"Helvetica [Cronyx]"
, 12);
13
//! [0]
14
15
16
//! [1]
17
QFont f(
"Helvetica"
);
18
//! [1]
19
20
}
// wrapper0
21
22
23
void
wrapper1
() {
24
QFont f1;
25
//! [2]
26
QFont f(
"Helvetica [Cronyx]"
);
27
//! [2]
28
29
30
//! [3]
31
QFontInfo info(f1);
32
QString family = info.family();
33
//! [3]
34
35
36
//! [4]
37
QFontMetrics fm(f1);
38
int
textWidthInPixels = fm.horizontalAdvance(
"How many pixels wide is this text?"
);
39
int
textHeightInPixels = fm.height();
40
//! [4]
41
42
Q_UNUSED(textWidthInPixels);
43
Q_UNUSED(textHeightInPixels);
44
}
// wrapper
45
}
// src_gui_text_qfont
src_gui_text_qfont
Definition
src_gui_text_qfont.cpp:7
src_gui_text_qfont::wrapper1
void wrapper1()
Definition
src_gui_text_qfont.cpp:23
src_gui_text_qfont::wrapper0
void wrapper0()
Definition
src_gui_text_qfont.cpp:9
qtbase
src
gui
doc
snippets
code
src_gui_text_qfont.cpp
Generated on
for Qt by
1.14.0