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. CheckBox. Slot for when change is done by UI

CheckBox. Slot for when change is done by UI

Scheduled Pinned Locked Moved Solved QML and Qt Quick
7 Posts 3 Posters 1.7k 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.
  • A Offline
    A Offline
    Ankit.Jain
    wrote on last edited by
    #1

    Hi,

    Currently my code uses onCheckedChanged for calling some code when check-box value has changed. This is causing me some problems.

    I want some code to be called only when the change is done by UI (user clicks on the checked box). Is there some slot to do this directly? I have my work arounds, but those will always cause the code to be messy.

    J.HilkJ 1 Reply Last reply
    0
    • A Ankit.Jain

      Hi,

      Currently my code uses onCheckedChanged for calling some code when check-box value has changed. This is causing me some problems.

      I want some code to be called only when the change is done by UI (user clicks on the checked box). Is there some slot to do this directly? I have my work arounds, but those will always cause the code to be messy.

      J.HilkJ Online
      J.HilkJ Online
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @Ankit.Jain what about the clicked signal ?
      https://doc.qt.io/qt-5/qabstractbutton.html#clicked


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

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

        onToggled is what you need:

        This signal is emitted when a checkable button is interactively toggled by the user via touch, mouse, or keyboard.

        J.HilkJ 1 Reply Last reply
        2
        • J.HilkJ J.Hilk

          @Ankit.Jain what about the clicked signal ?
          https://doc.qt.io/qt-5/qabstractbutton.html#clicked

          A Offline
          A Offline
          Ankit.Jain
          wrote on last edited by
          #4

          @J.Hilk I'll try that out. Seems like my vision is starting to narrow down in these things. Thanks for the help

          1 Reply Last reply
          0
          • GrecKoG GrecKo

            onToggled is what you need:

            This signal is emitted when a checkable button is interactively toggled by the user via touch, mouse, or keyboard.

            J.HilkJ Online
            J.HilkJ Online
            J.Hilk
            Moderators
            wrote on last edited by
            #5

            @GrecKo true, but usually you toggle the Checkbox from code vis setChecked, and that also triggers the signal

            This may be the result of a user action, click() slot activation, or because setChecked() is called.
            

            ?


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            GrecKoG 1 Reply Last reply
            1
            • J.HilkJ J.Hilk

              @GrecKo true, but usually you toggle the Checkbox from code vis setChecked, and that also triggers the signal

              This may be the result of a user action, click() slot activation, or because setChecked() is called.
              

              ?

              GrecKoG Offline
              GrecKoG Offline
              GrecKo
              Qt Champions 2018
              wrote on last edited by
              #6

              @J.Hilk You are talking about QWidget QCheckBox, OP is asking about QtQuick.Controls (2?) CheckBox

              J.HilkJ 1 Reply Last reply
              2
              • GrecKoG GrecKo

                @J.Hilk You are talking about QWidget QCheckBox, OP is asking about QtQuick.Controls (2?) CheckBox

                J.HilkJ Online
                J.HilkJ Online
                J.Hilk
                Moderators
                wrote on last edited by
                #7

                @GrecKo
                you are absolutely correct.

                I'm off my game to day! I think I may require more sleep....


                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                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