#define TEST_EVENT QEvent::User + 100
class CVxActuatorMain : public QMainWindow
{
protected:
void customEvent(QEvent *event);
}
CVxActuatorMain::CVxActuatorMain(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
QEvent *event = new QEvent(QEvent::Type(TEST_EVENT));
qApp->postEvent(this, event);
}
void CVxActuatorMain::customEvent(QEvent *event)
{
int type = event->type();
if (type == TEST_EVENT)
{
m_pEdt_Info->append(QObject::tr("Test"));
event->accept();
}
else
{
QMainWindow::customEvent(event);
}
}
http://blog.chinaunix.net/uid-20718335-id-2193953.html
http://www.java2s.com/Code/Cpp/Qt/SubclassQEvent.htm
QT 自定义消息(超级简单的一个例子)
原文:http://www.cnblogs.com/findumars/p/5040451.html