temporarily hide a dialog without causing it's "dismiss" action to fire?
-
if i call dialog->hide(), it's "Rejected" action fires. is this expected? can we NOT do that?
-
it's a modal dialog without a parent. that seems to be the problem. fixed by manually placing it offscreen, then manually placing it back (since offset seems to have run into some constraint)
-
why are you using dialog?? what you are trying to do is not a dialog... Try to use a normal window.. that can be hidden .. and implement 2 buttons there ok and cancel
-
i appreciate your attempting to help by suggesting something else, but i really just want to know how to do what i'm trying to do. I have reasons for doing it that i don't need to get into. I'm just asking if what i want to do is possible, or if there's a workaround (perhaps moving the dialog window way off the screen)
-
if i call dialog->hide(), it's "Rejected" action fires. is this expected? can we NOT do that?
I looked at that code a week ago, and I think the answers are: "Yes", "No".
As @mpergand suggests, https://doc.qt.io/qt-5/qwidget.html#size-prop :
Note: Setting the size to
QSize(0, 0)
will cause the widget to not appear on screen. This also applies to windows.Worth a try?
-
do i use
dlg.resize(QSize(0, 0))
for that? if so, it does nothing -
NONE of these techniques work:
#define kUseZeroSizeTechnique 0 #define kOffsetTechniqueVal 20000 ScDialogHideShow::ScDialogHideShow(CDialog *dlgP) : i_dlgP(dlgP) { #if _QT_ #if kUseZeroSizeTechnique QSize prevSize(i_dlgP->i_qDlgP->size()); i_prevPos.h = prevSize.width(); i_prevPos.v = prevSize.height(); i_dlgP->i_qDlgP->resize(0, 0); #else Point offsetPt = {kOffsetTechniqueVal, kOffsetTechniqueVal}; i_dlgP->OffsetPosition(offsetPt); #endif #else i_dlgP->Show(false); #endif } ScDialogHideShow::~ScDialogHideShow() { #if _QT_ #if kUseZeroSizeTechnique i_dlgP->i_qDlgP->resize(i_prevPos.h, i_prevPos.v); #else Point offsetPt = {kOffsetTechniqueVal, kOffsetTechniqueVal}; i_dlgP->OffsetPosition(offsetPt, true); #endif #else i_dlgP->Show(true); #endif i_dlgP->Select(); }
note that
Show(bool)
does the qt thing ie:dlg.hide()
ordlg.show()
depending on bool
using that causes the dialog to be dismissedusing the offset technique does not place the dialog back to where it should be (some positioning constraint?)
using the zero technique does nothing (no change to dialog)
-
I dont know if it works, but I would try to reimplement the hide function (or even custom dialog) or try to intercept the reject signal by triggering my own signal or by using an event.
EDIT:
@davecotter said in temporarily hide a dialog without causing it's "dismiss" action to fire?:
if i call dialog->hide(), it's "Rejected" action fires
According to Qt Doc "QDialog::hide()" does NOT trigger the "QDialog::rejected" signal. Strange...
QDialog::rejected Qt DocAre you using modal or non modal dialogs?
QDialogs get closed / destroyed when you try to hide them, while there is no parent alive / visible.
This would explain why you got a QDialog::rejected signal.But just a guess...
-
it's a modal dialog without a parent. that seems to be the problem. fixed by manually placing it offscreen, then manually placing it back (since offset seems to have run into some constraint)