Unable to load custom widgets in UI file with QUiLoader
-
I'm trying to use QUiLoader to load a UI file that contains a custom widget resident in a path, which I have registered with QUiLoader as shown below. Yet QUiLoader is unable to find the my plugin.
QUiLoader loader; loader.addPluginPath( "folder/containing/MySnazzyWidgetDll" ); QStringList paths = loader.pluginPaths(); // returns path to plugin QStringList availableWidgets = loader.availableWidgets(); if( availableWidgets.contains( "MySnazzyWidget" ) ) { QFile file( "File.ui" ); file.open( QFile::ReadOnly ); QWidget* widget = loader.load( &file ); } else { LOG_ERROR << "Unable to instantiate MySnazzyWidget"; // ALWAYS return; }
I'm not even sure what sort of plugin that's supposed to be loaded. A designer plugin or a widget plugin i.e. a widget class compiled as a DLL.
Please advise.
Thanks.
-
Hi and welcome to devnet,
I can't answer for the plugin part however "folder/containing/MySnazzyWidgetDll" is a relative path so are you sure that the plugin is searched ?
On thing you can do to check that is to run your application with QT_DEBUG_PLUGINS=1
Hope it helps