QML bindings for QtGrpc.
QML bindings for QtGrpc.
QtProtobuf allows to use generated classes in QML. All types are registred automatically when QtProtobuf::qRegisterProtobufTypes() called. To make generated classes and QtProtobuf types visible in QML you need to import QtProtobuf QML plugin and your protobuf package
sample.proto:
syntax = "proto3";
package qtprotobuf.sample;
message SampleMessage {
}
transparent< int32_t > int32
int32 signed 32-bit integer
Definition: qtprotobuftypes.h:104
QML:
import QtProtobuf 0.4
import qtprotobuf.sample 1.0
Item {
...
SampleMessage {
sampleField: 10
}
...
}
Static QtProtobuf with QML
For statically built QtProtobuf it's neccssary to link protobufquickplugin
target manually: CMakeLists.txt:
...
if(QT_PROTOBUF_STATIC)
target_link_libraries(${TARGET} PRIVATE QtProtobuf::protobufquickplugin)
endif()
...
To make QtProtobuf QML plugin visible in QML, call Q_PROTOBUF_IMPORT_QUICK_PLUGIN() macro:
int main(int argc, char *argv[]) {
...
...
}
#define Q_PROTOBUF_IMPORT_QUICK_PLUGIN()
Imports statically linked QtProtobufQuickPlugin.
Definition: qtprotobufglobal.h:88
void qRegisterProtobufTypes()
qRegisterProtobufTypes This method should be called in all applications that supposed to use QtProtob...
Definition: qtprotobuf.cpp:62