-
May 25th, 2009, 06:52 AM
#1
QT copy
Hi,
i have an issue with QT. Indeed, i try to make copies with, but i dont succeed. I use a splitter to choose the files which will be copied, at the moment it is *.*, it is to say all of them.
When i print on my widows application the path of the files to be copied, i get something like that :
c:\dir1\dir2\mydir\*.* and not the name of the files which should be replace thanks to *.* and of course no file have been copied.
Code:
#include <QApplication>
#include <QDirIterator>
#include <QWidget>
#include <QPushButton>
#include <QLCDNumber>
#include <QSlider>
#include <QLabel>
#include <QProgressBar>
#include <QMessageBox>
#include <windows.h>
#include <QFile>
#include <QString>
#include <QFileDialog>
#include <QObject>
#include <QStringList>
#include "fenetre.h"
#define WIDTH 75
#define SPACE 20
MaFenetre::MaFenetre() : QWidget()
{
// DIMENSION DE LA FENETRE
int ResX = (int)(0.33*GetSystemMetrics(SM_CXSCREEN));
int ResY = (int)(0.16*GetSystemMetrics(SM_CYSCREEN));
// ON FIXE LES DIMENSIONS POUR QUE LA FENETRE NE SOIT PLUS REDIMENSIONEE
setFixedSize(ResX, ResY);
// VARIABLE POUR LES CHEMINS DES DOSSIERS SUR LE PC DU TECHNICIEN
char S_XS [999];
char S_XS2 [999];
char S_D2A [999];
char S_EASY [999];
char S_ALCATEL [999];
char S_VOCALD6 [999];
char S_SAUVMATRA [999];
char S_MATRAPARALLELE[999];
// VARIABLE POUR LES CHEMINS DES DOSSIERS SUR LE RESEAU
char D_XS [999];
char D_XS2 [999];
char D_D2A [999];
char D_EASY [999];
char D_ALCATEL [999];
char D_VOCALD6 [999];
char D_SAUVMATRA [999];
char D_MATRAPARALLELE[999];
// VARIABLE CONTENANT LA COMMANDE DE COPIE
char COPY_XS [999];
char COPY_XS2 [999];
char COPY_D2A [999];
char COPY_EASY [999];
char COPY_ALCATEL [999];
char COPY_VOCALD6 [999];
char COPY_SAUVMATRA [999];
char COPY_MATRAPARALLELE[999];
// RECUPERATION DES CHEMIN SUR LE PC DU TECHNICIEN
GetPrivateProfileStringA("section", "S_XS" , "", S_XS , 999, ".//setup.ini");
GetPrivateProfileStringA("section", "S_XS2" , "", S_XS2 , 999, ".//setup.ini");
GetPrivateProfileStringA("section", "S_D2A" , "", S_D2A , 999, ".//setup.ini");
GetPrivateProfileStringA("section", "S_EASY" , "", S_EASY , 999, ".//setup.ini");
GetPrivateProfileStringA("section", "S_ALCATEL" , "", S_ALCATEL , 999, ".//setup.ini");
GetPrivateProfileStringA("section", "S_VOCALD6" , "", S_VOCALD6 , 999, ".//setup.ini");
GetPrivateProfileStringA("section", "S_SAUVMATRA" , "", S_SAUVMATRA , 999, ".//setup.ini");
GetPrivateProfileStringA("section", "S_MATRAPARALLELE", "", S_MATRAPARALLELE, 999, ".//setup.ini");
// RECUPERATION DES CHEMIN SUR LE RESEAU
GetPrivateProfileStringA("section", "D_XS" , "", D_XS , 999, ".//setup.ini");
GetPrivateProfileStringA("section", "D_XS2" , "", D_XS2 , 999, ".//setup.ini");
GetPrivateProfileStringA("section", "D_D2A" , "", D_D2A , 999, ".//setup.ini");
GetPrivateProfileStringA("section", "D_EASY" , "", D_EASY , 999, ".//setup.ini");
GetPrivateProfileStringA("section", "D_ALCATEL" , "", D_ALCATEL , 999, ".//setup.ini");
GetPrivateProfileStringA("section", "D_VOCALD6" , "", D_VOCALD6 , 999, ".//setup.ini");
GetPrivateProfileStringA("section", "D_SAUVMATRA" , "", D_SAUVMATRA , 999, ".//setup.ini");
GetPrivateProfileStringA("section", "D_MATRAPARALLELE", "", D_MATRAPARALLELE, 999, ".//setup.ini");
// TITRE
QLabel *titre = new QLabel("<SMALL><strong>SAUVEGARDE AUTOMATIQUES DES DONNEÉS</strong></SMALL>", this);
titre->move( (ResX - titre->minimumSizeHint().width())/2,0.1*ResY );
// AFFICHAGE DES BOUTONS
bouton0 = new QPushButton("ARRETER", this);
bouton1 = new QPushButton("QUITTER", this);
// POSITION DES BOUTONS DANS LA FENETRE
bouton0->setGeometry ( (int)((ResX-(2*WIDTH+SPACE))/2) , (int)(0.8*ResY), WIDTH, SPACE );
bouton1->setGeometry ( (int)((ResX-(2*WIDTH+SPACE))/2+WIDTH+SPACE), (int)(0.8*ResY), WIDTH, SPACE );
// BARRE DE PROGRESSION
QProgressBar *ProgressBar= new QProgressBar(this);
ProgressBar->setGeometry ( 0.1*ResX, 50, 0.8*ResX, 0.1*ResY );
ProgressBar->setRange( 0, 100 );
ProgressBar->setValue( 0 );
// On convertit le dossier source de type char vers QString
QString source=QString(S_XS);
// Opération de convertion Ã* trouver, on met le résultat dans la variable "source"
//QString source = "C:/MinGW/OTHER/projets C/QTPROJECT/debug/PABX/XS/";
// On convertit le dossier source de type char vers QString
// Opération de convertion Ã* trouver, on met le résultat dans la variable "destination"
QString destination = "C:/MinGW/OTHER/projets C/QTPROJECT/debug/SAVE/XS/";
// On se place dans le dossier dont on veut que les fichiers soient copiés
QDir::setCurrent(source);
// On choisit de copier tous les types de fichiers
QStringList filtre;
filtre << "*.*";
// On récupère le nombre de fichiers contenu dans le filtre
int nombre_de_fichiers=filtre.size();
// Variable qui va stocker le nom du fichier en cours
QString nom_du_fichier;
// On fait une boucle pour parcourir tous les fichiers contenus dans le dossier
int i;
for ( i=0 ; i < nombre_de_fichiers ; i++ )
{
// On récupère les noms de fichiers dans la liste
nom_du_fichier = filtre.at(i);
// On concatène le chemin source avec le nom du fichier
source+=nom_du_fichier;
// On concatène le chemin destination avec le nom du fichier
destination+=nom_du_fichier;
QLabel *test = new QLabel(" source : " + source, this);
titre->move( (ResX - titre->minimumSizeHint().width())/2,0.2*ResY );
// On spécifie le chemin source du fichier Ã* copier
QFile file(source);
// On spécifie le chemin destination du fichier Ã* copier
file.copy(destination);
}
ProgressBar->setValue( 100 );
// SIGNAUX
QObject::connect(bouton0, SIGNAL(clicked()) , qApp, SLOT( aboutQt() ) );
QObject::connect(bouton1, SIGNAL(clicked()) , qApp, SLOT( quit() ) );
}
I have no idea where the problem is comin from, so i beg you to help me
Thank you
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|