IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Qt Discussion :

Faire de la copie de dossier sous Qt


Sujet :

Qt

  1. #41
    Membre averti

    Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2006
    Messages
    281
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2006
    Messages : 281
    Points : 356
    Points
    356
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    // 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();
    C'est normal que ça renvoi "1", étant donné qu'il est demandé non pas le résultat d'un filtre, mais le nombre de filtres.

    Il manque quelque chose du genre :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    QDir dirSource(S_XS);
    int nombre_de_fichiers = dirSource.entryList(filtre).size();
    voir la doc : http://qt.developpez.com/doc/4.5/qdir/#entrylist

  2. #42
    Membre confirmé
    Homme Profil pro
    Etudiant administrateur systèmes et réseaux
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Etudiant administrateur systèmes et réseaux

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Points : 467
    Points
    467
    Par défaut
    Voilà ce que j'obtiens en remplaçant les lignes de codes, merci windows...



    Je suis pas sûr d'avoir tout compris parce que j'avoue avoir du mal à lire leur documentation.

    QFileInfoList QDir::entryInfoList ( const QStringList & nameFilters, Filters filters = NoFilter, SortFlags sort = NoSort ) const
    Returns a list of QFileInfo objects for all the files and directories in the directory, ordered according to the name and attribute filters previously set with setNameFilters() and setFilter(), and sorted according to the flags set with setSorting().

    The name filter, file attribute filter, and sorting specification can be overridden using the nameFilters, filters, and sort arguments.

    Returns an empty list if the directory is unreadable, does not exist, or if nothing matches the specification.

    See also entryList(), setNameFilters(), setSorting(), setFilter(), isReadable(), and exists().

    Retourne une liste d'objets de type QFileInfo pour tous les sous-répertoires et fichiers du répertoire en question, rangés selon leur nom et les options du filtre, precedement définit avec setNameFilters() et setFilter(), et precedement rangés selon les drapeaux de setSorting().

    Si j'ai bien compris setNameFilters, c'est pour définir plusieurs filtres dans le filtre (lol) au répertoire qu'on a choisit de filtrer ?
    donc j'ai rajouté dirSource.setNameFilters(filtre) après le filtre << "*.*", mais toujours la même erreur.

    Pour SetFilters j'ai l'impression que c'est à peu près la même chose mais comme vous pouvez le constater mon niveau d'anglais n'est pas génial alors je ne suis pas trop sur de ce que je raconte.

    Et les options de tri, je ne vais pas m'en occuper pour le moment, il faudrait déjà que cela fonctionne.
    UNE REPONSE UTILE : &|| UN PROBLEME RESOLU :

  3. #43
    Membre confirmé
    Homme Profil pro
    Etudiant administrateur systèmes et réseaux
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Etudiant administrateur systèmes et réseaux

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Points : 467
    Points
    467
    Par défaut
    y'a rien à faire j'ai toujours cette vilaine erreur, moi qui avait l'impression qu'on touchait presque au but
    UNE REPONSE UTILE : &|| UN PROBLEME RESOLU :

  4. #44
    yan
    yan est déconnecté
    Rédacteur
    Avatar de yan
    Homme Profil pro
    Ingénieur expert
    Inscrit en
    Mars 2004
    Messages
    10 033
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Ingénieur expert
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mars 2004
    Messages : 10 033
    Points : 13 968
    Points
    13 968
    Par défaut
    C'est dés que tu lance l'appli? au démarrage?

  5. #45
    Membre confirmé
    Homme Profil pro
    Etudiant administrateur systèmes et réseaux
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Etudiant administrateur systèmes et réseaux

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Points : 467
    Points
    467
    Par défaut
    Dès que je lance l'appli oui. Mais pas necessairement au démarrage, juste quand je l'execute normalement. Il me manquerait une bibliothèque VC++ ou un MSFK ?

    J'ai installé (re) VC++ 2008 et j'ai toujours l'erreur.
    UNE REPONSE UTILE : &|| UN PROBLEME RESOLU :

  6. #46
    yan
    yan est déconnecté
    Rédacteur
    Avatar de yan
    Homme Profil pro
    Ingénieur expert
    Inscrit en
    Mars 2004
    Messages
    10 033
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Ingénieur expert
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mars 2004
    Messages : 10 033
    Points : 13 968
    Points
    13 968
    Par défaut
    Citation Envoyé par darkwall_37 Voir le message
    Dès que je lance l'appli oui. Mais pas necessairement au démarrage, juste quand je l'execute normalement. Il me manquerait une bibliothèque VC++ ou un MSFK ?
    Si tu as ton appli qui est lancé avant ce message (ihm visible), tu as sûrement un bug mémoire. Comme un pointeur non initialisé ou autre. Essaie de voir avec un débugguer

  7. #47
    Membre confirmé
    Homme Profil pro
    Etudiant administrateur systèmes et réseaux
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Etudiant administrateur systèmes et réseaux

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Points : 467
    Points
    467
    Par défaut
    Je vais essayer xD.

    Mais l'erreur survient quand je mets la ligne de code un peu plus haut, donc je ne pense pas que ce la vienne d'un pointeur.
    UNE REPONSE UTILE : &|| UN PROBLEME RESOLU :

  8. #48
    yan
    yan est déconnecté
    Rédacteur
    Avatar de yan
    Homme Profil pro
    Ingénieur expert
    Inscrit en
    Mars 2004
    Messages
    10 033
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Ingénieur expert
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mars 2004
    Messages : 10 033
    Points : 13 968
    Points
    13 968
    Par défaut
    Citation Envoyé par darkwall_37 Voir le message
    Je vais essayer xD.

    Mais l'erreur survient quand je mets la ligne de code un peu plus haut, donc je ne pense pas que ce la vienne d'un pointeur.
    C'est le problème d'un bug mémoire. Ca plante pas toujours. Une ligne de code peut tout changer.
    Sinon, si tu peut faire un code minimal que l'on peut compiler, on pourra sûrement t'aider plus facilement.

  9. #49
    Membre confirmé
    Homme Profil pro
    Etudiant administrateur systèmes et réseaux
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Etudiant administrateur systèmes et réseaux

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Points : 467
    Points
    467
    Par défaut
    Ok, je vais essayer d'enlever le superflu.

    FENETRE.H
    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
    #ifndef DEF_MAFENETRE
    #define DEF_MAFENETRE
     
    #include <QApplication>
    #include <QWidget>
    #include <QPushButton>
    #include <QLCDNumber>
    #include <QSlider>
    #include <QInputDialog>
     
     
    class MaFenetre : public QWidget // On hérite de QWidget (IMPORTANT)
    {
        Q_OBJECT  
     
        public:
        MaFenetre();
     
        public slots:
     
        private:
     
    };
     
    #endif

    FENETRE.CPP
    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
    #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 <QDebug>
    #include "fenetre.h"
     
    #define WIDTH 75
    #define SPACE 20
     
    MaFenetre::MaFenetre() : QWidget()
    {
     
     
        // ON FIXE LES DIMENSIONS POUR QUE LA FENETRE NE SOIT PLUS REDIMENSIONEE
        setFixedSize(100, 30);
     
        //affichage du chemin source
        QLabel *test = new QLabel(" CODE MINIMALISE ", this);
     
        //
        QString source="c:/A/";
        QString destination="c:/B/";
     
        // On se place dans le dossier dont on veut que les fichiers soient copiés
        QDir dirSource(source);
     
        // On choisit de copier tous les types de fichiers
        QStringList filtre;
        filtre << "*.*";
        dirSource.setNameFilters(filtre);
     
        // On récupère le nombre de fichiers contenu dans le filtre
        int nombre_de_fichiers = dirSource.entryList().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;
     
     
     
                  // On spécifie le chemin source du fichier à copier
                  QFile file(source);
     
                  // On spécifie le chemin destination du fichier à copier
                  file.copy(destination);
            }
     
    }
    MAIN.CPP

    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
    #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 "fenetre.h"
     
     
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
     
           MaFenetre main_windows; 
     
           main_windows.show();
     
        return app.exec();
    }
    Voilà je peux pas réduire plus que ça, j'éspère que c'est suffisant.

    A tout hasard je joins quand même les fichiers originaux
    Fichiers attachés Fichiers attachés
    UNE REPONSE UTILE : &|| UN PROBLEME RESOLU :

  10. #50
    Membre confirmé
    Homme Profil pro
    Etudiant administrateur systèmes et réseaux
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Etudiant administrateur systèmes et réseaux

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Points : 467
    Points
    467
    Par défaut
    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
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    #############################################################################
    # Makefile for building: QTPROJECT
    # Generated by qmake (2.01a) (Qt 4.5.0) on: lun. 25. mai 15:46:14 2009
    # Project:  QTPROJECT.pro
    # Template: app
    #############################################################################
     
    ####### Compiler, tools and options
     
    CC            = gcc
    CXX           = g++
    DEFINES       = -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN
    CFLAGS        = -g -Wall $(DEFINES)
    CXXFLAGS      = -g -frtti -fexceptions -mthreads -Wall $(DEFINES)
    INCPATH       = -I"..\..\QT\include\QtCore" -I"..\..\QT\include\QtGui" -I"..\..\QT\include" -I"." -I"..\..\QT\include\ActiveQt" -I"debug" -I"." -I"..\..\QT\mkspecs\win32-g++"
    LINK        =        g++
    LFLAGS        =        -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows
    LIBS        =        -L"c:\MinGW\OTHER\QT\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4
    QMAKE         = c:\MinGW\OTHER\QT\bin\qmake.exe
    IDC           = c:\MinGW\OTHER\QT\bin\idc.exe
    IDL           = midl
    ZIP           = zip -r -9
    DEF_FILE      = 
    RES_FILE      = 
    COPY          = copy /y
    COPY_FILE     = $(COPY)
    COPY_DIR      = xcopy /s /q /y /i
    DEL_FILE      = del
    DEL_DIR       = rmdir
    MOVE          = move
    CHK_DIR_EXISTS= if not exist
    MKDIR         = mkdir
    INSTALL_FILE    = $(COPY_FILE)
    INSTALL_PROGRAM = $(COPY_FILE)
    INSTALL_DIR     = $(COPY_DIR)
     
    ####### Output directory
     
    OBJECTS_DIR   = debug
     
    ####### Files
     
    SOURCES       = fenetre.cpp \
    		main.cpp debug\moc_fenetre.cpp
    OBJECTS       = debug/fenetre.o \
    		debug/main.o \
    		debug/moc_fenetre.o
    DIST          = 
    QMAKE_TARGET  = QTPROJECT
    DESTDIR        = debug\ #avoid trailing-slash linebreak
    TARGET         = QTPROJECT.exe
    DESTDIR_TARGET = debug\QTPROJECT.exe
     
    ####### Implicit rules
     
    .SUFFIXES: .cpp .cc .cxx .c
     
    .cpp.o:
    	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
     
    .cc.o:
    	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
     
    .cxx.o:
    	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
     
    .c.o:
    	$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
     
    ####### Build rules
     
    first: all
    all: Makefile.Debug  $(DESTDIR_TARGET)
     
    $(DESTDIR_TARGET):  $(OBJECTS) 
    	$(LINK) $(LFLAGS) -o $(DESTDIR_TARGET) $(OBJECTS)  $(LIBS)
     
     
    qmake:  FORCE
    	@$(QMAKE) -win32 -o Makefile.Debug QTPROJECT.pro
     
    dist:
    	$(ZIP) QTPROJECT.zip $(SOURCES) $(DIST) QTPROJECT.pro ..\..\QT\mkspecs\qconfig.pri ..\..\QT\mkspecs\features\qt_functions.prf ..\..\QT\mkspecs\features\qt_config.prf ..\..\QT\mkspecs\features\exclusive_builds.prf ..\..\QT\mkspecs\features\default_pre.prf ..\..\QT\mkspecs\features\win32\default_pre.prf ..\..\QT\mkspecs\features\debug.prf ..\..\QT\mkspecs\features\debug_and_release.prf ..\..\QT\mkspecs\features\default_post.prf ..\..\QT\mkspecs\features\win32\default_post.prf ..\..\QT\mkspecs\features\build_pass.prf ..\..\QT\mkspecs\features\win32\rtti.prf ..\..\QT\mkspecs\features\win32\exceptions.prf ..\..\QT\mkspecs\features\win32\stl.prf ..\..\QT\mkspecs\features\shared.prf ..\..\QT\mkspecs\features\warn_on.prf ..\..\QT\mkspecs\features\qt.prf ..\..\QT\mkspecs\features\win32\thread.prf ..\..\QT\mkspecs\features\moc.prf ..\..\QT\mkspecs\features\win32\windows.prf ..\..\QT\mkspecs\features\resources.prf ..\..\QT\mkspecs\features\uic.prf ..\..\QT\mkspecs\features\yacc.prf ..\..\QT\mkspecs\features\lex.prf c:\MinGW\OTHER\QT\lib\qtmaind.prl  HEADERS RESOURCES IMAGES SOURCES OBJECTIVE_SOURCES FORMS YACCSOURCES YACCSOURCES LEXSOURCES 
     
    clean: compiler_clean 
    	-$(DEL_FILE) debug\fenetre.o debug\main.o debug\moc_fenetre.o
     
    distclean: clean
    	-$(DEL_FILE) $(DESTDIR_TARGET)
    	-$(DEL_FILE) Makefile.Debug
     
    mocclean: compiler_moc_header_clean compiler_moc_source_clean
     
    mocables: compiler_moc_header_make_all compiler_moc_source_make_all
     
    compiler_moc_header_make_all: debug/moc_fenetre.cpp
    compiler_moc_header_clean:
    	-$(DEL_FILE) debug\moc_fenetre.cpp
    debug/moc_fenetre.cpp: fenetre.h
    	C:\MinGW\OTHER\QT\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 fenetre.h -o debug\moc_fenetre.cpp
     
    compiler_rcc_make_all:
    compiler_rcc_clean:
    compiler_image_collection_make_all: qmake_image_collection.cpp
    compiler_image_collection_clean:
    	-$(DEL_FILE) qmake_image_collection.cpp
    compiler_moc_source_make_all:
    compiler_moc_source_clean:
    compiler_uic_make_all:
    compiler_uic_clean:
    compiler_yacc_decl_make_all:
    compiler_yacc_decl_clean:
    compiler_yacc_impl_make_all:
    compiler_yacc_impl_clean:
    compiler_lex_make_all:
    compiler_lex_clean:
    compiler_clean: compiler_moc_header_clean 
     
     
     
    ####### Compile
     
    debug/fenetre.o: fenetre.cpp fenetre.h
    	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\fenetre.o fenetre.cpp
     
    debug/main.o: main.cpp fenetre.h
    	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\main.o main.cpp
     
    debug/moc_fenetre.o: debug/moc_fenetre.cpp 
    	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_fenetre.o debug\moc_fenetre.cpp
     
    ####### Install
     
    install:   FORCE
     
    uninstall:   FORCE
     
    FORCE:
    Résultat du debug, je ne sais pas si cela peut aider.

    j'ai fais un debug release et cela ne marche pas non plus.
    UNE REPONSE UTILE : &|| UN PROBLEME RESOLU :

  11. #51
    yan
    yan est déconnecté
    Rédacteur
    Avatar de yan
    Homme Profil pro
    Ingénieur expert
    Inscrit en
    Mars 2004
    Messages
    10 033
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Ingénieur expert
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mars 2004
    Messages : 10 033
    Points : 13 968
    Points
    13 968
    Par défaut
    Voila ton problème
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    int nombre_de_fichiers = dirSource.entryList().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);
    le nombre_de_fichiers ne correspond pas au nombre contenue dans filtre => tu essai d'accéder à des données inexistante

  12. #52
    Membre confirmé
    Homme Profil pro
    Etudiant administrateur systèmes et réseaux
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Etudiant administrateur systèmes et réseaux

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Points : 467
    Points
    467
    Par défaut
    oui je l'avais déjà modifié ( j'ai oublié de le faire ici ) mais j'ai toujours la même erreur.

    QT ou comment devenir fou !
    UNE REPONSE UTILE : &|| UN PROBLEME RESOLU :

  13. #53
    yan
    yan est déconnecté
    Rédacteur
    Avatar de yan
    Homme Profil pro
    Ingénieur expert
    Inscrit en
    Mars 2004
    Messages
    10 033
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Ingénieur expert
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mars 2004
    Messages : 10 033
    Points : 13 968
    Points
    13 968
    Par défaut
    Citation Envoyé par darkwall_37 Voir le message
    oui je l'avais déjà modifié ( j'ai oublié de le faire ici ) mais j'ai toujours la même erreur.

    QT ou comment devenir fou !
    Tu doit avoir lemême style d'erreur autre part

  14. #54
    Membre confirmé
    Homme Profil pro
    Etudiant administrateur systèmes et réseaux
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Etudiant administrateur systèmes et réseaux

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Points : 467
    Points
    467
    Par défaut
    Voilà c'est bon ça marche. Je vais pourvoir passer à la partie thread et m'occuper des progressbar.



    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
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    #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 <QDebug>
    #include "fenetre.h"
     
    #define WIDTH 75
    #define SPACE 20
    MaFenetre::MaFenetre() : QWidget()
    {
     
    	// DIMENSION DE LA FENETRE
    	int ResX = (int)(0.66*GetSystemMetrics(SM_CXSCREEN));
    	int ResY = (int)(0.32*GetSystemMetrics(SM_CYSCREEN));
     
    	// ON FIXE LES DIMENSIONS POUR QUE LA FENETRE NE SOIT PLUS REDIMENSIONEE
    	setFixedSize(ResX, ResY);
     
    	// VARIABLES STOCKANT LES CHEMINS DES DOSSIERS DU PC DU TECHNICIEN
    	char S_XS[999], S_XS2[999], S_D2A[999], S_EASY[999], S_ALCATEL[999], S_VOCALD6[999], S_SAUVMATRA[999], S_MATRAPARALLELE[999];
     
    	// VARIABLE STOCKANT LES CHEMINS DES DOSSIERS DU RESEAU
    	char D_XS[999], D_XS2[999], D_D2A[999], D_EASY[999], D_ALCATEL[999], D_VOCALD6[999], D_SAUVMATRA[999], D_MATRAPARALLELE[999];
     
    	// STOCKAGE DES CHEMINS DES DOSSIERS DU 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");
     
    	// STOCKAGE DES CHEMINS DES DOSSIERS DU 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.05*ResY );
     
    	// AFFICHAGE DES BOUTONS 
    	bouton0 = new QPushButton("STOP", this);
    	bouton1 = new QPushButton("  OK", this);
     
    	// POSITION DES BOUTONS DANS LA FENETRE
    	bouton0 -> setGeometry( (int)((ResX-(2*WIDTH+SPACE))/2            ),  (int)(0.9*ResY), WIDTH, SPACE );
    	bouton1 -> setGeometry( (int)((ResX-(2*WIDTH+SPACE))/2+WIDTH+SPACE),  (int)(0.9*ResY), WIDTH, SPACE );
     
    	// BARRE DE PROGRESSION GENERALE
    	QProgressBar *progression_generale = new QProgressBar(this);
    	progression_generale -> setGeometry( 0.125*ResX, 0.2*ResY, 0.75*ResX, 0.075*ResY );
    	progression_generale -> setRange   (                      0,      100 ); 
    	progression_generale -> setValue   (                                0 );
     
    	// BARRE DE PROGRESSION DU FICHIER EN COURS DE COPIE
    	QProgressBar *progression_counrante = new QProgressBar(this);
    	progression_counrante -> setGeometry( 0.125*ResX, 0.3*ResY, 0.75*ResX, 0.075*ResY );
    	progression_counrante -> setRange   (                      0,      100 ); 
    	progression_counrante -> setValue   (                                0 );
     
    	// init
     
    	affichage_source = new QLabel(this);
    	affichage_destination = new QLabel(this);
    	affiche_taille = new QLabel(this);
    	affichage_courant = new QLabel(this);
     
        // CONVERSION EN QSTRING DES VARIABLES DE TYPE CHAR
            QString source      = QString(S_XS);
            QString destination = QString(D_XS); 
     
     
    	// ON SE PLACE DANS LE DOSSIER DONT ON VEUT QUE LES FICHIERS SOIENT COPIES
    	QDir::setCurrent(source);
    	QDir  dirSource (source);
     
    	// CREATION D'UN FILTRE SUR LES EXTENSIONS, ON COPIE TOUS LES FICHIERS POUR LE MOMENT
    	QStringList filtre;
    	filtre << "*.*";
    	dirSource.setNameFilters(filtre);
     
    	// ON RECUPERE LE NOMBRE DE FICHIERS CONTENU DANS LE FILTRE ET DONC DANS LE DOSSIER
    	int nombre_de_fichiers = dirSource.count();
     
    	// VARIABLE QUI STOCKE LE NOM DU FICHIER EN COURS DE COPIE 
    	QString nom_du_fichier;
     
    	// ON BOUCLE SUR LE NOMBRE DE FICHIERS CONTENU DANS LE REPERTOIRE POUR TOUT COPIER
    	int i;
    	for ( i=0 ; i < nombre_de_fichiers ; i++ )
    	{
    		QString sourcefile;
    		QString destinationfile;
    		// ON RECUPERE LES NOMS DES FICHIERS CONTENU DANS LE FILTRE ET ON LES STOCKENT DANS LA VARIABLE PREVUE A CETTE EFFET
    		nom_du_fichier = dirSource.entryList(filtre).at(i);
    		if (nom_du_fichier != "." && nom_du_fichier != ".." )
    		{
    			// ON CONCATENE LES CHEMINS SOURCE ET DESTINATIONS AVEC LE NOM DE FICHIER EN COURS POUR LE PASSER A LA FONCTION DE COPIE
    			sourcefile = source + nom_du_fichier;
    			destinationfile = destination + nom_du_fichier;
     
    			// AFFICHAGE D'INFORMATIONS CONCERNANT LE FICHIER EN COURS DE COPIE
     
    			// AFFICHAGE DU CHEMIN SOURCE/DESTINATION CONCATENE AVEC LE NOM DU FICHIER EN COURS DE COPIE  
    			affichage_source->setText(" <small><strong>SOURCE      :</strong></small> " + sourcefile);
    			affichage_destination->setText(" <small><strong>DESTINATION :</strong></small> " + destinationfile);
    			affichage_source->move( (ResX - affichage_source->minimumSizeHint().width())/2, 0.45*ResY );
    			affichage_destination->move( (ResX - affichage_destination->minimumSizeHint().width())/2, 0.55*ResY );
     
    			// NOM DU FICHIER EN COURS DE COPIE
    			affichage_courant->setText(" <small><strong>EN COURS :</strong></small> " + nom_du_fichier);
    			affichage_courant -> move( (ResX - affichage_courant->minimumSizeHint().width())/2,0.65*ResY );
     
    			// TAILLE EN MO DU FICHIER EN COURS DE COPIE
    			QFileInfo fi(sourcefile);
    			QString   Qtaille        = QString::number(fi.size() / 1024);
    			affiche_taille->setText("<small><strong>TAILLE :</strong></small> " + Qtaille + " Ko");
    			affiche_taille -> move( (ResX - affiche_taille->minimumSizeHint().width())/2,0.75*ResY );
     
    			//nombre de fichiers dans la liste
    			//QString nombre="";
    			//nombre=QString::number(nombre_de_fichiers);
    			//QLabel *test2 = new QLabel(" nombre de fichiers : " + nombre, this);
    			//test2->move( (ResX - test2->minimumSizeHint().width())/2,0.675*ResY );
     
    			// ON EFFECTUER LA COPIE
    			QFile file(sourcefile);
    			file.copy(destinationfile);
    		}
    	}
     
     
    	// SIGNAUX   
    	QObject::connect(bouton0, SIGNAL(clicked()) , qApp, SLOT( aboutQt() ) );
    	QObject::connect(bouton1, SIGNAL(clicked()) , qApp, SLOT( quit   () ) );
     
     
    }
    UNE REPONSE UTILE : &|| UN PROBLEME RESOLU :

  15. #55
    Membre éprouvé

    Profil pro
    Inscrit en
    Mai 2007
    Messages
    774
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France, Finistère (Bretagne)

    Informations forums :
    Inscription : Mai 2007
    Messages : 774
    Points : 969
    Points
    969
    Par défaut
    Et quel était le problème ?

    G.
    Un problème avec Qt ? Vous trouverez votre réponse ici : http://doc.trolltech.com/4.6/overviews.html
    En français (traduction réalisée par l'équipe Qt de DVP) : http://qt.developpez.com/doc/4.6/vues-d-ensemble/

  16. #56
    Membre confirmé
    Homme Profil pro
    Etudiant administrateur systèmes et réseaux
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Etudiant administrateur systèmes et réseaux

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Points : 467
    Points
    467
    Par défaut
    J'instanciais des QLabel dans la boucle de copie...

    Sinon j'ai pas mal avancé je crois.
    J'ai fais une fonction de copie, une fonction pour récupérer les données concernant la taille des fichiers et puis la mise à jour de la progressbar.

    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
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
     
    #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 <QDebug>
    #include "fenetre.h"
     
    #define WIDTH 75
    #define SPACE 20
     
    qint64 supercopy( char *src, char *dst, QLabel *affichage_taille_totale, QLabel *affichage_source, QLabel *affichage_destination, QLabel *affiche_taille, QLabel *affichage_courant, int ResX, int ResY, QString Qtaille_totale, qint64 progression );
    qint64 taille(char *path);
     
    MaFenetre::MaFenetre() : QWidget()
    {
    	// DIMENSION DE LA FENETRE
    	int ResX = (int)(0.66*GetSystemMetrics(SM_CXSCREEN));
    	int ResY = (int)(0.32*GetSystemMetrics(SM_CYSCREEN));
     
    	// ON FIXE LES DIMENSIONS POUR QUE LA FENETRE NE SOIT PLUS REDIMENSIONEE
    	setFixedSize(ResX, ResY);
     
    	// VARIABLES STOCKANT LES CHEMINS DES DOSSIERS DU PC DU TECHNICIEN
    	char S_XS[999], S_XS2[999], S_D2A[999], S_EASY[999], S_ALCATEL[999], S_VOCALD6[999], S_SAUVMATRA[999], S_MATRAPARALLELE[999];
     
    	// VARIABLE STOCKANT LES CHEMINS DES DOSSIERS DU RESEAU
    	char D_XS[999], D_XS2[999], D_D2A[999], D_EASY[999], D_ALCATEL[999], D_VOCALD6[999], D_SAUVMATRA[999], D_MATRAPARALLELE[999];
     
    	// STOCKAGE DES CHEMINS DES DOSSIERS DU 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");
     
    	// STOCKAGE DES CHEMINS DES DOSSIERS DU 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");
     
        // TAILLE TOTALE DE LE COPIE
    	qint64 taille_totale=taille(S_XS)+taille(S_XS2)+taille(S_D2A)+taille(S_EASY)+taille(S_ALCATEL)+taille(S_VOCALD6)+taille(S_SAUVMATRA)+taille(S_MATRAPARALLELE);
        QString Qtaille_totale = QString::number(taille_totale);
     
        // TITRE
    	QLabel *titre = new QLabel("<SMALL><strong>SAUVEGARDE AUTOMATIQUES DES DONNEÉS</strong></SMALL>", this);
    	titre -> move( (ResX - titre->minimumSizeHint().width())/2, 0.05*ResY );
     
    	// AFFICHAGE DES BOUTONS 
    	bouton0 = new QPushButton("STOP", this);
    	bouton1 = new QPushButton("  OK", this);
     
    	// POSITION DES BOUTONS DANS LA FENETRE
    	bouton0 -> setGeometry( (int)((ResX-(2*WIDTH+SPACE))/2            ),  (int)(0.9*ResY), WIDTH, SPACE );
    	bouton1 -> setGeometry( (int)((ResX-(2*WIDTH+SPACE))/2+WIDTH+SPACE),  (int)(0.9*ResY), WIDTH, SPACE );
     
    	// BARRE DE PROGRESSION GENERALE
    	QProgressBar *progression_generale = new QProgressBar(this);
    	progression_generale -> setGeometry( 0.125*ResX, 0.2*ResY, 0.75*ResX, 0.075*ResY );
    	progression_generale -> setRange   (                               0,        100 ); 
    	progression_generale -> setValue   (                                           0 );
     
    	// INITIALISATION DES QLABELS
        affichage_source          = new QLabel(this);
    	affichage_destination     = new QLabel(this);
    	affiche_taille            = new QLabel(this);
    	affichage_courant         = new QLabel(this);
    	affichage_taille_courante = new QLabel(this);
     
    	qint64 progression;
     
    	//COPIE DES DOSSIERS
        progression=supercopy( S_XS            , D_XS            , affichage_taille_courante, affichage_source, affichage_destination, affiche_taille, affichage_courant, ResX, ResY, Qtaille_totale, 0 );
        progression_generale -> setValue ( (int)(progression) );
    	progression=supercopy( S_XS2           , D_XS2           , affichage_taille_courante, affichage_source, affichage_destination, affiche_taille, affichage_courant, ResX, ResY, Qtaille_totale, progression );
        progression_generale -> setValue ( (int)(progression) );
        progression=supercopy( S_D2A           , D_D2A           , affichage_taille_courante, affichage_source, affichage_destination, affiche_taille, affichage_courant, ResX, ResY, Qtaille_totale, progression );
    	progression_generale -> setValue ( (int)(progression) );
        progression=supercopy( S_EASY          , D_EASY          , affichage_taille_courante, affichage_source, affichage_destination, affiche_taille, affichage_courant, ResX, ResY, Qtaille_totale, progression );
        progression_generale -> setValue ( (int)(progression) );
        progression=supercopy( S_ALCATEL       , D_ALCATEL       , affichage_taille_courante, affichage_source, affichage_destination, affiche_taille, affichage_courant, ResX, ResY, Qtaille_totale, progression );
    	progression_generale -> setValue ( (int)(progression) );
        progression=supercopy( S_VOCALD6       , D_VOCALD6       , affichage_taille_courante, affichage_source, affichage_destination, affiche_taille, affichage_courant, ResX, ResY, Qtaille_totale, progression );
        progression_generale -> setValue ( (int)(progression) );
        progression=supercopy( S_SAUVMATRA     , D_SAUVMATRA     , affichage_taille_courante, affichage_source, affichage_destination, affiche_taille, affichage_courant, ResX, ResY, Qtaille_totale, progression );
        progression_generale -> setValue ( (int)(progression) );
        progression=supercopy( S_MATRAPARALLELE, D_MATRAPARALLELE, affichage_taille_courante, affichage_source, affichage_destination, affiche_taille, affichage_courant, ResX, ResY, Qtaille_totale, progression );
    	progression_generale -> setValue ( 100 );
     
        // SIGNAUX   
    	QObject::connect(bouton0, SIGNAL(clicked()) , qApp, SLOT( aboutQt() ) );
    	QObject::connect(bouton1, SIGNAL(clicked()) , qApp, SLOT( quit   () ) );
    }
     
    qint64 supercopy( char *src, char *dst, QLabel *affichage_taille_courante, QLabel *affichage_source, QLabel *affichage_destination, QLabel *affiche_taille, QLabel *affichage_courant, int ResX, int ResY, QString Qtaille_totale, qint64 progression )
    {
         // CONVERSION EN QSTRING DES VARIABLES DE TYPE CHAR
        QString source      = QString(src);
        QString destination = QString(dst); 
     
        // ON SE PLACE DANS LE DOSSIER DONT ON VEUT QUE LES FICHIERS SOIENT COPIES
    	QDir::setCurrent(source);
    	QDir  dirSource (source);
     
    	// CREATION D'UN FILTRE SUR LES EXTENSIONS, ON COPIE TOUS LES FICHIERS POUR LE MOMENT
    	QStringList filtre;
    	filtre << "*.*";
    	dirSource.setNameFilters(filtre);
     
    	// ON RECUPERE LE NOMBRE DE FICHIERS CONTENU DANS LE FILTRE ET DONC DANS LE DOSSIER
    	int nombre_de_fichiers = dirSource.count();
     
    	// VARIABLE QUI STOCKE LE NOM DU FICHIER EN COURS DE COPIE 
    	QString nom_du_fichier;
     
    	// ON BOUCLE SUR LE NOMBRE DE FICHIERS CONTENU DANS LE REPERTOIRE POUR TOUT COPIER
    	int i;
    	for ( i=0 ; i < nombre_de_fichiers ; i++ )
    	{
     
            // QSTRING POUR CONTENIR LES CHEMINS SOURCE/DESTINATION DES FICHIERS
            QString sourcefile     ;
    		QString destinationfile;
     
            // ON RECUPERE LES NOMS DES FICHIERS CONTENU DANS LE FILTRE ET ON LES STOCKENT DANS LA VARIABLE PREVUE A CETTE EFFET
    		nom_du_fichier = dirSource.entryList(filtre).at(i);
     
            if (nom_du_fichier != "." && nom_du_fichier != ".." )
    		{
    			// ON CONCATENE LES CHEMINS SOURCE ET DESTINATIONS AVEC LE NOM DE FICHIER EN COURS POUR LE PASSER A LA FONCTION DE COPIE
    			sourcefile      = source      + nom_du_fichier;
    			destinationfile = destination + nom_du_fichier;
     
    			// AFFICHAGE DU CHEMIN SOURCE/DESTINATION CONCATENE AVEC LE NOM DU FICHIER EN COURS DE COPIE  
    			affichage_source      -> setText(" <small><strong>SOURCE      :</strong></small> " + sourcefile          );
    			affichage_destination -> setText(" <small><strong>DESTINATION :</strong></small> " + destinationfile     );
    			affichage_source      -> move   ( (ResX - affichage_source->minimumSizeHint().width())/2, 0.45*ResY      );
    			affichage_destination -> move   ( (ResX - affichage_destination->minimumSizeHint().width())/2, 0.55*ResY );
     
    			// NOM DU FICHIER EN COURS DE COPIE
    			affichage_courant -> setText(" <small><strong>EN COURS   :</strong></small> " + nom_du_fichier   );
    			affichage_courant -> move   ( (ResX - affichage_courant->minimumSizeHint().width())/2, 0.65*ResY );
     
    			// TAILLE DU FICHIER EN COURS DE COPIE
    			QFileInfo fi(sourcefile);
    			qint64    taille  = fi.size();                              // TAILLE EN OCTETS DU FICHIER EN COURS DE COPIE
                QString   Qtaille = QString::number((taille/(1024*1024)));  // CONVERTION EN QSTRING DE LA TAILLE DU FICHIER EN MO
     
    			// QUANTITE INSTANTANEE DES FICHIERS DEJA COPIES 
    			qint64  taille_courante  = progression;                                    // TAILLE EN OCTET DE LA QUANTITE DE DONNEES DEJA COPIEE
    			QString Qtaille_courante = QString::number((taille_courante/(1024*1024))); // CONVERTION EN QSTRING DE LA TAILLE DES DONNEES DEJA COPIEE EN MO
     
                // AFFICHAGE DE LA QUANTITE DE DONNEES DEJA COPIEE
                affichage_taille_courante -> setText(" <small><strong>TRANSFERT :</strong></small> " + Qtaille_courante+"/"+Qtaille_totale+" Mo");
    			affichage_taille_courante -> move   ( (ResX - affichage_taille_courante->minimumSizeHint().width())/2, 0.35*ResY                        );
     
    			// AFFICHAGE DE LA TAILLE DU FICHIER EN COURS DE COPIE
                affiche_taille -> setText("<small><strong>TAILLE :</strong></small> " + Qtaille + " Mo"    );
    			affiche_taille -> move   ( (ResX - affiche_taille->minimumSizeHint().width())/2, 0.75*ResY );
    		    //nombre de fichiers dans la liste
    			//QString nombre="";
    			//nombre=QString::number(nombre_de_fichiers);
    			//QLabel *test2 = new QLabel(" nombre de fichiers : " + nombre, this);
    			//test2->move( (ResX - test2->minimumSizeHint().width())/2,0.675*ResY );
     
    			// ON EFFECTUER LA COPIE
    			QFile file(sourcefile);
    			file.copy(destinationfile);
     
    			// ON MET A JOUR LA TAILLE DE DONNEES TRANSFEREES
                taille_courante  = taille_courante+taille;
                Qtaille_courante = QString::number((taille_courante/(1024*1024)));
                affichage_taille_courante -> setText(" <small><strong>TRANSFERT :</strong></small> " + Qtaille_courante+"/"+Qtaille_totale+" Mo");
                return taille_courante;
    		}
    	}
    }
     
     
    qint64 taille(char *path)
    {
        // CONVERSION EN QSTRING DE LA VARIABLE DE TYPE CHAR   
        QString source = QString(path); 
     
        // ON SE PLACE DANS LE DOSSIER DONT ON VEUT QUE LES FICHIERS SOIENT COPIES
    	QDir::setCurrent(source);
    	QDir  dirSource (source);
     
    	// CREATION D'UN FILTRE SUR LES EXTENSIONS, ON COPIE TOUS LES FICHIERS POUR LE MOMENT
    	QStringList filtre;
    	filtre << "*.*";
    	dirSource.setNameFilters(filtre);
     
    	// ON RECUPERE LE NOMBRE DE FICHIERS CONTENU DANS LE FILTRE ET DONC DANS LE DOSSIER
    	int nombre_de_fichiers = dirSource.count();
     
    	// VARIABLE QUI STOCKE LE NOM DU FICHIER EN COURS DE COPIE 
    	QString nom_du_fichier;
     
        // VARIABLE POUR STOCKER LA TAILLE DU DOSSIER
        qint64 taille_dossier=0;
     
    	// ON BOUCLE SUR LE NOMBRE DE FICHIERS CONTENU DANS LE REPERTOIRE POUR TOUT COPIER
    	int i;
    	for ( i=0 ; i < nombre_de_fichiers ; i++ )
    	{
    		QString sourcefile;
     
            // ON RECUPERE LES NOMS DES FICHIERS CONTENU DANS LE FILTRE ET ON LES STOCKENT DANS LA VARIABLE PREVUE A CETTE EFFET
    		nom_du_fichier = dirSource.entryList(filtre).at(i);
     
            if (nom_du_fichier != "." && nom_du_fichier != ".." )
    		{
    			// ON CONCATENE LES CHEMINS SOURCE ET DESTINATIONS AVEC LE NOM DE FICHIER EN COURS POUR LE PASSER A LA FONCTION DE COPIE
    			sourcefile = source + nom_du_fichier;
     
    			// ON RECUPERE LA TAILLE DU DOSSIER
    			QFileInfo fi(sourcefile);
    			qint64    taille_fichier=fi.size()/(1024*1024);
    			          taille_dossier=taille_dossier+taille_fichier;
    		}
    	}
     
    	return taille_dossier;
    }
    Me reste à faire le thread, le contrôle de copie sur les heures et les dâtes.
    Pour les threads pour afficher le fenêtre pendant la copie. Si vous avez une idée je suis preneur, hormis la FAQ, je l'ai déjà lu et elle n'aide pas vraiment à comprendre pour des neophites comme moi.

    Je viens de me rendre compte que tous les fichiers n'étaient pas copiés.
    UNE REPONSE UTILE : &|| UN PROBLEME RESOLU :

  17. #57
    Membre confirmé
    Homme Profil pro
    Etudiant administrateur systèmes et réseaux
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Etudiant administrateur systèmes et réseaux

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Points : 467
    Points
    467
    Par défaut
    Même pas une petite idée ?
    UNE REPONSE UTILE : &|| UN PROBLEME RESOLU :

  18. #58
    Membre éprouvé

    Profil pro
    Inscrit en
    Mai 2007
    Messages
    774
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France, Finistère (Bretagne)

    Informations forums :
    Inscription : Mai 2007
    Messages : 774
    Points : 969
    Points
    969
    Par défaut
    1) Concernant la mise en place d'un thread

    Pour faire un thread, tu fais une classe qui étend QThread.
    Tu redéfinis la méthode run(). Le contenu de cette méthode run() sera le code éxécuté dans le nouveau thread.

    Attention, seul ce qui se trouve dans la méthode run() est effectué "paralèllement", le constructeur de ton objet ne le sera pas.

    Pour démarrer un thread, il faut appeler la fonction start() sur l'instance de ta classe dérivée de QThread.

    2) Concernant la mise à jour de ta progress bar

    Tu crées un timer avec une période de 1s environ.
    Tu connectes son timeout à un slot de ta classe.
    Dans ce slot, tu récupères la taille des fichiers deja copies que tu divises par la taille totale des fichiers à copier.
    Tu multiplies le résultat de cette division par la valeur max de ta progrssbar, et tu mets cette valeur dans ta progressbar.
    Une fois que ta progress bar est pleine, tu stop ton timer, et tu passes à la suite.

    G.
    Un problème avec Qt ? Vous trouverez votre réponse ici : http://doc.trolltech.com/4.6/overviews.html
    En français (traduction réalisée par l'équipe Qt de DVP) : http://qt.developpez.com/doc/4.6/vues-d-ensemble/

  19. #59
    Membre confirmé
    Homme Profil pro
    Etudiant administrateur systèmes et réseaux
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Etudiant administrateur systèmes et réseaux

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Points : 467
    Points
    467
    Par défaut
    Merci pour les indications, j'ai essayé de faire quelque chose. Evidemment cela ne marche pas. J'ai essayé de calquer sur l'exemple de QT mais j'ai du râter pas mal de truc en sachant que j'ai du mal avec la structure et les liens entre tous les fichiers.

    Etant donné que j'ai 3 objets à mettre à jours, je fais 3 starts donc 1 pour chaque objet et par phase (en cours de copie et copie terminée).

    En parallèle de la copie, la fenêtre de met à jour avec le bouton le texte "ANNULER" et l'image "en cours de copie"

    A la fin de la copie idem sauf que le texte du bouton devient "OK" et l'image change en "copie terminée".

    Ne me grondez pas s'il vous plait parce que jce que 'ai fais doit être un ramassis de n'importe quoi, mais faut bien essayer

    J'ai mis le projet en pièce jointe et sinon je vous le redonne là :

    MAIN.cpp
    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
    #include <QtGui>
    #include <windows.h>
    #include "fenetre.h"
    #include "thread.h"
     
     
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
     
           MaFenetre MainWindows; 
     
           MainWindows.show();
     
        return app.exec();
    }
    FENETRE.cpp
    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
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    // BIBLIOTHEQUES //////////////////////////////////////////////////////////////
    #include <QtGui>
    #include <windows.h>
    #include "fenetre.h"
    #include "thread.h"
     
     
     
    // PROTOTYPES //////////////////////////////////////////////////////////////////
    void QtCopy(QString SrcPath, QString TarPath);
     
    // CLASSE FENETRE //////////////////////////////////////////////////////////////
    MaFenetre::MaFenetre() : QWidget()
    {
     
     
        PictureA = new QPixmap("FT1.jpg"); /* image "en cours de copie" */
        PictureB = new QPixmap("FT1.jpg"); /* image "copie terminée" */
     
        /* On s'adapte à la taille de l'image */
        int X=PictureA->width();
        int Y=PictureA->height();
     
        /* On fixe définitivement la taille de la fenêtre */
    	setFixedSize(X, Y);
     
        /* Variables pour stocker les chemins du setup.ini */
        char S_XS[999], S_XS2[999], S_D2A[999], S_EASY[999], S_ALCATEL[999], S_VOCALD6[999], S_SAUVMATRA[999], S_MATRAPARALLELE[999]; // Chemin des dossiers sources 
        char D_XS[999], D_XS2[999], D_D2A[999], D_EASY[999], D_ALCATEL[999], D_VOCALD6[999], D_SAUVMATRA[999], D_MATRAPARALLELE[999]; // Chemin des dossiers cibles
     
    	/* On récupère ces chemins dans setup.ini */
    	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");
    	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");
     
    	/* Création des objets */
        Frame   = new QLabel     (this);
        Button  = new QPushButton(this);
        QString text; 
     
        /* On envoit le texte du bouton et l'image correspondante pour la phase de copie */
        text="ANNULER";   /* Texte du bouton pour l'image "en cours de copie" */
           Frame.start(*Frame, *Button, text, *PictureA, X, Y);
          Button.start(*Frame, *Button, text, *PictureA, X, Y);
        PictureA.start(*Frame, *Button, text, *PictureA, X, Y);
     
    	/* Copie des dossiers */
        QtCopy(S_XS            , D_XS            );                                                                                                                  
        QtCopy(S_XS2           , D_XS2           );
        QtCopy(S_D2A           , D_D2A           );
        QtCopy(S_EASY          , D_EASY          );
        QtCopy(S_ALCATEL       , D_ALCATEL       );
        QtCopy(S_VOCALD6       , D_VOCALD6       );                                                                                                                     
        QtCopy(S_SAUVMATRA     , D_SAUVMATRA     );
        QtCopy(S_MATRAPARALLELE, D_MATRAPARALLELE);
     
        /* On envoit le texte du bouton et l'image correspondante pour la phase de fin de copie */
        text="OK";   /* Texte du bouton pour l'image "copie terminée" */
          Frame.start(*Frame, *Button, text, *PictureB, X, Y);
         Button.start(*Frame, *Button, text, *PictureB, X, Y);
        PictureB.start(*Frame, *Button, text, *PictureB, X, Y);;
     
        /* Signaux */
    	QObject::connect(Button, SIGNAL(clicked()) , qApp, SLOT( quit() ));
    }
     
    // FUNCTIONS ///////////////////////////////////////////////////////////////////
    void QtCopy(QString SrcPath, QString TarPath)
    {
     
        QString Src = QString(SrcPath); /* Convertion de la variable char en QString ( répertoire source ) */
        QString Tar = QString(TarPath); /* Convertion de la variable char en QString ( répertoire cible ) */
     
        QDir::setCurrent(Src); /* On se place dans le repertoire source */
    	QDir  dirSource (Src); /**/
     
            QStringList Filter; /* On déclare un filtre sur les extentions de fichiers */
    	Filter << "*.*"; /* On récupère tous les types de fichier */
    	dirSource.setNameFilters(Filter); /* On enregistre les noms de fichiers dans le filtre */
     
    	int i;
    	int FileNumbers = dirSource.count(); /* On récupère le nombre de fichiers à copier */
    	for ( i=0 ; i < FileNumbers ; i++ )
    	{
     
    		QString FileName = dirSource.entryList(Filter).at(i); /* On récupère chaque nom de fichier contenu dans le filtre grâce à la boucle */
    		if (FileName != "." && FileName != ".." ) /* On controle que le fichier n'est pas le repertoire parent ou le répertoire courant */
    		{
    		    QString SrcPath = Src + FileName; /* On concatène le chemin du fichier source avec son nom */
             	QString	TarPath = Tar + FileName; /* Variable QString pour stocker le chemin complet du fichier source */
     
                QFile file(SrcPath); /* On déclare le fichier de chemin SrcPath */
    			file.copy(TarPath); /* On effectue la copie de ce fichier */
            }
    	}
    }
    FENETRE.h
    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
    #ifndef DEF_MAFENETRE
    #define DEF_MAFENETRE
     
    #include <QtGui>
    #include <windows.h>
    #include "thread.h"
     
    class MaFenetre : public QWidget // On hérite de QWidget (IMPORTANT)
    {
        Q_OBJECT  
     
        public:
        MaFenetre();
     
        public slots:
     
        private:
    	QLabel      *Frame;
        QPushButton *Button;
        QPixmap     *PictureA;
        QPixmap     *PictureB;
    };
     
    #endif
    THREAD.cpp
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    #include <QtGui>
    #include <windows.h>
    #include "thread.h"
     
     
    void RenderThread::run(QLabel *Frame, QPushButton *Button, QString Text, QPixmap *Picture, int X, int Y)
    {
        Frame  -> setPixmap  (*Picture);
        Button -> SetText(Text);
        Button -> setGeometry( (X - Button -> minimumSizeHint().width())/2, 0.6*Y, 0.3*X, 0.3*Y );   
    }
    THREAD.h
    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
     
    #include <QtGui>
     
     class ThreadForDisplay : public QThread
     {
         Q_OBJECT
     
     public:
     
     signals:
     
     protected:
             void run(QLabel *Frame, QPushButton *Button, QPixmap *Picture, int X, int Y);
     
     private:
     QLabel      *Frame;
     QPushButton *Button;
     QPixmap     *PictureA;
     QPixmap     *PictureB;
     
     
     };
     
     #endif
    Fichiers attachés Fichiers attachés
    UNE REPONSE UTILE : &|| UN PROBLEME RESOLU :

  20. #60
    Membre confirmé
    Homme Profil pro
    Etudiant administrateur systèmes et réseaux
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Etudiant administrateur systèmes et réseaux

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Points : 467
    Points
    467
    Par défaut
    UNE REPONSE UTILE : &|| UN PROBLEME RESOLU :

+ Répondre à la discussion
Cette discussion est résolue.
Page 3 sur 4 PremièrePremière 1234 DernièreDernière

Discussions similaires

  1. [CSV] Création dossier sous dossier et copie image
    Par mrsoyer dans le forum Langage
    Réponses: 9
    Dernier message: 11/07/2007, 16h34
  2. Faire apparaître les entêtes d'un sous-état
    Par Le Pharaon dans le forum IHM
    Réponses: 3
    Dernier message: 10/07/2007, 12h52
  3. protection dossier sous excel 2000
    Par grandnello dans le forum Excel
    Réponses: 1
    Dernier message: 03/08/2005, 21h47
  4. [NetBeans] Faire un "Mount" d'un jar sous Netbeans 4.0
    Par itechparadise dans le forum NetBeans
    Réponses: 1
    Dernier message: 18/05/2005, 22h28
  5. Faire un raccoucis vers une application sous wine
    Par zamanika dans le forum Applications et environnements graphiques
    Réponses: 7
    Dernier message: 01/10/2004, 14h10

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo