Dear visitor, welcome to QtForum.org.
If this is your first visit here, please read the Help. It explains in detail how this page works.
To use all features of this page, you should consider registering.
Please use the registration form, to register here or read more information about the registration process.
If you are already registered, please login here.
about qptrlist and qvaluelist
Hello for all.
I inside created a list with qptrlist of a function. How I make to inside have access the content of this list of another function?
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
class Node
{
public:
Node(long id, long nid, float x, float y, float z)
{
fid = id;
fnid = nid;
fx = x;
fy = y;
fz = z;
used = 0;
}
int used;
float fx, fy, fz;
long fid;
long fnid;
};
long cnvnodes()
{
QPtrList<Node> nodes;
nodes.append(new Node(nn, nrec, x, y, z));
}
long cnvelems()
{
int tn;
QPtrList<Node> nodes;
node = nodes.find(nodes.at(tn));
}
|
You are creating the QPtrList only inside a function and not return it in any point (the object is automatically destroyed in the function's end).
I recommend tha you change your functions to :
|
Source code
|
1
2
3
4
5
6
|
QPtrList<Node> cnvnodes()
{
QPtrList<Node> nodes;
nodes.append(new Node(nn, nrec, x, y, z));
return nodes;
}
|
The second function I think is redundant.
Mundus vult decipi, ergo decipiatur.
Thanks for help !!!