Hi all;
I am tring to create a dynamic matrix of QString but I have not succed.
Are there any possibility to do it?
thanks
Hi all;
I am tring to create a dynamic matrix of QString but I have not succed.
Are there any possibility to do it?
thanks
power of mind > mind of power
Show us what you tried.
Would that do?
What it is you need it for?Qt Code:
QVector<QVecotr<QString> > stringMatrix;To copy to clipboard, switch view to plain text mode
May be what you need is a map?
Qt Code:
QVector<QVecotr<QString> > stringMatrix;To copy to clipboard, switch view to plain text mode![]()
Qt Code:
QVector<QVector<QString> > stringMatrix;To copy to clipboard, switch view to plain text mode
power of mind > mind of power
And.... what is the problem?
J-P Nurmi
I gave no 'solution', I marely made a suggestion, in trying to understand the problem.How can I (Read/Write) (from/to) element (i,j) according to your solution?
As Jpn hinted, what I suggested was a principal - which is why I asked what you need it for, since sometimes insted of string 'matrxes' string maps might be better, depending on needs.
If the principal of a 2D vector is good foryou , then making the wrapper class you got from qt-interest is trivial.
Oh, and reading/wiring to the bare QVector< QVector<QString> > is tright forword.
objs[i][j] = someString.
Resizing is offered by QVector. as you can see your self in the class you posted.
exectution failed ,debugger indicte:
![]()
power of mind > mind of power
what do you mean?exectution failed ,debugger indicte:
Segmentation fault, or compilation problem?
show your code
nothing in Q2Dvector.cppQt Code:
//Q2DVector.h #include <QVector> template <class type> class Q2DVector : public QVector< QVector<type> > { public: Q2DVector() : QVector< QVector<type> >(){}; Q2DVector(int rows, int columns) : QVector< QVector<type> >(rows) { for(int r=0; r<rows; r++) { this[r].resize(columns); } }; virtual ~Q2DVector() {}; }; typedef Q2DVector<QString> Q2DQStringVector; typedef Q2DVector<int> Q2DQIntVector;To copy to clipboard, switch view to plain text mode
Qt Code:
//main.cpp ... Q2DQStringVector myStringMatrix(P,Q); ... myStringMatrix[i][j]= someString; ...To copy to clipboard, switch view to plain text mode
I have got
Unhandled exception at 0x004244e0 in APP.exe: 0x80000001: Not implemented
Last edited by QiT; 3rd April 2007 at 15:12.
power of mind > mind of power
Oh right, you can't have a templete class that subclasses QObject.
any suggestion
![]()
power of mind > mind of power
I am now even able to do:Qt Code:
template <class type> class Q2DVector : public QVector< QVector<type> > { public: Q2DVector() : QVector< QVector<type> >(){}; Q2DVector(int rows, int columns) : QVector< QVector<type> >(rows) { for(int r=0; r<rows; r++) { this[r].resize(columns); } }; virtual ~Q2DVector() {}; }; typedef Q2DVector<QString> Q2DQStringVector;To copy to clipboard, switch view to plain text mode
Qt Code:
Q2DQStringVector my2DArray(4,10); my2DArray[1][5] = "thanks Robin Ericsson schrieb from qt-interest";To copy to clipboard, switch view to plain text mode
![]()
power of mind > mind of power
Bookmarks