2

I'm new to QT Designer and am building interfaces for Maya. In most tutorials I've seen, setting signals/slots between two objects is pretty straightforward.

I'm trying to setup a slider and spinbox to drive each other. If the slider is updated, the value in the spinbox updates, and vice versa. However, there don't seem to be any updates for all the connections I try.

I want to try and do this purely through QT Designer.

Here's an image of the options I get going from the slider to the spinbox:

enter image description here

john
  • 408
  • 9
  • 30
  • 1
    Have you tried connecting `QSlider::valueChanged` with `QDoubleSpinBox::setValue` and viceversa? – Miki Jul 01 '15 at 17:13
  • Thanks for the reply. It looks like neither widget has a 'setValue' input. I do see the 'valueChanged' though. – john Jul 01 '15 at 17:21
  • 1
    See also this: http://stackoverflow.com/questions/8791621/how-to-connect-a-qslider-to-qdoublespinbox – Miki Jul 01 '15 at 17:21
  • 1
    BTW, both QSlider and QDoubleSpinBox do have setValue – Miki Jul 01 '15 at 17:23
  • Hmm for some reason they don't show in the connection setup box. – john Jul 01 '15 at 17:28
  • 1
    Why are you using a QDoubleSpinBox in the first place, since QSlider uses int? As described in the link I mentioned, you should do your own slot to manage type conversion. But If you use a QSpinBox you don't need this extra step. – Miki Jul 01 '15 at 17:31
  • That's a good point. I like the float instead of int. But that doesn't seem super important when I take another look. Went and used a regular QSpinBox and all is well. Thanks! – john Jul 01 '15 at 17:36

1 Answers1

5

One of my Maya's script use something similar, except that these are Int in the QSpinBox. I use these sliders to set the first and last frame when baking animations.

Here is a screenshot (couldn't manage to move the labels on it, sorry)enter image description here

If you use the signals ans slots in the table below, this should work fine.

_______________________________________________________________________
| Source Widget | Signal            | TO | Slot          | Dest Widget |
|---------------|-------------------|----|---------------|-------------|
| QSlider       | sliderMoved(int)  | TO | setValue(int) | QSpinBox    |
| QSpinBox      | valueChanged(int) | TO | setValue(int) | QSlider     |
DrHaze
  • 1,318
  • 10
  • 22