的提示我正在致力於異步多線程服務器,基於this example。現在,我下面的方法:QObject :: connect:沒有這樣的信號運行時間警告 - 無法找到
void UeClient::ueSlotReadyRead()
{
QList<QVariant> incomingData=QList<QVariant>();
QByteArray incomingMessage=this->ueSocket()->readAll();
UePosCommProtocolArch::UeCommand incomingCommand=UePOSCommProtocol::ueDecodeCommand(incomingMessage,
incomingData);
UeTask* ueTask=new UeTask("testDb",
"testUsername",
"testPassword",
"localhost",
"3306",
incomingCommand);
connect(ueTask,
SIGNAL(ueSignalTaskFinished(UePosCommProtocolArch::UeCommand,
QByteArray)),
this,
SLOT(ueSlotFetchData(UePosCommProtocolArch::UeCommand,
QByteArray)),
Qt::QueuedConnection);
QThreadPool::globalInstance()->start(ueTask);
} // ueSlotReadyRead
我獲得以下運行時警告/錯誤QtCreator
:
的QObject ::連接:沒有這樣的信號UeTask :: ueSignalTaskFinished(UePosCommProtocolArch :: UeCommand,QByteArray中)在../../../net/ueclient.cpp:55
這裏是UeTask類的頭文件,從中我們可以看到ueSignalTaskFinished(UePosCommProtocolArch::UeCommand& executedCommand, QByteArray& fetchedData);
聲明:
#ifndef UETASK_H
#define UETASK_H
#include <QObject>
#include <QRunnable>
#include <QSqlDatabase>
#include <QSqlError>
#include <QUuid>
#include <QString>
#include <QSqlQuery>
#include <QSqlRecord>
#include <QVariant>
#include <QJsonDocument>
#include <QJsonValue>
#include <QJsonObject>
#include <QJsonArray>
#include <QByteArray>
#include "../../uePOSCommProtocol/uecommands.h"
#include "database/models/uefieldindexes.h"
#include "database/models/uequeries.h"
/*!
* \brief The UeTask class
*/
class UeTask : public QObject,
public QRunnable
{
Q_OBJECT
private:
/*!
* \brief m_ueDatabaseName
*/
QString m_ueDatabaseName;
/*!
* \brief m_ueUserName
*/
QString m_ueUserName;
/*!
* \brief m_uePassword
*/
QString m_uePassword;
/*!
* \brief m_ueHostName
*/
QString m_ueHostName;
/*!
* \brief m_uePort
*/
QString m_uePort;
/*!
* \brief m_ueCommand
*/
UePosCommProtocolArch::UeCommand m_ueCommand;
/*!
* @brief ueDatabaseName
* @return database name
*/
inline const QString& ueDatabaseName() const
{ return this->m_ueDatabaseName; }
/*!
* @brief ueDatabaseUserName
* @return database user name
*/
inline const QString& ueDatabaseUserName() const
{ return this->m_ueUserName; }
/*!
* @brief ueDatabasePassword
* @return database password
*/
inline const QString& ueDatabasePassword() const
{ return this->m_uePassword; }
/*!
* @brief ueDatabasHost
* @return database host name
*/
inline const QString& ueDatabasHost() const
{ return this->m_ueHostName; }
/*!
* @brief uePort
* @return database host port
*/
inline const QString& ueDatabaseHostPort() const
{ return this->m_uePort; }
/*!
* \brief ueCommand
* \return task command
*/
inline UePosCommProtocolArch::UeCommand& ueCommand()
{ return this->m_ueCommand; }
/*!
* @brief ueSetDatbaseName
* @param name
*/
inline void ueSetDatbaseName(const QString& name)
{ this->m_ueDatabaseName=name; }
/*!
* @brief ueSetDatabaseUserName
* @param userName
*/
inline void ueSetDatabaseUserName(const QString& userName)
{ this->m_ueUserName=userName; }
/*!
* @brief ueSetDatabasePassword
* @param password
*/
inline void ueSetDatabasePassword(const QString& password)
{ this->m_uePassword=password; }
/*!
* @brief ueSetDatabaseHostName
* @param hostName
*/
inline void ueSetDatabaseHostName(const QString& hostName)
{ this->m_ueHostName=hostName; }
/*!
* @brief ueSetDatabaseHostPort
* @param port
*/
inline void ueSetDatabaseHostPort(const QString& port)
{ this->m_uePort=port; }
/*!
* \brief ueSetCommand
* \param command
*/
inline void ueSetCommand(const UePosCommProtocolArch::UeCommand& command)
{ this->m_ueCommand=command; }
public:
/*!
* @brief UeTask
*/
explicit UeTask(const QString& databaseName,
const QString& userName,
const QString& password,
const QString& hostName,
const QString& port,
const UePosCommProtocolArch::UeCommand& command);
protected:
/*!
* @brief run
*/
void run();
signals:
/*!
* \brief ueSignalTaskFinished
* \param executedCommand
* \param fetchedData
*/
void ueSignalTaskFinished(UePosCommProtocolArch::UeCommand& executedCommand,
QByteArray& fetchedData);
/*!
* @brief ueSignalDatabaseConnectionOk
*/
void ueSignalDatabaseConnectionOk();
/*!
* @brief ueSignalDatabaseConnectionError
* @param error
*/
void ueSignalDatabaseConnectionError(const QSqlError& error);
};
#endif // UETASK_H
憑啥我是一個得到這個運行時警告/錯誤和signal
是不連接到slot
?這可能是一些愚蠢的錯誤做,但我一直在用這個bug了幾個小時的奮力...
請注意,它將匹配,如果它是一個const引用 – UmNyobe