Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. MongoDB integration with Qt
Forum Updated to NodeBB v4.3 + New Features

MongoDB integration with Qt

Scheduled Pinned Locked Moved Solved General and Desktop
19 Posts 6 Posters 6.0k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Christian EhrlicherC Online
    Christian EhrlicherC Online
    Christian Ehrlicher
    Lifetime Qt Champion
    wrote on last edited by
    #4

    As I already said you've three possibilities

    • don't use MongoDB
    • write a proper Qt plugin
    • use the MongoDB api directly.

    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
    Visit the Qt Academy at https://academy.qt.io/catalog

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by SGaist
      #5

      Hi,

      Did you check the official MongoDB C API ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • E Offline
        E Offline
        enne9
        wrote on last edited by
        #6

        I did as you suggested to me and I'm including the mongocxx library.
        Unfortunatelly I get a
        usr/local/include/bsoncxx/v_noabi/bsoncxx/types.hp:39: Parse error at "{"
        and I don't know what to do, since a collage of mine working on the same project is not getting this problem (using the exact same code).

        The error is in correspondence of

        enum class type : std::uint8_t {
        #define BSONCXX_ENUM(name, val) k_##name = val,
        #include <bsoncxx/enums/type.hpp>
        #undef BSONCXX_ENUM
        };
        

        If I remove type : std::uint8_t it then complains about other errors...
        Any suggestions?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #7

          Hi,

          Can you show the code that you are using that triggers that error ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • E Offline
            E Offline
            enne9
            wrote on last edited by
            #8

            Sorry, but it is confidential and I'm not sure I can share it.
            Using #ifndef Q_MOC_RUN as suggested here https://bugreports.qt.io/browse/QTBUG-80578 makes the compilation error disappears but the program then crashes immediately at runtime.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #9

              In that kind of case, you can also provide a minimal example that shows the issue.

              And what does the stack trace of the crash say ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • E Offline
                E Offline
                enne9
                wrote on last edited by
                #10
                home/../mongo/bsoncxx/v_noabi/bsoncxx/types.hp:39: Parse error at "{"
                make[1]: *** [Makefile:1117: moc_server.cpp] Error 1
                

                This is what I get in the compilation output, if it is useful

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #11

                  Well, without the code, it doesn't help much.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • E Offline
                    E Offline
                    enne9
                    wrote on last edited by
                    #12

                    A minimal piece of code to reproduce the error is already available here https://bugreports.qt.io/browse/QTBUG-80578, but it seems to be a bug. Unfortunately, I didn't find any workaround and I'm unable to continue with the project.

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #13

                      You wrote that the compilation was successful so that part is fine, isn't it ?

                      As for the run time crash, what is the stack trace ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • E Offline
                        E Offline
                        enne9
                        wrote on last edited by
                        #14

                        9faceab0-cb44-4ad4-ac62-4fbe96b68b0e-image.png

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #15

                          Do you have the same issue if you write a minimal test application using only bsoncxx ?

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0
                          • E Offline
                            E Offline
                            enne9
                            wrote on last edited by
                            #16

                            In the end, it was a problem of compatibility between mongocxx and my Qt version. Installing a previous release fixed the issue.

                            A 1 Reply Last reply
                            0
                            • E enne9

                              In the end, it was a problem of compatibility between mongocxx and my Qt version. Installing a previous release fixed the issue.

                              A Offline
                              A Offline
                              Ahmed000001
                              wrote on last edited by
                              #17

                              @enne9 said in MongoDB integration with Qt:

                              n mongocxx and my Qt version. I

                              so, what was the compatible versions?

                              1 Reply Last reply
                              1
                              • P Offline
                                P Offline
                                plaristote
                                wrote on last edited by plaristote
                                #18

                                I confirm that I have the very same issue with Qt 5.15.2 and mongo-cxx-driver 3.5.0 (had to add Q_MOC_RUN defines, and then the same crash when building mongocxx::client).

                                If the author of the thread show up again, which combination of version did you use that worked ? Did you perhaps use the legacy mongo-cxx-driver ? Considering how different the two are, it might work... but the new generation of mongo-cxx-driver is already pretty damn mature, and the legacy one has reached end of life, so it's not really a viable solution on the long term.

                                EDIT: Alright, the original author wording lacked precision: this has nothing to do with the combined use of Qt and mongo-cxx-driver.
                                The problem is due to linking to a certain version of the mongo-cxx library, while using the includes for another version.

                                Turns out I had already installed mongocxx elsewhere, and the CMake package files for mongo-cxx-driver seem to have some issue finding the include files on its own, so that issue might happen if you're not careful enough and mess up the include part.

                                1 Reply Last reply
                                0
                                • Q Offline
                                  Q Offline
                                  qxorm
                                  wrote on last edited by
                                  #19

                                  Hello,

                                  If you want an easier integration with Qt and MongoDB, you can try QxOrm library.
                                  The documentation can be found here.
                                  And here is a project example on GitHub.

                                  Please note that the latest commit on GitHub for QxOrm library supports Qt6.

                                  1 Reply Last reply
                                  0

                                  • Login

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • Users
                                  • Groups
                                  • Search
                                  • Get Qt Extensions
                                  • Unsolved