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
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()
88 ->createPlatformDialogHelper(static_cast<QPlatformTheme::DialogType>(type));
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)
109 ->usePlatformNativeDialog(static_cast<QPlatformTheme::DialogType>(type));
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
182
366QDialog::QDialog(QWidget *parent, Qt::WindowFlags f)
367 : QWidget(*new QDialogPrivate, parent,
368 f | ((f & Qt::WindowType_Mask) == 0 ? Qt::Dialog : Qt::WindowType(0)))
369{
370}
371
376QDialog::QDialog(QDialogPrivate &dd, QWidget *parent, Qt::WindowFlags f)
377 : QWidget(dd, parent, f | ((f & Qt::WindowType_Mask) == 0 ? Qt::Dialog : Qt::WindowType(0)))
378{
379}
380
386{
387 QT_TRY {
388 // Need to hide() here, as our (to-be) overridden hide()
389 // will not be called in ~QWidget.
390 hide();
391 } QT_CATCH(...) {
392 // we're in the destructor - just swallow the exception
393 }
394}
395
403#if QT_CONFIG(pushbutton)
404void QDialogPrivate::setDefault(QPushButton *pushButton)
405{
406 Q_Q(QDialog);
407 bool hasMain = false;
408 QList<QPushButton*> list = q->findChildren<QPushButton*>();
409 for (int i=0; i<list.size(); ++i) {
410 QPushButton *pb = list.at(i);
411 if (pb->window() == q) {
412 if (pb == mainDef)
413 hasMain = true;
414 if (pb != pushButton)
415 pb->setDefault(false);
416 }
417 }
418 if (!pushButton && hasMain)
419 mainDef->setDefault(true);
420 if (!hasMain)
421 mainDef = pushButton;
422}
423
429void QDialogPrivate::setMainDefault(QPushButton *pushButton)
430{
431 mainDef = nullptr;
432 setDefault(pushButton);
433}
434
440void QDialogPrivate::hideDefault()
441{
442 Q_Q(QDialog);
443 QList<QPushButton*> list = q->findChildren<QPushButton*>();
444 for (int i=0; i<list.size(); ++i) {
445 list.at(i)->setDefault(false);
446 }
447}
448#endif
449
451{
452 Q_Q(QDialog);
453 if (resetModalityTo != -1 && !q->testAttribute(Qt::WA_SetWindowModality)) {
454 // open() changed the window modality and the user didn't touch it afterwards; restore it
455 q->setWindowModality(Qt::WindowModality(resetModalityTo));
457#ifdef Q_OS_MAC
459 q->setParent(q->parentWidget(), Qt::Dialog);
460#endif
461 }
462 resetModalityTo = -1;
463}
464
476{
477 Q_D(const QDialog);
478 return d->rescode;
479}
480
490{
491 Q_D(QDialog);
492 d->rescode = r;
493}
494
504{
505 Q_D(QDialog);
506
508 if (modality != Qt::WindowModal) {
509 d->resetModalityTo = modality;
510 d->wasModalitySet = testAttribute(Qt::WA_SetWindowModality);
513#ifdef Q_OS_MAC
515#endif
516 }
517
518 setResult(0);
519 show();
520}
521
544{
545 Q_D(QDialog);
546
547 if (Q_UNLIKELY(d->eventLoop)) {
548 qWarning("QDialog::exec: Recursive call detected");
549 return -1;
550 }
551
552 bool deleteOnClose = testAttribute(Qt::WA_DeleteOnClose);
554
555 d->resetModalitySetByOpen();
556
557 bool wasShowModal = testAttribute(Qt::WA_ShowModal);
559 setResult(0);
560
561 show();
562
563 QPointer<QDialog> guard = this;
564 if (d->nativeDialogInUse) {
565 d->platformHelper()->exec();
566 } else {
567 QEventLoop eventLoop;
568 d->eventLoop = &eventLoop;
569 (void) eventLoop.exec(QEventLoop::DialogExec);
570 }
571 if (guard.isNull())
572 return QDialog::Rejected;
573 d->eventLoop = nullptr;
574
575 setAttribute(Qt::WA_ShowModal, wasShowModal);
576
577 int res = result();
578 if (d->nativeDialogInUse)
579 d->helperDone(static_cast<QDialog::DialogCode>(res), d->platformHelper());
580 if (deleteOnClose)
581 delete this;
582 return res;
583}
584
603{
604 QPointer<QDialog> guard(this);
605
606 Q_D(QDialog);
607 d->close(r);
608
609 if (!guard)
610 return;
611
612 int dialogCode = d->dialogCode();
613 if (dialogCode == QDialog::Accepted)
614 emit accepted();
615 else if (dialogCode == QDialog::Rejected)
616 emit rejected();
617
618 if (guard)
619 emit finished(r);
620}
621
629{
630 done(Accepted);
631}
632
640{
641 done(Rejected);
642}
643
646{
647 return QWidget::eventFilter(o, e);
648}
649
650/*****************************************************************************
651 Event handlers
652 *****************************************************************************/
653
654#ifndef QT_NO_CONTEXTMENU
657{
658#if !QT_CONFIG(whatsthis) || !QT_CONFIG(menu)
659 Q_UNUSED(e);
660#else
661 QWidget *w = childAt(e->pos());
662 if (!w) {
663 w = rect().contains(e->pos()) ? this : nullptr;
664 if (!w)
665 return;
666 }
667 while (w && w->whatsThis().size() == 0 && !w->testAttribute(Qt::WA_CustomWhatsThis))
668 w = w->isWindow() ? nullptr : w->parentWidget();
669 if (w) {
670 QPointer<QMenu> p = new QMenu(this);
671 QAction *wt = p.data()->addAction(tr("What's This?"));
672 if (p.data()->exec(e->globalPos()) == wt) {
673 QHelpEvent e(QEvent::WhatsThis, w->rect().center(),
674 w->mapToGlobal(w->rect().center()));
676 }
677 delete p.data();
678 }
679#endif
680}
681#endif // QT_NO_CONTEXTMENU
682
685{
686#ifndef QT_NO_SHORTCUT
687 // Calls reject() if Escape is pressed. Simulates a button
688 // click for the default button if Enter is pressed. Move focus
689 // for the arrow keys. Ignore the rest.
690 if (e->matches(QKeySequence::Cancel)) {
691 reject();
692 } else
693#endif
694 if (!e->modifiers() || (e->modifiers() & Qt::KeypadModifier && e->key() == Qt::Key_Enter)) {
695 switch (e->key()) {
696#if QT_CONFIG(pushbutton)
697 case Qt::Key_Enter:
698 case Qt::Key_Return: {
699 QList<QPushButton*> list = findChildren<QPushButton*>();
700 for (int i=0; i<list.size(); ++i) {
701 QPushButton *pb = list.at(i);
702 if (pb->isDefault() && pb->isVisible()) {
703 if (pb->isEnabled())
704 pb->click();
705 return;
706 }
707 }
708 }
709 break;
710#endif
711 default:
712 e->ignore();
713 return;
714 }
715 } else {
716 e->ignore();
717 }
718}
719
722{
723#if QT_CONFIG(whatsthis)
726#endif
727 if (isVisible()) {
728 QPointer<QObject> that = this;
729 reject();
730 if (that && isVisible())
731 e->ignore();
732 } else {
733 e->accept();
734 }
735}
736
737/*****************************************************************************
738 Geometry management.
739 *****************************************************************************/
740
744void QDialog::setVisible(bool visible)
745{
746 Q_D(QDialog);
747
749 return;
750
751 d->setVisible(visible);
752}
753
755{
756 Q_Q(QDialog);
757 if (!q->testAttribute(Qt::WA_DontShowOnScreen) && canBeNativeDialog() && setNativeDialogVisible(visible))
758 return;
759
760 // We should not block windows by the invisible modal dialog
761 // if a platform-specific dialog is implemented as an in-process
762 // Qt window, because in this case it will also be blocked.
763 const bool dontBlockWindows = q->testAttribute(Qt::WA_DontShowOnScreen)
765 Qt::WindowModality oldModality;
766 bool wasModalitySet;
767
768 if (dontBlockWindows) {
769 oldModality = q->windowModality();
770 wasModalitySet = q->testAttribute(Qt::WA_SetWindowModality);
771 q->setWindowModality(Qt::NonModal);
772 }
773
774 if (visible) {
775 q->QWidget::setVisible(visible);
776
777 // Window activation might be prevented. We can't test isActiveWindow here,
778 // as the window will be activated asynchronously by the window manager.
779 if (!q->testAttribute(Qt::WA_ShowWithoutActivating)) {
780 QWidget *fw = q->window()->focusWidget();
781 if (!fw)
782 fw = q;
783
784 /*
785 The following block is to handle a special case, and does not
786 really follow proper logic in concern of autoDefault and TAB
787 order. However, it's here to ease usage for the users. If a
788 dialog has a default QPushButton, and first widget in the TAB
789 order also is a QPushButton, then we give focus to the main
790 default QPushButton. This simplifies code for the developers,
791 and actually catches most cases... If not, then they simply
792 have to use [widget*]->setFocus() themselves...
793 */
794#if QT_CONFIG(pushbutton)
795 if (mainDef && fw->focusPolicy() == Qt::NoFocus) {
796 QWidget *first = fw;
797 while ((first = first->nextInFocusChain()) != fw && first->focusPolicy() == Qt::NoFocus)
798 ;
799 if (first != mainDef && qobject_cast<QPushButton*>(first))
800 mainDef->setFocus();
801 }
802 if (!mainDef && q->isWindow()) {
803 QWidget *w = fw;
804 while ((w = w->nextInFocusChain()) != fw) {
805 QPushButton *pb = qobject_cast<QPushButton *>(w);
806 if (pb && pb->autoDefault() && pb->focusPolicy() != Qt::NoFocus) {
807 pb->setDefault(true);
808 break;
809 }
810 }
811 }
812#endif
813 if (fw && !fw->hasFocus()) {
816 }
817 }
818
819#if QT_CONFIG(accessibility)
820 QAccessibleEvent event(q, QAccessible::DialogStart);
821 QAccessible::updateAccessibility(&event);
822#endif
823
824 } else {
825
826#if QT_CONFIG(accessibility)
827 if (q->isVisible()) {
828 QAccessibleEvent event(q, QAccessible::DialogEnd);
829 QAccessible::updateAccessibility(&event);
830 }
831#endif
832
833 // Reimplemented to exit a modal event loop when the dialog is hidden.
834 q->QWidget::setVisible(visible);
835 if (eventLoop)
836 eventLoop->exit();
837 }
838
839 if (dontBlockWindows) {
840 q->setWindowModality(oldModality);
842 }
843
844#if QT_CONFIG(pushbutton)
846 if (mainDef && q->isActiveWindow()
848 QCursor::setPos(mainDef->mapToGlobal(mainDef->rect().center()));
849#endif
850}
851
854{
855 if (!event->spontaneous() && !testAttribute(Qt::WA_Moved)) {
856 Qt::WindowStates state = windowState();
858 setAttribute(Qt::WA_Moved, false); // not really an explicit position
859 if (state != windowState())
861 }
862}
863
866{
867 Q_D(QDialog);
868
870 if (theme->themeHint(QPlatformTheme::WindowAutoPlacement).toBool())
871 return;
872 QPoint p(0, 0);
873 int extraw = 0, extrah = 0;
874 const QWindow *parentWindow = nullptr;
875 if (w) {
876 w = w->window();
877 } else {
878 parentWindow = d->transientParentWindow();
879 }
880 QRect desk;
881 QScreen *scrn = nullptr;
882 if (w)
883 scrn = w->screen();
884 else if (parentWindow)
885 scrn = parentWindow->screen();
886 else if (QGuiApplication::primaryScreen()->virtualSiblings().size() > 1)
888 else
889 scrn = screen();
890 if (scrn)
891 desk = scrn->availableGeometry();
892
894 for (int i = 0; (extraw == 0 || extrah == 0) && i < list.size(); ++i) {
895 QWidget * current = list.at(i);
896 if (current->isVisible()) {
897 int framew = current->geometry().x() - current->x();
898 int frameh = current->geometry().y() - current->y();
899
900 extraw = qMax(extraw, framew);
901 extrah = qMax(extrah, frameh);
902 }
903 }
904
905 // sanity check for decoration frames. With embedding, we
906 // might get extraordinary values
907 if (extraw == 0 || extrah == 0 || extraw >= 10 || extrah >= 40) {
908 extrah = 40;
909 extraw = 10;
910 }
911
912
913 if (w) {
914 // Use pos() if the widget is embedded into a native window
915 QPoint pp;
916 if (w->windowHandle() && qvariant_cast<WId>(w->windowHandle()->property("_q_embedded_native_parent_handle")))
917 pp = w->pos();
918 else
919 pp = w->mapToGlobal(QPoint(0,0));
920 p = QPoint(pp.x() + w->width()/2,
921 pp.y() + w->height()/ 2);
922 } else if (parentWindow) {
923 // QTBUG-63406: Widget-based dialog in QML, which has no Widget parent
924 // but a transient parent window.
925 QPoint pp = parentWindow->mapToGlobal(QPoint(0, 0));
926 p = QPoint(pp.x() + parentWindow->width() / 2, pp.y() + parentWindow->height() / 2);
927 } else {
928 // p = middle of the desktop
929 p = QPoint(desk.x() + desk.width()/2, desk.y() + desk.height()/2);
930 }
931
932 // p = origin of this
933 p = QPoint(p.x()-width()/2 - extraw,
934 p.y()-height()/2 - extrah);
935
936
937 if (p.x() + extraw + width() > desk.x() + desk.width())
938 p.setX(desk.x() + desk.width() - width() - extraw);
939 if (p.x() < desk.x())
940 p.setX(desk.x());
941
942 if (p.y() + extrah + height() > desk.y() + desk.height())
943 p.setY(desk.y() + desk.height() - height() - extrah);
944 if (p.y() < desk.y())
945 p.setY(desk.y());
946
947 // QTBUG-52735: Manually set the correct target screen since scaling in a
948 // subsequent call to QWindow::resize() may otherwise use the wrong factor
949 // if the screen changed notification is still in an event queue.
950 if (scrn) {
951 if (QWindow *window = windowHandle())
952 window->setScreen(scrn);
953 }
954
955 move(p);
956}
957
960{
961 Q_D(const QDialog);
962 if (d->extension) {
963 if (d->orientation == Qt::Horizontal)
964 return QSize(QWidget::sizeHint().width(),
965 qMax(QWidget::sizeHint().height(),d->extension->sizeHint().height()));
966 else
967 return QSize(qMax(QWidget::sizeHint().width(), d->extension->sizeHint().width()),
969 }
970 return QWidget::sizeHint();
971}
972
973
976{
977 Q_D(const QDialog);
978 if (d->extension) {
979 if (d->orientation == Qt::Horizontal)
981 qMax(QWidget::minimumSizeHint().height(), d->extension->minimumSizeHint().height()));
982 else
983 return QSize(qMax(QWidget::minimumSizeHint().width(), d->extension->minimumSizeHint().width()),
985 }
986
988}
989
1004void QDialog::setModal(bool modal)
1005{
1007}
1008
1009
1011{
1012#if QT_CONFIG(sizegrip)
1013 Q_D(const QDialog);
1014 return !!d->resizer;
1015#else
1016 return false;
1017#endif
1018}
1019
1020
1022{
1023#if !QT_CONFIG(sizegrip)
1025#else
1026 Q_D(QDialog);
1027#if QT_CONFIG(sizegrip)
1028 d->sizeGripEnabled = enabled;
1029 if (enabled && d->doShowExtension)
1030 return;
1031#endif
1032 if (!enabled != !d->resizer) {
1033 if (enabled) {
1034 d->resizer = new QSizeGrip(this);
1035 // adjustSize() processes all events, which is suboptimal
1036 d->resizer->resize(d->resizer->sizeHint());
1037 if (isRightToLeft())
1038 d->resizer->move(rect().bottomLeft() -d->resizer->rect().bottomLeft());
1039 else
1040 d->resizer->move(rect().bottomRight() -d->resizer->rect().bottomRight());
1041 d->resizer->raise();
1042 d->resizer->show();
1043 } else {
1044 delete d->resizer;
1045 d->resizer = nullptr;
1046 }
1047 }
1048#endif // QT_CONFIG(sizegrip)
1049}
1050
1051
1052
1055{
1056#if QT_CONFIG(sizegrip)
1057 Q_D(QDialog);
1058 if (d->resizer) {
1059 if (isRightToLeft())
1060 d->resizer->move(rect().bottomLeft() -d->resizer->rect().bottomLeft());
1061 else
1062 d->resizer->move(rect().bottomRight() -d->resizer->rect().bottomRight());
1063 d->resizer->raise();
1064 }
1065#endif
1066}
1067
1111#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:562
The QContextMenuEvent class contains parameters that describe a context menu event.
Definition qevent.h:594
const QPoint & pos() const
Returns the position of the mouse pointer relative to the widget that received the event.
Definition qevent.h:611
const QPoint & globalPos() const
Returns the global position of the mouse pointer at the time of the event.
Definition qevent.h:612
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:754
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:450
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:721
QSize sizeHint() const override
\reimp
Definition qdialog.cpp:959
bool isSizeGripEnabled() const
Definition qdialog.cpp:1010
void finished(int result)
bool eventFilter(QObject *, QEvent *) override
\reimp
Definition qdialog.cpp:645
void rejected()
void setSizeGripEnabled(bool)
Definition qdialog.cpp:1021
virtual void reject()
Hides the modal dialog and sets the result code to Rejected.
Definition qdialog.cpp:639
void setResult(int r)
Sets the modal dialog's result code to i.
Definition qdialog.cpp:489
~QDialog()
Destroys the QDialog, deleting all its children.
Definition qdialog.cpp:385
void keyPressEvent(QKeyEvent *) override
\reimp
Definition qdialog.cpp:684
virtual int exec()
Shows the dialog as a \l{QDialog::Modal Dialogs}{modal dialog}, blocking until the user closes it.
Definition qdialog.cpp:543
QSize minimumSizeHint() const override
\reimp
Definition qdialog.cpp:975
int result() const
In general returns the modal dialog's result code, Accepted or Rejected.
Definition qdialog.cpp:475
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:1004
void resizeEvent(QResizeEvent *) override
\reimp
Definition qdialog.cpp:1054
void accepted()
void showEvent(QShowEvent *) override
\reimp
Definition qdialog.cpp:853
void contextMenuEvent(QContextMenuEvent *) override
\reimp
Definition qdialog.cpp:656
QDialog(QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
Constructs a dialog with parent parent.
Definition qdialog.cpp:366
virtual void done(int)
Closes the dialog and sets its result code to r.
Definition qdialog.cpp:602
void adjustPosition(QWidget *)
Definition qdialog.cpp:865
virtual void open()
Definition qdialog.cpp:503
void setVisible(bool visible) override
\reimp
Definition qdialog.cpp:744
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:628
\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
Type type() const
Returns the event type.
Definition qcoreevent.h:304
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Definition qcoreevent.h:311
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
Definition qcoreevent.h:310
The QFocusEvent class contains event parameters for widget focus events.
Definition qevent.h:470
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:788
The QKeyEvent class describes a key event.
Definition qevent.h:424
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
Definition qevent.cpp:1468
int key() const
Returns the code of the key that was pressed or released.
Definition qevent.h:434
qsizetype size() const noexcept
Definition qlist.h:397
const_reference at(qsizetype i) const noexcept
Definition qlist.h:446
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:73
\inmodule QtCore
Definition qobject.h:103
Q_INVOKABLE QObject(QObject *parent=nullptr)
Constructs an object with parent object parent.
Definition qobject.cpp:936
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
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:1555
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
\inmodule QtCore\reentrant
Definition qpoint.h:25
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 QPoint bottomLeft() const noexcept
Returns the position of the rectangle's bottom-left corner.
Definition qrect.h:230
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:855
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
Definition qrect.h:185
constexpr QPoint bottomRight() const noexcept
Returns the position of the rectangle's bottom-right corner.
Definition qrect.h:224
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
Definition qrect.h:188
The QResizeEvent class contains event parameters for resize events.
Definition qevent.h:548
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:578
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:133
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:130
\inmodule QtCore
Definition qvariant.h:65
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:4313
void setWindowModality(Qt::WindowModality windowModality)
Definition qwidget.cpp:2799
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:6828
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:8135
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:2937
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:7875
void setScreen(QScreen *)
Sets the screen on which the widget should be shown to screen.
Definition qwidget.cpp:2524
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:2483
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:6446
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:2888
QScreen * screen() const
Returns the screen the widget is on.
Definition qwidget.cpp:2496
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
else opt state
[0]
Combined button and popup list for selecting options.
Definition qcompare.h:63
@ WA_WState_ExplicitShowHide
Definition qnamespace.h:335
@ WA_SetWindowModality
Definition qnamespace.h:400
@ WA_CustomWhatsThis
Definition qnamespace.h:313
@ WA_DontShowOnScreen
Definition qnamespace.h:383
@ WA_Moved
Definition qnamespace.h:309
@ WA_WState_Hidden
Definition qnamespace.h:297
@ WA_ShowWithoutActivating
Definition qnamespace.h:374
@ WA_ShowModal
Definition qnamespace.h:337
@ WA_DeleteOnClose
Definition qnamespace.h:321
WindowModality
@ NonModal
@ WindowModal
@ NoFocus
Definition qnamespace.h:107
@ Horizontal
Definition qnamespace.h:99
@ Key_Return
Definition qnamespace.h:667
@ Key_Enter
Definition qnamespace.h:668
@ KeypadModifier
@ AA_DontUseNativeDialogs
Definition qnamespace.h:458
@ Dialog
Definition qnamespace.h:208
@ Sheet
Definition qnamespace.h:209
@ 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:166
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
#define SLOT(a)
Definition qobjectdefs.h:52
#define SIGNAL(a)
Definition qobjectdefs.h:53
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLboolean r
[2]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLfloat GLfloat f
GLint GLsizei width
GLenum type
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]