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. Looking for Control.noShown signal
Qt 6.11 is out! See what's new in the release blog

Looking for Control.noShown signal

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 633 Views 1 Watching
  • 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.
  • M Offline
    M Offline
    MiklYarochkin
    wrote on last edited by
    #1

    Hello,

    I am making HMI for machine working on the CAN bus.
    So, it is important to keep the bus load as low as possible.

    For this, I need to request parameters only for visible on UI parameters. Like I don't need "CurrentSpeed", if on UI user currently activated view with "Settings".

    But I am missing a signal from Control what saying: "Hi. I am TextVew for CurrentSpeed. And User just open Layout with me!".
    And I can ask for updates from PLC only for this parameter(s).

    Can you help me, please?

    Mikl

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MiklYarochkin
      wrote on last edited by
      #2

      Temporary, I solved it with:

      Button {
          property string control
          ...
          Component.onCompleted: panel.controlShowed(control)
          ...
      }
      

      But hot sure what it is a good idea.

      1 Reply Last reply
      0
      • GrecKoG Offline
        GrecKoG Offline
        GrecKo
        Qt Champions 2018
        wrote on last edited by GrecKo
        #3

        Let's consider a Label displaying a value, I assume you are showing the value of a property of some device.

        What you might currently be doing now is (keep in my that I don't know how CAN works or how you are actually using it):

        Label {
            text: CanController.device(deviceName).propertyName
        }
        

        If I understand correctly your problem, it's that the CAN controller has to always update the property because it doesn't know when it's needed or not.

        I would consider 2 solutions :

        • Use an instantiable type to access your CAN values, and update the value only when an instance exists/is enabled
        Label {
            id: myLabel
            CanProperty {
                id: myProperty
                device: deviceName
                property: propertyName
                enabled: myLabel.visible // optional, maybe just relying on the automatic destruction of the Label is enough for you (only works if you remove/replace your controls/pages, not if you simply hide them)
            }
            text: myProperty.value
        }
        
        • Use an attached property ( https://doc.qt.io/qt-5/qtqml-cppintegration-definetypes.html#providing-attached-properties ) to hold a handle on a property that will tell the controller to keep updating its value when the handle exists/is enabled (in the c++ implementation of the attached object, you can connect to the visibleChanged signal of the Item to enable/disable the handle)
        Label {
            id: myLabel
            CanHandle.device: deviceName
            CanHandle.property: propertyName
            text: CanController.device(deviceName).propertyName // same API as before here
        }
        

        I don't really know what your current code looks like, so I'm not sure if it's applicable but that's something I would do.

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

          Thank you for your answer

          My problem is, that I need to request only 10 of 50 possible properties on CanBus. The ones showed on UI

          If i understand your proposal correct, you showing how to "bind" "Label.text" to "device.property"

          Maybe i overlook this, but I don't see how it is informing CanController what properties to request

          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