- The provider module is used to provide data
- is displayed as a node in a tree
- Must have at least two classes
- Provider class, inheritance and Qgsdataprovider
- Rootitem class, Node class
- The connection node class is also required to provide a connection node.
- If you provide a custom connection, you also need to implement the connection class
- No parent class, free to play
- The system has a well-written HTTLP connection class that can be used directly
- The simplest provider module is written
- Create a new directory under Src/providers
- Imitate the OWS plug-in, ows all the files in the past, replace the name on the line, note that the file name in the code is also to be modified
- Modify the. cpp. h file name
- Modify the file name of the code reference
- Modify the class name in the code
- Replace provider display name in *provider.cpp
- Modify the file name in the CMakeLists.txt
- Modify CMakeLists.txt under Src/providers, add Harmony Directory
- Write a provider module with a custom UI harmony
- Description
- The OWS module uses its own qgsnewhttpconnection class, so there is no UI
- The UI of the provider module is uniformly placed in the \src\ui directory
- The interface classes that inherit from the Qt window class can be placed in the \src\gui directory (where Qgis's own GUI is placed), which we can put in the provider directory
- This example implements a connection window class that pops up a dialog box after a new stand-alone connection
- Modified on the basis of OWS
- Required modifications
- Harmonydataitems.cpp
- Open this # If, activate the newconnection () slot function
- To invoke a new Write dialog box in Newconnection
- Steps
- On the basis of a provider module with no UI
- Create a new Qdialog-based dialog box
- Copy the code into the Src/providers/harmony
- and add these two files to the CMakeLists.txt
- To copy the UI files to Src/ui
- CMakeLists.txt
########################################################
# Files
#设置源文件列表
SET(HARMONY_SRCS
harmonyprovider.cpp
harmonydataitems.cpp
harmonyconnection.cpp
)
#头文件
SET(HARMONY_MOC_HDRS
harmonyprovider.h
harmonydataitems.h
harmonyconnection.h
)
########################################################
# Build
#添加生成的MOC源文件,这些文件是根据头文件生成的
QT4_WRAP_CPP(HARMONY_MOC_SRCS ${HARMONY_MOC_HDRS})
#设置库文件目录
INCLUDE_DIRECTORIES(
#qgis core
../../core
#qgis gui
../../gui
${CMAKE_CURRENT_BINARY_DIR}/../../ui
)
#生成动态库
ADD_LIBRARY (harmonyprovider MODULE ${HARMONY_SRCS} ${HARMONY_MOC_SRCS})
#链接其他库
TARGET_LINK_LIBRARIES (harmonyprovider
qgis_core
qgis_gui
)
########################################################
# Install
#生成插件
INSTALL(TARGETS harmonyprovider
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})
From for notes (Wiz)
List of attachments
QGis Provider Module Writing