• 5477阅读
  • 0回复

多线程临界变量的类型,STL vector可以直接用吗? [复制链接]

上一主题 下一主题
离线fogsnow
 
只看楼主 正序阅读 楼主  发表于: 2009-01-06
— 本帖被 XChinux 从 General Qt Programming 移动到本区(2011-01-02) —
就是不同线程之间,connect 的signal 和 slot中函数的变量
是叫临界变量吧?

Qt Mandelbrot Example:

The interesting part of the constructor is the qRegisterMetaType() and QObject::connect() calls. Let's start with the connect() call.
Although it looks like a standard signal-slot connection between two QObjects, because the signal is emitted in a different thread than the receiver lives in, the connection is effectively a queued connection. These connections are asynchronous (i.e., non-blocking), meaning that the slot will be called at some point after the emit statement. What's more, the slot will be invoked in the thread in which the receiver lives. Here, the signal is emitted in the worker thread, and the slot is executed in the GUI thread when control returns to the event loop.
With queued connections, Qt must store a copy of the arguments that were passed to the signal so that it can pass them to the slot later on. Qt knows how to take of copy of many C++ and Qt types, but QImage isn't one of them. We must therefore call the template function qRegisterMetaType() before we can use QImage as parameter in queued connections.

STL的vector可以直接用吗?
我试了试,好像不行啊
但是注册的话,不知道vector<vector<double>>这样的该如何注册啊

大家有遇到过这种情况吗
快速回复
限100 字节
 
上一个 下一个