Bonjour,
J'ai essay� d'utiliser Qt avec Visual Studio. J'ai une fonction de trouver toutes les images dans un directory. �a marche bien comme un "console project", mais quand j'ai cr�� le Qt projet, j'ai des fautes suivantes:
voil� les fonctions qui introduitent les probl�mes:
Code : S�lectionner tout - Visualiser dans une fen�tre � part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 1>.\Utils.cpp(38) : error C2664: 'FindFirstFileW' : impossible de convertir le paramètre 1 de 'const char *' en 'LPCWSTR' 1> Les types pointés n'ont aucun rapport entre eux ; conversion nécessitant reinterpret_cast, cast de style C ou cast de style fonction 1>.\Utils.cpp(44) : error C2664: 'strlen' : impossible de convertir le paramètre 1 de 'WCHAR [260]' en 'const char *' 1> Les types pointés n'ont aucun rapport entre eux ; conversion nécessitant reinterpret_cast, cast de style C ou cast de style fonction 1>.\Utils.cpp(44) : error C2664: 'CheckExtension' : impossible de convertir le paramètre 1 de 'WCHAR [260]' en 'const char *' 1> Les types pointés n'ont aucun rapport entre eux ; conversion nécessitant reinterpret_cast, cast de style C ou cast de style fonction 1>.\Utils.cpp(60) : error C2664: 'FindFirstFileW' : impossible de convertir le paramètre 1 de 'const char *' en 'LPCWSTR' 1> Les types pointés n'ont aucun rapport entre eux ; conversion nécessitant reinterpret_cast, cast de style C ou cast de style fonction 1>.\Utils.cpp(66) : error C2664: 'strlen' : impossible de convertir le paramètre 1 de 'WCHAR [260]' en 'const char *' 1> Les types pointés n'ont aucun rapport entre eux ; conversion nécessitant reinterpret_cast, cast de style C ou cast de style fonction 1>.\Utils.cpp(66) : error C2664: 'CheckExtension' : impossible de convertir le paramètre 1 de 'WCHAR [260]' en 'const char *' 1> Les types pointés n'ont aucun rapport entre eux ; conversion nécessitant reinterpret_cast, cast de style C ou cast de style fonction 1>.\Utils.cpp(68) : error C2664: 'strcpy' : impossible de convertir le paramètre 2 de 'WCHAR [260]' en 'const char *' 1> Les types pointés n'ont aucun rapport entre eux ; conversion nécessitant reinterpret_cast, cast de style C ou cast de style fonction
De plus j'ai essay� les deux " character set" :MBCS et Unicode , mais toujours marche pas......
Code : S�lectionner tout - Visualiser dans une fen�tre � part
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86 bool FindImagesInDirectory(const char *szDirectoryPath, char ***pszImgPaths, int *piNbImg) { int i; HANDLE hFind; WIN32_FIND_DATA data; // Initialize piNbImg *piNbImg = 0; // Looking for the first file of the directory if( (hFind = FindFirstFile(szDirectoryPath, &data))== INVALID_HANDLE_VALUE ) return false; // Count the number of valid file do { if( CheckExtension(data.cFileName, (int)strlen(data.cFileName) ) != 0) *piNbImg+=1; } while(FindNextFile(hFind, &data)); // Close the file FindClose(hFind); // If no file found => return ture if(*piNbImg == 0) return true; // Allocation of pszImgFilePaths; Alloc2DMem(pszImgPaths,*piNbImg); // Looking for the first file of the directory if( (hFind = FindFirstFile(szDirectoryPath, &data)) == INVALID_HANDLE_VALUE) return false; // Store all the valid images into pszImgFilePaths i=0; do{ if( CheckExtension(data.cFileName, (int)strlen(data.cFileName)) != 0 ) { strcpy((*pszImgPaths)[i],data.cFileName); i++; } } while(FindNextFile(hFind, &data)); FindClose(hFind); return true; } int CheckExtension(const char *szFileName, int iLenght) { const char *P=szFileName; while(*P!='\0') P++; //End of string if((int)(P-szFileName) > iLenght) //No '\0' in the string return 0; while(*P!='.') P--; P++; //Search for a dot if((int)(P-szFileName)<0)return 0; //if no dot if(strcmp(P,"jpg")==0 || strcmp(P,"JPG")==0 ) return 1; else if(strcmp(P,"bmp")==0 || strcmp(P,"BMP")==0 ) return 1; else if(strcmp(P,"tiff")==0|| strcmp(P,"TIFF")==0 ||strcmp(P,"tif")==0 || strcmp(P,"TIF")==0) return 1; else if(strcmp(P,"png")==0 || strcmp(P,"PNG")==0 ) return 1; else if(strcmp(P,"j2k")==0 || strcmp(P,"J2K")==0 ) return 1; else if(strcmp(P,"gif")==0 || strcmp(P,"GIF")==0 ) return 1; else if(strcmp(P,"WAV")==0 || strcmp(P,"wav")==0 ) return 1; return 0; }
Je vous remercie pour votre aides!!!
Xiaoming
Partager