18

I never check it when promoting widgets, and everything works, but I've always wondered what it is for. Does anyone know?

enter image description here

László Papp
  • 51,870
  • 39
  • 111
  • 135
sashoalm
  • 75,001
  • 122
  • 434
  • 781

1 Answers1

19

Checking this box leads to the header file being included as a global header file in the generated ui code. I.e. it will be included as #include <foowidget.h> instead of #include "foowidget.h".

For example, you'll need to use it if you want to promote a widget to a custom widget from a library if the library is installed system-wide but you cannot directly create that widget in the designer. An example would be to promote a QSlider to a QxtSpanSlider if you install Qxt via the linux package manager.

anderas
  • 5,744
  • 30
  • 49
  • Hm, it's kind of strange, as any such header would normally come from Qt itself, so it would already be available in Qt Designer, so no need to promote to it, right? – sashoalm Jun 04 '14 at 09:10
  • 2
    There could also be other sources of global includes. For example, you could split your project into several subprojects/libraries and have a main GUI project that uses these libraries. The main GUI project would then add the directories containing the headers to its global include path and you have the situation where you `#include` custom headers from the global include path. – anderas Jun 04 '14 at 09:14
  • @sashoalm "it would already be available in Qt Designer" would only make sense if Qt Designer was a compiler. All that Designer does is generate `.ui` files that are then converted to source code by the `uic` tool. That source is then compiled with a C++ compiler. The `uic` will include headers only for classes it knows about - so either Qt widget classes, or the classes from the plugins. Since the promotion mechanism is a workaround for not writing a plugin, you need to tell `uic` how to include relevant headers. `uic` is not omniscient. It otherwise knows nothing about that class's needs. – Kuba hasn't forgotten Monica Jun 04 '14 at 13:44
  • @KubaOber I meant any widget class that ships with Qt would be added to the Designer View toolbox, I doubt there are any widgets that ship with Qt and aren't present in the toolbox. Do you know of any? – sashoalm Jun 04 '14 at 18:03
  • I finally found a case where it's needed - ships widgets and I needed to use it for QxtSpanSlider from libqxt. – sashoalm Jan 15 '16 at 13:51
  • @sashoalm your edit sounded a bit misleading to me; I generalized it a bit and hopefully made it more clear. Is the current version ok to you? – anderas Jan 15 '16 at 20:06
  • @anderas Sure. Btw, I have libqxt installed system wide ("sudo apt-get install libqxt-dev" on linux), and I still needed a global include. – sashoalm Jan 15 '16 at 22:53
  • @sashoalm argh, my fault. I totally got that backwards with the last edit, somehow must not have been paying full attention. It should be correct now, sorry for that. – anderas Jan 16 '16 at 00:08