[Interest] someclass.h, someclass_alternative.cpp and auto moc

René J.V. Bertin rjvbertin at gmail.com
Tue Oct 10 11:35:10 CEST 2017


Hi,

Apologies for asking something that should probably be evident (I can't come up with a specific enough google search term).

I'm getting inspiration from Qt's Assistant sources to modify KDevelop's documentation viewer so it can use QTextBrowser instead of WebKit or WebEngine. It currently has a single standarddocumentationview.cpp file that implements the support for both web frameworks. I began by adding  USE_QTEXTBROWSER #ifdefs but am now looking to clean things up by moving the QTB implementation to its own file. There are so many differences that there isn't much point in keeping a standarddocumentationview.cpp file for the few remaining common code. The standarddocumentationview.h header is used by documentation plugins, so I cannot really change that (the rendering framework is supposed to be hidden).

KDevelop uses CMake, so here's how I modified the docviewer cmake file at first:

if(KDEVELOP_USE_QTEXTBROWSER)
    set(KDevPlatformDocumentation_LIB_SRCS
        standarddocumentationview_qtb.cpp)
else()
    set(KDevPlatformDocumentation_LIB_SRCS
        standarddocumentationview.cpp)
endif()
set(KDevPlatformDocumentation_LIB_SRCS ${KDevPlatformDocumentation_LIB_SRCS}
    documentationfindwidget.cpp
    documentationview.cpp
)


Sadly I get a number of link errors that show that something goes wrong with the moc files. The standarddocumentationview_qtb.cpp file wants its own standarddocumentationview_qtb.moc file, but then it will apparently miss anything defined in standarddocumentationview.h .

This approach only works if I keep standarddocumentationview.cpp included with almost all code #ifdef'ed out and have it include its own standarddocumentationview.moc file.

That's better than nothing but is there no more elegant way to do what I'm trying to do here?

Thanks,
René



More information about the Interest mailing list