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_dialogs_qfontdialog.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
4//! [0]
5bool ok;
6QFont font = QFontDialog::getFont(
7 &ok, QFont("Helvetica [Cronyx]", 10), this);
8if (ok) {
9 // the user clicked OK and font is set to the font the user selected
10} else {
11 // the user canceled the dialog; font is set to the initial
12 // value, in this case Helvetica [Cronyx], 10
13}
14//! [0]
15
16
17//! [1]
18myWidget.setFont(QFontDialog::getFont(0, myWidget.font()));
19//! [1]
20
21
22//! [2]
23bool ok;
24QFont font = QFontDialog::getFont(&ok, QFont("Times", 12), this);
25if (ok) {
26 // font is set to the font the user selected
27} else {
28 // the user canceled the dialog; font is set to the initial
29 // value, in this case Times, 12.
30}
31//! [2]
32
33
34//! [3]
35myWidget.setFont(QFontDialog::getFont(0, myWidget.font()));
36//! [3]
37
38
39//! [4]
40bool ok;
41QFont font = QFontDialog::getFont(&ok, this);
42if (ok) {
43 // font is set to the font the user selected
44} else {
45 // the user canceled the dialog; font is set to the default
46 // application font, QApplication::font()
47}
48//! [4]