Qt 文档为 Qt::ConnectionType 提供了以下值:
AutoConnection = 0;
DirectConnection = 1;
QueuedConnection = 2;
BlockingQueuedConnection = 4;
UniqueConnection = 0x80;
很明显,这表明您可以建立一个既是BlockingQueuedConnection
又是 的连接UniqueConnection
。但是,仅将这两者与|
运算符结合会导致编译器错误:
connect(foo, SIGNAL(bar()), this, SLOT(bar()),
BlockingQueuedConnection | UniqueConnection));
error: invalid conversion from 'int' to 'Qt::ConnectionType'
所以必须强制转换参数:
connect(foo, SIGNAL(bar()), this, SLOT(bar()),
(Qt::ConnectionType) (BlockingQueuedConnection | UniqueConnection)));
由于某种原因,在这种情况下,铸造感觉不对。这真的是建立独特的阻塞队列连接的合适方法吗?