Hi. I want to dynamically load a .ui file. I know to use QUILoader.

Supposing the widget the .ui file describes new signals and slots. If this was a compile-time problem, I could generate the ui_foo.h and implement the slot in code.

Since this is all dynamic, when I load the .ui file, the widget will have slots with no definitions. I have constructed a simple example:

Qt Code:
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <ui version="4.0">
  3. <class>Form</class>
  4. <widget class="QWidget" name="my_widget">
  5. <widget class="QPushButton" name="pushButton">
  6. </widget>
  7. </widget>
  8. <resources/>
  9. <connections>
  10. <connection>
  11. <sender>pushButton</sender>
  12. <signal>clicked()</signal>
  13. <receiver>Form</receiver>
  14. <slot>my_slot()</slot>
  15. </connection>
  16. </connections>
  17. <slots>
  18. <slot>my_slot()</slot>
  19. </slots>
  20. </ui>
To copy to clipboard, switch view to plain text mode 

Now suppose I do something like this:
Qt Code:
  1. QUiLoader loader;
  2. QFile file("my_widget.ui");
  3. file.open(QFile::ReadOnly);=
  4. QWidget * my_widget = loader.load(&file, this);
To copy to clipboard, switch view to plain text mode 

What happens when I click the button? my_slot() isn't defined.

I want to intercept calls to my_slot but I have no idea how. Something clever with QMetaObject maybe?