[SOLVED]Qvector Problem instansiate Thanks ALL
-
wrote on 21 Nov 2011, 10:50 last edited by
Try again with this code
I had comment the problem spots in the last code.
The new one is here
"Vectorproblems":http://rghost.net/31386231pls
-
wrote on 21 Nov 2011, 11:11 last edited by
toho71 either you have to read more about C++ or you did horrible typo. Here it is:
@myClass::~myClass()
{
delete this;
}@ -
wrote on 21 Nov 2011, 11:30 last edited by
copy and paste is the to magic words
Ok now it works again.I have to look in my header prj to and see if this is the magic case.
-
wrote on 21 Nov 2011, 11:59 last edited by
in my testcase i do like this in my constructor
@GlobalParams::GlobalParams()
{
testRunning(false);qDebug() << presetVector.isEmpty(); qDebug() << presetVector.size() << " vectorsize and kapacitet =" << presetVector.capacity(); //Create a tempobject for test ClPresetLoadsTestValues p(10,10,10); qDebug() << "create object "; presetVector.append(p); qDebug() << "appendat obj"; qDebug() << presetVector.size() << " vectorsize and kapacitet =" << presetVector.capacity();
}@
and I got this text in my consol
true
0 vectorsize and kapacitet = 0
create ClPresetLoadsTestValues
create object
delete ClPresetLoadsTestValues
appendat obj
1 vectorsize and kapacitet = 1
delete ClPresetLoadsTestValuesAnd later when I try to add a ClPresetLoadsTestValues my program crashes and NO i don't delete the object.
here is my object
@@ClPresetLoadsTestValues::ClPresetLoadsTestValues()
{
qDebug() << "create ClPresetLoadsTestValues";
}ClPresetLoadsTestValues::ClPresetLoadsTestValues(int k, int m, int s)
{
this->kw = k;
this->min = m;
this->sec = s;
qDebug() << "create ClPresetLoadsTestValues";
}ClPresetLoadsTestValues::~ClPresetLoadsTestValues()
{
qDebug() << "delete ClPresetLoadsTestValues";
}//set and getters
@and my func to add the obj
@void GlobalParams::addValuesToLoadsTestTemp(int kw, int min, int sec)
{
ClPresetLoadsTestValues p(kw,min,sec);qDebug() << "try to append"; qDebug() << this->presetVector.size() << " vektorstorlek"; //IT crashes here if (this->presetVector.isEmpty()) qDebug() << "Empty"; else qDebug() << "SIZE " << presetVector.size() ; presetVector.append(p); qDebug() << "appendad";
}
@
-
wrote on 21 Nov 2011, 12:05 last edited by
Can you make another tarball?
-
wrote on 21 Nov 2011, 12:07 last edited by
it gonna be big with many files but maybe only the files in the spec region and it will not compile.
I'll try -
wrote on 21 Nov 2011, 12:10 last edited by
You should provide only source files. Do not include object files (and autogenerated moc_, ui_, qrc_*) in the tarball.
-
wrote on 21 Nov 2011, 12:14 last edited by
Here it is
the two files with this problem
"myFiles":http://rghost.net/31396481 -
wrote on 21 Nov 2011, 13:05 last edited by
Please provide a
- complete
- compilable
- minimal
test case.
leave out
- intermediate object file (*.o)
- autogenerated stuff from moc and uic (moc_.cpp, ui_.h)
- Qt Creator user data (*.pro.user)
- the final executable
You're more likely to get an answer if the fellows trying to help here in the forums do not need to guess how to set up a correct test case and a project file.
-
wrote on 21 Nov 2011, 13:39 last edited by
Here is a full tested version with compiling.
I uploaded a small ex earlier
"MyApp":http://rghost.net/31409351 -
wrote on 21 Nov 2011, 15:22 last edited by
it works very well to append objects when I instantiates the object globalParam but later when I try to append some new objects later in the program it seems like the vector isn't there.
-
wrote on 27 Nov 2011, 21:39 last edited by
Unfortunately I can spend some time on it right now, but the archive is no longer available. Do you mind uploading it again, please?
-
wrote on 28 Nov 2011, 10:17 last edited by
Volker
I got it solved and it had a Nullpointer in another place so this worked fine but some dependent functions made some errors to this.
//T
28/31