今天进行最后编译了,遇到了不少问题,现已解决,将问题和解决方法都记录下来;

Q:
出现`staticMetaObject' is not a member of `QThread'的错误
A:
我自己的有关这个错误的总结:
在没有使用信号与槽的情况下,尽量不要使用Q_OBJECT宏,否则,很容易出现`staticMetaObject' is not a member of `QThread'的错误;

其他说法:
QThread doesn't inherit QObject, so you can't use signals and slot with it.
Remember that in Qt3 you can't send signals across different threads --- you must use custom events for this.
Why is it not possible to use slots and signals over distinct threads as you told me ?

From Qt docs (http://doc.trolltech.com/3.3/threads.html#8):
The Signals and Slots mechanism can be used in separate threads, as long as the rules for QObject based classes are followed. The Signals and Slots mechanism is synchronous: when a signal is emitted, all slots are called immediately. The slots are executed in the thread context that emitted the signal.
Warning: Slots that generate window system events or use window system functions must not be connected to a signal that is emitted from a thread that is not the GUI thread. See the Qt Library Mutex section above for more details.
This says you can use them under certain conditions, but this:
None of the QObject based classes included in the Qt library are reentrant. [...] QObject and all of its subclasses are not thread-safe.
says that you probably won't be able to meet those conditions.

If you want to use signals & slots across threads, switch to Qt4 and use queued connections.

from:http://www.qtcentre.org/forum/archive/index.php/t-984.html

About writing Makefile

编写makefile时,要注意库的连接顺序,这样是可以编译通过的:
g++ -o tv q_main.o gui/gui.a interface/interface.a hdware/hdware.a -L/usr/lib/qt-3.3/lib -lqt-mt -lavformat -lavcodec -lavutil
但是这样子就不行了:
g++ -o tv gui/gui.a interface/interface.a hdware/hdware.a -L/usr/lib/qt-3.3/lib q_main.o -lqt-mt -lavformat -lavcodec -lavutil
也就是,所有的静态链接库和动态链接库一定要放在编译文件的后面进行编译连接,这样才能保证不出问题,否则,出的问题会非常诡异;
例如这个错误出的问题就是:undefined reference to `CMainWindow::CMainWindow(QWidget*, char const*)'
让你摸不着头脑,呵呵。。。

你可能感兴趣的:(thread,qt,library,makefile,Signal,events)