StupidBeauty
Read times:283Posted at:Sun May 8 00:19:07 2011
- no title specified

Wt3.1.9文档翻译:Wt::WSignalMapper< T, A1 >类模板参考,Wt::WSignalMapper< T, A1 > Class Template Reference

template<typename T, typename A1 = NoClass>
class Wt::WSignalMapper< T, A1 >

一个辅助类,用来将多个发送者连接到同一个槽。

在以下情况下,这个类很有用:你想要在单个槽里对很多对象或者部件的信号进行响应,但是需要用某些属性来识别特定的发送者

使用示例:

 void Test::createWidgets()

 {

Wt::WSignalMapper<WText *> *MyMap = new Wt::WSignalMapper<Wt::WText *>(this);

   //将mapped()连接到我们的目标槽

   MyMap->mapped().connect(this, &Test::onClick);

   //将每个源信号连接并且映射到映射器

   MyMap->mapConnect(text1->clicked(), text1);

   MyMap->mapConnect(text2->clicked(), text2);

   MyMap->mapConnect(text3->clicked(), text3);

 }

 void Test::onClick(WText* source)

 {

   // source就是信号的发送者

   // ...

 }

类型T 可以是任何拥有适当的复制方法和一个默认构造函数的类型。映射器可以将一个额外的参数(类型 A1 )从原信号传递到 mapped() 信号。在那种情况下 ,你必须将原信号连接到 map1() ,或者使用 mapConnect1()

Your opinions
Your name:Email:Website url:Opinion content:
- no title specified

HxLauncher: Launch Android applications by voice commands

 
Recent comments
2017年4月~2019年4月垃圾短信排行榜Posted at:Thu Sep 26 04:51:48 2024
Qt5.7文档翻译:QWebEngineCookieStore类,QWebEngineCookieStore ClassPosted at:Fri Aug 11 06:50:35 2023盲盒kill -9 18289 Grebe.20230517.211749.552.mp4