Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. temporarily hide a dialog without causing it's "dismiss" action to fire?
Forum Updated to NodeBB v4.3 + New Features

temporarily hide a dialog without causing it's "dismiss" action to fire?

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 5 Posters 2.3k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    davecotter
    wrote on last edited by
    #1

    if i call dialog->hide(), it's "Rejected" action fires. is this expected? can we NOT do that?

    JonBJ 1 Reply Last reply
    0
    • D Offline
      D Offline
      davecotter
      wrote on last edited by
      #9

      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)

      1 Reply Last reply
      0
      • A Offline
        A Offline
        arsinte_andrei
        wrote on last edited by
        #2

        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

        1 Reply Last reply
        0
        • D Offline
          D Offline
          davecotter
          wrote on last edited by
          #3

          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)

          1 Reply Last reply
          1
          • M Offline
            M Offline
            mpergand
            wrote on last edited by mpergand
            #4

            Set the dialog size to zero ?

            moving the dialog window way off the screen)

            Work well on Mac, but not on Linux, some desktop managers don't like that (my experience)

            1 Reply Last reply
            1
            • D davecotter

              if i call dialog->hide(), it's "Rejected" action fires. is this expected? can we NOT do that?

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #5

              @davecotter

              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?

              1 Reply Last reply
              0
              • D Offline
                D Offline
                davecotter
                wrote on last edited by
                #6

                do i use dlg.resize(QSize(0, 0)) for that? if so, it does nothing

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  davecotter
                  wrote on last edited by
                  #7

                  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() or dlg.show() depending on bool
                  using that causes the dialog to be dismissed

                  using 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)

                  Pl45m4P 1 Reply Last reply
                  0
                  • D davecotter

                    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() or dlg.show() depending on bool
                    using that causes the dialog to be dismissed

                    using 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)

                    Pl45m4P Offline
                    Pl45m4P Offline
                    Pl45m4
                    wrote on last edited by Pl45m4
                    #8

                    @davecotter

                    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 Doc

                    Are 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...


                    If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                    ~E. W. Dijkstra

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      davecotter
                      wrote on last edited by
                      #9

                      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)

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved