PDA

View Full Version : Any way to force a signal?



dbrmik
13th March 2009, 14:35
Hi

I would like to force a set signals (from combo boxes and spinboxes) to call slots in my application even though the indices have not changed. Is this possible?

Best regards

JimDaniel
13th March 2009, 14:52
Yes. Just create your own signals and emit them whenever you want.

dbrmik
13th March 2009, 14:54
Can I do this with QComboBox and QSpinBox?

e.g

emit iterSpinBox->valueChanged(DEFAULT_ITERS);

gives me a compile error "is protected withinn this context"

^NyAw^
13th March 2009, 15:06
Hi,

SLOTs are functions, so call it directly.

JimDaniel
13th March 2009, 15:14
Yes, just like ^NyAw^ says, a slot is just a function so you actually don't need signals. Here is an example:


int combo_index = myComboBox->currentIndex();
mySlot(combo_index);

dbrmik
13th March 2009, 15:14
Thanks Jim,

I thought there might be a way of setting values in my comboxboxes which would force an automatic call to my slots. This happens if the index values change from their defaults but not if they remain the same

JimDaniel
13th March 2009, 15:18
You ought to post your code, but as long as your connections are made before you do whatever you are doing in SetDefaults() then the signals should be properly emitted.

dbrmik
13th March 2009, 15:33
Thanks Jim, ^NyAw^

Yes, the connections are made before setDefaults() is called. I suppose what I was looking for is a way to propogate the settings of my spinboxes to MyClass even if their values have not changed ( I am now called the slots directly)

Thanks for your time