PDA

View Full Version : Trying to use customwidget in the ui file that is loaded using QtUiLoader class



dpatel
6th May 2010, 10:55
Hi,

I have a situation.
I am using Qt 4.6.2. I am loading ui using QtUiLoader.load() function. It works fine for Qt provided widgets, but when I create a custom dial derived from QDial and use it in the ui file, that part of ui is blank.
Does anyone know the reason.
Is there any other way I can load a custom widget at runtime?

Thanks

tbscope
6th May 2010, 11:54
Your custom widget should be in the plugin path.

dpatel
6th May 2010, 12:03
What is plugin path?
Do you mean I should put the .cpp and .h file in that path.
When I load the ui regular way (without QtUILoader) I can see the customwidget. I have included the .cpp and .h files of customwidget in the project.

Thanks

tbscope
6th May 2010, 17:52
http://doc.qt.nokia.com/4.6/quiloader.html#pluginPaths

Check what the output is of that function, then add your widget to that path. And I guess, it needs to be the object (compiled widget)

dpatel
7th May 2010, 13:08
Sorry for the basic questions but, how do I compile the widget? it would be great if you can give me a command to do that.
thanks

dpatel
7th May 2010, 13:54
Actually I got a solution to the problem. Its in examples/script/qstetrix example. We have to create a custom QUiLoader class and implement createWidget() function. In that we will have to create our custom widgets differently then the Qt native widgets.