c++qt5signals-slotsqtimerqt-slot

Qt Pushbutton must process the signal after a delay


I am using a push button which records incoming microphone sound signal. Usually, the signal arrives a little late after pressing the record button and my recorded output contains zero until 10 ms(after which i receive an actual output). I am using the following QTimer function to set the delay but there is the ouput is the same,

QTimer->singleShot(0.010, this, SLOT(onStartRecordPushButton))

Are there any other methods to crop the signal for the first 10 ms or start recording only when a non zero signal arrive? Thanks


Solution

  • QTimer::singleShot takes milliseconds as an argument, not seconds. Your call should probably look like this:

    QTimer->singleShot(10, this, SLOT(onStartRecordPushButton))