Qt 6.x
The Qt SDK
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
8
9void wrapper0() {
11QFont serifFont("Times", 10, QFont::Bold);
12QFont sansFont("Helvetica [Cronyx]", 12);
14
15
17QFont f("Helvetica");
19
20} // wrapper0
21
22
23void wrapper1() {
24QFont f1;
26QFont f("Helvetica [Cronyx]");
28
29
31QFontInfo info(f1);
32QString family = info.family();
34
35
37QFontMetrics fm(f1);
38int textWidthInPixels = fm.horizontalAdvance("How many pixels wide is this text?");
39int textHeightInPixels = fm.height();
41
42Q_UNUSED(textWidthInPixels);
43Q_UNUSED(textHeightInPixels);
44} // wrapper
45} // src_gui_text_qfont
\reentrant
Definition qfontinfo.h:14
\reentrant \inmodule QtGui
int height() const
Returns the height of the font.
int horizontalAdvance(const QString &, int len=-1) const
Returns the horizontal advance in pixels of the first len characters of text.
\reentrant
Definition qfont.h:20
@ Bold
Definition qfont.h:67
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
GLfloat GLfloat f
#define Q_UNUSED(x)
QFileInfo info(fileName)
[8]