PDA

View Full Version : Very strange thing



Sheng
21st October 2008, 20:03
In a slots function responded to click of a button,
I changed the a value:
value+=50;
then emit a signal
emit isChanged();
in another slots function, I updated changed value in GUI like
updateGUI(value);

the project was built successfully,
however, when I click the button, it shows +=100, not 50,
anyone has any clue? thanks.

maverick_pol
21st October 2008, 20:07
Ideas:
1. Your GUI automatically connect the button with the slot, if your slot is named the way Qt uses it. Check the Docs for automatic connections.
2. Be somehow autorepeat takes place like in QAction when you enable auto repeat.
3. Check when the slot and signal are used and which happen after which; one signal two slots invoked, signal,slot, signal, slot etc. It may give you a clue what is happening.
4. Provide an example and someone will surely help you.

Kacper

Sheng
21st October 2008, 20:18
Ideas:
1. Your GUI automatically connect the button with the slot, if your slot is named the way Qt uses it. Check the Docs for automatic connections.
2. Be somehow autorepeat takes place like in QAction when you enable auto repeat.
3. Check when the slot and signal are used and which happen after which; one signal two slots invoked, signal,slot, signal, slot etc. It may give you a clue what is happening.
4. Provide an example and someone will surely help you.

Kacper

Thanks, I found the problem, I just write same connect function twice.
It is interesting though, see, if I have two same connect function, how QT interpret it?
It seems Qt generated two signals and slots responded twice, but I added mutex to lock the object and disable the button, it still +=100. any ideas?

maverick_pol
21st October 2008, 20:20
It seems you have doubled a connection or have a repeat signal.
Still can't tell more without seeing the code.

Kacper

wysota
21st October 2008, 22:44
A signal is "generated" once, but gets "propagated" to all slots in sequence. If you have the same slot connected twice, it will be triggered twice.