add mouse area
This commit is contained in:
parent
e9de03cbed
commit
0784fa844c
@ -1,9 +1,11 @@
|
||||
#include <QDebug>
|
||||
#include <QQmlContext>
|
||||
#include <QQuickView>
|
||||
|
||||
#include "DoricDemoBridge.h"
|
||||
#include "DoricPanel.h"
|
||||
#include "utils/DoricUtils.h"
|
||||
#include "utils/DoricMouseAreaBridge.h"
|
||||
|
||||
DoricDemoBridge::DoricDemoBridge(QObject *parent) : QObject(parent) {}
|
||||
|
||||
@ -44,4 +46,8 @@ void DoricDemoBridge::navigate(QVariant route) {
|
||||
}
|
||||
|
||||
view->show();
|
||||
|
||||
auto context = view->engine()->rootContext();
|
||||
DoricMouseAreaBridge *mouseAreaBridge = new DoricMouseAreaBridge();
|
||||
context->setContextProperty("mouseAreaBridge", mouseAreaBridge);
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ SOURCES += \
|
||||
shader/DoricViewNode.cpp \
|
||||
utils/DoricConstant.cpp \
|
||||
utils/DoricContextHolder.cpp \
|
||||
utils/DoricMouseAreaBridge.cpp \
|
||||
widget/flex/FlexLayout.cpp \
|
||||
widget/flex/FlexLayoutConfig.cpp \
|
||||
widget/flex/FlexLayoutService.cpp \
|
||||
@ -104,6 +105,7 @@ HEADERS += \
|
||||
utils/DoricConstant.h \
|
||||
utils/DoricContextHolder.h \
|
||||
utils/DoricCountDownLatch.h \
|
||||
utils/DoricMouseAreaBridge.h \
|
||||
utils/DoricObjectFactory.h \
|
||||
utils/DoricThreadMode.h \
|
||||
utils/DoricUtils.h \
|
||||
|
@ -48,4 +48,11 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
mouseAreaBridge.onClick("index")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
7
doric-Qt/doric/utils/DoricMouseAreaBridge.cpp
Normal file
7
doric-Qt/doric/utils/DoricMouseAreaBridge.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include "DoricMouseAreaBridge.h"
|
||||
|
||||
DoricMouseAreaBridge::DoricMouseAreaBridge(QObject *parent) : QObject(parent) {}
|
||||
|
||||
void DoricMouseAreaBridge::onClick(QVariant functionId) {
|
||||
qCritical() << functionId;
|
||||
}
|
17
doric-Qt/doric/utils/DoricMouseAreaBridge.h
Normal file
17
doric-Qt/doric/utils/DoricMouseAreaBridge.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef DORICMOUSEAREABRIDGE_H
|
||||
#define DORICMOUSEAREABRIDGE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
|
||||
class DoricMouseAreaBridge : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DoricMouseAreaBridge(QObject *parent = nullptr);
|
||||
|
||||
Q_INVOKABLE
|
||||
void onClick(QVariant functionId);
|
||||
signals:
|
||||
};
|
||||
|
||||
#endif // DORICMOUSEAREABRIDGE_H
|
Reference in New Issue
Block a user