Important: Please read the Qt Code of Conduct -

How to create global #include from QtDesigner plugin

  • Hello,

    I'm working on QtDesigner plugin for my widgets library. I use following code:

    @QString MyWidgetPlugin::includeFile() const
    return "mywidget.h";

    It works well, but uic produces local include like this:

    @#include "mywidget.h"@

    But I want to install my widget library into system and use it in number of projects,
    so I need to generate something like:

    @#include <mywidget.h>@

    I found an undocumented feature in the QtDesigner sources - one can return "<mywidget.h>" instead of "mywidget.h" in his includeFile(), and then include recognized as global, and correctly handled by uic.

    The question is simple - can I use this feature, or it's an implementation detail and will be removed in the next versions of Qt?

  • It is unlikely to be changed, but if it isn't documented there is most probably no guarantee.

    But one should mention that <code>#include <...></code> and <code>#include "..."</code> behaves exactly the same, except that <code>"..."</code> looks in the current directory first, then in global directories. From the technical point of view there is no need to use the <code><...></code> notation just to include global files.

Log in to reply