首页| 论坛| 消息
主题:vc写的DLL接口如何向QT界面发送进度信息,感谢!
回帖:在vc里面使用postMessage将自定义消息传出,然后再qt主体程序中重写nativeEvent函数,在该函数接收windows自定义消息
bool EmbededWidget::nativeEvent(const QByteArray &eventType, void *message, long *result)
{
if (eventType == "windows_generic_MSG") //windows平台
{
MSG* msg = reinterpret_cast(message); //

if(msg->message == WM_COPYDATA)//消息类型
{
COPYDATASTRUCT *data = reinterpret_cast(msg->lParam);
QTextCodec *gbk = QTextCodec::codecForName("GB18030");
QString recevice = gbk->toUnicode((char *)(data->lpData));//转码

if(recevice.contains("Command="))
{
return true;//消息不再进行传递,不再处理
}

m_wnd = reinterpret_cast(msg->wParam);//高地址的参数

}
}

return QWidget::nativeEvent(eventType, message, result);//交给Qt处理
}
‹上一楼:通过回调的方式会好一些,vc接口里定义好设置回调函数的接口,qt里将回调函数指针设置进去,然后 ..

查看全部回帖(2)
«返回主帖