【发布时间】:2014-02-13 05:31:34
【问题描述】:
我在我的应用程序中使用的 iris xmpp 库中有信号。在 Mac OS X 和 Linux 上一切正常,但 Windows 会产生一大堆未找到信号的警告。
warning: QObject::connect: signal not found in XMPP::AdvancedConnector
warning: QObject::connect: signal not found in XMPP::AdvancedConnector
warning: QObject::connect: signal not found in XMPP::AdvancedConnector
warning: QObject::connect: signal not found in XMPP::AdvancedConnector
warning: QObject::connect: signal not found in XMPP::QCATLSHandler
warning: QObject::connect: signal not found in XMPP::ClientStream
warning: QObject::connect: signal not found in XMPP::ClientStream
warning: QObject::connect: signal not found in XMPP::ClientStream
warning: QObject::connect: signal not found in XMPP::ClientStream
warning: QObject::connect: signal not found in XMPP::ClientStream
warning: QObject::connect: signal not found in XMPP::ClientStream
warning: QObject::connect: signal not found in XMPP::ClientStream
warning: QObject::connect: signal not found in XMPP::ClientStream
warning: QObject::connect: signal not found in XMPP::ClientStream
warning: QObject::connect: signal not found in XMPP::ClientStream
warning: QObject::connect: signal not found in XMPP::Client
warning: QObject::connect: signal not found in XMPP::Client
warning: QObject::connect: signal not found in XMPP::Client
warning: QObject::connect: signal not found in XMPP::Client
我尝试使用的一个信号示例是
signals:
void srvLookup(const QString &server);
我的连接调用
conn = std::make_shared<XMPP::AdvancedConnector>();
QObject::connect(conn.get(), &XMPP::AdvancedConnector::srvLookup, this, &XmppConnection::connServerLookupHandler);
QObject::connect(conn.get(), &XMPP::AdvancedConnector::srvResult, this, &XmppConnection::connServerResultHandler);
QObject::connect(conn.get(), &XMPP::AdvancedConnector::httpSyncStarted, this, &XmppConnection::connHttpSyncStartedHandler);
QObject::connect(conn.get(), &XMPP::AdvancedConnector::httpSyncFinished, this, &XmppConnection::connHttpSyncFinishedHandler);
if(QCA::isSupported("tls")) {
tls = make_unique<QCA::TLS>();
tlsHandler = make_unique<XMPP::QCATLSHandler>(tls.get());
// dont check the certificate because we self sign
tlsHandler->setXMPPCertCheck(false);
QObject::connect(tlsHandler.get(), &XMPP::QCATLSHandler::tlsHandshaken, this, &XmppConnection::tlsHandshakenHandler);
} else {
tls = 0;
tlsHandler = 0;
}
stream = std::make_shared<XMPP::ClientStream>(conn.get(), tlsHandler.get());
QObject::connect(stream.get(), &XMPP::ClientStream::connected, this, &XmppConnection::streamConnectedHandler);
QObject::connect(stream.get(), &XMPP::ClientStream::securityLayerActivated, this, &XmppConnection::streamSecurityLayerActivatedHanlder);
QObject::connect(stream.get(), &XMPP::ClientStream::needAuthParams, this, &XmppConnection::streamNeedAuthParamsHandler);
QObject::connect(stream.get(), &XMPP::ClientStream::authenticated, this, &XmppConnection::streamAuthenticatedHandler);
QObject::connect(stream.get(), &XMPP::ClientStream::connectionClosed, this, &XmppConnection::streamConnectionClosedHandler);
QObject::connect(stream.get(), &XMPP::ClientStream::delayedCloseFinished, this, &XmppConnection::streamDelayedCloseFinished);
QObject::connect(stream.get(), &XMPP::ClientStream::readyRead, this, &XmppConnection::streamReadyRead);
QObject::connect(stream.get(), &XMPP::ClientStream::stanzaWritten, this, &XmppConnection::streamStanzaWritten);
QObject::connect(stream.get(), &XMPP::ClientStream::warning, this, &XmppConnection::streamWarningHandler);
QObject::connect(stream.get(), &XMPP::ClientStream::error, this, &XmppConnection::streamErrorHandler);
xmpp = std::make_shared<XMPP::Client>();
QObject::connect(xmpp.get(), &XMPP::Client::rosterRequestFinished, this, &XmppConnection::onRosterRequestFinished);
QObject::connect(xmpp.get(), &XMPP::Client::rosterItemAdded, this, &XmppConnection::onRosterItemAdded);
QObject::connect(xmpp.get(), &XMPP::Client::rosterItemUpdated, this, &XmppConnection::onRosterItemUpdated);
QObject::connect(xmpp.get(), &XMPP::Client::rosterItemRemoved, this, &XmppConnection::onRosterItemRemoved);
这是我的实际插槽之一
void XmppConnection::connServerLookupHandler(const QString &server)
{
qDebug() << "Looking up Server: " << server;
return;
}
我不明白为什么 mac 和 linux 可以工作,而 windows 不能。我已经考虑过编译器选项,但我使用 cmake,所以除非我的 linux gcc 和我的 mingw gcc 之间存在巨大差异,否则我不明白这有什么关系。我正在使用 C++11 功能,这在我的连接调用中很明显。但是我适当地编译和链接,所以我假设 C++11 的功能像我预期的那样工作。有人有想法吗?
编辑:
我正在使用 Qt5.2.0 MinGW OpenGL。我正在使用Qt5.2.0附带的MinGW,即MinGW48 32。我正在编译库iris,与我的应用程序同时使用cmake to automoc,将其设置为链接依赖项,并包含正确的标题。
EDIT2:包括了我所有的连接调用。
【问题讨论】:
-
你在 Windows 上使用的 Qt 和 GCC 匹配吗? XMMP 库是否也与您使用的 GCC 匹配?
-
编辑了有关我如何构建的信息。
-
采用函数指针的连接不需要 C++11。警告提到您的连接语句中未列出的类,因此必须有其他连接失败。也许来自 XMPP 本身?
-
@Frank Osterfeld 这只是我的连接语句之一,它们看起来都一样。我想我会和他们一起编辑更多。
标签: c++ windows qt c++11 mingw