gy19920615
gy19920615
2017-12-05 09:13

新人,没有写过c++的程序,想问下关于线程函数的定义和使用。

  • 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函数是这样定义的:
DWORD
stdcall 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条回答