Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
5bool ok;
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}
15
16
18myWidget.setFont(QFontDialog::getFont(0, myWidget.font()));
20
21
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}
32
33
35myWidget.setFont(QFontDialog::getFont(0, myWidget.font()));
37
38
40bool ok;
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}
static QFont getFont(bool *ok, QWidget *parent=nullptr)
This is an overloaded member function, provided for convenience. It differs from the above function o...
\reentrant
Definition qfont.h:22