Home > Mobile >  Qt completely look not to understand a piece of code
Qt completely look not to understand a piece of code

Time:03-31

See a Qt code, as follows:

 
Void
CustomCefView: : onQCefUrlRequest (const QString& Url)
{
QString title (" QCef Url Request ");
QString text=QString (" Current Thread: QT_UI \ r \ n "
"Url: % 1")
. Arg (url);

QMetaObject: : invokeMethod (this, [=] () {
QMessageBox: : information (this - & gt; The window (), the title and text);
}, Qt: : QueuedConnection);


}



QMetaObject: : invokeMethod (this, [=] () {
QMessageBox: : information (this - & gt; The window (), the title and text);
}, Qt: : QueuedConnection); How do you understand the code? QMetaObject: : invokeMethod (this, [=] (a) what is the usage?

CodePudding user response:

This usage is the lambda throw into the main thread of the event queue, rather than directly in this method to perform
So even if now this method is called is not in the main thread, but the lambda is performed must be in the main thread
  •  Tags:  
  • Qt
  • Related