【发布时间】:2016-03-01 12:22:01
【问题描述】:
我已经定义了一个像这样的强类型枚举:
enum class RequestType{
type1, type2, type3
};
我还有一个函数定义如下:
sendRequest(RequestType request_type){
// actions here
}
我想每 10 秒调用一次 sendRequest 函数,所以在一个简单的情况下,我会使用如下代码:
QTimer * timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(sendRequest()));
timer->start(10000);
由于我需要将一些参数传递给sendRequest 函数,我想我必须使用QSignalMapper,但因为QSignalMapper::setMapping 只能直接用于int 和QString,所以我不知道如何实现这。有没有比较简单的方法呢?
【问题讨论】:
-
请记住,强类型枚举需要注册为元类型。
-
@user3528438 你能举个例子吗