Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Prevent resize and flicker when showing a window

Prevent resize and flicker when showing a window

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 21 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.
  • K Offline
    K Offline
    krasko
    wrote last edited by
    #1

    When displaying a (modal) window (QQuickView) with a QML component (with children) inside it, the QML component (and its children) does not report correct size until after the window is made visible. The result is that the window initially appears small and then as the QML components are laid out and rendered, their sizes are updated, eventually the size of the window is updated too to reflect the content size change. The problem is that this is all visible to the user and does not look nice. Are there any techniques to show a window such that the only thing the user sees is the final appearance and size of the window? Like fully prepare the window and then show it so the preparation does not happen in front of the user? One thing that comes to mind is make the window transparent, show it and then make it opaque but there's got to be a better way.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Shrishashank
      wrote last edited by
      #2

      You're seeing the window resize because QML layouts and implicit sizes are only resolved after the window is shown. To avoid this visual flicker, the best approach is to fully prepare the window before making it visible.

      To prevent the visual flicker:

      Use

      visible: false
      

      and

      Component.onCompleted
      

      Defer display until layout is complete.
      Use

      setVisibility(QWindow::Hidden)
      

      first.Create and prepare window off-screen, then show.

      SHRISHASHANK S K

      1 Reply Last reply
      0
      • K Offline
        K Offline
        krasko
        wrote last edited by
        #3

        How exactly should I prepare it off-screen if the preparation happens when it is shown? The QML is created dynamically with Qt.createComponent its Component.onCompleted executes before the QQuickView is shown. The QML component is added as a child of the QQuickView and then the QQuickView is shown. Since we use this to display a simple question dialog, we want the QML component to auto-resize itself and the dialog to resize as well to accommodate for this. It works but as I said this is all visible to the user.

        1 Reply Last reply
        0

        • Login

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