f9e224204d
signal 和 slot 原理;以及 moc 原理(做了什么内容)
30 lines
520 B
C++
30 lines
520 B
C++
#include "object.h"
|
|
|
|
//db_object: 是由 moc 编译器 将 object.cpp 展开的内容(此处手写表示)
|
|
|
|
const char sig_names[] = "sig1()";
|
|
const char slot_names[] = "slot1()";
|
|
MetaObject Object::meta = {sig_names, slot_names};
|
|
|
|
void Object::sig1()
|
|
{
|
|
MetaObject::active(this, 0);
|
|
}
|
|
|
|
void Object::slot1()
|
|
{
|
|
cout << "-----------> this is slot1()";
|
|
}
|
|
|
|
// 槽的索引==> 槽函数
|
|
void Object::metacall(int idx)
|
|
{
|
|
switch (idx) {
|
|
case 0:
|
|
slot1();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|