Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QDoubleSpinBox, why isn't valueChanged signal fired when content is empty?

QDoubleSpinBox, why isn't valueChanged signal fired when content is empty?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 786 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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by SPlatten
    #1

    I have a QDoubleSpinBox on a form, I have a button on the form and I am trying to enable or disable the button based on the content of the spin box.

    I use the slot valueChanged and this works fine whilst there is content in the spin box, in the slot I enable the button if the spin box has content, but the signal is emitted when the spin box is empty, why?

    It is still a change in state, very frustrating and I cannot see any other way of doing this.

    What I mean is, lets say I add some content to the spin box, then delete the content, for every key stroke the valueChanged signal is emitted, but when the last byte is removed from the control, no signal is emitted.

    Kind Regards,
    Sy

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      An empty string is no valid value so no value changed signal.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      3
      • fcarneyF Offline
        fcarneyF Offline
        fcarney
        wrote on last edited by
        #3

        @SPlatten said in QDoubleSpinBox, why isn't valueChanged signal fired when content is empty?:

        I use the slot valueChanged

        Is the string version of the signal any different than the double version?

        void 	valueChanged(double d)
        void 	valueChanged(const QString &text)
        

        C++ is a perfectly valid school of magic.

        1 Reply Last reply
        1
        • SPlattenS Offline
          SPlattenS Offline
          SPlatten
          wrote on last edited by
          #4

          There is a difference in the behaviour and the way these signals are emitted, I've found that valueChanged(double) does not emit when the content of the control is empty, but valueChanged(const String &text) does.

          Kind Regards,
          Sy

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            ... which is exactly what I mentioned - an empty string is no valid number.

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            3

            • Login

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