Thursday, July 9, 2009

Cannot convert from QTstring to string in C++?

hello...............i hav ethis error : Error 1 error C2664:: cannot convert parameter 1 from 'QString' to 'const char *'





i have c function like this


prototype:





void LoadPPM( const char * , ppm *);





void Face_Detection::open()


{





ppm* image;


image = (ppm *) malloc (sizeof(ppm));


QString fileName = QFileDialog::getOpenFileName(this,


tr("Open File"), QDir::currentPath(),tr("Images (*.ppm)"));








LoadPPM(fileName,image);


}





void LoadPPM(const char *filename, ppm *pPpm ) {





FILE* ifp;


int word=0,word1=0,word2=0;


int nRead = 0;


char readChars[256];





//open the file, check if successful


ifp = fopen( filename, "r" );


if (!ifp) {


printf("Error: Unable to open file %s.\n\n", filename);


exit(1);


}





}


error in this line LoadPPM(fileName,image);


please help me

Cannot convert from QTstring to string in C++?
I'm not familiar with Qt, but is there a method of QString that returns a const char *? Perhaps ".c_str()"?

survey monkey

No comments:

Post a Comment