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. Qbs and Q_PRIVATE_SLOT: doing it right
Forum Updated to NodeBB v4.3 + New Features

Qbs and Q_PRIVATE_SLOT: doing it right

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

    PIMPL is a pattern widely used across the Qt itself and countless Qt-based libraries. Despite the fact that Q_PRIVATE_SLOT macro is currently an undocumented private API, many developers (including me) is using it in their code.

    When compiling the moc-generated file for the header using Q_PRIVATE_SLOT macro we have basically two different ways:

    Somehow include private header to the moc file so the private slot declarations be available at the compile time. It is easily done using -f command line argument when calling moc.

    Do not compile moc file separately and manually include it to your C++ file doing something like #include "moc_yourgloriouspimplclass.cpp" to your class implementation.

    Since I've been using CMake for most of my projects before I generally preferred the first way simply adding something like @QT4_WRAP_CPP(sources include/SomeClass.h
    OPTIONS -f${CMAKE_CURRENT_SOURCE_DIR}/src/SomeClass_p.h)@

    to CMakeLists.txt.

    Currently I'm trying to use qbs and got a general question: what is the right way to build Q_PRIVATE_SLOT-containing classes using qbs? Do I need to find a way to skip MOC-generated file compilation and include it manually or maybe there's a simplier way?

    Thank you in advance.

    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