PDA

View Full Version : Advanced use of QUiLoader



doberkofler
28th October 2009, 15:53
I'm aware that this is a cross post but I'm not sure what is the appropriate forum.

I would need to load some ui resources converted from an other application (the ui files are generated form a 3rd party dialog editor) and use the QUiLoader to load the resources and manipulate the creation of widgets by overwriting the QUiLoader::createWidget method.

I actually need to create some "special" widgets based on some dynamic properties that are added to the ui file but unfortunately the QUiLoader::createWidget method does not seem to offer any information about the properties in the ui file.

I came only up with a very ugly way to solve this until now (create a temporary parent first to get the dynamic properties, delete it and then start again with the real parent widget) and would be most interested to hear how the Qt gurus would solve this (not so untypical) problem.

Thank you in advance!

caduel
28th October 2009, 16:41
the Qt idiom is: create the widget "naked" and then set the properties afterwards with QObject::setProperty(). (Thus the createWidget call does not need to know about properties set in the .ui file).

doberkofler
28th October 2009, 16:47
I understand but what if in my case not only the class name but also some dynamic properties are needed to know what widget needs to be created?