[SOLVED]Qvector Problem instansiate Thanks ALL
-
I got a little confusing problem with one of my Vectors.
In my headerfile I set it up like this.
@QVector <ClPresetLoadsTestValues> presetVector;
@later when I want to use it i try to add some Object with append like this
@if (presetVector.isEmpty())
qDebug() << "Empty";
else
qDebug() << "SIZE " << presetVector.size() ;presetVector.append(p);
@
but my program crashes
I have tried to do like this also
@QVector <ClPresetLoadsTestValues>* presetVector;
@and then i my constructor using new but with the same result;
anyone??? -
My h.file
@#ifndef GLOBALPARAMS_H
#define GLOBALPARAMS_H
#include <QVector>
#include <QList>
#include <QTime>
#include <clpresetloadstestvalues.h>class GlobalParams
{
public:
GlobalParams();
~GlobalParams();
enum Tester {Starttest, Loadtest, Batterytest, ParallellToMains, MainsFailureTEst, PresetLoadsTest , Notest};void setTest(int); int getTest(); void testRunning(bool ); bool getTestRunning(); void setNBState(int s); void setGBState(int s); void setRunningState(int s); void setRunningMode(int s); int getNBState(); int getGBState(); int getRunningState(); int getRunningMode(); void addValuesToLoadsTestTemp(int,int,int); double getRandomNumbers(float max, float min); QString roundnumbers(double dNumber);
private:
int testTyp;int NBState; int GBState; int RunningState; int RunningMode; bool TestRunning; QVector <ClPresetLoadsTestValues> presetVector;
};
@in my cpp file
@void GlobalParams::addValuesToLoadsTestTemp(int kw, int min, int sec)
{
ClPresetLoadsTestValues p;
p.setKW(kw);
p.setMin(min);
p.setSec(sec);if (presetVector.isEmpty()) qDebug() << "Empty"; else qDebug() << "SIZE " << presetVector.size() ; presetVector.append(p); qDebug() << "appendad";
}
@
My h.file to the object I want to save
@class ClPresetLoadsTestValues
{
public:
ClPresetLoadsTestValues();
ClPresetLoadsTestValues(int k, int m, int s);
~ClPresetLoadsTestValues();//set
void setKW(int k);
void setMin(int k);
void setSec(int k);//get
int getKw();
int getMin();
int getSec();private:
int kw;
int min;
int sec;};
@
I tried with a Struct also but same crash -
I think that any file sharing hosting will be suitable. For example try http://rghost.net/
-
look for a file hoster (e.g. gitorious.org, but you need a logon) or any other
-
-
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