• 4950阅读
  • 1回复

[提问]run function的问题 [复制链接]

上一主题 下一主题
离线u332744
 
只看楼主 倒序阅读 楼主  发表于: 2011-10-03

void hello(QString name)
{
    system(hq);
    qDebug() << "Hello" << name << "from" << QThread::currentThread();
}

int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    QFuture<void> f1 = run(hello, QString(hq));
    f1.waitForFinished();
}
上面这段代码可以通过,现在我的问题是函数hello(QString name)改下为void myclass::hello(QString myfile)
调用的时候
myclass *myclasssl=new myclass;
QFuture<void> f1 = run(myclasssl->hello, "cc.txt");
编译出错:
错误:no matching function for call to 'run(<unresolved overloaded function type>, QString)'
编译报错
离线wxj120bw

只看该作者 1楼 发表于: 2011-10-06
回 楼主(u332744) 的帖子
参考下qt手册的Using Member Functions说明
http://doc.trolltech.com/main-snapshot/qtconcurrentrun.html#run
PS:先不要把hello函数放到MainWindow类里 自己先声明一个类
快速回复
限100 字节
 
上一个 下一个