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. Export enum classes
Forum Updated to NodeBB v4.3 + New Features

Export enum classes

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 2 Posters 958 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.
  • C Offline
    C Offline
    Creaperdown
    wrote on last edited by
    #1

    Hey, I need to export some enum classes from my dll's on windows. They look like this:

    namespace application::book_operation_status
    {
    
    Q_NAMESPACE
    
    enum class BookOperationStatus
    {
        Success,
        ...
    };
    
    Q_ENUM_NS(BookOperationStatus)
    
    }  // namespace application::book_operation_status
    

    I have defined a symbol "APPLICATION_LIBRARY" for the export (following the Qt documentation), but just adding it here:

    enum class APPLICATION_LIBRARY BookOperationStatus
    

    Gives me an error on this line:

    Q_ENUM_NS(BookOperationStatus)
    

    What is the proper way to export Q-enum classes?

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

      Hi,

      I think, you need to use Q_NAMESPACE_EXPORT).

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

      C 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        I think, you need to use Q_NAMESPACE_EXPORT).

        C Offline
        C Offline
        Creaperdown
        wrote on last edited by
        #3

        @SGaist Thanks, this is exactly what I was looking for!

        Aside of that, do you know if there is any mechanism to automatically export all symbols from my dlls? It is quite annoying to put the macros described here: https://doc.qt.io/qt-6/sharedlibrary.html everywhere.

        1 Reply Last reply
        0
        • C Creaperdown has marked this topic as solved on
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          I currently don't however it's rather a good thing to only export what you are currently using rather than just everything "just in case".

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

          C 1 Reply Last reply
          0
          • SGaistS SGaist

            I currently don't however it's rather a good thing to only export what you are currently using rather than just everything "just in case".

            C Offline
            C Offline
            Creaperdown
            wrote on last edited by
            #5

            @SGaist Well, since my application is split into multiple layers which are shared libraries, its not that useful to export everything manually. It is also not really that nice to add all that export stuff to more than 1000 symbols during the linux->windows port haha.

            I know that cmake has this: https://cmake.org/cmake/help/latest/prop_tgt/WINDOWS_EXPORT_ALL_SYMBOLS.html for exporting all symbols, but it doesnt work with Qt

            SGaistS 1 Reply Last reply
            0
            • C Creaperdown

              @SGaist Well, since my application is split into multiple layers which are shared libraries, its not that useful to export everything manually. It is also not really that nice to add all that export stuff to more than 1000 symbols during the linux->windows port haha.

              I know that cmake has this: https://cmake.org/cmake/help/latest/prop_tgt/WINDOWS_EXPORT_ALL_SYMBOLS.html for exporting all symbols, but it doesnt work with Qt

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Creaperdown are you using cmake for your project ?

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

              C 3 Replies Last reply
              0
              • SGaistS SGaist

                @Creaperdown are you using cmake for your project ?

                C Offline
                C Offline
                Creaperdown
                wrote on last edited by
                #7

                @SGaist yes, cmake and Qt 6.5

                1 Reply Last reply
                0
                • SGaistS SGaist

                  @Creaperdown are you using cmake for your project ?

                  C Offline
                  C Offline
                  Creaperdown
                  wrote on last edited by
                  #8

                  @SGaist Is there a way to export all symbols (including the Qt stuff) via cmake?

                  1 Reply Last reply
                  0
                  • SGaistS SGaist

                    @Creaperdown are you using cmake for your project ?

                    C Offline
                    C Offline
                    Creaperdown
                    wrote on last edited by
                    #9

                    @SGaist I have tried set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) again but it does not seem to work for qt symbols. I get errors mentioning the static meta object

                    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