[Qt-interest] signals and slots, combination and execution order

Girish Ramakrishnan girish at forwardbias.in
Wed Jun 10 07:43:54 CEST 2009


hilbert at beuth-hochschule.de wrote:
> hello,
> 
> i have a QLineEdit with the signal 'editingFinished()' connected to 'slot1
> ()'. there is also a QPushButton with the signal 'clicked()' connected to 
> another 'slot2()'. as to be expected: when the text in the QLineEdit is 
> changed and the QPushButton ist clicked both slots are executed. in my 
> case 'slot1()' is always called first. in some cases i need to execute a 
> QMessegeBox::question(...) in 'slot1()' and wait for the return value of the 
> question box. if this is the case, the QPushButton hangs (at least visually) 
> in the 'pressed' state and 'slot2()' is never called. the 'clicked()'-signal 
> of the QPushButton seems to be lost even when the connection is set to 
> Qt::QueuedConnection. is there an easy or at least a reasonable way to solve 
> this problem without tricky event-handling?
> 

The answer depends on the behavior you want: Should the button not
appear pressed? (If so, would the user not mistake that the popup was as
a result of the button press and not editing finished?) And you want the
button clicked slot to be executed after the modal dialog is dismissed?
Sounds very confusing to me :-)

Girish



More information about the Qt-interest-old mailing list