Hi,

I want to configure objects that are encapsulated in other objects using a configuration file and a plugin architecture, so I do not know in advance which objects are contained within the object. Is it possible to do this using the QObject:roperty() function?

Example:
Qt Code:
  1. class BInterface {
  2. public:
  3. virtual ~BInterface() {}
  4. virtual int foo() = 0;
  5. };
  6.  
  7. class B : public QObject, public BInterface
  8. {
  9. Q_OBJECT
  10. Q_PROPERTY(int b READ b WRITE setB );
  11. public:
  12. virtual ~B() {}
  13. virtual int foo() { return mv_b; }
  14. const int b() const { return mv_b; }
  15. void setB( const int b ) { mv_b = b; }
  16. private:
  17. int mv_b;
  18. };
  19.  
  20. class A : public QObject{
  21. Q_OBJECT
  22. Q_PROPERTY(BInterface* B READ B WRITE setB);
  23. public:
  24. A() { mv_B = NULL; }
  25. virtual ~A() { if(mv_B) delete mv_B; }
  26. const BInterface * B() { return mv_B; }
  27. void setB( const BInterface * B ) { if (mv_B) delete mv_B; mv_B = B; }
  28. private:
  29. BInterface * mv_B;
  30. };
To copy to clipboard, switch view to plain text mode 

what I want to do is something like:
Qt Code:
  1. QObject * objA = new A();
  2. BInterface* b = a.property("B");
  3. b.setProperty("b", someValue);
To copy to clipboard, switch view to plain text mode 
can this be done at all?