Qt-interest Archive, August 2007
QtDesigner Plugins and namespaces
Message 1 in thread
I have some questions concerning namespaces and designer plugins. Is it
possible to set things up so that when ui header files are generated, it
could add a using namespace directive? Or is there a way to write
plugins so they work with widgets inside of namespaces? I am currently
working on making several custom widgets that my company uses into
plugins for designer. It is common practice in the company I work for
to place all code we create inside a specific namespace. I have the Qt
Visual Studio Integration installed and I am using the Qt Designer
Plugin template to create the plugins.
The problem that I am having is that because our custom widgets are in a
namespace (and must stay in that namespace) designer gives me
warning/error messages when I try to test the plugins I make. When I am
compiling the plugin, I have custom widgets .h file in the namespace my
company uses. I add the necessary using namespace directives to the
plugin. It compiles just fine, the problem is in designer. I get a
mismatch class name warning when I try to use the widget in a dialog.
If I ignore the warning and in my test project I compile the ui file, I
get the following compiler error:
fatal error C1083: Cannot open include file: 'magpie::table_widget.h':
No such file or directory.
The actual include it is supposed to get is "magpie_table_widget.h". In
my plugin project the includeFile() function is set to return
"magpie_table_widget.h".
If I compile my plugin project with the namespace removed from the
custom widget source files, I do not get any errors in designer.
However, when I try to compile my test program, I get errors symptomatic
of trying to use a class that is inside a namespace and not having the
appropriate using namespace directive. My make file is set to search a
QtWidgets library we created to hold the source for all of our custom
widgets. The header file for my custom widget that exists in that
library uses the our namespace. I am getting namespace errors because
my ui file is using the magpie_table_widget which is inside a namespace.
Thanks,
Justin Haight
Justin.Haight@xxxxxxxxxxxxxxxx
Message 2 in thread
You can have designer plugins in a namespace. Just make sure that the
implementation of QDesignerWidgetInterface::name returns the same name as
the class attribute in the implementation of domXml.
For example, from below:
QString magpie_table_widget_plugin::name() const
{
return "magpie::table_widget"; // namespace specified
}
and
QString magpie_table_widget_plugin::domXml() const
{
return "<widget class=\"magpie::table_widget\" name=\"table_widget\">\n"
// namespace specified here too
" <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"
"</widget>\n";
}
Regards,
Chris
On 8/1/07, Haight, Justin <Justin.Haight@xxxxxxxxxxxxxxxx> wrote:
>
> I have some questions concerning namespaces and designer plugins. Is it
> possible to set things up so that when ui header files are generated, it
> could add a using namespace directive? Or is there a way to write plugins
> so they work with widgets inside of namespaces? I am currently working on
> making several custom widgets that my company uses into plugins for
> designer. It is common practice in the company I work for to place all code
> we create inside a specific namespace. I have the Qt Visual Studio
> Integration installed and I am using the Qt Designer Plugin template to
> create the plugins.
>
>
>
> The problem that I am having is that because our custom widgets are in a
> namespace (and must stay in that namespace) designer gives me warning/error
> messages when I try to test the plugins I make. When I am compiling the
> plugin, I have custom widgets .h file in the namespace my company uses. I
> add the necessary using namespace directives to the plugin. It compiles
> just fine, the problem is in designer. I get a mismatch class name warning
> when I try to use the widget in a dialog. If I ignore the warning and in my
> test project I compile the ui file, I get the following compiler error:
>
>
>
> fatal error C1083: Cannot open include file: 'magpie::table_widget.h': No
> such file or directory.
>
>
>
> The actual include it is supposed to get is "magpie_table_widget.h". In
> my plugin project the includeFile() function is set to return
> "magpie_table_widget.h".
>
>
>
> If I compile my plugin project with the namespace removed from the custom
> widget source files, I do not get any errors in designer. However, when I
> try to compile my test program, I get errors symptomatic of trying to use a
> class that is inside a namespace and not having the appropriate using
> namespace directive. My make file is set to search a QtWidgets library we
> created to hold the source for all of our custom widgets. The header file
> for my custom widget that exists in that library uses the our namespace. I
> am getting namespace errors because my ui file is using the
> magpie_table_widget which is inside a namespace.
>
>
>
> Thanks,
>
> Justin Haight
>
> Justin.Haight@xxxxxxxxxxxxxxxx
>
--
[ signature omitted ]