Hello. I have this class in pure C++.

Qt Code:
  1. #ifndef VALUEVECTOR_HPP_
  2. #define VALUEVECTOR_HPP_
  3.  
  4. #include <iostream>
  5. #include <vector>
  6. #include <algorithm>
  7. using std::cout;
  8. using std::endl;
  9. using std::vector;
  10. using std::find;
  11. #include "Object.hpp"
  12. #include "ComaPtr.hpp"
  13. #include "Value.hpp"
  14.  
  15. class ValueVector : public Object {
  16. typedef ComaPtr<Value> type;
  17. public:
  18.  
  19. ValueVector() {
  20. }
  21.  
  22. ValueVector(Value* value) {
  23. clearChildren();
  24. addChildren(value);
  25. }
  26.  
  27. ValueVector(unsigned length) {
  28. clearChildren();
  29. size(length);
  30. }
  31.  
  32. ValueVector(const ValueVector& rhs) {
  33. *this = rhs;
  34. }
  35.  
  36. type& operator[](unsigned index) {
  37. return m_children[index];
  38. }
  39.  
  40. bool operator==(ValueVector& vv) {
  41. if(size() != vv.size()) {
  42. return false;
  43. }
  44.  
  45. for(unsigned i = 0; i < size(); ++i) {
  46. for(unsigned j = 0; j < vv.size(); ++j) {
  47. if(m_children[i] != vv[i]){
  48. return false;
  49. }
  50. }
  51. }
  52. return true;
  53. }
  54.  
  55. bool operator!=(ValueVector& vv) {
  56. if(size() != vv.size()) {
  57. return true;
  58. }
  59.  
  60. for(unsigned i = 0; i < size(); ++i) {
  61. for(unsigned j = 0; j < vv.size(); ++j) {
  62. if(m_children[i] != vv[i]){
  63. return true;
  64. }
  65. }
  66. }
  67. return false;
  68. }
  69.  
  70. void addChildren(type children) {
  71. assert(find(m_children.begin(), m_children.end(), children) == m_children.end());
  72. m_children.push_back(children);
  73. }
  74.  
  75. unsigned capacity() const {
  76. return m_children.capacity();
  77. }
  78.  
  79. void capacity(unsigned length) {
  80. m_children.reserve(length);
  81. }
  82.  
  83. void clearChildren() {
  84. m_children.clear();
  85. }
  86.  
  87. void setChildren(unsigned index, type children) {
  88. assert(index < size());
  89. m_children[index] = children;
  90. }
  91.  
  92. unsigned size() const {
  93. return m_children.size();
  94. }
  95.  
  96. void size(unsigned length) {
  97. m_children.resize(length);
  98. }
  99. private:
  100. vector<type> m_children;
  101. };
  102.  
  103. typedef ComaPtr<ValueVector> ValueVectorPtr;
  104.  
  105. #endif /*VALUEVECTOR_HPP_*/
To copy to clipboard, switch view to plain text mode 

And I was googling around for like a Smart Pointer in Qt4.4 but I couldn't seem to come up with any answers except for QGuardedPtr<> but only seems to appear in Qt3 which I don't use.

ComaPtr<> is like boost::shared_ptr except my pointer class addRef and release which is all done in ComaPtr<> which only works on classes that inherit from my custom reference counting class Object. And was wondering. how do I set up QVector to hold an array of pointers of Value (example class). And automatically reference count it?