×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    58

    QSpinBox::setValue without emitting valueChanged() signal?

    Hello,

    Calling setValue on a QSpinBox emits a valueChanged signal. I would like to respond to the valueChanged signal when the user makes a change, but not when the program itself makes a setValue call. Is there a way of setting the value of a QSpinBox or QDoubleSpinBox without emitting a valueChanged signal? (I suppose I could set a flag before the setValue call and in my slot function check the flag, but I'm hoping there's a simpler and cleaner way. I haven't found a function to do it. Another possibility is to call lineEdit()->setText(""), but that seems to circumvent the numerical format processing of the spin box.)

    Thanks,

    Phil

  2. #2
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: QSpinBox::setValue without emitting valueChanged() signal?

    Well, you could disconnect the signal.

    Or store the new value you're about to set somewhere. When valueChanged is signalled, check to see if the new value is equal to that value, and if so ignore the signal (after clearing the stored value).

  3. #3
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: QSpinBox::setValue without emitting valueChanged() signal?


  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    58

    Re: QSpinBox::setValue without emitting valueChanged() signal?

    Great! That answers the question. Thanks to you both.

  5. #5
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: QSpinBox::setValue without emitting valueChanged() signal?

    Good catch, d!! I haven't reviewed QObject recently enough, apparently.

Similar Threads

  1. Replies: 6
    Last Post: 2010-03-20, 14:06
  2. Which signal should be used for an interface?
    By siuping in forum Symbian
    Replies: 1
    Last Post: 2006-09-13, 09:22
  3. determining whether there is a signal
    By taperoni in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2006-08-24, 10:38

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×