Qt C++ 函数指针作为函数的参数

有两种情况,

1:普通函数作为函数的参数

void ppp(int a,int b)
{
    qDebug()<

2:类的成员函数作为函数的参数

void MainWindow4::on_toolButton_clicked()
{
    //haha(3,4,MainWindow4::hhwe);
    haha(3,4,&MainWindow4::hhwe);
}

void MainWindow4::haha(int para1, int para2, void (MainWindow4::*hanshu)(int, int))
{
    (this->*hanshu)(1,2);
}

void MainWindow4::hhwe(int para1,int para2)
{
    qDebug()<

如果是类的成员函数作为函数的参数  指针类型和函数名要加类名      

 

 

参考博客:https://blog.csdn.net/afei__/article/details/81985937

你可能感兴趣的:(c++,qt)