GitHub:下載地址:https://github.com/google/PRotobuf 自定義.proto文件然后通過工具生成.h/.cc文件
生成.h/.cc文件
pro文件中
CONFIG(debug,debug|release){#debug macx:{ # macOS only LIBS += -L"$$PWD/third_party_lib/lib/macOS" / -lprotobufd/ -lgmappingd } linux-g++:{ # linux only LIBS += -L"$$PWD/third_party_lib/lib/linux_x64" / -lprotobufd/ -lgmappingd } win32:{ # windows only LIBS += -lWs2_32 LIBS += -lnetapi32 LIBS += -lmpr LIBS += -L"$$PWD/third_party_lib/lib/mingw_x86" / -lprotobufd/ -lgmappingd / -lopencv_core2410d.dll/ -lopencv_highgui2410d.dll/ -lopencv_imgproc2410d.dll }} CONFIG(release,debug|release){#release macx:{ # macOS only LIBS += -L"$$PWD/third_party_lib/lib/macOS" / -lprotobuf/ -lgmapping } linux-g++:{ # linux only LIBS += -L"$$PWD/third_party_lib/lib/linux_x64" / -lprotobuf/ -lgmapping } win32:{ # windows only LIBS += -lWs2_32 LIBS += -lnetapi32 LIBS += -lmpr LIBS += -L"$$PWD/third_party_lib/lib/mingw_x86" / -lprotobuf/ -lgmapping / -lopencv_core2410.dll/ -lopencv_highgui2410.dll/ -lopencv_imgproc2410.dll }}在代碼中使用
//.h#include "Messages/message_map.pb.h"Message_MapLog _map_log_;//.cpp#include "google/protobuf/util/json_util.h"#include "google/protobuf/util/type_resolver.h"#include "google/protobuf/util/type_resolver_util.h" //注冊(cè)MapData信號(hào)槽可用 qRegisterMetaType<Message_MapLogData*>("Message_MapLogData*");//讀取離線文件數(shù)據(jù)bool GThreadDrawMap::readOffLineMap(const QString&filename){ _map_log_.Clear(); QFile file(filename); bool is_ok = file.open(QIODevice::ReadOnly); if (is_ok) { QByteArray b = file.readAll(); //-------------------------------- google::protobuf::util::TypeResolver* type_resolver = google::protobuf::util:: NewTypeResolverForDescr新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注