mainwindow.h
#include "stdio.h"
class MainWindow : public QMainWindow
{
Q_OBJECT
......
public:
signals:
void testsignal(int i,float j);
public
slots:
void testslot(int i,float j){printf("slot\n");};
};
////////////////////////////
mainwindow.cpp
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(this,SIGNAL(testsignal(int,float)),SLOT(testslot(int,float)));
emit testsignal(0,1.0);
}
emit testsignal(0,1.0);会进入
///////////////////////////////////////
moc_mainwindow.cpp
void MainWindow::testsignal(int _t1, float _t2)
{
void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)), const_cast<void*>(reinterpret_cast<const void*>(&_t2)) };
QMetaObject::activate(this, &staticMetaObject, 0, _a);
}
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QMainWindow::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
case 0: testsignal((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< float(*)>(_a[2]))); break;
case 1: testslot((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< float(*)>(_a[2]))); break;
default: ;
}
_id -= 2;
}
return _id;
}