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

activateWindow() does not work properly if there are several windows

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Done
    • Affects Version/s: 4.6.0
    • Fix Version/s: 4.6.0
    • Labels:
      None

      Description

      This is an import of the old task 260685 for reference.
      Was reported against S60 and is mentioned in tst_qwidget::activateWindow.

      A bit of a strange bug. The activateWindow() call succeeds visually, e.g. the right window is shown, but activeWindow() still reports the old window as being active. In addition the window title is wrong.

      This is the testcase from the reporter:

      int main(int argc, char *argv[])
      {
          MyApp a(argc, argv);
       
       
          QMainWindow* m1 = new QMainWindow();
          QScrollArea* s1 = new QScrollArea(m1);
          m1->setCentralWidget(s1);
          m1->setGeometry(0, 100, 300,  500);
          s1->viewport()->setFocusPolicy(Qt::ClickFocus);
          QPalette pal = s1->palette();
          pal.setColor(s1->backgroundRole(), Qt::blue);
          s1->setPalette(pal);
          a.processEvents();
          m1->setVisible(true);
          m1->activateWindow();
          a.processEvents();
          QMainWindow* m2 = new QMainWindow();
          QScrollArea* s2 = new QScrollArea(m2);
          m2->setCentralWidget(s2);
          m2->setGeometry(0, 100 , 300,  300);
          s2->viewport()->setFocusPolicy(Qt::ClickFocus);
          pal = s2->palette();
          pal.setColor(s2->backgroundRole(), Qt::red);
          s2->setPalette(pal);
          a.processEvents();
          m2->setVisible(true);
          m2->activateWindow();
          a.processEvents();
       
          m1->setVisible(true);
          m1->activateWindow();
          a.processEvents();
       
          if (m1->isActiveWindow() || s1->isActiveWindow()
                  || s1->viewport()->isActiveWindow())
              {
              m1->setWindowTitle("m1 is the active window");
              }
          else
              {
              m1->setWindowTitle("m1 is not a active window");
              if (a.activeWindow() == m2)
                  {
                  m2->setWindowTitle("Something wrong");
                  }
              }
       
          a.exec();
      }
      

        Attachments

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

          Activity

            People

            Assignee:
            jbornema Joerg Bornemann
            Reporter:
            jbornema Joerg Bornemann
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes