• «
  • 1
  • 2
  • »
  • Pages: 1/2     Go
主题 : qtopia多线程信号机制出错 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 15570
精华: 0
发帖: 28
金钱: 140 两
威望: 28 点
综合积分: 56 分
注册时间: 2010-03-07
最后登录: 2010-06-28
楼主  发表于: 2010-04-06 00:45

 qtopia多线程信号机制出错

我的一个程序是通过QThread的一个子类Thread发送一个信号display()给主界面进程执行printMessage()函数,
mythread=new Thread();connect(mythread,SIGNAL(display()),this,SLOT(printMessage()));
结果编译不通过,提示如下:
pr9000.cpp: In constructor 'PR9000::PR9000(QWidget*, const char*, uint)':
pr9000.cpp:89: error: no matching function for call to 'PR9000::connect(Thread*&, const char [11], PR9000* const, const char [16])'
/opt/FriendlyARM/Qte/arm-qtopia-2.2.0/qt2/include/qobject.h:110: note: candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*)
/opt/FriendlyARM/Qte/arm-qtopia-2.2.0/qt2/include/qobject.h:209: note:                 bool QObject::connect(const QObject*, const char*, const char*) const
make: *** [pr9000.o] 错误 1
这是什么原因?谢谢
用过的Linux发行版:Arch,Gentoo,Debian,Fedora,RHEL,CentOS,Ubuntu,OpenSUSE,RedFlag,Ylmf,De ..
级别: 骑士
UID: 12662
精华: 0
发帖: 181
金钱: 955 两
威望: 191 点
综合积分: 362 分
注册时间: 2010-01-11
最后登录: 2014-02-14
1楼  发表于: 2010-04-06 08:54
友善之臂提供的Qtopia是不带多线程支持的。
业余Linux爱好者。
级别: 新手上路
UID: 15570
精华: 0
发帖: 28
金钱: 140 两
威望: 28 点
综合积分: 56 分
注册时间: 2010-03-07
最后登录: 2010-06-28
2楼  发表于: 2010-04-06 14:54
是不带 我自己在原来的基础上重新加上多线程选项再编译的。请问问题怎么解决?
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
3楼  发表于: 2010-04-06 15:10
pr9000.cpp:89: error: no matching function for call to 'PR9000::connect(Thread*&, const char [11], PR9000* const, const char [16])'
/opt/FriendlyARM/Qte/arm-qtopia-2.2.0/qt2/include/qobject.h:110: note: candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*)
/opt/FriendlyARM/Qte/arm-qtopia-2.2.0/qt2/include/qobject.h:209: note:                 bool QObject::connect(const QObject*, const char*, const char*) const

这是C++的语法问题,PR9000这个类里(是什么类?)里找不到connect这个method。
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 15570
精华: 0
发帖: 28
金钱: 140 两
威望: 28 点
综合积分: 56 分
注册时间: 2010-03-07
最后登录: 2010-06-28
4楼  发表于: 2010-04-06 15:23
PR9000是一个继承Qwidget的窗口类,提示好像说找到connect()函数了,但是不匹配 ,我的mythread是继承Thread的 这两个都是QOBJECT的子类,我最后强制转换了一下(QOBJECT*)但是编译通过 运行时段错误 ,这该怎么解决?
级别: 新手上路
UID: 15570
精华: 0
发帖: 28
金钱: 140 两
威望: 28 点
综合积分: 56 分
注册时间: 2010-03-07
最后登录: 2010-06-28
5楼  发表于: 2010-04-06 15:27
我就是想用信号与曹的链接connect()函数 。找到了又说参数不匹配 是不是我定义的那个线程类的问题?
级别: 新手上路
UID: 15570
精华: 0
发帖: 28
金钱: 140 两
威望: 28 点
综合积分: 56 分
注册时间: 2010-03-07
最后登录: 2010-06-28
6楼  发表于: 2010-04-06 15:42
Re: QProcess in a QThread
afaik QThreads are not QObjects in Qt3, so you can't emit signals and activate slots. I think you have to derive from both QThread and QObject if you need this features, but be careful.

in Qt4, instead, QThreads are Qobjects (so they have signals and slots) and they have their own event loop.
可能因为这个原因吧?qt版本太低 qthread还不是qobject的子类?是不是我要用到这个功能的话,继承两次,一次qobject 类,一次 qthread类?
级别: 新手上路
UID: 15570
精华: 0
发帖: 28
金钱: 140 两
威望: 28 点
综合积分: 56 分
注册时间: 2010-03-07
最后登录: 2010-06-28
7楼  发表于: 2010-04-06 17:09
QThread::postEvent(receiver, e); 用这个机制可以代替信号与曹的机制吧?
级别: 新手上路
UID: 22698
精华: 0
发帖: 7
金钱: 35 两
威望: 7 点
综合积分: 14 分
注册时间: 2010-06-05
最后登录: 2017-09-13
8楼  发表于: 2010-06-18 15:28
请问你是怎么编译是的qtopia 自带多线程
级别: 新手上路
UID: 24720
精华: 0
发帖: 2
金钱: 10 两
威望: 2 点
综合积分: 4 分
注册时间: 2010-07-13
最后登录: 2010-09-11
9楼  发表于: 2010-07-20 15:40
楼主怎么编译自带多线程支持的,望给予解答
  • «
  • 1
  • 2
  • »
  • Pages: 1/2     Go