Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qdialog.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 <QtWidgets/qtwidgetsglobal.h>
5#if QT_CONFIG(colordialog)
6#include "qcolordialog.h"
7#endif
8#if QT_CONFIG(fontdialog)
9#include "qfontdialog.h"
10#endif
11#if QT_CONFIG(filedialog)
12#include "qfiledialog.h"
13#endif
14
15#include "qevent.h"
16#include "qapplication.h"
17#include "qlayout.h"
18#if QT_CONFIG(sizegrip)
19#include "qsizegrip.h"
20#endif
21#if QT_CONFIG(whatsthis)
22#include "qwhatsthis.h"
23#endif
24#if QT_CONFIG(menu)
25#include "qmenu.h"
26#endif
27#include "qcursor.h"
28#if QT_CONFIG(messagebox)
29#include "qmessagebox.h"
30#endif
31#if QT_CONFIG(errormessage)
32#include "qerrormessage.h"
33#endif
34#include <qpa/qplatformtheme.h>
35#include "private/qdialog_p.h"
36#include "private/qguiapplication_p.h"
37#if QT_CONFIG(accessibility)
38#include "qaccessible.h"
39#endif
40
42
43static inline int themeDialogType(const QDialog *dialog)
44{
45#if QT_CONFIG(filedialog)
46 if (qobject_cast<const QFileDialog *>(dialog))
48#endif
49#if QT_CONFIG(colordialog)
50 if (qobject_cast<const QColorDialog *>(dialog))
52#endif
53#if QT_CONFIG(fontdialog)
54 if (qobject_cast<const QFontDialog *>(dialog))
56#endif
57#if QT_CONFIG(messagebox)
58 if (qobject_cast<const QMessageBox *>(dialog))
60#endif
61#if QT_CONFIG(errormessage)
62 if (qobject_cast<const QErrorMessage *>(dialog))
64#endif
65#if !QT_CONFIG(filedialog) && !QT_CONFIG(colordialog) && !QT_CONFIG(fontdialog) && \
66 !QT_CONFIG(messagebox) && !QT_CONFIG(errormessage)
68#endif
69 return -1;
70}
71
73{
74 delete m_platformHelper;
75}
76
78{
79 // Delayed creation of the platform, ensuring that
80 // that qobject_cast<> on the dialog works in the plugin.
81 if (!m_platformHelperCreated && canBeNativeDialog()) {
82 m_platformHelperCreated = true;
83 QDialogPrivate *ncThis = const_cast<QDialogPrivate *>(this);
84 QDialog *dialog = ncThis->q_func();
85 const int type = themeDialogType(dialog);
86 if (type >= 0) {
87 m_platformHelper = QGuiApplicationPrivate::platformTheme()
89 if (m_platformHelper) {
90 QObject::connect(m_platformHelper, SIGNAL(accept()), dialog, SLOT(accept()));
91 QObject::connect(m_platformHelper, SIGNAL(reject()), dialog, SLOT(reject()));
92 ncThis->initHelper(m_platformHelper);
93 }
94 }
95 }
96 return m_platformHelper;
97}
98
100{
102 return false;
103
104 QDialogPrivate *ncThis = const_cast<QDialogPrivate *>(this);
105 QDialog *dialog = ncThis->q_func();
106 const int type = themeDialogType(dialog);
107 if (type >= 0)
110 return false;
111}
112
118void QDialogPrivate::close(int resultCode)
119{
120 Q_Q(QDialog);
121
122 q->setResult(resultCode);
123
124 if (!data.is_closing) {
125 // Until Qt 6.3 we didn't close dialogs, so they didn't receive a QCloseEvent.
126 // It is likely that subclasses implement closeEvent and handle them as rejection
127 // (like QMessageBox and QProgressDialog do), so eat those events.
128 struct CloseEventEater : QObject
129 {
130 using QObject::QObject;
131 protected:
132 bool eventFilter(QObject *o, QEvent *e) override
133 {
134 if (e->type() == QEvent::Close)
135 return true;
136 return QObject::eventFilter(o, e);
137 }
138 } closeEventEater;
139 q->installEventFilter(&closeEventEater);
141 } else {
142 // If the close was initiated outside of QDialog we will end up
143 // here via QDialog::closeEvent calling reject(), in which case
144 // we need to hide the dialog to ensure QDialog::closeEvent does
145 // not ignore the close event. FIXME: Why is QDialog doing this?
146 q->hide();
147 }
148
150}
151
153{
154 Q_Q(const QDialog);
155 if (const QWidget *parent = q->nativeParentWidget())
156 return parent->windowHandle();
157 else if (q->windowHandle())
158 return q->windowHandle()->transientParent();
159 return nullptr;
160}
161
163{
164 if (QPlatformDialogHelper *helper = platformHelper()) {
165 if (visible) {
166 Q_Q(QDialog);
167 helperPrepareShow(helper);
168 nativeDialogInUse = helper->show(q->windowFlags(), q->windowModality(), transientParentWindow());
169 } else if (nativeDialogInUse) {
170 helper->hide();
171 }
172 }
173 return nativeDialogInUse;
174}
175
177{
178 if (const QPlatformDialogHelper *helper = platformHelper())
179 return helper->styleHint(hint);
181}
182
364 f | ((f & Qt::WindowType_Mask) == 0 ? Qt::Dialog : Qt::WindowType(0)))
365{
366}
367
373 : QWidget(dd, parent, f | ((f & Qt::WindowType_Mask) == 0 ? Qt::Dialog : Qt::WindowType(0)))
374{
375}
376
382{
383 QT_TRY {
384 // Need to hide() here, as our (to-be) overridden hide()
385 // will not be called in ~QWidget.
386 hide();
387 } QT_CATCH(...) {
388 // we're in the destructor - just swallow the exception
389 }
390}
391
399#if QT_CONFIG(pushbutton)
400void QDialogPrivate::setDefault(QPushButton *pushButton)
401{
402 Q_Q(QDialog);
403 bool hasMain = false;
404 QList<QPushButton*> list = q->findChildren<QPushButton*>();
405 for (int i=0; i<list.size(); ++i) {
406 QPushButton *pb = list.at(i);
407 if (pb->window() == q) {
408 if (pb == mainDef)
409 hasMain = true;
410 if (pb != pushButton)
411 pb->setDefault(false);
412 }
413 }
414 if (!pushButton && hasMain)
415 mainDef->setDefault(true);
416 if (!hasMain)
417 mainDef = pushButton;
418}
419
425void QDialogPrivate::setMainDefault(QPushButton *pushButton)
426{
427 mainDef = nullptr;
428 setDefault(pushButton);
429}
430
436void QDialogPrivate::hideDefault()
437{
438 Q_Q(QDialog);
439 QList<QPushButton*> list = q->findChildren<QPushButton*>();
440 for (int i=0; i<list.size(); ++i) {
441 list.at(i)->setDefault(false);
442 }
443}
444#endif
445
447{
448 Q_Q(QDialog);
449 if (resetModalityTo != -1 && !q->testAttribute(Qt::WA_SetWindowModality)) {
450 // open() changed the window modality and the user didn't touch it afterwards; restore it
451 q->setWindowModality(Qt::WindowModality(resetModalityTo));
453#ifdef Q_OS_MAC
455 q->setParent(q->parentWidget(), Qt::Dialog);
456#endif
457 }
458 resetModalityTo = -1;
459}
460
472{
473 Q_D(const QDialog);
474 return d->rescode;
475}
476
486{
487 Q_D(QDialog);
488 d->rescode = r;
489}
490
500{
501 Q_D(QDialog);
502
504 if (modality != Qt::WindowModal) {
505 d->resetModalityTo = modality;
506 d->wasModalitySet = testAttribute(Qt::WA_SetWindowModality);
509#ifdef Q_OS_MAC
511#endif
512 }
513
514 setResult(0);
515 show();
516}
517
540{
541 Q_D(QDialog);
542
543 if (Q_UNLIKELY(d->eventLoop)) {
544 qWarning("QDialog::exec: Recursive call detected");
545 return -1;
546 }
547
548 bool deleteOnClose = testAttribute(Qt::WA_DeleteOnClose);
550
551 d->resetModalitySetByOpen();
552
553 bool wasShowModal = testAttribute(Qt::WA_ShowModal);
555 setResult(0);
556
557 show();
558
559 QPointer<QDialog> guard = this;
560 if (d->nativeDialogInUse) {
561 d->platformHelper()->exec();
562 } else {
563 QEventLoop eventLoop;
564 d->eventLoop = &eventLoop;
565 (void) eventLoop.exec(QEventLoop::DialogExec);
566 }
567 if (guard.isNull())
568 return QDialog::Rejected;
569 d->eventLoop = nullptr;
570
571 setAttribute(Qt::WA_ShowModal, wasShowModal);
572
573 int res = result();
574 if (d->nativeDialogInUse)
575 d->helperDone(static_cast<QDialog::DialogCode>(res), d->platformHelper());
576 if (deleteOnClose)
577 delete this;
578 return res;
579}
580
599{
600 QPointer<QDialog> guard(this);
601
602 Q_D(QDialog);
603 d->close(r);
604
605 if (!guard)
606 return;
607
608 int dialogCode = d->dialogCode();
609 if (dialogCode == QDialog::Accepted)
610 emit accepted();
611 else if (dialogCode == QDialog::Rejected)
612 emit rejected();
613
614 if (guard)
615 emit finished(r);
616}
617
625{
626 done(Accepted);
627}
628
636{
637 done(Rejected);
638}
639
642{
643 return QWidget::eventFilter(o, e);
644}
645
646/*****************************************************************************
647 Event handlers
648 *****************************************************************************/
649
650#ifndef QT_NO_CONTEXTMENU
653{
654#if !QT_CONFIG(whatsthis) || !QT_CONFIG(menu)
655 Q_UNUSED(e);
656#else
657 QWidget *w = childAt(e->pos());
658 if (!w) {
659 w = rect().contains(e->pos()) ? this : nullptr;
660 if (!w)
661 return;
662 }
663 while (w && w->whatsThis().size() == 0 && !w->testAttribute(Qt::WA_CustomWhatsThis))
664 w = w->isWindow() ? nullptr : w->parentWidget();
665 if (w) {
666 QPointer<QMenu> p = new QMenu(this);
667 QAction *wt = p.data()->addAction(tr("What's This?"));
668 if (p.data()->exec(e->globalPos()) == wt) {
669 QHelpEvent e(QEvent::WhatsThis, w->rect().center(),
670 w->mapToGlobal(w->rect().center()));
672 }
673 delete p.data();
674 }
675#endif
676}
677#endif // QT_NO_CONTEXTMENU
678
681{
682#ifndef QT_NO_SHORTCUT
683 // Calls reject() if Escape is pressed. Simulates a button
684 // click for the default button if Enter is pressed. Move focus
685 // for the arrow keys. Ignore the rest.
686 if (e->matches(QKeySequence::Cancel)) {
687 reject();
688 } else
689#endif
690 if (!e->modifiers() || (e->modifiers() & Qt::KeypadModifier && e->key() == Qt::Key_Enter)) {
691 switch (e->key()) {
692#if QT_CONFIG(pushbutton)
693 case Qt::Key_Enter:
694 case Qt::Key_Return: {
695 QList<QPushButton*> list = findChildren<QPushButton*>();
696 for (int i=0; i<list.size(); ++i) {
697 QPushButton *pb = list.at(i);
698 if (pb->isDefault() && pb->isVisible()) {
699 if (pb->isEnabled())
700 pb->click();
701 return;
702 }
703 }
704 }
705 break;
706#endif
707 default:
708 e->ignore();
709 return;
710 }
711 } else {
712 e->ignore();
713 }
714}
715
718{
719#if QT_CONFIG(whatsthis)
722#endif
723 if (isVisible()) {
724 QPointer<QObject> that = this;
725 reject();
726 if (that && isVisible())
727 e->ignore();
728 } else {
729 e->accept();
730 }
731}
732
733/*****************************************************************************
734 Geometry management.
735 *****************************************************************************/
736
740void QDialog::setVisible(bool visible)
741{
742 Q_D(QDialog);
743 d->setVisible(visible);
744}
745
747{
748 Q_Q(QDialog);
749 if (!q->testAttribute(Qt::WA_DontShowOnScreen) && canBeNativeDialog() && setNativeDialogVisible(visible))
750 return;
751
752 // We should not block windows by the invisible modal dialog
753 // if a platform-specific dialog is implemented as an in-process
754 // Qt window, because in this case it will also be blocked.
755 const bool dontBlockWindows = q->testAttribute(Qt::WA_DontShowOnScreen)
757 Qt::WindowModality oldModality;
758 bool wasModalitySet;
759
760 if (dontBlockWindows) {
761 oldModality = q->windowModality();
762 wasModalitySet = q->testAttribute(Qt::WA_SetWindowModality);
763 q->setWindowModality(Qt::NonModal);
764 }
765
766 if (visible) {
767 if (q->testAttribute(Qt::WA_WState_ExplicitShowHide) && !q->testAttribute(Qt::WA_WState_Hidden))
768 return;
769
770 q->QWidget::setVisible(visible);
771
772 // Window activation might be prevented. We can't test isActiveWindow here,
773 // as the window will be activated asynchronously by the window manager.
774 if (!q->testAttribute(Qt::WA_ShowWithoutActivating)) {
775 QWidget *fw = q->window()->focusWidget();
776 if (!fw)
777 fw = q;
778
779 /*
780 The following block is to handle a special case, and does not
781 really follow proper logic in concern of autoDefault and TAB
782 order. However, it's here to ease usage for the users. If a
783 dialog has a default QPushButton, and first widget in the TAB
784 order also is a QPushButton, then we give focus to the main
785 default QPushButton. This simplifies code for the developers,
786 and actually catches most cases... If not, then they simply
787 have to use [widget*]->setFocus() themselves...
788 */
789#if QT_CONFIG(pushbutton)
790 if (mainDef && fw->focusPolicy() == Qt::NoFocus) {
791 QWidget *first = fw;
792 while ((first = first->nextInFocusChain()) != fw && first->focusPolicy() == Qt::NoFocus)
793 ;
794 if (first != mainDef && qobject_cast<QPushButton*>(first))
795 mainDef->setFocus();
796 }
797 if (!mainDef && q->isWindow()) {
798 QWidget *w = fw;
799 while ((w = w->nextInFocusChain()) != fw) {
800 QPushButton *pb = qobject_cast<QPushButton *>(w);
801 if (pb && pb->autoDefault() && pb->focusPolicy() != Qt::NoFocus) {
802 pb->setDefault(true);
803 break;
804 }
805 }
806 }
807#endif
808 if (fw && !fw->hasFocus()) {
811 }
812 }
813
814#if QT_CONFIG(accessibility)
815 QAccessibleEvent event(q, QAccessible::DialogStart);
816 QAccessible::updateAccessibility(&event);
817#endif
818
819 } else {
820 if (q->testAttribute(Qt::WA_WState_ExplicitShowHide) && q->testAttribute(Qt::WA_WState_Hidden))
821 return;
822
823#if QT_CONFIG(accessibility)
824 if (q->isVisible()) {
825 QAccessibleEvent event(q, QAccessible::DialogEnd);
826 QAccessible::updateAccessibility(&event);
827 }
828#endif
829
830 // Reimplemented to exit a modal event loop when the dialog is hidden.
831 q->QWidget::setVisible(visible);
832 if (eventLoop)
833 eventLoop->exit();
834 }
835
836 if (dontBlockWindows) {
837 q->setWindowModality(oldModality);
839 }
840
841#if QT_CONFIG(pushbutton)
843 if (mainDef && q->isActiveWindow()
845 QCursor::setPos(mainDef->mapToGlobal(mainDef->rect().center()));
846#endif
847}
848
851{
852 if (!event->spontaneous() && !testAttribute(Qt::WA_Moved)) {
853 Qt::WindowStates state = windowState();
855 setAttribute(Qt::WA_Moved, false); // not really an explicit position
856 if (state != windowState())
858 }
859}
860
863{
864 Q_D(QDialog);
865
867 if (theme->themeHint(QPlatformTheme::WindowAutoPlacement).toBool())
868 return;
869 QPoint p(0, 0);
870 int extraw = 0, extrah = 0;
871 const QWindow *parentWindow = nullptr;
872 if (w) {
873 w = w->window();
874 } else {
875 parentWindow = d->transientParentWindow();
876 }
877 QRect desk;
878 QScreen *scrn = nullptr;
879 if (w)
880 scrn = w->screen();
881 else if (parentWindow)
882 scrn = parentWindow->screen();
883 else if (QGuiApplication::primaryScreen()->virtualSiblings().size() > 1)
885 else
886 scrn = screen();
887 if (scrn)
888 desk = scrn->availableGeometry();
889
891 for (int i = 0; (extraw == 0 || extrah == 0) && i < list.size(); ++i) {
892 QWidget * current = list.at(i);
893 if (current->isVisible()) {
894 int framew = current->geometry().x() - current->x();
895 int frameh = current->geometry().y() - current->y();
896
897 extraw = qMax(extraw, framew);
898 extrah = qMax(extrah, frameh);
899 }
900 }
901
902 // sanity check for decoration frames. With embedding, we
903 // might get extraordinary values
904 if (extraw == 0 || extrah == 0 || extraw >= 10 || extrah >= 40) {
905 extrah = 40;
906 extraw = 10;
907 }
908
909
910 if (w) {
911 // Use pos() if the widget is embedded into a native window
912 QPoint pp;
913 if (w->windowHandle() && qvariant_cast<WId>(w->windowHandle()->property("_q_embedded_native_parent_handle")))
914 pp = w->pos();
915 else
916 pp = w->mapToGlobal(QPoint(0,0));
917 p = QPoint(pp.x() + w->width()/2,
918 pp.y() + w->height()/ 2);
919 } else if (parentWindow) {
920 // QTBUG-63406: Widget-based dialog in QML, which has no Widget parent
921 // but a transient parent window.
922 QPoint pp = parentWindow->mapToGlobal(QPoint(0, 0));
923 p = QPoint(pp.x() + parentWindow->width() / 2, pp.y() + parentWindow->height() / 2);
924 } else {
925 // p = middle of the desktop
926 p = QPoint(desk.x() + desk.width()/2, desk.y() + desk.height()/2);
927 }
928
929 // p = origin of this
930 p = QPoint(p.x()-width()/2 - extraw,
931 p.y()-height()/2 - extrah);
932
933
934 if (p.x() + extraw + width() > desk.x() + desk.width())
935 p.setX(desk.x() + desk.width() - width() - extraw);
936 if (p.x() < desk.x())
937 p.setX(desk.x());
938
939 if (p.y() + extrah + height() > desk.y() + desk.height())
940 p.setY(desk.y() + desk.height() - height() - extrah);
941 if (p.y() < desk.y())
942 p.setY(desk.y());
943
944 // QTBUG-52735: Manually set the correct target screen since scaling in a
945 // subsequent call to QWindow::resize() may otherwise use the wrong factor
946 // if the screen changed notification is still in an event queue.
947 if (scrn) {
948 if (QWindow *window = windowHandle())
949 window->setScreen(scrn);
950 }
951
952 move(p);
953}
954
957{
958 Q_D(const QDialog);
959 if (d->extension) {
960 if (d->orientation == Qt::Horizontal)
961 return QSize(QWidget::sizeHint().width(),
962 qMax(QWidget::sizeHint().height(),d->extension->sizeHint().height()));
963 else
964 return QSize(qMax(QWidget::sizeHint().width(), d->extension->sizeHint().width()),
966 }
967 return QWidget::sizeHint();
968}
969
970
973{
974 Q_D(const QDialog);
975 if (d->extension) {
976 if (d->orientation == Qt::Horizontal)
978 qMax(QWidget::minimumSizeHint().height(), d->extension->minimumSizeHint().height()));
979 else
980 return QSize(qMax(QWidget::minimumSizeHint().width(), d->extension->minimumSizeHint().width()),
982 }
983
985}
986
1001void QDialog::setModal(bool modal)
1002{
1004}
1005
1006
1008{
1009#if QT_CONFIG(sizegrip)
1010 Q_D(const QDialog);
1011 return !!d->resizer;
1012#else
1013 return false;
1014#endif
1015}
1016
1017
1019{
1020#if !QT_CONFIG(sizegrip)
1022#else
1023 Q_D(QDialog);
1024#if QT_CONFIG(sizegrip)
1025 d->sizeGripEnabled = enabled;
1026 if (enabled && d->doShowExtension)
1027 return;
1028#endif
1029 if (!enabled != !d->resizer) {
1030 if (enabled) {
1031 d->resizer = new QSizeGrip(this);
1032 // adjustSize() processes all events, which is suboptimal
1033 d->resizer->resize(d->resizer->sizeHint());
1034 if (isRightToLeft())
1035 d->resizer->move(rect().bottomLeft() -d->resizer->rect().bottomLeft());
1036 else
1037 d->resizer->move(rect().bottomRight() -d->resizer->rect().bottomRight());
1038 d->resizer->raise();
1039 d->resizer->show();
1040 } else {
1041 delete d->resizer;
1042 d->resizer = nullptr;
1043 }
1044 }
1045#endif // QT_CONFIG(sizegrip)
1046}
1047
1048
1049
1052{
1053#if QT_CONFIG(sizegrip)
1054 Q_D(QDialog);
1055 if (d->resizer) {
1056 if (isRightToLeft())
1057 d->resizer->move(rect().bottomLeft() -d->resizer->rect().bottomLeft());
1058 else
1059 d->resizer->move(rect().bottomRight() -d->resizer->rect().bottomRight());
1060 d->resizer->raise();
1061 }
1062#endif
1063}
1064
1108#include "moc_qdialog.cpp"
void click()
Performs a click.
The QAction class provides an abstraction for user commands that can be added to different user inter...
Definition qaction.h:30
QVariant data() const
Returns the user data as set in QAction::setData.
Definition qaction.cpp:1056
static QWidgetList topLevelWidgets()
Returns a list of the top-level widgets (windows) in the application.
The QCloseEvent class contains parameters that describe a close event.
Definition qevent.h:561
The QContextMenuEvent class contains parameters that describe a context menu event.
Definition qevent.h:593
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.
static void setPos(int x, int y)
Moves the cursor (hot spot) of the primary screen to the global screen position (x,...
Definition qcursor.cpp:240
static QPoint pos()
Returns the position of the cursor (hot spot) of the primary screen in global screen coordinates.
Definition qcursor.cpp:188
bool setNativeDialogVisible(bool visible)
Definition qdialog.cpp:162
virtual void setVisible(bool visible)
Definition qdialog.cpp:746
virtual void initHelper(QPlatformDialogHelper *)
Definition qdialog_p.h:96
QPlatformDialogHelper * platformHelper() const
Definition qdialog.cpp:77
virtual bool canBeNativeDialog() const
Definition qdialog.cpp:99
bool wasModalitySet
Definition qdialog_p.h:82
QVariant styleHint(QPlatformDialogHelper::StyleHint hint) const
Definition qdialog.cpp:176
int resetModalityTo
Definition qdialog_p.h:81
void resetModalitySetByOpen()
Definition qdialog.cpp:446
QPointer< QEventLoop > eventLoop
Definition qdialog_p.h:84
bool nativeDialogInUse
Definition qdialog_p.h:86
virtual void helperPrepareShow(QPlatformDialogHelper *)
Definition qdialog_p.h:97
QWindow * transientParentWindow() const
Definition qdialog.cpp:152
The QDialog class is the base class of dialog windows.
Definition qdialog.h:19
void closeEvent(QCloseEvent *) override
\reimp
Definition qdialog.cpp:717
QSize sizeHint() const override
\reimp
Definition qdialog.cpp:956
bool isSizeGripEnabled() const
Definition qdialog.cpp:1007
void finished(int result)
bool eventFilter(QObject *, QEvent *) override
\reimp
Definition qdialog.cpp:641
void rejected()
void setSizeGripEnabled(bool)
Definition qdialog.cpp:1018
virtual void reject()
Hides the modal dialog and sets the result code to Rejected.
Definition qdialog.cpp:635
void setResult(int r)
Sets the modal dialog's result code to i.
Definition qdialog.cpp:485
~QDialog()
Destroys the QDialog, deleting all its children.
Definition qdialog.cpp:381
void keyPressEvent(QKeyEvent *) override
\reimp
Definition qdialog.cpp:680
virtual int exec()
Shows the dialog as a \l{QDialog::Modal Dialogs}{modal dialog}, blocking until the user closes it.
Definition qdialog.cpp:539
QSize minimumSizeHint() const override
\reimp
Definition qdialog.cpp:972
int result() const
In general returns the modal dialog's result code, Accepted or Rejected.
Definition qdialog.cpp:471
DialogCode
The value returned by a modal dialog.
Definition qdialog.h:30
@ Accepted
Definition qdialog.h:30
@ Rejected
Definition qdialog.h:30
void setModal(bool modal)
Definition qdialog.cpp:1001
void resizeEvent(QResizeEvent *) override
\reimp
Definition qdialog.cpp:1051
void accepted()
void showEvent(QShowEvent *) override
\reimp
Definition qdialog.cpp:850
void contextMenuEvent(QContextMenuEvent *) override
\reimp
Definition qdialog.cpp:652
QDialog(QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
Constructs a dialog with parent parent.
Definition qdialog.cpp:362
virtual void done(int)
Closes the dialog and sets its result code to r.
Definition qdialog.cpp:598
void adjustPosition(QWidget *)
Definition qdialog.cpp:862
virtual void open()
Definition qdialog.cpp:499
bool modal
whether show() should pop up the dialog as modal or modeless
Definition qdialog.h:24
virtual void accept()
Hides the modal dialog and sets the result code to Accepted.
Definition qdialog.cpp:624
\inmodule QtCore
Definition qeventloop.h:16
int exec(ProcessEventsFlags flags=AllEvents)
Enters the main event loop and waits until exit() is called.
void exit(int returnCode=0)
Tells the event loop to exit with a return code.
\inmodule QtCore
Definition qcoreevent.h:45
@ FocusIn
Definition qcoreevent.h:66
@ WhatsThis
Definition qcoreevent.h:148
The QFocusEvent class contains event parameters for widget focus events.
Definition qevent.h:469
static QPlatformTheme * platformTheme()
QScreen * primaryScreen
the primary (or default) screen of the application.
static QScreen * screenAt(const QPoint &point)
Returns the screen at point, or \nullptr if outside of any screen.
The QHelpEvent class provides an event that is used to request helpful information about a particular...
Definition qevent.h:787
The QKeyEvent class describes a key event.
Definition qevent.h:423
Definition qlist.h:74
qsizetype size() const noexcept
Definition qlist.h:386
const_reference at(qsizetype i) const noexcept
Definition qlist.h:429
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus.
Definition qmenu.h:26
QObject * parent
Definition qobject.h:61
\inmodule QtCore
Definition qobject.h:90
Q_INVOKABLE QObject(QObject *parent=nullptr)
Constructs an object with parent object parent.
Definition qobject.cpp:910
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
virtual bool eventFilter(QObject *watched, QEvent *event)
Filters events if this object has been installed as an event filter for the watched object.
Definition qobject.cpp:1518
The QPlatformDialogHelper class allows for platform-specific customization of dialogs.
static QVariant defaultStyleHint(QPlatformDialogHelper::StyleHint hint)
StyleHint
This enum type specifies platform-specific style hints.
The QPlatformTheme class allows customizing the UI based on themes.
virtual QVariant themeHint(ThemeHint hint) const
virtual QPlatformDialogHelper * createPlatformDialogHelper(DialogType type) const
virtual bool usePlatformNativeDialog(DialogType type) const
\inmodule QtCore\reentrant
Definition qpoint.h:23
constexpr int x() const noexcept
Returns the x coordinate of this point.
Definition qpoint.h:127
constexpr int y() const noexcept
Returns the y coordinate of this point.
Definition qpoint.h:132
\inmodule QtCore
Definition qpointer.h:18
bool isNull() const
Returns true if the referenced object has been destroyed or if there is no referenced object; otherwi...
Definition qpointer.h:67
The QPushButton widget provides a command button.
Definition qpushbutton.h:20
bool autoDefault
whether the push button is an auto default button
Definition qpushbutton.h:23
void setDefault(bool)
bool isDefault() const
\inmodule QtCore\reentrant
Definition qrect.h:30
constexpr int height() const noexcept
Returns the height of the rectangle.
Definition qrect.h:238
bool contains(const QRect &r, bool proper=false) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qrect.cpp:851
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
Definition qrect.h:184
constexpr int width() const noexcept
Returns the width of the rectangle.
Definition qrect.h:235
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
Definition qrect.h:187
The QResizeEvent class contains event parameters for resize events.
Definition qevent.h:547
The QScreen class is used to query screen properties. \inmodule QtGui.
Definition qscreen.h:32
QRect availableGeometry
the screen's available geometry in pixels
Definition qscreen.h:46
The QShowEvent class provides an event that is sent when a widget is shown.
Definition qevent.h:577
The QSizeGrip class provides a resize handle for resizing top-level windows.
Definition qsizegrip.h:16
\inmodule QtCore
Definition qsize.h:25
constexpr int height() const noexcept
Returns the height.
Definition qsize.h:132
\inmodule QtCore
Definition qvariant.h:64
bool toBool() const
Returns the variant as a bool if the variant has userType() Bool.
static void leaveWhatsThisMode()
If the user interface is in "What's This?" mode, this function switches back to normal mode; otherwis...
static bool inWhatsThisMode()
Returns true if the user interface is in "What's This?" mode; otherwise returns false.
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.
QWidget * window() const
Returns the window for this widget, i.e.
Definition qwidget.cpp:4320
void setWindowModality(Qt::WindowModality windowModality)
Definition qwidget.cpp:2806
void setParent(QWidget *parent)
Sets the parent of the widget to parent, and resets the window flags.
Qt::WindowModality windowModality
which windows are blocked by the modal widget
Definition qwidget.h:104
QSize size
the size of the widget excluding any window frame
Definition qwidget.h:113
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition qwidget.h:106
int width
the width of the widget excluding any window frame
Definition qwidget.h:114
QWidget * childAt(int x, int y) const
Returns the visible child widget at the position ({x}, {y}) in the widget's coordinate system.
Definition qwidget.h:798
void move(int x, int y)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qwidget.h:880
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition qwidget.cpp:6851
bool isModal() const
Definition qwidget.h:817
QSize minimumSizeHint
the recommended minimum size for the widget
Definition qwidget.h:149
void hide()
Hides the widget.
Definition qwidget.cpp:8209
int height
the height of the widget excluding any window frame
Definition qwidget.h:115
QRect rect
the internal geometry of the widget excluding any window frame
Definition qwidget.h:116
void setWindowState(Qt::WindowStates state)
Sets the window state to windowState.
Definition qwidget.cpp:2944
void setFocus()
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qwidget.h:423
int y
the y coordinate of the widget relative to its parent and including any window frame
Definition qwidget.h:110
void show()
Shows the widget and its child widgets.
Definition qwidget.cpp:7956
virtual void setVisible(bool visible)
Definition qwidget.cpp:8329
void setScreen(QScreen *)
Sets the screen on which the widget should be shown to screen.
Definition qwidget.cpp:2531
int x
the x coordinate of the widget relative to its parent including any window frame
Definition qwidget.h:109
bool isEnabled() const
Definition qwidget.h:814
QWindow * windowHandle() const
If this is a native widget, return the associated QWindow.
Definition qwidget.cpp:2490
QSize sizeHint
the recommended size for the widget
Definition qwidget.h:148
bool isRightToLeft() const
Definition qwidget.h:419
bool enabled
whether the widget is enabled
Definition qwidget.h:105
bool hasFocus() const
Definition qwidget.cpp:6471
Qt::FocusPolicy focusPolicy
the way the widget accepts keyboard focus
Definition qwidget.h:140
QWidget * parentWidget() const
Returns the parent of this widget, or \nullptr if it does not have any parent widget.
Definition qwidget.h:904
Qt::WindowStates windowState() const
Returns the current window state.
Definition qwidget.cpp:2895
QScreen * screen() const
Returns the screen the widget is on.
Definition qwidget.cpp:2503
bool isVisible() const
Definition qwidget.h:874
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
\inmodule QtGui
Definition qwindow.h:63
int width
the width of the window's geometry
Definition qwindow.h:82
int height
the height of the window's geometry
Definition qwindow.h:83
#define this
Definition dialogs.cpp:9
double e
else opt state
[0]
Combined button and popup list for selecting options.
@ WA_WState_ExplicitShowHide
Definition qnamespace.h:334
@ WA_SetWindowModality
Definition qnamespace.h:399
@ WA_CustomWhatsThis
Definition qnamespace.h:312
@ WA_DontShowOnScreen
Definition qnamespace.h:382
@ WA_Moved
Definition qnamespace.h:308
@ WA_WState_Hidden
Definition qnamespace.h:296
@ WA_ShowWithoutActivating
Definition qnamespace.h:373
@ WA_ShowModal
Definition qnamespace.h:336
@ WA_DeleteOnClose
Definition qnamespace.h:320
WindowModality
@ NonModal
@ WindowModal
@ NoFocus
Definition qnamespace.h:106
@ Horizontal
Definition qnamespace.h:98
@ Key_Return
Definition qnamespace.h:662
@ Key_Enter
Definition qnamespace.h:663
@ KeypadModifier
@ AA_DontUseNativeDialogs
Definition qnamespace.h:457
@ Dialog
Definition qnamespace.h:207
@ Sheet
Definition qnamespace.h:208
@ TabFocusReason
#define Q_UNLIKELY(x)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
static QT_BEGIN_NAMESPACE int themeDialogType(const QDialog *dialog)
Definition qdialog.cpp:43
#define QT_CATCH(A)
#define QT_TRY
#define qWarning
Definition qlogging.h:162
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
#define SLOT(a)
Definition qobjectdefs.h:51
#define SIGNAL(a)
Definition qobjectdefs.h:52
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLboolean r
[2]
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLfloat GLfloat f
GLint GLsizei width
GLenum type
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint first
struct _cl_event * event
GLuint res
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLfloat GLfloat p
[1]
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
#define tr(X)
#define emit
#define Q_UNUSED(x)
QList< int > list
[14]
QPushButton * pushButton
QObject::connect nullptr
QFileDialog dialog(this)
[1]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent