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. Qt5 CMake AUTOMOC "bug" and Widget Collections (duplicate plugin symbols) [solved]
Forum Updated to NodeBB v4.3 + New Features

Qt5 CMake AUTOMOC "bug" and Widget Collections (duplicate plugin symbols) [solved]

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.2k Views 1 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.
  • L Offline
    L Offline
    liuq
    wrote on last edited by
    #1

    I've been puzzled for a couple of days while trying to port a custom widget consisting of two basic sub widgets to Qt5. I am using CMake as the building system and I discovered a subtle AUTOMOC bug in case of widget collections.

    In my case I had two basic widget plugins plus another plugin that combined both in a single interface to be exposed in a widget collection library.

    @
    class SchedulingWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface {};

    class RoutingWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface {};

    class CombinedWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface {};
    @

    and the overall widget collection:

    @
    class SRViewers : public QObject, public QDesignerCustomWidgetCollectionInterface {};
    @

    and all these files (plus all the other dependencies) were compiled with the following CMake rules, where ${srviewersplugin_SOURCES} included all the sources and ${srviewersplugin_HEADERS} all the headers (to be automocced) as follows:

    @
    add_library(srviewersplugin ${srviewersplugin_SOURCES} ${srviewersplugin_FORMS_HEADERS} ${srviewersplugin_HEADERS} ${srviewersplugin_RESOURCES_RCC})
    target_link_libraries(srviewersplugin ${Boost_LIBRARIES} Qt5::Widgets Qt5::Designer Qt5::WebKit Qt5::WebKitWidgets Qt5::Core Qt5::Gui)
    @

    In Qt5, AUTOMOC seems to call moc on each of the three basic widget plugins in isolation, resulting in duplicate plugin symbols:
    @Redefinition of 'qt_section_alignment_dummy'@
    plus a bunch of other symbols). The only option for me to switch off AUTOMOC and to use a qt5_wrap_cpp() cmake rule so to avoid duplicate symbols.

    Hope this will be helpful to someone else

    Cheers,

    Luca

    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