Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-6456

Mac Cocoa modal QDialogs do not re-activate prior window after done and QApplication::setActiveWindow doesn't work either

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 4.7.0
    • 4.6.0
    • None
    • mac coca on leopard 32bit
    • macOS
    • 464306df827cbf3378f72f9aead0448a32ab5a21

    Description

      popup QDialog's are not returning focus/active window status to the previously active/focused window after they go away, only in the cocoa version (carbon works fine as it has in prior versions). for example, the clicked() signal on a button is connected to a popup dialog, and when I tab over to that button, hit the space bar, get the popup, select something, and then close it, the previous window is no longer active.

      this is in an application with multiple QMainWindow's – it is always re-activating the first such window that was created.

      to create a work-around, we have a sub-classed QDialog called iDialog, to which I added a new exec() function as shown below. My first attempt to fix the but using QApplication::setActiveWindow failed, but using the activateWindow() call directly works! perhaps this problem with setActiveWindow is the source of the problem in the first place?

      int iDialog::exec() {
      // we're losing focus here so need to restore it!!
      #ifdef TA_OS_MAC
      QPointer<QWidget> m_prev_active = QApplication::activeWindow();
      #endif
      int rval = QDialog::exec();
      #ifdef TA_OS_MAC
      if((bool)m_prev_active)

      { // QApplication::setActiveWindow(m_prev_active); // note: above does NOT work! -- likely source of bug in cocoa 4.6.0 m_prev_active->activateWindow(); }

      #endif
      return rval;
      }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            richard Richard Moe Gustavsen
            rcoreilly Randall O'Reilly
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes