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. Top-Level Window vs Window in QGuiApplication?
Forum Update on Monday, May 27th 2025

Top-Level Window vs Window in QGuiApplication?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 1.6k 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.
  • CJhaC Offline
    CJhaC Offline
    CJha
    wrote on last edited by
    #1

    The QGuiApplication class has two functions:

    QWindowList QGuiApplication::topLevelWindows()

    Returns a list of the top-level windows in the application.

    and
    QWindowList QGuiApplication::allWindows()

    Returns a list of all the windows in the application.

    Isn't a window a top-level window as well? What is the difference between these two functions?

    JKSHJ JonBJ 2 Replies Last reply
    0
    • CJhaC CJha

      The QGuiApplication class has two functions:

      QWindowList QGuiApplication::topLevelWindows()

      Returns a list of the top-level windows in the application.

      and
      QWindowList QGuiApplication::allWindows()

      Returns a list of all the windows in the application.

      Isn't a window a top-level window as well? What is the difference between these two functions?

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      @CJha said in Top-Level Window vs Window in QGuiApplication?:

      Isn't a window a top-level window as well? What is the difference between these two functions?

      A window could be embedded inside another window. That makes it a window that is not top-level.

      For example, see https://specifications.freedesktop.org/xembed-spec/xembed-spec-latest.html

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      5
      • CJhaC CJha

        The QGuiApplication class has two functions:

        QWindowList QGuiApplication::topLevelWindows()

        Returns a list of the top-level windows in the application.

        and
        QWindowList QGuiApplication::allWindows()

        Returns a list of all the windows in the application.

        Isn't a window a top-level window as well? What is the difference between these two functions?

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

        @CJha
        All topLevelWindows() appear in allWindows(), but not all allWindows() appear in topLevelWindows() :)

        In Qt "Any widget without a parent widget is a top-level widget or window. " You should be able to verify this holds for all the windows/widgets in those two lists --- all topLevelWindows() should have no parent, and no other window in allWindows() should have no parent.

        CJhaC 1 Reply Last reply
        4
        • CJhaC Offline
          CJhaC Offline
          CJha
          wrote on last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • JonBJ JonB

            @CJha
            All topLevelWindows() appear in allWindows(), but not all allWindows() appear in topLevelWindows() :)

            In Qt "Any widget without a parent widget is a top-level widget or window. " You should be able to verify this holds for all the windows/widgets in those two lists --- all topLevelWindows() should have no parent, and no other window in allWindows() should have no parent.

            CJhaC Offline
            CJhaC Offline
            CJha
            wrote on last edited by
            #5

            @JonB Thanks! sounds a little complicated, but I think I get it. The basic distinction being if a window has a parent then I will only find it using allWindows() and not using topLevelWindows()?

            JonBJ 1 Reply Last reply
            1
            • CJhaC CJha

              @JonB Thanks! sounds a little complicated, but I think I get it. The basic distinction being if a window has a parent then I will only find it using allWindows() and not using topLevelWindows()?

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

              @CJha Yes, exactly that.

              1 Reply Last reply
              2

              • Login

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