Qt 6.x
The Qt SDK
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:
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
67{
70}
71
72static const Qt::WindowFlags qfd_DefaultWindowFlags =
74
76 : writingSystem(QFontDatabase::Any),
77 options(QFontDialogOptions::create())
78{
79}
80
82{
83}
84
123{
124 Q_D(QFontDialog);
125 d->init();
126}
127
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);
184 QVBoxLayout *vbox = new QVBoxLayout(effects);
186 vbox->addWidget(strikeout);
188 vbox->addWidget(underline);
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
212 QObject::connect(familyList, SIGNAL(highlighted(int)), q, SLOT(_q_familyHighlighted(int)));
213 QObject::connect(styleList, SIGNAL(highlighted(int)), q, SLOT(_q_styleHighlighted(int)));
214 QObject::connect(sizeList, SIGNAL(highlighted(int)), q, SLOT(_q_sizeHighlighted(int)));
216
219
220 for (int i = 0; i < QFontDatabase::WritingSystemsCount; ++i) {
222 QString writingSystemName = QFontDatabase::writingSystemName(ws);
223 if (writingSystemName.isEmpty())
224 break;
225 writingSystemCombo->addItem(writingSystemName);
226 }
227
229 if (familyList->count() != 0) {
232 }
233
234 // grid layout
235 QGridLayout *mainGrid = new QGridLayout(q);
236
237 int spacing = mainGrid->spacing();
238 if (spacing >= 0) { // uniform spacing
239 mainGrid->setSpacing(0);
240
241 mainGrid->setColumnMinimumWidth(1, spacing);
242 mainGrid->setColumnMinimumWidth(3, spacing);
243
244 int margin = 0;
245 mainGrid->getContentsMargins(nullptr, nullptr, nullptr, &margin);
246
247 mainGrid->setRowMinimumHeight(3, margin);
248 mainGrid->setRowMinimumHeight(6, 2);
249 mainGrid->setRowMinimumHeight(8, margin);
250 }
251
252 mainGrid->addWidget(familyAccel, 0, 0);
253 mainGrid->addWidget(familyEdit, 1, 0);
254 mainGrid->addWidget(familyList, 2, 0);
255
256 mainGrid->addWidget(styleAccel, 0, 2);
257 mainGrid->addWidget(styleEdit, 1, 2);
258 mainGrid->addWidget(styleList, 2, 2);
259
260 mainGrid->addWidget(sizeAccel, 0, 4);
261 mainGrid->addWidget(sizeEdit, 1, 4);
262 mainGrid->addWidget(sizeList, 2, 4);
263
264 mainGrid->setColumnStretch(0, 38);
265 mainGrid->setColumnStretch(2, 24);
266 mainGrid->setColumnStretch(4, 10);
267
268 mainGrid->addWidget(effects, 4, 0);
269
270 mainGrid->addWidget(sample, 4, 2, 4, 3);
271
272 mainGrid->addWidget(writingSystemAccel, 5, 0);
273 mainGrid->addWidget(writingSystemCombo, 7, 0);
274
276 mainGrid->addWidget(buttonBox, 9, 0, 1, 5);
277
280 QObject::connect(buttonBox, SIGNAL(accepted()), q, SLOT(accept()));
281 button->setDefault(true);
282
284 QObject::connect(buttonBox, SIGNAL(rejected()), q, SLOT(reject()));
285
286 q->resize(500, 360);
287
289 familyList->installEventFilter(q);
290 styleList->installEventFilter(q);
291 sizeList->installEventFilter(q);
292
293 familyList->setFocus();
295 sampleEdit->setObjectName("qt_fontDialog_sampleEdit"_L1);
296}
297
304{
305}
306
332 FontDialogOptions options)
333{
335}
336
358{
359 QFont initial;
360 return QFontDialogPrivate::getFont(ok, initial, parent, QString(), { });
361}
362
364 const QString &title, QFontDialog::FontDialogOptions options)
365{
366 QFontDialog dlg(parent);
367 dlg.setOptions(options);
368 dlg.setCurrentFont(initial);
369 if (!title.isEmpty())
371
372 int ret = (dlg.exec() || (options & QFontDialog::NoButtons));
373 if (ok)
374 *ok = !!ret;
375 if (ret) {
376 return dlg.selectedFont();
377 } else {
378 return initial;
379 }
380}
381
390{
391 Q_D(QFontDialog);
392 if (e->type() == QEvent::KeyPress) {
393 QKeyEvent *k = static_cast<QKeyEvent *>(e);
394 if (o == d->sizeEdit &&
395 (k->key() == Qt::Key_Up ||
396 k->key() == Qt::Key_Down ||
397 k->key() == Qt::Key_PageUp ||
398 k->key() == Qt::Key_PageDown)) {
399
400 int ci = d->sizeList->currentItem();
401 QCoreApplication::sendEvent(d->sizeList, k);
402
403 if (ci != d->sizeList->currentItem()
404 && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, this))
405 d->sizeEdit->selectAll();
406 return true;
407 } else if ((o == d->familyList || o == d->styleList) &&
408 (k->key() == Qt::Key_Return || k->key() == Qt::Key_Enter)) {
409 k->accept();
410 accept();
411 return true;
412 }
413 } else if (e->type() == QEvent::FocusIn
414 && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, this)) {
415 if (o == d->familyList)
416 d->familyEdit->selectAll();
417 else if (o == d->styleList)
418 d->styleEdit->selectAll();
419 else if (o == d->sizeList)
420 d->sizeEdit->selectAll();
421 } else if (e->type() == QEvent::MouseButtonPress && o == d->sizeList) {
422 d->sizeEdit->setFocus();
423 }
424 return QDialog::eventFilter(o, e);
425}
426
428{
429 Q_Q(QFontDialog);
430 auto *fontDialogHelper = static_cast<QPlatformFontDialogHelper *>(h);
431 fontDialogHelper->setOptions(options);
432 fontDialogHelper->setCurrentFont(q->currentFont());
433 QObject::connect(h, SIGNAL(currentFontChanged(QFont)), q, SIGNAL(currentFontChanged(QFont)));
434 QObject::connect(h, SIGNAL(fontSelected(QFont)), q, SIGNAL(fontSelected(QFont)));
435}
436
438{
439 options->setWindowTitle(q_func()->windowTitle());
440}
441
442/*
443 Updates the contents of the "font family" list box. This
444 function can be reimplemented if you have special requirements.
445*/
446
448{
449 Q_Q(QFontDialog);
450
451 enum match_t { MATCH_NONE = 0, MATCH_LAST_RESORT = 1, MATCH_APP = 2, MATCH_FAMILY = 3 };
452
453 const QFontDialog::FontDialogOptions scalableMask = (QFontDialog::ScalableFonts | QFontDialog::NonScalableFonts);
454 const QFontDialog::FontDialogOptions spacingMask = (QFontDialog::ProportionalFonts | QFontDialog::MonospacedFonts);
455 const QFontDialog::FontDialogOptions options = q->options();
456
457 QStringList familyNames;
458 const auto families = QFontDatabase::families(writingSystem);
459 for (const QString &family : families) {
461 continue;
462
463 if ((options & scalableMask) && (options & scalableMask) != scalableMask) {
465 continue;
466 }
467 if ((options & spacingMask) && (options & spacingMask) != spacingMask) {
469 continue;
470 }
471 familyNames << family;
472 }
473
474 familyList->model()->setStringList(familyNames);
475
476 QString foundryName1, familyName1, foundryName2, familyName2;
477 int bestFamilyMatch = -1;
478 match_t bestFamilyType = MATCH_NONE;
479
480 QFont f;
481
482 // ##### do the right thing for a list of family names in the font.
483 QFontDatabasePrivate::parseFontName(family, foundryName1, familyName1);
484
485 QStringList::const_iterator it = familyNames.constBegin();
486 int i = 0;
487 for(; it != familyNames.constEnd(); ++it, ++i) {
488 QFontDatabasePrivate::parseFontName(*it, foundryName2, familyName2);
489
490 //try to match...
491 if (familyName1 == familyName2) {
492 bestFamilyType = MATCH_FAMILY;
493 if (foundryName1 == foundryName2) {
494 bestFamilyMatch = i;
495 break;
496 }
497 if (bestFamilyMatch < MATCH_FAMILY)
498 bestFamilyMatch = i;
499 }
500
501 //and try some fall backs
502 match_t type = MATCH_NONE;
503 if (bestFamilyType <= MATCH_NONE && familyName2 == QStringLiteral("helvetica"))
504 type = MATCH_LAST_RESORT;
505 if (bestFamilyType <= MATCH_LAST_RESORT && familyName2 == f.families().first())
506 type = MATCH_APP;
507 // ### add fallback for writingSystem
508 if (type != MATCH_NONE) {
509 bestFamilyType = type;
510 bestFamilyMatch = i;
511 }
512 }
513
514 if (i != -1 && bestFamilyType != MATCH_NONE)
515 familyList->setCurrentItem(bestFamilyMatch);
516 else
519 if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q)
520 && familyList->hasFocus())
522
523 updateStyles();
524}
525
526/*
527 Updates the contents of the "font style" list box. This
528 function can be reimplemented if you have special requirements.
529*/
531{
532 Q_Q(QFontDialog);
534 styleList->model()->setStringList(styles);
535
536 if (styles.isEmpty()) {
537 styleEdit->clear();
538 smoothScalable = false;
539 } else {
540 if (!style.isEmpty()) {
541 bool found = false;
542 bool first = true;
543 QString cstyle = style;
544
545 redo:
546 for (int i = 0; i < static_cast<int>(styleList->count()); i++) {
547 if (cstyle == styleList->text(i)) {
549 found = true;
550 break;
551 }
552 }
553 if (!found && first) {
554 if (cstyle.contains("Italic"_L1)) {
555 cstyle.replace("Italic"_L1, "Oblique"_L1);
556 first = false;
557 goto redo;
558 } else if (cstyle.contains("Oblique"_L1)) {
559 cstyle.replace("Oblique"_L1, "Italic"_L1);
560 first = false;
561 goto redo;
562 } else if (cstyle.contains("Regular"_L1)) {
563 cstyle.replace("Regular"_L1, "Normal"_L1);
564 first = false;
565 goto redo;
566 } else if (cstyle.contains("Normal"_L1)) {
567 cstyle.replace("Normal"_L1, "Regular"_L1);
568 first = false;
569 goto redo;
570 }
571 }
572 if (!found)
574 } else {
576 }
577
579 if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q)
580 && styleList->hasFocus())
582
584 }
585
586 updateSizes();
587}
588
596{
597 Q_Q(QFontDialog);
598
599 if (!familyList->currentText().isEmpty()) {
601
602 int i = 0;
603 int current = -1;
604 QStringList str_sizes;
605 str_sizes.reserve(sizes.size());
607 str_sizes.append(QString::number(*it));
608 if (current == -1 && *it == size)
609 current = i;
610 ++i;
611 }
612 sizeList->model()->setStringList(str_sizes);
613 if (current != -1)
614 sizeList->setCurrentItem(current);
615
616 const QSignalBlocker blocker(sizeEdit);
618 if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q)
619 && sizeList->hasFocus())
621 } else {
622 sizeEdit->clear();
623 }
624
626}
627
629{
630 // compute new font
631 int pSize = sizeEdit->text().toInt();
633 newFont.setStrikeOut(strikeout->isChecked());
634 newFont.setUnderline(underline->isChecked());
635
637 sampleEdit->clear();
638
639 updateSampleFont(newFont);
640}
641
643{
644 Q_Q(QFontDialog);
645 if (newFont != sampleEdit->font()) {
646 sampleEdit->setFont(newFont);
647 emit q->currentFontChanged(newFont);
648 }
649}
650
655{
659}
660
665{
666 Q_Q(QFontDialog);
669 if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q)
670 && familyList->hasFocus())
672
673 updateStyles();
674}
675
676
682{
683 Q_Q(QFontDialog);
686 if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q)
687 && styleList->hasFocus())
689
690 style = s;
691
692 updateSizes();
693}
694
695
701{
702 Q_Q(QFontDialog);
705 if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q)
706 && sizeEdit->hasFocus())
708
709 size = s.toInt();
711}
712
720{
721 // no need to check if the conversion is valid, since we have an QIntValidator in the size edit
722 int size = s.toInt();
723 if (this->size == size)
724 return;
725
726 this->size = size;
727 if (sizeList->count() != 0) {
728 int i;
729 for (i = 0; i < sizeList->count() - 1; i++) {
730 if (sizeList->text(i).toInt() >= this->size)
731 break;
732 }
733 const QSignalBlocker blocker(sizeList);
734 if (sizeList->text(i).toInt() == this->size)
736 else
738 }
740}
741
743{
744 familyAccel->setText(QFontDialog::tr("&Font"));
745 styleAccel->setText(QFontDialog::tr("Font st&yle"));
746 sizeAccel->setText(QFontDialog::tr("&Size"));
747 effects->setTitle(QFontDialog::tr("Effects"));
748 strikeout->setText(QFontDialog::tr("Stri&keout"));
749 underline->setText(QFontDialog::tr("&Underline"));
750 sample->setTitle(QFontDialog::tr("Sample"));
751 writingSystemAccel->setText(QFontDialog::tr("Wr&iting System"));
752}
753
758{
759 Q_D(QFontDialog);
760 if (e->type() == QEvent::LanguageChange) {
761 d->retranslateStrings();
762 }
764}
765
781{
782 Q_D(QFontDialog);
783 d->family = font.families().value(0);
785 d->size = font.pointSize();
786 if (d->size == -1) {
788 d->size = fi.pointSize();
789 }
790 d->strikeout->setChecked(font.strikeOut());
791 d->underline->setChecked(font.underline());
792 d->updateFamilies();
793
794 if (d->nativeDialogInUse) {
795 if (QPlatformFontDialogHelper *helper = d->platformFontDialogHelper())
796 helper->setCurrentFont(font);
797 }
798}
799
808{
809 Q_D(const QFontDialog);
810
811 if (d->nativeDialogInUse) {
812 if (const QPlatformFontDialogHelper *helper = d->platformFontDialogHelper())
813 return helper->currentFont();
814 }
815 return d->sampleEdit->font();
816}
817
827{
828 Q_D(const QFontDialog);
829 return d->selectedFont;
830}
831
864{
865 const QFontDialog::FontDialogOptions previousOptions = options();
866 if (!(previousOptions & option) != !on)
867 setOptions(previousOptions ^ option);
868}
869
877{
878 Q_D(const QFontDialog);
879 return d->options->testOption(static_cast<QFontDialogOptions::FontDialogOption>(option));
880}
881
895void QFontDialog::setOptions(FontDialogOptions options)
896{
897 Q_D(QFontDialog);
898
900 return;
901
902 d->options->setOptions(QFontDialogOptions::FontDialogOptions(int(options)));
903 d->buttonBox->setVisible(!(options & NoButtons));
904}
905
906QFontDialog::FontDialogOptions QFontDialog::options() const
907{
908 Q_D(const QFontDialog);
909 return QFontDialog::FontDialogOptions(int(d->options->options()));
910}
911
920void QFontDialog::open(QObject *receiver, const char *member)
921{
922 Q_D(QFontDialog);
923 connect(this, SIGNAL(fontSelected(QFont)), receiver, member);
924 d->receiverToDisconnectOnClose = receiver;
925 d->memberToDisconnectOnClose = member;
927}
928
961void QFontDialog::setVisible(bool visible)
962{
964 return;
965 Q_D(QFontDialog);
966 if (d->canBeNativeDialog())
967 d->setNativeDialogVisible(visible);
968 if (d->nativeDialogInUse) {
969 // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below
970 // updates the state correctly, but skips showing the non-native version:
972 } else {
974 }
976}
977
986{
987 Q_D(QFontDialog);
988 if (result == Accepted) {
989 // We check if this is the same font we had before, if so we emit currentFontChanged
991 if (selectedFont != d->selectedFont)
993 d->selectedFont = selectedFont;
994 emit fontSelected(d->selectedFont);
995 } else
996 d->selectedFont = QFont();
997 if (d->receiverToDisconnectOnClose) {
999 d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
1000 d->receiverToDisconnectOnClose = nullptr;
1001 }
1002 d->memberToDisconnectOnClose.clear();
1004}
1005
1007{
1008 // Don't use Q_Q here! This function is called from ~QDialog,
1009 // so Q_Q calling q_func() invokes undefined behavior (invalid cast in q_func()).
1010 const QDialog * const q = static_cast<const QDialog*>(q_ptr);
1012 return true;
1014 || q->testAttribute(Qt::WA_DontShowOnScreen)
1016 return false;
1017 }
1018
1019 return strcmp(QFontDialog::staticMetaObject.className(), q->metaObject()->className()) == 0;
1020}
1021
1023
1024#include "qfontdialog.moc"
1025#include "moc_qfontdialog.cpp"
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.
virtual void currentChanged(const QModelIndex &current, const QModelIndex &previous)
This slot is called when a new item becomes the current item.
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 is a combined button and popup list.
Definition qcombobox.h:24
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:224
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 addButton(QAbstractButton *button, ButtonRole role)
Adds the given button to the button box with the specified role.
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:641
virtual int exec()
Shows the dialog as a \l{QDialog::Modal Dialogs}{modal dialog}, blocking until the user closes it.
Definition qdialog.cpp:539
@ Accepted
Definition qdialog.h:30
virtual void done(int)
Closes the dialog and sets its result code to r.
Definition qdialog.cpp:598
virtual void open()
Definition qdialog.cpp:499
virtual void accept()
Hides the modal dialog and sets the result code to Accepted.
Definition qdialog.cpp:624
\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
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
Definition qcoreevent.h:305
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
QLineEdit * styleEdit
void updateSampleFont(const QFont &newFont)
QLineEdit * sizeEdit
void _q_sizeHighlighted(int)
QGroupBox * effects
void _q_writingSystemHighlighted(int)
QLineEdit * familyEdit
bool canBeNativeDialog() const override
virtual void helperPrepareShow(QPlatformDialogHelper *) override
void _q_sizeChanged(const QString &)
QLabel * writingSystemAccel
void _q_styleHighlighted(int)
QSharedPointer< QFontDialogOptions > options
static QFont getFont(bool *ok, const QFont &initial, QWidget *parent, const QString &title, QFontDialog::FontDialogOptions options)
void _q_familyHighlighted(int)
QComboBox * writingSystemCombo
QDialogButtonBox * buttonBox
QFontListView * sizeList
QFontListView * styleList
QLineEdit * sampleEdit
QCheckBox * underline
QCheckBox * strikeout
QFontDatabase::WritingSystem writingSystem
\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 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 currentFontChanged(const QFont &font)
virtual void open()
Definition qdialog.cpp:499
void setCurrentFont(const QFont &font)
\reentrant
Definition qfontinfo.h:14
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:20
void setStrikeOut(bool)
If enable is true, sets strikeout on; otherwise sets strikeout off.
Definition qfont.cpp:1300
bool strikeOut() const
Returns true if strikeout has been set; otherwise returns false.
Definition qfont.cpp:1289
bool underline() const
Returns true if underline has been set; otherwise returns false.
Definition qfont.cpp:1236
QStringList families() const
Definition qfont.cpp:2469
int pointSize() const
Returns the point size of the font.
Definition qfont.cpp:863
void setUnderline(bool)
If enable is true, sets underline on; otherwise sets underline off.
Definition qfont.cpp:1247
The QGridLayout class lays out widgets in a grid.
Definition qgridlayout.h:21
void addWidget(QWidget *w)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qgridlayout.h:64
void setRowMinimumHeight(int row, int minSize)
Sets the minimum height of row row to minSize pixels.
void setColumnMinimumWidth(int column, int minSize)
Sets the minimum width of column column to minSize pixels.
void setSpacing(int spacing) override
This function sets both the vertical and horizontal spacing to spacing.
int spacing() const override
If the vertical spacing is equal to the horizontal spacing, this function returns that value; otherwi...
void setColumnStretch(int column, int stretch)
Sets the stretch factor of column column to stretch.
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:423
int key() const
Returns the code of the key that was pressed or released.
Definition qevent.h:433
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
void getContentsMargins(int *left, int *top, int *right, int *bottom) const
Definition qlayout.cpp:347
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 (i.e.
void clear()
Clears the contents of the line edit.
void setReadOnly(bool)
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
Definition qlist.h:74
\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:60
QObject * parent
Definition qobject.h:61
\inmodule QtCore
Definition qobject.h:90
void installEventFilter(QObject *filterObj)
Installs an event filter filterObj on this object.
Definition qobject.cpp:2269
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:311
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2823
Q_WEAK_OVERLOAD void setObjectName(const QString &name)
Sets the object's name to name.
Definition qobject.h:114
The QPlatformDialogHelper class allows for platform-specific customization of dialogs.
The QPlatformFontDialogHelper class allows for platform-specific customization of font dialogs.
void setOptions(const QSharedPointer< QFontDialogOptions > &options)
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:443
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:127
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:660
QString & replace(qsizetype i, qsizetype len, QChar after)
Definition qstring.cpp:3794
QString first(qsizetype n) const
Definition qstring.h:337
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:1083
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition qstring.h:1217
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:7822
@ SH_FontDialog_SelectAssociatedText
Definition qstyle.h:596
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 setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
void setSizePolicy(QSizePolicy)
void setFocusProxy(QWidget *)
Sets the widget's focus proxy to widget w.
Definition qwidget.cpp:6372
void setFocusPolicy(Qt::FocusPolicy policy)
Definition qwidget.cpp:7904
virtual void setVisible(bool visible)
Definition qwidget.cpp:8329
virtual void changeEvent(QEvent *)
This event handler can be reimplemented to handle state changes.
Definition qwidget.cpp:9428
void setWindowTitle(const QString &)
Definition qwidget.cpp:6109
QStyle * style() const
Definition qwidget.cpp:2607
void setFont(const QFont &)
Definition qwidget.cpp:4674
QFont font
the font currently set for the widget
Definition qwidget.h:133
bool hasFocus() const
Definition qwidget.cpp:6471
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition qwidget.h:910
bool visible
whether the widget is visible
Definition qwidget.h:144
#define this
Definition dialogs.cpp:9
qreal spacing
QPushButton * button
[2]
void textChanged(const QString &newText)
double e
QSet< QString >::iterator it
Combined button and popup list for selecting options.
@ AlignCenter
Definition qnamespace.h:162
@ WA_WState_ExplicitShowHide
Definition qnamespace.h:334
@ WA_DontShowOnScreen
Definition qnamespace.h:382
@ WA_WState_Hidden
Definition qnamespace.h:296
@ ClickFocus
Definition qnamespace.h:108
@ Key_Return
Definition qnamespace.h:662
@ Key_Enter
Definition qnamespace.h:663
@ Key_PageUp
Definition qnamespace.h:676
@ Key_Up
Definition qnamespace.h:673
@ Key_Down
Definition qnamespace.h:675
@ Key_PageDown
Definition qnamespace.h:677
@ AA_DontUseNativeDialogs
Definition qnamespace.h:457
@ Dialog
Definition qnamespace.h:207
@ WindowSystemMenuHint
Definition qnamespace.h:226
@ WindowCloseButtonHint
Definition qnamespace.h:240
static const Qt::WindowFlags qfd_DefaultWindowFlags
return ret
#define SLOT(a)
Definition qobjectdefs.h:51
#define SIGNAL(a)
Definition qobjectdefs.h:52
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLfloat GLfloat f
GLenum type
GLint first
GLfloat GLfloat GLfloat GLfloat h
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]
GLdouble s
[6]
Definition qopenglext.h:235
GLuint GLenum option
#define QStringLiteral(str)
#define Q_OBJECT
#define signals
#define emit
static QT_BEGIN_NAMESPACE QString windowTitle(HWND hwnd)
const char className[16]
[1]
Definition qwizard.cpp:100
QFileInfo fi("c:/temp/foo")
[newstuff]
QString title
[35]
myObject disconnect()
[26]
QGraphicsItem * item
view create()
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent