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. Unwanted delay when switching focus between MainWindow and non-modal dialog window
Forum Updated to NodeBB v4.3 + New Features

Unwanted delay when switching focus between MainWindow and non-modal dialog window

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 1.5k Views
  • 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.
  • DiracsbracketD Offline
    DiracsbracketD Offline
    Diracsbracket
    wrote on last edited by Diracsbracket
    #1

    Hi,
    It's just a small thing, but I am facing the following situation.

    I have a main app window with 4 of QTreeViews, one of which contains a QFileSystemModel.

    Then there is a situation where I need to open a dialog window in a non-modal way, such that I can change the current row selection in one of the QTreeViews.

    However, I have noticed that there is a small, but noticeable delay when switching between the MainWindow window and the dialog window. This delay is for example clearly noticeable when I click/drag on the respective window's title bar to move it: it would initially not seem to react, and then snap to the current mouse position to follow the cursor's movement.

    Although not critical, I find this delay somewhat user unfriendly, and was wondering what the underlying causes might be. After all, when switch-drag-moving between the main app window and the Qt Creator for example, this noticeable delay does not occur. So why would it occur between the Main window and the dialog window?

    Any insights provided will be greatly appreciated!

    jsulmJ JonBJ 2 Replies Last reply
    0
    • DiracsbracketD Diracsbracket

      Hi,
      It's just a small thing, but I am facing the following situation.

      I have a main app window with 4 of QTreeViews, one of which contains a QFileSystemModel.

      Then there is a situation where I need to open a dialog window in a non-modal way, such that I can change the current row selection in one of the QTreeViews.

      However, I have noticed that there is a small, but noticeable delay when switching between the MainWindow window and the dialog window. This delay is for example clearly noticeable when I click/drag on the respective window's title bar to move it: it would initially not seem to react, and then snap to the current mouse position to follow the cursor's movement.

      Although not critical, I find this delay somewhat user unfriendly, and was wondering what the underlying causes might be. After all, when switch-drag-moving between the main app window and the Qt Creator for example, this noticeable delay does not occur. So why would it occur between the Main window and the dialog window?

      Any insights provided will be greatly appreciated!

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Diracsbracket On what OS? Which Qt version? Is your app doing any heavy calculations? ...?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      DiracsbracketD 1 Reply Last reply
      0
      • DiracsbracketD Diracsbracket

        Hi,
        It's just a small thing, but I am facing the following situation.

        I have a main app window with 4 of QTreeViews, one of which contains a QFileSystemModel.

        Then there is a situation where I need to open a dialog window in a non-modal way, such that I can change the current row selection in one of the QTreeViews.

        However, I have noticed that there is a small, but noticeable delay when switching between the MainWindow window and the dialog window. This delay is for example clearly noticeable when I click/drag on the respective window's title bar to move it: it would initially not seem to react, and then snap to the current mouse position to follow the cursor's movement.

        Although not critical, I find this delay somewhat user unfriendly, and was wondering what the underlying causes might be. After all, when switch-drag-moving between the main app window and the Qt Creator for example, this noticeable delay does not occur. So why would it occur between the Main window and the dialog window?

        Any insights provided will be greatly appreciated!

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

        @Diracsbracket
        After you have answered @jsulm's questions...

        We may need to see your code. For example, if there is any way that when changing windows (or something you do in the modeless window) causes your main app window to re-read the file system to re-populate the QFileSystemModel's QTreeView that might lead to the delay....

        DiracsbracketD 1 Reply Last reply
        0
        • jsulmJ jsulm

          @Diracsbracket On what OS? Which Qt version? Is your app doing any heavy calculations? ...?

          DiracsbracketD Offline
          DiracsbracketD Offline
          Diracsbracket
          wrote on last edited by Diracsbracket
          #4

          @jsulm said in Unwanted delay when switching focus between MainWindow and non-modal dialog window:

          On what OS? Which Qt version? Is your app doing any heavy calculations?

          Hi @jsulm. My system detail (as per Qt Creator's Help | System Information):

          Qt 5.9.2 (i386-little_endian-ilp32 shared (dynamic) release build; by MSVC 2015) on "windows" 
          OS: Windows 7 SP 1 (6.1) [winnt version 6.1.7601]
          
          Architecture: x86_64; features: SSE2 SSE3 SSSE3 SSE4.1 SSE4.2 AVX
          

          No heavy calculations are performed. Before opening the dialog, signal/slot connections related to selection change in the tree view are disconnected, and also all models have been populated at that point.

          I have an eventFilter installed on several objects, among which the viewports of the QTreeViews.

          If I activate the debug lines in my eventFilter, as follows:

          bool MainWindow::eventFilter(QObject *obj, QEvent *event)
          {
              const QEvent::Type type = event->type();
              qDebug() << "event: " << type << obj->objectName() << obj->parent()->objectName();
          ...
          }
          

          I get the following output upon click-dragging the main window (with previously the dialog being active) (the WindowDeactivate event stems from the app losing focus when I copied the output below from Qt's Debug output):

          event:  QEvent::Type(WindowActivate) "qt_scrollarea_viewport" "scriptTree"
          event:  QEvent::Type(WindowActivate) "qt_scrollarea_viewport" "fileTree"
          event:  QEvent::Type(WindowActivate) "" "qt_scrollarea_hcontainer"
          event:  QEvent::Type(WindowActivate) "qt_scrollarea_viewport" ""
          event:  QEvent::Type(Paint) "qt_scrollarea_viewport" "scriptTree"
          event:  QEvent::Type(Paint) "qt_scrollarea_viewport" "fileTree"
          event:  QEvent::Type(Paint) "qt_scrollarea_viewport" ""
          event:  QEvent::Type(Paint) "" "qt_scrollarea_hcontainer"
          event:  QEvent::Type(DynamicPropertyChange) "" "qt_scrollarea_hcontainer"
          event:  QEvent::Type(Paint) "qt_scrollarea_viewport" "scriptTree"
          event:  QEvent::Type(Paint) "qt_scrollarea_viewport" "fileTree"
          event:  QEvent::Type(Paint) "qt_scrollarea_viewport" ""
          event:  QEvent::Type(WindowDeactivate) "qt_scrollarea_viewport" "scriptTree"
          event:  QEvent::Type(WindowDeactivate) "qt_scrollarea_viewport" "fileTree"
          event:  QEvent::Type(WindowDeactivate) "" "qt_scrollarea_hcontainer"
          event:  QEvent::Type(WindowDeactivate) "qt_scrollarea_viewport" ""
          event:  QEvent::Type(Paint) "qt_scrollarea_viewport" "scriptTree"
          event:  QEvent::Type(Paint) "qt_scrollarea_viewport" "fileTree"
          event:  QEvent::Type(Paint) "qt_scrollarea_viewport" ""
          event:  QEvent::Type(Paint) "" "qt_scrollarea_hcontainer"
          event:  QEvent::Type(DynamicPropertyChange) "" "qt_scrollarea_hcontainer"
          event:  QEvent::Type(Paint) "qt_scrollarea_viewport" "scriptTree"
          event:  QEvent::Type(Paint) "qt_scrollarea_viewport" "fileTree"
          event:  QEvent::Type(Paint) "qt_scrollarea_viewport" ""
          

          I have added trace lines like the one below in all my functions:

          qDebug() << Q_FUNC_INFO;
          

          None of the other functions' traces appear in the debug output above, so no calculations are performed by my code before/after the switch from dialog to MainWindow.

          1 Reply Last reply
          0
          • JonBJ JonB

            @Diracsbracket
            After you have answered @jsulm's questions...

            We may need to see your code. For example, if there is any way that when changing windows (or something you do in the modeless window) causes your main app window to re-read the file system to re-populate the QFileSystemModel's QTreeView that might lead to the delay....

            DiracsbracketD Offline
            DiracsbracketD Offline
            Diracsbracket
            wrote on last edited by Diracsbracket
            #5

            @JonB Thanks for reacting!
            There is nothing that causes the data in the various treeviews to be updated upon switching windows, as my qDebug() trace output in the post above shows (these qDebug() trace statements are in virtually all my functions).

            What is also obvious is that when switching, the menu bar of my main window is slow to getting disabled/enabled again. The window title and frame however, are activated immediately upon clicking.

            1 Reply Last reply
            0
            • DiracsbracketD Offline
              DiracsbracketD Offline
              Diracsbracket
              wrote on last edited by
              #6

              Since my old laptop died, and I moved to a new one using Windows 10, etc... the delay is basically gone, or is small enough not to be noticed. Don't know if it was because I have a more powerful machine now, or because I changed to 5.9.4 or Windows 10, or all of it. So I'll close this thread.

              1 Reply Last reply
              1

              • Login

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