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. Issue with Qt Controls signals inside ListView
Forum Updated to NodeBB v4.3 + New Features

Issue with Qt Controls signals inside ListView

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 1.2k 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.
  • G Offline
    G Offline
    guillaumesmo
    wrote on last edited by
    #1

    Hi,

    I'm trying to make a ListView of Controls (Sliders, Checkboxes, ...) and I use a QAbstractListModel to populate the slide values and checkbox states.

    However, when a data update comes from the Model, the onValueChanged and onCheckedChanged in QML are called, and I need to know if the change has been made by the user or by the Model.

    Is there any way to block these signals when it's being updated by the model ?

    Thanks !

    1 Reply Last reply
    0
    • V Offline
      V Offline
      Vincent007
      wrote on last edited by
      #2

      Do you see where in your C++ code emits valueChanged and checkedChanged?

      1 Reply Last reply
      0
      • G Offline
        G Offline
        guillaumesmo
        wrote on last edited by
        #3

        Yes but the model should always notify changes. The problem is that in QML, using the ListView, the controller which updates the values when the model is updated is "invisible" by the developer.

        Anyways I have found a solution for the Sliders (I haven't tested for the checkboxes yet). I just add this in the onValueChanged :
        @if(pressed)@

        My fear was that, if the model is updated while the user presses the slider, it will bypass the if and override the value. Luckily QML blocks any value change signals while the user presses the slider, so it "magically" works but it's a bit of speculation.

        1 Reply Last reply
        0
        • V Offline
          V Offline
          Vincent007
          wrote on last edited by
          #4

          Did you try "bool QObject::blockSignals(bool block)" ?

          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