簡體   English   中英

QTimer::singleShot 沒有調用我的超時槽

[英]QTimer::singleShot not calling my timeout slot

我在按鈕按下回調中調用單次觸發,但我的超時槽從未被調用,在調試器中我的代碼到達我調用單次觸發 function 的位置,但它永遠不會在我的超時 function 中到達斷點。

在.h中:

private slots:

void on_snoozeTimeout(Data d);

在.cpp中:

void MyClass::on_snoozeBtn_clicked()
{                   
   QTimer::singleShot(snoozeTimeoutValue*1000,this,SLOT(on_snoozeTimeout(selectedData)));
}
void MyClass::on_snoozeTimeout(Data d)
{
//not hitting this breakpoint
}

SLOT宏不能以您嘗試使用它的方式接受 function 參數。 使用 lambda 代替:

QTimer::singleShot(snoozeTimeoutValue*1000, [this, selectedData](){
    on_snoozeTimeout(selectedData);
});

使用qt4.8,重構代碼不使用參數

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM