QGis Provider Module Writing

Source: Internet
Author: User

  • 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
      1. Create a new directory under Src/providers

      2. 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
        1. Modify the. cpp. h file name
        2. Modify the file name of the code reference
        3. Modify the class name in the code
        4. Replace provider display name in *provider.cpp

        5. Modify the file name in the CMakeLists.txt
      3. 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
        1. On the basis of a provider module with no UI
        2. Create a new Qdialog-based dialog box

        3. Copy the code into the Src/providers/harmony

        4. and add these two files to the CMakeLists.txt
        5. To copy the UI files to Src/ui
    • CMakeLists.txt
      •       
             
        1. ########################################################
        2. # Files
        3. #设置源文件列表
        4. SET(HARMONY_SRCS
        5. harmonyprovider.cpp
        6. harmonydataitems.cpp
        7. harmonyconnection.cpp
        8. )
        9. #头文件
        10. SET(HARMONY_MOC_HDRS
        11. harmonyprovider.h
        12. harmonydataitems.h
        13. harmonyconnection.h
        14. )
        15. ########################################################
        16. # Build
        17. #添加生成的MOC源文件,这些文件是根据头文件生成的
        18. QT4_WRAP_CPP(HARMONY_MOC_SRCS ${HARMONY_MOC_HDRS})
        19. #设置库文件目录
        20. INCLUDE_DIRECTORIES(
        21. #qgis core
        22. ../../core
        23. #qgis gui
        24. ../../gui
        25. ${CMAKE_CURRENT_BINARY_DIR}/../../ui
        26. )
        27. #生成动态库
        28. ADD_LIBRARY (harmonyprovider MODULE ${HARMONY_SRCS} ${HARMONY_MOC_SRCS})
        29. #链接其他库
        30. TARGET_LINK_LIBRARIES (harmonyprovider
        31. qgis_core
        32. qgis_gui
        33. )
        34. ########################################################
        35. # Install
        36. #生成插件
        37. INSTALL(TARGETS harmonyprovider
        38. RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
        39. LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})



From for notes (Wiz)

List of attachments

    QGis Provider Module Writing

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.