[Qt-interest] isUnderModal?
Ishan Arora
ishanarora at gmail.com
Thu Jun 10 20:40:37 CEST 2010
Thanks Rohan,
Except for a typo our code works flawlessly.
Regards,
Ishan Arora
Student of Mathematics and Computing
Indian Institute of Technology Delhi, India
http://www.google.com/profiles/ishanarora
On Thu, Jun 10, 2010 at 11:23 PM, Rohan Prabhu <rohan at rohanprabhu.com> wrote:
>
> I'm assuming here that you are using QDialog's for all your dialogs
> and that you are properly setting up non-zero parent pointers for your
> QObject. In that case, what I suggest you do is:
>
> 1. Find all the children of your main window (which is naturally
> inherited from QWidget, be it QWidget itself or QMainWindow) which are
> of type QDialog.
> 2. For each item found, check to see if the dialog is modal using
> QDialog::isModal() and also if it is currently visible using
> QWidget::isVisible().
> 3. If both of the above are true, then your main window can be sure
> that there is a modal window which is opened.
>
> A code sample might help:
>
> typedef QList<QDialog*> QDList;
>
> class MainWindow : public QMainWindow {
> public:
> bool checkForModals();
>
> //Rest of the functions here
> };
>
> bool MainWindow::checkForModals() {
> //Returns true if there are any modal windows visible
> QDList dialog_list = findChildren<QDialog*>();
> QDList::const_iterator i;
>
> for(i = dialog_list.begin(); i != list.constEnd(); i++) {
> if(((*i)->isModal() == true) && ((*i)->isVisible() == true)) {
> return true;
> }
> }
>
> return false;
> }
>
> On Thu, Jun 10, 2010 at 9:17 PM, Ishan Arora <ishanarora at gmail.com> wrote:
> > Hi,
> >
> > I my Qt application I have a main window from which several modal dialog can
> > be opened. The main window is able to receive WindowStateChange event
> > through my WM's "show desktop" command even when under a modal dialog. I
> > wish to be able to find out from inside the main window's event procedure if
> > it is under a modal dialog. Does Qt have a function to do this?
> > Alternatively I will have to manage a boolean flag to keep track of this.
> > Thanks.
> >
> > Regards,
> > Ishan Arora
> >
> > Student of Mathematics and Computing
> > Indian Institute of Technology Delhi, India
> > http://www.google.com/profiles/ishanarora
> >
> > _______________________________________________
> > Qt-interest mailing list
> > Qt-interest at trolltech.com
> > http://lists.trolltech.com/mailman/listinfo/qt-interest
> >
> >
More information about the Qt-interest-old
mailing list