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 939 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 20 Jul 2023, 18:37 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
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 20 Jul 2023, 19:07 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 20 Jul 2023, 19:42
      0
      • S SGaist
        20 Jul 2023, 19:07

        Hi,

        I think, you need to use Q_NAMESPACE_EXPORT).

        C Offline
        C Offline
        Creaperdown
        wrote on 20 Jul 2023, 19:42 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 20 Jul 2023, 19:42
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 20 Jul 2023, 19:48 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 20 Jul 2023, 20:04
          0
          • S SGaist
            20 Jul 2023, 19:48

            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 20 Jul 2023, 20:04 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

            S 1 Reply Last reply 20 Jul 2023, 20:07
            0
            • C Creaperdown
              20 Jul 2023, 20:04

              @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

              S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 20 Jul 2023, 20:07 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 20 Jul 2023, 20:15
              0
              • S SGaist
                20 Jul 2023, 20:07

                @Creaperdown are you using cmake for your project ?

                C Offline
                C Offline
                Creaperdown
                wrote on 20 Jul 2023, 20:15 last edited by
                #7

                @SGaist yes, cmake and Qt 6.5

                1 Reply Last reply
                0
                • S SGaist
                  20 Jul 2023, 20:07

                  @Creaperdown are you using cmake for your project ?

                  C Offline
                  C Offline
                  Creaperdown
                  wrote on 20 Jul 2023, 20:46 last edited by
                  #8

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

                  1 Reply Last reply
                  0
                  • S SGaist
                    20 Jul 2023, 20:07

                    @Creaperdown are you using cmake for your project ?

                    C Offline
                    C Offline
                    Creaperdown
                    wrote on 21 Jul 2023, 22:07 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

                    1/9

                    20 Jul 2023, 18:37

                    • Login

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