简体   繁体   中英

Return value from Q_INVOKABLE function In QtWebEngine

Greeting

Is there anyway to get return value of Q_INVOKABLE function in Qt webEngine without passing callback function ? ( Qt Documentation ) . Like what we were doing in Qt WebKit .

More Information About Question

In QT4 and Qt WebKit i could get my function result as QVariant and cast it to JSON or any other type.

For example in my c++ project i have the following function that return application's version as QVariant .

Q_INVOKABLE QVariant getAppVersion();

I could simply use the following line in my HTML file and get result.

var applicationVersion = ApplicationObject.getAppVersion();

Now With Qt 5.5 and Qt WebEngine i have to use following form in order to get the result.

ApplicationObject.getAppVersion(myResultFunction);

function myResultFunction(result){
     console.log(result);
}

I'm using QT 5.5 And Visual Studio 2013 .

Thanks in Advance

Well, There is not other way. You have to pass callback function.

But with using promise in javascript , It gets alot better!

Good luck

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM