Home > Back-end >  [for] signals in QT slot sometimes not be invoked
[for] signals in QT slot sometimes not be invoked

Time:12-17

Excuse me,, I have A question, is now have two classes, A and B, class A is the GUI layer, class B is A logical processing layer, class B to class A signal, A kind of response and processing, the question now is sometimes sent class B signal but class A does not handle and led to A kind of suspended animation, I really don't know what to do, here is the abridged version of my code:
Dialog: the Dialog (QWidget * parent) :
QDialog (parent),
UI (new UI: : Dialog)
{
The UI - & gt; SetupUi (this);
The init ();
}

Void Dialog: : init ()
{
Qt: : WindowFlags flags=Qt: : Dialog.
Flags |=Qt: : FramelessWindowHint;
SetWindowFlags (flags);
The UI - & gt; AbbFileBtn - & gt; SetEnabled (false);
The UI - & gt; ExportBtn - & gt; SetEnabled (false);
The UI - & gt; ExpInd - & gt; SetEnabled (false);
The UI - & gt; VerifyBtn - & gt; SetEnabled (false);

MasterInterFace: : getInstancePtr () - & gt; The init ();
The connect (MasterInterFace: : getInstancePtr (), SIGNAL (sigInitApiFinish (bool, const QString & amp;) )
, this SLOT (onApiInited (bool, const QString & amp;) ));
The connect (MasterInterFace: : getInstancePtr (), SIGNAL (sigVerify (const QString& , const QVariant & amp;) )
, this SLOT (onVerifyInfo (const QString & amp; , const QVariant & amp;) ), Qt: : QueuedConnection);
}

MasterInterFace: : getInstancePtr () is the singleton pattern logic layer,

Void Dialog: : onVerifyInfo (const QString & amp; FilePath, const QVariant & amp; Var)
{
QDebug () & lt; & lt;" OnVerifyInfo ";

SignatureInfo info=var. Value (a);
SignatureInfo newInfo;
If (m_translateVerifyInfo==NULL)
{
M_translateVerifyInfo=new TranslateVerifyInfo;
}
M_translateVerifyInfo - & gt; TranslateVerifyInfo (info, newInfo);
If (m_fileItemMap. The contains (filePath))
{
FileItemWidget * widget=m_fileItemMap [filePath];////
Widgets - & gt; SetIconVerify (newInfo iconUrl, newInfo verifyRet, newInfo, errorMsg);
Widgets - & gt; SetSignatureInfo (newInfo);
}
}

The FileItemWidget class is a subclass of inheritance QFrame, verifyMsg is an inherited QPushButton control,

Void MasterInterFace: : startVerify (QStringList fileList)
{
M_controlPtr=new MasterControlVerify;
The connect (m_controlPtr, SIGNAL (sigVerifyFinish (const QString& , const QVariant & amp;) ),
This SLOT (onVerify (const QString& The const QVariant & amp; )), Qt: : DirectConnection);
//connect (m_controlPtr, SIGNAL (sigVerifyAllFinish ()), and this, SLOT (onVerifyAllFinished ()), Qt: : DirectConnection);

M_controlPtr - & gt; Start working (fileList, "");
M_controlPtr - & gt; Wait ();
Emit sigVerifyAllFinish ();
The delete m_controlPtr;

}
This MasterInterFace startVerify method of a class will send sigVerifyFinish signal, and then the logic layer through cell function signals are sent to the GUI layer, called onVerifyInfo,

Void MasterInterFace: : onVerify (const QString & amp; FilePath, const QVariant & amp; Var)
{
Emit sigVerify (filePath, var);
QDebug () & lt; & lt;" Emit sigVerify (filePath, var); ";
}

The question now is whether this logic layer signal sent GUI sometimes receive less than, cause feign death, also, the GUI of the connect fill the fifth parameter of Qt: : DirectConnection words will quote error on the picture, the younger brother is really no way out, not only food to death and always be scold, hope everybody who help me in, thanks!

CodePudding user response:

Oh, MasterControlVerify is a thread, inherit the QThread
  • Related