c++ - QT UIC does not automatically append the headers for custom widgets -


i made custom widget "duwagwidget" , custom widget plugin "duwagwidgetplugin" can dragged&dropped inside qt designer create duwag.ui file.

however, when try compile program, ui_duwag.h generated qt user interface compiler, in auto generated file, uic not include "duwagwidget.h" necessary create custom widget class.

the duwagwidgetplugin (derived interface in qt create customwidgets) factory class duwagwidget.

here code duwagwidgetplugin :^

    #include <duwagwidgetplugin.h>     #include <qtplugin>     #include <qwidget.h>     #include <mtbfwidget.h>       duwagwidgetplugin::duwagwidgetplugin( qobject *parent ) : qobject(parent) {         initialized = false;     }      void duwagwidgetplugin::initialize(qdesignerformeditorinterface * /* core */) {          if (initialized)             return;         initialized = true;      }      bool duwagwidgetplugin::isinitialized() const {         return initialized;     }      qwidget *duwagwidgetplugin::createwidget(qwidget *parent) {         return new duwagwidget( parent );     }      qstring duwagwidgetplugin::name() const {         return "duwagwidget";     }      qstring duwagwidgetplugin::group() const {         return "duwagplugin";     }      qicon duwagwidgetplugin::icon() const {         return qicon();     }      qstring duwagwidgetplugin::tooltip() const {         return "the duwag control panel";     }      qstring duwagwidgetplugin::whatsthis() const {         return "the duwag control panel";     }      bool duwagwidgetplugin::iscontainer() const {         return false;     }      qstring duwagwidgetplugin::domxml() const {         return  "<widget class=\"duwagwidget\" name=\"duwagwidget\">\n"                     " <property name=\"geometry\">\n"                 "  <rect>\n"                 "   <x>0</x>\n"                 "   <y>0</y>\n"                 "   <width>100</width>\n"                 "   <height>100</height>\n"                 "  </rect>\n"                 " </property>\n"                 " <property name=\"tooltip\" >\n"                 "  <string>the mtbf control panel</string>\n"                 " </property>\n"                 " <property name=\"whatsthis\" >\n"                 "  <string>the mtbf control panel.</string>\n"                 " </property>\n"                 "</widget>\n";     }      qstring duwagwidgetplugin::includefile() const {         return "duwagwidget.h";     }      q_export_plugin2(duwagplugin, duwagwidgetplugin) 

so problem is, in generated header file, cannot make custom widget "duwagwidget" because not know is..

i have had problem when including custom classes in qtdesigner .ui file. uic okay job of adding appropriate headers when use "promote to.." option.

  1. right-click on widget in layout.
  2. select "promote to..".
  3. select base class , type name of promoted class "newclass". automatically adds #include "newclass.h" file "ui_yourclass.h".

unfortunately, creates redundant include warnings when designer file accesses same custom class , both "ui_yourclass.h" files included same header. also, need promote widget makes mandatory create , initialize 1 instance of class within designer layout file.

another way, i've read about, go tools > form editor > form settings , add "newclass.h" in sections entitled "include hints". have never done way.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -