[Qt-interest] Where is the mistake ?

rafal skowroniasty at onet.pl
Mon Nov 16 10:33:01 CET 2009


Hi,  
I have some problem for this code: 

This is my class: 
-------------------8<--------------
#include "data.h"

#include <QString>

#include <QVector>

#include <QList>

#ifndef KASINSKI_H

#define KASINSKI_H

class Kasinski

{

private:

QString key; 

QVector <unsigned int> index; 

QList <Data> freq;

public:

Kasinski();

~Kasinski();

void getKey(int i, QString text);

void getAllIndex(QString text);

};

#endif // KASINSKI_H
------------------8<-------------------

and part of My *.cpp file with problematical methods:

--------------------8<-------------------------- //part of cpp file

void Kasinski::getKey(int i , QString text)

{

for(int j = 0; j<=i;j++)

{

this->key = text.left(i);  

if(key.count() !=i)

{

	qFatal("blad -key");

}

}

}

void Kasinski::getAllIndex(QString text)

{

if ( !key.isEmpty() && !key.isNull())

{

 qFatal("empty this->key!!!!");

 return;

}

int indeks = text.indexOf(key);

while( indeks != text.length())

{

index.append(indeks);

indeks= text.indexOf(key,indeks+ key.length());

}

}

-----------------8<-------------------------------


Problem: 
"key"  is member of this class,  
method getKey(int i , QString text) get first "i" (dafault :4)chars from
"text" string and put them to "key" (QString").

next i run getAllIndex(QString text), 
this method get all index of "key" value on "text" . ....  But this
method always return error "empty this->key!!!!"

I don't have any idea where I make mistake.  All this method operate on
this same object (this same class)

TIA for any reply

 
 




More information about the Qt-interest-old mailing list