Hi, I need declare a vector of vector; is it possible? thanks
Qt Code:
vector<QSpinBox*> sbz; vector<QSpinBox*> sby; vector<QSpinBox*> sbz; vector<vector> sb; //errorTo copy to clipboard, switch view to plain text mode
Hi, I need declare a vector of vector; is it possible? thanks
Qt Code:
vector<QSpinBox*> sbz; vector<QSpinBox*> sby; vector<QSpinBox*> sbz; vector<vector> sb; //errorTo copy to clipboard, switch view to plain text mode
Regards
Yes, but you must specify the type which the inner vector will hold.Originally Posted by mickey
Ok, but i don't know how push in it elements:
Qt Code:
vector<QSpinBox> sb; sb.push_back(sbx); //errorTo copy to clipboard, switch view to plain text mode
Another Q: Wich is better (between 2 below)? Thanks
Qt Code:
vector<QSpinBox*> sbz; vector<QSpinBox> sbz;To copy to clipboard, switch view to plain text mode
Regards
You can't copy Qt widgets, so you can't have a vector of spin boxes. Use a vector of pointers instead.
if you referred to this, don't compile...
Qt Code:
vector<QSpinBox*> sbx; vector<QSpinBox*> sb; sb.push_back(sbx); //errorTo copy to clipboard, switch view to plain text mode
Maybe this?
Qt Code:
vector<QSpinBox**> sb; sb.push_back(&sbx[0]);To copy to clipboard, switch view to plain text mode
Last edited by mickey; 5th June 2006 at 00:44.
Regards
If you want a vector of vectors of pointers to spin boxes you need:Originally Posted by mickey
Qt Code:
vector<QSpinBox*> sbx; vector< vector<QSpinBox*> > sb; sb.push_back(sbx); // no errorTo copy to clipboard, switch view to plain text mode
mickey (5th June 2006)
Jacek,
How does that work again? When setting an object equal to another object in c++, it doesn't call the copy constructor, but rather the operator =, right? So in either case we can't "copy" widgets? That is, even when evoking the copy constructor?
widgets can't be copied! All you can use is a pointer (or a reference depending what you want to do, but a pointer is better anyway) to them that can be used to modify them.Originally Posted by kroenecker
Current Qt projects : QCodeEdit, RotiDeCode
Yes, you can't copy widgets, but here you have a vector of pointers to widgets.Originally Posted by kroenecker
Bookmarks