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. How can I know if my item is showing?
Forum Updated to NodeBB v4.3 + New Features

How can I know if my item is showing?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 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.
  • I Offline
    I Offline
    igor_stravinsky
    wrote on last edited by
    #1

    I'd like to do some optimization of my code, and only update my item when it's on the screen. e.g. the screen it's on is now on top of a stack view, or on the current tab of a tab view.

    Is there a signal I can respond to that indicates when an item is visible to the user?

    I'm not changing the visibility of the object, so onVisibilityChanged isn't the right way to go...

    1 Reply Last reply
    0
    • 6thC6 Offline
      6thC6 Offline
      6thC
      wrote on last edited by
      #2

      Do you mean something like dynamically constructing / loading QML objects as you change tabs?
      http://doc.qt.io/qt-5/qtqml-javascript-dynamicobjectcreation.html

      Qt.createQmlObject || Qt.createComponent()
      

      and

      (object).destroy()
      

      I don't know if it answers that loaded question of visibility... "visible to the user" is a tricky definition. What's yours because objects can be "visible" and treated as such, all the work still has to happen but still not be actually be seen (under layers, no dimensions, uniform colors, off screen/window drawing).

      1 Reply Last reply
      0
      • I Offline
        I Offline
        igor_stravinsky
        wrote on last edited by
        #3

        No, I wasn't thinking about dynamic loading.

        Consider you have five popups running, and each one has a video in it. The video will continue to render, even if the popup isn't showing.

        Suppose the video is on a tab in a tabbed interface, and you'd like to stop the video from rendering if the tab it's on isn't showing.

        Suppose the video is in a scrollable view, but that part of the scrollable view isn't currently shown.

        Suppose your Qt app has multiple windows, and one of the windows is hiding a window showing the video.

        What I'm really trying to do is improve CPU usage by having Qt do less work when particular items aren't shown. The interfaces are laid out statically, not dynamically, but I want to dynamically control if a video, a graph, or some other control is doing work that will increase CPU usage.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          medyakovvit
          wrote on last edited by
          #4

          @igor_stravinsky

          Suppose the video is on a tab in a tabbed interface, and you'd like to stop the video from rendering if the tab it's on isn't showing.
          Check currentIndex in TabView.

          Suppose the video is in a scrollable view, but that part of the scrollable view isn't currently shown.
          Check viewport in ScrollView.

          Suppose your Qt app has multiple windows, and one of the windows is hiding a window showing the video.
          Here you can look at "visible" property.

          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