Hi,

I have a plugin that loads and shows a custom widget that displays an image (as a background for a QLabel) loaded from a resource file (resources.qrc). The problem I'm facing is that once the plugin is loaded, it shows the widget properly, but not the image. I tried putting "Q_INIT_RESOURCE( resources )" everywhere, but nothing happens. I have created many custom widgets that use qrc files to display images, but only directly within an app, which have worked just fine. This time is from a plugin, so there must be something I'm missing here. Any help?


Qt Code:
  1. // TheInterface.h
  2. class TheInterface
  3. {
  4. ...
  5. }
  6. Q_DECLARE_INTERFACE(TheInterface,"com.system.subsystem.TheInterface/1.0");
  7.  
  8.  
  9.  
  10. // MyWidget.h
  11. class MyWidget : public QWidget, public Ui::MyWidget
  12. {
  13. Q_OBJECT
  14. ...
  15. }
  16.  
  17.  
  18.  
  19. // MyPlugin.h
  20. #include "TheInterface.h"
  21. class MyPlugin : public QOBject,
  22. public TheInterface
  23. {
  24. Q_OBJECT
  25. Q_INTERFACES(TheInterface)
  26.  
  27. ...
  28. };
  29.  
  30. // MyPlugin.cpp
  31. #include "MyPlugin.h"
  32. #include "MyWidget.h"
  33. MyPlugin::MyPlugin()
  34. {
  35. MyPlugin* w = new MyPlugin();
  36. w->show();
  37. }
  38.  
  39. Q_EXPORT_PLUGIN2(myplugin, MyPlugin)
To copy to clipboard, switch view to plain text mode