PDA

View Full Version : Custom widget not visible in Integrated designer of Qt Creator



John82
17th November 2009, 11:26
Hi

I made a custom widget plugin based on the custom widgets example ( using AnalogClock ) provided in Qt Assistant. I changed the name of the plugin class to MyPlugin and the name of the AnalogClock class to MyClock.

I then added libMyPlugin.so to the ../plugins/designer folder. When I check the "Plugin information" pop up from Tools->Form Editor->About Qt Designer plugins,
I can see that my plugin information has been loaded. But the plugin / widget is not visible in Qt Designer. It was supposed to be added to the group "Display widgets [Examples]".

Can someone tell me how to add this to designer or how do I use this widget in my form ? I tried restarting Qt creator and promoting a placeholder widget to no avail.

yogeshgokul
17th November 2009, 11:37
Can someone tell me how to add this to designer or how do I use this widget in my form ? I tried restarting Qt creator and promoting a placeholder widget to no avail.
There could be many reasons for this.
1. Your plugin is not properly exported, please refer the code of Analog clock for example.
2. In doXML function of your plugin class, try to change the group and other properties.

John82
17th November 2009, 13:16
There could be many reasons for this.
1. Your plugin is not properly exported, please refer the code of Analog clock for example.

-- If the plugin is not exported properly, Does it still show up in the plugin information ?


2. In doXML function of your plugin class, try to change the group and other properties.

-- I commented out this section to return only a simple string. I will see if that was causing the problem.

John82
17th November 2009, 14:43
Yup! It was because I had commented out the code in domXml (). The plugin became visible. After this there was a small problem because because the actual widget itself wasn't displayed when I dropped it into a form. In the terminal, I got this message :

Designer: The class attribute for the class MyClock does not match the class name NewPlugin.
Designer: A class name mismatch occurred when creating a widget using the custom widget factory registered for widgets of class NewPlugin. It returned a widget of class MyClock.

I went through the code again and realized that the name () was returning the name of the plugin class rather than the widget class. I changed this and everything started working properly. Thanks!