gy19920615
2017-12-05 09:13新人,没有写过c++的程序,想问下关于线程函数的定义和使用。
用QT做上位机界面,在QT头文件定义类
class MainWindow : public QMainWindow
{ QOBJECT
piblic :
explicit MainWindow(QWidget parent =0);
~MainWindow();
int initPort(); //串口初始化
DWORD stdcall ThreadPDoTest( DWORD EventID, LPVOID pBuf, DWORD BufLen, LPVOID UserData);
.....
...
}
串口初始化函数中有这么一句,设置事件回调函数
ZCOMA_SetEventCallback(hdChannel, ThreadPDoTest, NULL,0 ,0)
然后ThreadPDoTest函数是这样定义的:
DWORDstdcall MainWindow threadDotest(DWORD EventID, LPVOID pBuf, DWORD Buflen, LPVOID UserData)。主要功能是完成数据的计算并且显示到QT的控件上,编译报错
cannot convert 'MainWindow::ThreadPDoTest ' from type 'DWORD (MainWindow::)(DWORD ,LPVOID ,DWORD ,LPVOID){aka long unsinged int (MainWindow::)(long unsigned int ,void ,long unsigned int ,void*)}' to type 'LPZCOMA_EVENTCB {aka long unsigned int (__attribute((__stdcall__)) (long unsigned int , void,long unsigned int, void*) }'
- 点赞
- 回答
- 收藏
- 复制链接分享
4条回答
为你推荐
- 请问c++怎么让函数等待特定函数运行后再调用呢?
- 事件
- c++
- 线程
- 10个回答
- c++ 的模板问题,如何定义构造函数
- c++
- 4个回答
- 请问C++11的多线程如何在类的成员函数里调用另一个成员函数在新线程里执行
- qt
- c++
- 多线程
- 2个回答
- C++ 关于复制构造函数
- 复制构造函数
- 构造函数
- 继承
- c++
- 3个回答
- C++多线程中使用函数的问题
- 调试
- c++
- 多线程
- 5个回答