Problem Description:
If you run this code "connect (sendBtn, SIGNAL (clicked ()), this, SLOT (sendMsg ()));" n times , so that when the button click sendBtn , sendMsg ( ) is executed n times ...
I do not know the signals and slots mechanism for internal implementation mechanism , but from the point of view of this phenomenon , when sendBtn is clicked , the system will traverse the clicked () signal is maintained with the slot ( signal ) contact form , to executing the corresponding slots (signal ) function. Because of the above connect the function executes n times , and the slot function are sendMsg (), so we performed n times .
trouble connect function under expert advice and disconnect functions are what had been done ?
------ Solution ---------------------------------------- ----
your thread will not be run N times, leading to a press button, the actual trigger N times clicked ()
------ Solution ------ --------------------------------------
you think Qt would like to achieve it , or say you think that the reality of the library would anyone use it ?
------ Solution ------------------------------------ --------
that not all one-time thing , signal is clicked, slot is sendMsg. How are there so many times performed
See signal - slot explain enough . This stuff is not the same for each person to understand .
------ eference --------------------------------------- < br>
will indeed perform a click function n times slots , you can try.
没有评论:
发表评论