int qmlRegisterType(const char * uri, int versionMajor, int versionMinor, const char * qmlName)
实例:
qmlRegisterType<GLVideoItemStub>("org.freedesktop.gstreamer.GLVideoItem", 1, 0, "GstGLVideoItem");
目的:将C++实现的类在QML中调用的,连接C++和QML的一个工具 This template function registers the C++ type in the QML system with the name qmlName, in the library imported from uri having the version number composed from versionMajor and versionMinor. Returns the QML type id.
const char * uri
QML中import后的内容,在本例中是org.freedesktop.gstreamer.GLVideoItem , 所以qml中:
import QtQuick 2.11
import QtQuick.Controls 2.4
import org.freedesktop.gstreamer.GLVideoItem 1.0
GstGLVideoItem {
id: videoBackground
property var receiver
}
int versionMajor
主版本 major version
int versionMinor
次版本 minor version
const char * qmlName
第四个指的是QML中类的名字,
GstGLVideoItem{
...
}
第四个QML的类名首字母一定要大写
|