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
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 LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qwindowdefs.h"
5#include "qfontdialog.h"
6
7#include "qfontdialog_p.h"
8
9#include <qapplication.h>
10#include <qcheckbox.h>
11#include <qcombobox.h>
12#include <qevent.h>
13#include <qgroupbox.h>
14#include <qlabel.h>
15#include <qlayout.h>
16#include <qlineedit.h>
17#include <qpushbutton.h>
18#include <qstyle.h>
19#include <qdialogbuttonbox.h>
20#include <qheaderview.h>
21#include <qlistview.h>
22#include <qstringlistmodel.h>
23#include <qvalidator.h>
24#include <private/qfontdatabase_p.h>
25#include <private/qdialog_p.h>
26#include <private/qfont_p.h>
27
29
30using namespace Qt::StringLiterals;
31
33{
35public:
36 QFontListView(QWidget *parent);
37 inline QStringListModel *model() const {
38 return static_cast<QStringListModel *>(QListView::model());
39 }
40 inline void setCurrentItem(int item) {
42 }
43 inline int currentItem() const {
45 }
46 inline int count() const {
47 return model()->rowCount();
48 }
49 inline QString currentText() const {
51 return row < 0 ? QString() : model()->stringList().at(row);
52 }
53 void currentChanged(const QModelIndex &current, const QModelIndex &previous) override {
54 QListView::currentChanged(current, previous);
55 if (current.isValid())
56 emit highlighted(current.row());
57 }
58 QString text(int i) const {
59 return model()->stringList().at(i);
60 }
62 void highlighted(int);
63};
64
71
72static const Qt::WindowFlags qfd_DefaultWindowFlags =
74
76 : writingSystem(QFontDatabase::Any),
77 options(QFontDialogOptions::create())
78{
79}
80
84
123{
124 Q_D(QFontDialog);
125 d->init();
126}
127
134QFontDialog::QFontDialog(const QFont &initial, QWidget *parent)
135 : QFontDialog(parent)
136{
137 setCurrentFont(initial);
138}
139
141{
142 Q_Q(QFontDialog);
143
144 q->setSizeGripEnabled(true);
145 q->setWindowTitle(QFontDialog::tr("Select Font"));
146
147 // grid
148 familyEdit = new QLineEdit(q);
149 familyEdit->setReadOnly(true);
152
153 familyAccel = new QLabel(q);
154#ifndef QT_NO_SHORTCUT
156#endif
158
159 styleEdit = new QLineEdit(q);
160 styleEdit->setReadOnly(true);
163
164 styleAccel = new QLabel(q);
165#ifndef QT_NO_SHORTCUT
167#endif
169
170 sizeEdit = new QLineEdit(q);
172 QIntValidator *validator = new QIntValidator(1, 512, q);
173 sizeEdit->setValidator(validator);
174 sizeList = new QFontListView(q);
175
176 sizeAccel = new QLabel(q);
177#ifndef QT_NO_SHORTCUT
179#endif
181
182 // effects box
183 effects = new QGroupBox(q);
189
190 sample = new QGroupBox(q);
191 QHBoxLayout *hbox = new QHBoxLayout(sample);
195 // Note that the sample text is *not* translated with tr(), as the
196 // characters used depend on the charset encoding.
197 sampleEdit->setText("AaBbYyZz"_L1);
198 hbox->addWidget(sampleEdit);
199
201
203#ifndef QT_NO_SHORTCUT
205#endif
207
208 size = 0;
209 smoothScalable = false;
210
221
226
227 for (int i = 0; i < QFontDatabase::WritingSystemsCount; ++i) {
229 QString writingSystemName = QFontDatabase::writingSystemName(ws);
230 if (writingSystemName.isEmpty())
231 break;
232 writingSystemCombo->addItem(writingSystemName);
233 }
234
236 if (familyList->count() != 0) {
239 }
240
241 // grid layout
242 QGridLayout *mainGrid = new QGridLayout(q);
243
244 int spacing = mainGrid->spacing();
245 if (spacing >= 0) { // uniform spacing
246 mainGrid->setSpacing(0);
247
248 mainGrid->setColumnMinimumWidth(1, spacing);
249 mainGrid->setColumnMinimumWidth(3, spacing);
250
251 int margin = 0;
252 mainGrid->getContentsMargins(nullptr, nullptr, nullptr, &margin);
253
254 mainGrid->setRowMinimumHeight(3, margin);
255 mainGrid->setRowMinimumHeight(6, 2);
256 mainGrid->setRowMinimumHeight(8, margin);
257 }
258
259 mainGrid->addWidget(familyAccel, 0, 0);
260 mainGrid->addWidget(familyEdit, 1, 0);
261 mainGrid->addWidget(familyList, 2, 0);
262
263 mainGrid->addWidget(styleAccel, 0, 2);
264 mainGrid->addWidget(styleEdit, 1, 2);
265 mainGrid->addWidget(styleList, 2, 2);
266
267 mainGrid->addWidget(sizeAccel, 0, 4);
268 mainGrid->addWidget(sizeEdit, 1, 4);
269 mainGrid->addWidget(sizeList, 2, 4);
270
271 mainGrid->setColumnStretch(0, 38);
272 mainGrid->setColumnStretch(2, 24);
273 mainGrid->setColumnStretch(4, 10);
274
275 mainGrid->addWidget(effects, 4, 0);
276
277 mainGrid->addWidget(sample, 4, 2, 4, 3);
278
279 mainGrid->addWidget(writingSystemAccel, 5, 0);
280 mainGrid->addWidget(writingSystemCombo, 7, 0);
281
283 mainGrid->addWidget(buttonBox, 9, 0, 1, 5);
284
288 button->setDefault(true);
289
292
293 q->resize(500, 360);
294
296 familyList->installEventFilter(q);
297 styleList->installEventFilter(q);
298 sizeList->installEventFilter(q);
299
300 familyList->setFocus();
302 sampleEdit->setObjectName("qt_fontDialog_sampleEdit"_L1);
303}
304
313
338QFont QFontDialog::getFont(bool *ok, const QFont &initial, QWidget *parent, const QString &title,
339 FontDialogOptions options)
340{
342}
343
365{
366 QFont initial;
367 return QFontDialogPrivate::getFont(ok, initial, parent, QString(), { });
368}
369
370QFont QFontDialogPrivate::getFont(bool *ok, const QFont &initial, QWidget *parent,
371 const QString &title, QFontDialog::FontDialogOptions options)
372{
373 QFontDialog dlg(parent);
374 dlg.setOptions(options);
375 dlg.setCurrentFont(initial);
376 if (!title.isEmpty())
377 dlg.setWindowTitle(title);
378
379 int ret = (dlg.exec() || (options & QFontDialog::NoButtons));
380 if (ok)
381 *ok = !!ret;
382 if (ret) {
383 return dlg.selectedFont();
384 } else {
385 return initial;
386 }
387}
388
397{
398 Q_D(QFontDialog);
399 if (e->type() == QEvent::KeyPress) {
400 QKeyEvent *k = static_cast<QKeyEvent *>(e);
401 if (o == d->sizeEdit &&
402 (k->key() == Qt::Key_Up ||
403 k->key() == Qt::Key_Down ||
404 k->key() == Qt::Key_PageUp ||
405 k->key() == Qt::Key_PageDown)) {
406
407 int ci = d->sizeList->currentItem();
408 QCoreApplication::sendEvent(d->sizeList, k);
409
410 if (ci != d->sizeList->currentItem()
411 && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, this))
412 d->sizeEdit->selectAll();
413 return true;
414 } else if ((o == d->familyList || o == d->styleList) &&
415 (k->key() == Qt::Key_Return || k->key() == Qt::Key_Enter)) {
416 k->accept();
417 accept();
418 return true;
419 }
420 } else if (e->type() == QEvent::FocusIn
421 && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, this)) {
422 if (o == d->familyList)
423 d->familyEdit->selectAll();
424 else if (o == d->styleList)
425 d->styleEdit->selectAll();
426 else if (o == d->sizeList)
427 d->sizeEdit->selectAll();
428 } else if (e->type() == QEvent::MouseButtonPress && o == d->sizeList) {
429 d->sizeEdit->setFocus();
430 }
431 return QDialog::eventFilter(o, e);
432}
433
435{
436 Q_Q(QFontDialog);
437 auto *fontDialogHelper = static_cast<QPlatformFontDialogHelper *>(h);
438 fontDialogHelper->setOptions(options);
439 fontDialogHelper->setCurrentFont(q->currentFont());
444}
445
450
451/*
452 Updates the contents of the "font family" list box. This
453 function can be reimplemented if you have special requirements.
454*/
455
457{
458 Q_Q(QFontDialog);
459
460 enum match_t { MATCH_NONE = 0, MATCH_LAST_RESORT = 1, MATCH_APP = 2, MATCH_FAMILY = 3 };
461
462 const QFontDialog::FontDialogOptions scalableMask = (QFontDialog::ScalableFonts | QFontDialog::NonScalableFonts);
463 const QFontDialog::FontDialogOptions spacingMask = (QFontDialog::ProportionalFonts | QFontDialog::MonospacedFonts);
464 const QFontDialog::FontDialogOptions options = q->options();
465
466 QStringList familyNames;
467 const auto families = QFontDatabase::families(writingSystem);
468 for (const QString &family : families) {
470 continue;
471
472 if ((options & scalableMask) && (options & scalableMask) != scalableMask) {
474 continue;
475 }
476 if ((options & spacingMask) && (options & spacingMask) != spacingMask) {
478 continue;
479 }
480 familyNames << family;
481 }
482
483 familyList->model()->setStringList(familyNames);
484
485 QString foundryName1, familyName1, foundryName2, familyName2;
486 int bestFamilyMatch = -1;
487 match_t bestFamilyType = MATCH_NONE;
488
489 QFont f;
490
491 // ##### do the right thing for a list of family names in the font.
492 QFontDatabasePrivate::parseFontName(family, foundryName1, familyName1);
493
494 QStringList::const_iterator it = familyNames.constBegin();
495 int i = 0;
496 for(; it != familyNames.constEnd(); ++it, ++i) {
497 QFontDatabasePrivate::parseFontName(*it, foundryName2, familyName2);
498
499 //try to match...
500 if (familyName1 == familyName2) {
501 bestFamilyType = MATCH_FAMILY;
502 if (foundryName1 == foundryName2) {
503 bestFamilyMatch = i;
504 break;
505 }
506 if (bestFamilyMatch < MATCH_FAMILY)
507 bestFamilyMatch = i;
508 }
509
510 //and try some fall backs
511 match_t type = MATCH_NONE;
512 if (bestFamilyType <= MATCH_NONE && familyName2 == "helvetica"_L1)
513 type = MATCH_LAST_RESORT;
514 if (bestFamilyType <= MATCH_LAST_RESORT && familyName2 == f.families().constFirst())
515 type = MATCH_APP;
516 // ### add fallback for writingSystem
517 if (type != MATCH_NONE) {
518 bestFamilyType = type;
519 bestFamilyMatch = i;
520 }
521 }
522
523 if (i != -1 && bestFamilyType != MATCH_NONE)
524 familyList->setCurrentItem(bestFamilyMatch);
525 else
528 if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q)
529 && familyList->hasFocus())
531
532 updateStyles();
533}
534
535/*
536 Updates the contents of the "font style" list box. This
537 function can be reimplemented if you have special requirements.
538*/
540{
541 Q_Q(QFontDialog);
543 styleList->model()->setStringList(styles);
544
545 if (styles.isEmpty()) {
546 styleEdit->clear();
547 smoothScalable = false;
548 } else {
549 if (!style.isEmpty()) {
550 bool found = false;
551 bool first = true;
552 QString cstyle = style;
553
554 redo:
555 for (int i = 0; i < static_cast<int>(styleList->count()); i++) {
556 if (cstyle == styleList->text(i)) {
558 found = true;
559 break;
560 }
561 }
562 if (!found && first) {
563 if (cstyle.contains("Italic"_L1)) {
564 cstyle.replace("Italic"_L1, "Oblique"_L1);
565 first = false;
566 goto redo;
567 } else if (cstyle.contains("Oblique"_L1)) {
568 cstyle.replace("Oblique"_L1, "Italic"_L1);
569 first = false;
570 goto redo;
571 } else if (cstyle.contains("Regular"_L1)) {
572 cstyle.replace("Regular"_L1, "Normal"_L1);
573 first = false;
574 goto redo;
575 } else if (cstyle.contains("Normal"_L1)) {
576 cstyle.replace("Normal"_L1, "Regular"_L1);
577 first = false;
578 goto redo;
579 }
580 }
581 if (!found)
583 } else {
585 }
586
588 if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q)
589 && styleList->hasFocus())
591
593 }
594
595 updateSizes();
596}
597
605{
606 Q_Q(QFontDialog);
607
608 if (!familyList->currentText().isEmpty()) {
610
611 int i = 0;
612 int current = -1;
613 QStringList str_sizes;
614 str_sizes.reserve(sizes.size());
616 str_sizes.append(QString::number(*it));
617 if (current == -1 && *it == size)
618 current = i;
619 ++i;
620 }
621 sizeList->model()->setStringList(str_sizes);
622 if (current != -1)
623 sizeList->setCurrentItem(current);
624
625 const QSignalBlocker blocker(sizeEdit);
627 if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q)
628 && sizeList->hasFocus())
630 } else {
631 sizeEdit->clear();
632 }
633
634 updateSample();
635}
636
638{
639 // compute new font
640 int pSize = sizeEdit->text().toInt();
642 newFont.setStrikeOut(strikeout->isChecked());
643 newFont.setUnderline(underline->isChecked());
644
646 sampleEdit->clear();
647
648 updateSampleFont(newFont);
649}
650
652{
653 Q_Q(QFontDialog);
654 if (newFont != sampleEdit->font()) {
655 sampleEdit->setFont(newFont);
656 emit q->currentFontChanged(newFont);
657 }
658}
659
669
674{
675 Q_Q(QFontDialog);
678 if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q)
679 && familyList->hasFocus())
681
682 updateStyles();
683}
684
685
691{
692 Q_Q(QFontDialog);
695 if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q)
696 && styleList->hasFocus())
698
699 style = s;
700
701 updateSizes();
702}
703
704
710{
711 Q_Q(QFontDialog);
714 if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q)
715 && sizeEdit->hasFocus())
717
718 size = s.toInt();
719 updateSample();
720}
721
729{
730 // no need to check if the conversion is valid, since we have an QIntValidator in the size edit
731 int size = s.toInt();
732 if (this->size == size)
733 return;
734
735 this->size = size;
736 if (sizeList->count() != 0) {
737 int i;
738 for (i = 0; i < sizeList->count() - 1; i++) {
739 if (sizeList->text(i).toInt() >= this->size)
740 break;
741 }
742 const QSignalBlocker blocker(sizeList);
743 if (sizeList->text(i).toInt() == this->size)
745 else
747 }
748 updateSample();
749}
750
752{
753 familyAccel->setText(QFontDialog::tr("&Font"));
754 styleAccel->setText(QFontDialog::tr("Font st&yle"));
755 sizeAccel->setText(QFontDialog::tr("&Size"));
756 effects->setTitle(QFontDialog::tr("Effects"));
757 strikeout->setText(QFontDialog::tr("Stri&keout"));
758 underline->setText(QFontDialog::tr("&Underline"));
759 sample->setTitle(QFontDialog::tr("Sample"));
760 writingSystemAccel->setText(QFontDialog::tr("Wr&iting System"));
761}
762
767{
768 Q_D(QFontDialog);
769 if (e->type() == QEvent::LanguageChange) {
770 d->retranslateStrings();
771 }
773}
774
790{
791 Q_D(QFontDialog);
792 d->family = font.families().value(0);
794 d->size = font.pointSize();
795 if (d->size == -1) {
796 QFontInfo fi(font);
797 d->size = fi.pointSize();
798 }
799 d->strikeout->setChecked(font.strikeOut());
800 d->underline->setChecked(font.underline());
801 d->updateFamilies();
802
803 if (d->nativeDialogInUse) {
804 if (QPlatformFontDialogHelper *helper = d->platformFontDialogHelper())
805 helper->setCurrentFont(font);
806 }
807}
808
817{
818 Q_D(const QFontDialog);
819
820 if (d->nativeDialogInUse) {
821 if (const QPlatformFontDialogHelper *helper = d->platformFontDialogHelper())
822 return helper->currentFont();
823 }
824 return d->sampleEdit->font();
825}
826
836{
837 Q_D(const QFontDialog);
838 return d->selectedFont;
839}
840
873{
874 const QFontDialog::FontDialogOptions previousOptions = options();
875 if (!(previousOptions & option) != !on)
876 setOptions(previousOptions ^ option);
877}
878
886{
887 Q_D(const QFontDialog);
888 return d->options->testOption(static_cast<QFontDialogOptions::FontDialogOption>(option));
889}
890
904void QFontDialog::setOptions(FontDialogOptions options)
905{
906 Q_D(QFontDialog);
907
909 return;
910
911 d->options->setOptions(QFontDialogOptions::FontDialogOptions(int(options)));
912 d->buttonBox->setVisible(!(options & NoButtons));
913}
914
915QFontDialog::FontDialogOptions QFontDialog::options() const
916{
917 Q_D(const QFontDialog);
918 return QFontDialog::FontDialogOptions(int(d->options->options()));
919}
920
929void QFontDialog::open(QObject *receiver, const char *member)
930{
931 Q_D(QFontDialog);
932 connect(this, SIGNAL(fontSelected(QFont)), receiver, member);
933 d->receiverToDisconnectOnClose = receiver;
934 d->memberToDisconnectOnClose = member;
936}
937
970void QFontDialog::setVisible(bool visible)
971{
972 // will call QFontDialogPrivate::setVisible
974}
975
984{
985 Q_Q(QFontDialog);
986
987 if (canBeNativeDialog())
988 setNativeDialogVisible(visible);
989 if (nativeDialogInUse) {
990 // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below
991 // updates the state correctly, but skips showing the non-native version:
992 q->setAttribute(Qt::WA_DontShowOnScreen, true);
993 } else {
994 q->setAttribute(Qt::WA_DontShowOnScreen, false);
995 }
997}
998
1007{
1008 Q_D(QFontDialog);
1009 if (result == Accepted) {
1010 // We check if this is the same font we had before, if so we emit currentFontChanged
1012 if (selectedFont != d->selectedFont)
1014 d->selectedFont = selectedFont;
1015 emit fontSelected(d->selectedFont);
1016 } else
1017 d->selectedFont = QFont();
1018 if (d->receiverToDisconnectOnClose) {
1020 d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
1021 d->receiverToDisconnectOnClose = nullptr;
1022 }
1023 d->memberToDisconnectOnClose.clear();
1025}
1026
1028{
1029 // Don't use Q_Q here! This function is called from ~QDialog,
1030 // so Q_Q calling q_func() invokes undefined behavior (invalid cast in q_func()).
1031 const QDialog * const q = static_cast<const QDialog*>(q_ptr);
1033 return true;
1035 || q->testAttribute(Qt::WA_DontShowOnScreen)
1037 return false;
1038 }
1039
1040 return strcmp(QFontDialog::staticMetaObject.className(), q->metaObject()->className()) == 0;
1041}
1042
1044
1045#include "qfontdialog.moc"
1046#include "moc_qfontdialog.cpp"
void clicked(bool checked=false)
This signal is emitted when the button is activated (i.e., pressed down then released while the mouse...
void setText(const QString &text)
bool isChecked() const
void setEditTriggers(EditTriggers triggers)
QAbstractItemModel * model() const
Returns the model that this view is presenting.
void setCurrentIndex(const QModelIndex &index)
Sets the current item to be the item at index.
QModelIndex currentIndex() const
Returns the model index of the current item.
virtual void setModel(QAbstractItemModel *model)
Sets the model for the view to present.
void clearSelection()
Deselects all selected items.
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=Qt::Alignment())
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment.
The QCheckBox widget provides a checkbox with a text label.
Definition qcheckbox.h:19
The QComboBox widget combines a button with a dropdown list.
Definition qcombobox.h:24
void activated(int index)
This signal is sent when the user chooses an item in the combobox.
void addItem(const QString &text, const QVariant &userData=QVariant())
Adds an item to the combobox with the given text, and containing the specified userData (stored in th...
Definition qcombobox.h:209
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static bool testAttribute(Qt::ApplicationAttribute attribute)
Returns true if attribute attribute is set; otherwise returns false.
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...
void accepted()
This signal is emitted when a button inside the button box is clicked, as long as it was defined with...
void addButton(QAbstractButton *button, ButtonRole role)
Adds the given button to the button box with the specified role.
void rejected()
This signal is emitted when a button inside the button box is clicked, as long as it was defined with...
bool setNativeDialogVisible(bool visible)
Definition qdialog.cpp:162
virtual void setVisible(bool visible)
Definition qdialog.cpp:754
bool nativeDialogInUse
Definition qdialog_p.h:86
The QDialog class is the base class of dialog windows.
Definition qdialog.h:19
bool eventFilter(QObject *, QEvent *) override
\reimp
Definition qdialog.cpp:645
virtual void reject()
Hides the modal dialog and sets the result code to Rejected.
Definition qdialog.cpp:639
@ Accepted
Definition qdialog.h:30
virtual void done(int)
Closes the dialog and sets its result code to r.
Definition qdialog.cpp:602
virtual void open()
Definition qdialog.cpp:503
void setVisible(bool visible) override
\reimp
Definition qdialog.cpp:744
virtual void accept()
Hides the modal dialog and sets the result code to Accepted.
Definition qdialog.cpp:628
\inmodule QtCore
Definition qcoreevent.h:45
@ KeyPress
Definition qcoreevent.h:64
@ FocusIn
Definition qcoreevent.h:66
@ MouseButtonPress
Definition qcoreevent.h:60
@ LanguageChange
Definition qcoreevent.h:123
Type type() const
Returns the event type.
Definition qcoreevent.h:304
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
Definition qcoreevent.h:310
static void parseFontName(const QString &name, QString &foundry, QString &family)
\threadsafe \inmodule QtGui
static QString writingSystemName(WritingSystem writingSystem)
Returns the names the writingSystem (e.g.
WritingSystem
\value Any \value Latin \value Greek \value Cyrillic \value Armenian \value Hebrew \value Arabic \val...
static bool isSmoothlyScalable(const QString &family, const QString &style=QString())
Returns true if the font that has family family and style style is smoothly scalable; otherwise retur...
static bool isPrivateFamily(const QString &family)
static QString styleString(const QFont &font)
Returns a string that describes the style of the font.
static QFont font(const QString &family, const QString &style, int pointSize)
Returns a QFont object that has family family, style style and point size pointSize.
static QString writingSystemSample(WritingSystem writingSystem)
Returns a string with sample characters from writingSystem.
static QStringList families(WritingSystem writingSystem=Any)
Returns a sorted list of the available font families which support the writingSystem.
static QList< int > pointSizes(const QString &family, const QString &style=QString())
Returns a list of the point sizes available for the font that has family family and style styleName.
static QStringList styles(const QString &family)
Returns a list of the styles available for the font family family.
static bool isFixedPitch(const QString &family, const QString &style=QString())
Returns true if the font that has family family and style style is fixed pitch; otherwise returns fal...
void setWindowTitle(const QString &)
FontDialogOptions options() const
virtual void initHelper(QPlatformDialogHelper *) override
QFontListView * familyList
void setVisible(bool visible) override
QLineEdit * styleEdit
void updateSampleFont(const QFont &newFont)
void sizeHighlighted(int)
QLineEdit * sizeEdit
QGroupBox * effects
void styleHighlighted(int)
QLineEdit * familyEdit
bool canBeNativeDialog() const override
virtual void helperPrepareShow(QPlatformDialogHelper *) override
QLabel * writingSystemAccel
QSharedPointer< QFontDialogOptions > options
static QFont getFont(bool *ok, const QFont &initial, QWidget *parent, const QString &title, QFontDialog::FontDialogOptions options)
QComboBox * writingSystemCombo
void writingSystemHighlighted(int)
QDialogButtonBox * buttonBox
QFontListView * sizeList
QFontListView * styleList
QLineEdit * sampleEdit
QCheckBox * underline
QCheckBox * strikeout
QFontDatabase::WritingSystem writingSystem
void familyHighlighted(int)
void sizeChanged(const QString &)
\inmodule QtWidgets
Definition qfontdialog.h:20
QFontDialog(QWidget *parent=nullptr)
void fontSelected(const QFont &font)
void setOption(FontDialogOption option, bool on=true)
Sets the given option to be enabled if on is true; otherwise, clears the given option.
void setVisible(bool visible) override
\reimp
void setOptions(FontDialogOptions options)
@ DontUseNativeDialog
Definition qfontdialog.h:29
FontDialogOptions options
the various options that affect the look and feel of the dialog
Definition qfontdialog.h:24
bool testOption(FontDialogOption option) const
Returns true if the given option is enabled; otherwise, returns false.
QFont selectedFont() const
Returns the font that the user selected by clicking the \uicontrol{OK} or equivalent button.
QFont currentFont
the current font of the dialog.
Definition qfontdialog.h:23
bool eventFilter(QObject *object, QEvent *event) override
void changeEvent(QEvent *event) override
\reimp
static QFont getFont(bool *ok, QWidget *parent=nullptr)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void done(int result) override
Closes the dialog and sets its result code to result.
void currentFontChanged(const QFont &font)
virtual void open()
Definition qdialog.cpp:503
void setCurrentFont(const QFont &font)
\reentrant
Definition qfontinfo.h:16
QStringListModel * model() const
QFontListView(QWidget *parent)
int count() const
void setCurrentItem(int item)
void currentChanged(const QModelIndex &current, const QModelIndex &previous) override
This slot is called when a new item becomes the current item.
QString currentText() const
void highlighted(int)
int currentItem() const
QString text(int i) const
\reentrant
Definition qfont.h:22
bool strikeOut() const
Returns true if strikeout has been set; otherwise returns false.
Definition qfont.cpp:1304
bool underline() const
Returns true if underline has been set; otherwise returns false.
Definition qfont.cpp:1251
QStringList families() const
Definition qfont.cpp:2699
int pointSize() const
Returns the point size of the font.
Definition qfont.cpp:884
The QGridLayout class lays out widgets in a grid.
Definition qgridlayout.h:21
The QGroupBox widget provides a group box frame with a title.
Definition qgroupbox.h:17
void setTitle(const QString &title)
The QHBoxLayout class lines up widgets horizontally.
Definition qboxlayout.h:78
The QIntValidator class provides a validator that ensures a string contains a valid integer within a ...
Definition qvalidator.h:56
The QKeyEvent class describes a key event.
Definition qevent.h:424
int key() const
Returns the code of the key that was pressed or released.
Definition qevent.h:434
The QLabel widget provides a text or image display.
Definition qlabel.h:20
void setBuddy(QWidget *)
Sets this label's buddy to buddy.
Definition qlabel.cpp:1169
void setText(const QString &)
Definition qlabel.cpp:263
void setIndent(int)
Definition qlabel.cpp:510
The QLineEdit widget is a one-line text editor.
Definition qlineedit.h:28
void setValidator(const QValidator *)
Sets the validator for values of line edit to v.
void setAlignment(Qt::Alignment flag)
void selectAll()
Selects all the text (highlights it) and moves the cursor to the end.
void clear()
Clears the contents of the line edit.
void setReadOnly(bool)
void textChanged(const QString &)
This signal is emitted whenever the text changes.
void setText(const QString &)
QString text
The line edit's text.
Definition qlineedit.h:32
The QListView class provides a list or icon view onto a model.
Definition qlistview.h:17
void currentChanged(const QModelIndex &current, const QModelIndex &previous) override
\reimp
\inmodule QtCore
constexpr int row() const noexcept
Returns the row this model index refers to.
constexpr bool isValid() const noexcept
Returns {true} if this model index is valid; otherwise returns {false}.
QObject * q_ptr
Definition qobject.h:72
QObject * parent
Definition qobject.h:73
static QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
Definition qobject_p.h:299
\inmodule QtCore
Definition qobject.h:103
void installEventFilter(QObject *filterObj)
Installs an event filter filterObj on this object.
Definition qobject.cpp:2339
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
Q_WEAK_OVERLOAD void setObjectName(const QString &name)
Sets the object's name to name.
Definition qobject.h:127
The QPlatformDialogHelper class allows for platform-specific customization of dialogs.
The QPlatformFontDialogHelper class allows for platform-specific customization of font dialogs.
void fontSelected(const QFont &font)
void setOptions(const QSharedPointer< QFontDialogOptions > &options)
void currentFontChanged(const QFont &font)
The QPushButton widget provides a command button.
Definition qpushbutton.h:20
void setDefault(bool)
const_iterator constBegin() const noexcept
Definition qset.h:139
const_iterator constEnd() const noexcept
Definition qset.h:143
Exception-safe wrapper around QObject::blockSignals().
Definition qobject.h:483
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
Definition qsizepolicy.h:18
\inmodule QtCore
QStringList stringList() const
Returns the string list used by the model to store data.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of rows in the model.
void setStringList(const QStringList &strings)
Sets the model's internal string list to strings.
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
int toInt(bool *ok=nullptr, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
Definition qstring.h:731
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:8084
@ SH_FontDialog_SelectAssociatedText
Definition qstyle.h:598
The QVBoxLayout class lines up widgets vertically.
Definition qboxlayout.h:91
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
void setSizePolicy(QSizePolicy)
void setFocusProxy(QWidget *)
Sets the widget's focus proxy to widget w.
Definition qwidget.cpp:6368
void setFocusPolicy(Qt::FocusPolicy policy)
Definition qwidget.cpp:7822
virtual void changeEvent(QEvent *)
This event handler can be reimplemented to handle state changes.
Definition qwidget.cpp:9382
QStyle * style() const
Definition qwidget.cpp:2600
void setFont(const QFont &)
Definition qwidget.cpp:4667
QFont font
the font currently set for the widget
Definition qwidget.h:133
bool hasFocus() const
Definition qwidget.cpp:6446
bool visible
whether the widget is visible
Definition qwidget.h:144
#define this
Definition dialogs.cpp:9
qreal spacing
QPushButton * button
[2]
QSet< QString >::iterator it
Combined button and popup list for selecting options.
@ AlignCenter
Definition qnamespace.h:163
@ WA_DontShowOnScreen
Definition qnamespace.h:383
@ ClickFocus
Definition qnamespace.h:109
@ Key_Return
Definition qnamespace.h:667
@ Key_Enter
Definition qnamespace.h:668
@ Key_PageUp
Definition qnamespace.h:681
@ Key_Up
Definition qnamespace.h:678
@ Key_Down
Definition qnamespace.h:680
@ Key_PageDown
Definition qnamespace.h:682
@ AA_DontUseNativeDialogs
Definition qnamespace.h:458
@ Dialog
Definition qnamespace.h:208
@ WindowSystemMenuHint
Definition qnamespace.h:227
@ WindowCloseButtonHint
Definition qnamespace.h:241
static const Qt::WindowFlags qfd_DefaultWindowFlags
return ret
#define SIGNAL(a)
Definition qobjectdefs.h:53
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLfloat GLfloat f
GLenum type
GLint first
GLfloat GLfloat GLfloat GLfloat h
GLdouble s
[6]
Definition qopenglext.h:235
GLuint GLsizei const GLuint const GLintptr const GLsizeiptr * sizes
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLenum GLenum GLsizei void * row
GLuint64EXT * result
[6]
GLuint GLenum option
#define Q_OBJECT
#define signals
#define emit
static QString windowTitle(HWND hwnd)
const char className[16]
[1]
Definition qwizard.cpp:100
QString title
[35]
myObject disconnect()
[26]
QGraphicsItem * item
QVBoxLayout * vbox
view create()