Commit 179f6e9a authored by Laurent Montel's avatar Laurent Montel 😁

Improve test apps

parent ffc3973c
......@@ -24,9 +24,31 @@
#include <QPushButton>
#include <QTextEdit>
#include <QVBoxLayout>
#include <QPointer>
#include <WebEngineViewer/WebEngineManageScript>
#include <WebEngineViewer/WebEnginePage>
template<typename Arg, typename R, typename C>
struct InvokeWrapper {
QPointer<R> receiver;
void (C::*memberFunction)(Arg);
void operator()(Arg result)
{
if (receiver) {
(receiver->*memberFunction)(result);
}
}
};
template<typename Arg, typename R, typename C>
InvokeWrapper<Arg, R, C> invoke(R *receiver, void (C::*memberFunction)(Arg))
{
InvokeWrapper<Arg, R, C> wrapper = {receiver, memberFunction};
return wrapper;
}
TestJQuerySupportWebEngine::TestJQuerySupportWebEngine(QWidget *parent)
: QWidget(parent)
{
......@@ -60,12 +82,18 @@ void TestJQuerySupportWebEngine::slotShowConsoleMessage(const QString &message)
qDebug() <<"TestJQuerySupportWebEngine::slotShowConsoleMessage :"<<message;
}
void TestJQuerySupportWebEngine::handleResultScript(const QVariant &var)
{
qDebug() << " void TestJQuerySupportWebEngine::handleResultScript(const QVariant &var)"<<var;
}
void TestJQuerySupportWebEngine::slotExecuteQuery()
{
const QString code = mEditor->toPlainText();
if (!code.isEmpty()) {
#if QT_VERSION >= 0x050700
pageView->page()->runJavaScript(code, WebEngineViewer::WebEngineManageScript::scriptWordId());
pageView->page()->runJavaScript(code, WebEngineViewer::WebEngineManageScript::scriptWordId(),
invoke(this, &TestJQuerySupportWebEngine::handleResultScript));
#else
pageView->page()->runJavaScript(code);
#endif
......
......@@ -38,6 +38,7 @@ private Q_SLOTS:
void slotExecuteQuery();
private:
void handleResultScript(const QVariant &var);
void slotShowConsoleMessage(const QString &message);
WebEngineViewer::WebEngineView *pageView;
QTextEdit *mEditor;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment