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

Discussion :

Emission d'un signal lors d'un click sur une image

  1. #21
    Membre confirmé
    Profil pro
    Inscrit en
    Juillet 2005
    Messages
    102
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 102
    Par défaut
    Ha oui comme tu lui rentres une QStringList, il faut aussi changer la fonction scale... c'est logique...

    Encore un dernier problème lié justement au main.moc...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    g++ -c -pipe -g -Wall -W -DQT_SQL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.4.1/mkspecs/macx-g++ -I. -I/usr/local/Trolltech/Qt-4.4.1/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Trolltech/Qt-4.4.1/include/QtCore -I/usr/local/Trolltech/Qt-4.4.1/include/QtCore -I/usr/local/Trolltech/Qt-4.4.1/lib/QtGui.framework/Versions/4/Headers -I/usr/local/Trolltech/Qt-4.4.1/include/QtGui -I/usr/local/Trolltech/Qt-4.4.1/include/QtGui -I/usr/local/Trolltech/Qt-4.4.1/lib/QtSql.framework/Versions/4/Headers -I/usr/local/Trolltech/Qt-4.4.1/include/QtSql -I/usr/local/Trolltech/Qt-4.4.1/include/QtSql -I/usr/local/Trolltech/Qt-4.4.1/include -I. -I. -I. -F/usr/local/Trolltech/Qt-4.4.1/lib -o FenPrincipale.o FenPrincipale.cpp
    make: *** No rule to make target `main.moc', needed by `main.o'.  Stop.
    Ah oui pour info, j'ai 4 fichiers main.cpp, FenPrincipale.h, FenPrincipale.cpp et affiche.cpp.

    Dans FenPrincipale.cpp, j'ai mis les fonctions liées au mainWindow:

    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
    #include "FenPrincipale.h"
     
    FenPrincipale::FenPrincipale()
    {
        // Génération des widgets de la fenêtre principale
        creerActions();
        creerMenus();
        //creerBarresOutils();
     
        // Génération des onglets et chargement de la page d'accueil
        //onglets = new QTabWidget;
    	//connect(onglets, SIGNAL(currentChanged(int)), this, SLOT(changementOnglet(int)));
     
        // Définition de quelques propriétés de la fenêtre
        setMinimumSize(500, 500);
        //setWindowIcon(QIcon("images/VoPhotos.png"));
        setWindowTitle(tr("VoPhotos"));
     
        QWidget *w = new QWidget;
        layout = new QHBoxLayout;
        w->setLayout(layout);
     
        setCentralWidget(w);
        //setWidgetResizable (true);
    }
     
    void FenPrincipale::creerActions()
    {
        //Fichier
        actionOuvrirRep = new QAction(tr("&Définir un répertoire racine"), this);
        //actionAPropos->setIcon(QIcon("images/information.png"));    
        connect(actionOuvrirRep, SIGNAL(triggered()), this, SLOT(ouvrirRep()));
        //actionAPropos->setShortcut(QKeySequence::HelpContents);
     
        //Autres...
        actionAPropos = new QAction(tr("&A propos..."), this);
        //actionAPropos->setIcon(QIcon("images/information.png"));    
        connect(actionAPropos, SIGNAL(triggered()), this, SLOT(aPropos()));
        actionAPropos->setShortcut(QKeySequence::HelpContents);
     
        actionQuitter = new QAction(tr("&Quitter"), this);
        //actionQuitter->setIcon(QIcon("images/quitter.png"));    
        actionQuitter->setShortcut(tr("Ctrl+Q"));
        connect(actionQuitter, SIGNAL(triggered()), qApp, SLOT(quit()));
    }
     
    void FenPrincipale::creerMenus()
    {
        //Fichier
        QMenu *menuFichier = menuBar()->addMenu(tr("&Fichier"));
        menuFichier->addAction(actionOuvrirRep);
        menuFichier->addAction(actionQuitter);
     
        //Aide
        QMenu *menuAide = menuBar()->addMenu(tr("&?"));
    	menuAide->addAction(actionAPropos);
    }

  2. #22
    yan
    yan est déconnecté
    Rédacteur
    Avatar de yan
    Homme Profil pro
    Ingénieur expert
    Inscrit en
    Mars 2004
    Messages
    10 035
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    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 035
    Par défaut
    je ne suis pas sur que tu est compris pourquoi j'avais ajuter le main.moc. Toi tu n'en as pas besoin
    le xxx.moc sert quand tu déclare un class dans un .cpp
    http://qt.developpez.com/doc/4.4/moc/#moc

  3. #23
    Membre confirmé
    Profil pro
    Inscrit en
    Juillet 2005
    Messages
    102
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 102
    Par défaut
    ha ok, c'est parque tu avais tout mis dans le main.cpp...

    Nickel, ca marche au poil maintenant !!!

    Merci pour ton aide... C'était vraiment sympa de ta part!!

  4. #24
    yan
    yan est déconnecté
    Rédacteur
    Avatar de yan
    Homme Profil pro
    Ingénieur expert
    Inscrit en
    Mars 2004
    Messages
    10 035
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    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 035
    Par défaut
    Citation Envoyé par peuf23 Voir le message
    ha ok, c'est parque tu avais tout mis dans le main.cpp...

    Nickel, ca marche au poil maintenant !!!

    Merci pour ton aide... C'était vraiment sympa de ta part!!
    maintenat, j'espère que tu as compris le code

  5. #25
    Membre confirmé
    Profil pro
    Inscrit en
    Juillet 2005
    Messages
    102
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 102
    Par défaut
    Salut,

    J'ai eu un peu le temps de reprendre, mais je me heurte à un problème. Voici mon code actuel, mais lorsque je clique sur l'image, le programme quitte purement et simplement, sans même indiquer un run time error...

    Pourrais-tu jeter un coup d'oeil?

    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
     
    #include "FenPrincipale.h"
    #include <qtconcurrentmap.h>
     
     QImage scale(const QString &name)
     {
        QImage image(name);
        return image.scaled(100, 100,Qt::KeepAspectRatio);
     }
     
    void FenPrincipale::traitementImages()
    {
    	    QTimer::singleShot(0 , this , SLOT( charger() ));
     
    	    miniLayout = new QHBoxLayout;
    	    QGroupBox *groupMiniatures = new QGroupBox("Miniatures:");
        	groupMiniatures->setLayout(miniLayout);
     
            imageGrandeLayout = new QHBoxLayout;
         	QGroupBox *groupImageGrande = new QGroupBox("Image:");       
        	groupImageGrande->setLayout(imageGrandeLayout);
     
        	QLabel *metaData = new QLabel;
        	QHBoxLayout *metaDataLayout = new QHBoxLayout;
            metaDataLayout->addWidget(metaData);
        	QGroupBox *groupMetaData = new QGroupBox("Métadonnées:");
        	groupMetaData->setLayout(metaDataLayout);
     
     
        	QGridLayout *triLayout = new QGridLayout;
    		triLayout->addWidget(groupMetaData,0,0,1,1);
        	triLayout->addWidget(groupImageGrande,0,1,1,1);
        	triLayout->addWidget(groupMiniatures,1,0,1,2);
     
    		QWidget *w = new QWidget;
    		w->setLayout(triLayout);
    		mainLayout->addWidget(w);
    }
     
     
    void FenPrincipale::charger()
    {	    
     
        /*recupere un repertoire*/
        QString s = QFileDialog::getExistingDirectory(this);
        if(s.isEmpty()) return;
        QDir  imageDir(s);
        QStringList fileFilter;
        /*recupere toute les nom d'image*/
        fileFilter << "*.png" << "*.jpg" <<"*.gif" << "*.bmp" << "*.ppm" << "*.pgm";
    	QStringList lImage = imageDir.entryList(fileFilter,QDir::Files);        
     
        /*ajoute le path des images*/
        for(int i=0;i<lImage.size();++i)
        {
            lImage[i] = imageDir.absolutePath() + "/" + lImage[i];
        }
    	pathImages = new QStringList;
    	pathImages = &lImage;
        /*dialog avec bar de progression*/
        QProgressDialog dialog
                (
                        QString("Progression utilisant %1 thread(s)...").arg(QThread::idealThreadCount()),
                        "Stop",
                        0,100
                );
     
        /*futurewatcher recuperant l'avancement et le resultat du mapped*/
        QFutureWatcher<QImage> futureWatcher;
        QObject::connect(&futureWatcher, SIGNAL(finished()), &dialog, SLOT(reset()));
        QObject::connect(&dialog, SIGNAL(canceled()), &futureWatcher, SLOT(cancel()));
        QObject::connect(&futureWatcher, SIGNAL(progressRangeChanged(int, int)), &dialog, SLOT(setRange(int, int)));
        QObject::connect(&futureWatcher, SIGNAL(progressValueChanged(int)), &dialog, SLOT(setValue(int)));
     
        /*a chaque nouvelle imagette genere on l'affiche*/
        QObject::connect(&futureWatcher, SIGNAL(resultReadyAt ( int  )),this,SLOT(newImage(int)));
     
        /*lancement du mapped*/
        futureWatcher.setFuture(QtConcurrent::mapped(lImage,scale ));
     
        /*permet de certifier que futureWatcher et lImage ne sont pas détruit avant la fin du mapped*/
        dialog.exec();
     
        /*attend la fin des traitement en cours*/
        futureWatcher.waitForFinished();
     
    }
     
    void FenPrincipale::newImage(int index)
    {
        /*on récuper le sender du signal connecte*/
         QFutureWatcher<QImage> * watcher =static_cast< QFutureWatcher<QImage> * >(sender());
         if (!watcher) return;
     
         /*creation d'un QLabel et ajout dans le layout d'image*/
         monLabel *label = new monLabel;
         label->setPixmap( QPixmap::fromImage(watcher->resultAt (index)) );
         label->setValue(index);
         miniLayout->addWidget(label);
         connect(label, SIGNAL(onClicked(int)), this, SLOT(afficheImageGrand(int)));
    }
     
    void FenPrincipale::afficheImageGrand(int i)
    {
        	QLabel *imageGrande = new QLabel;
        	QMessageBox::critical(this, "test", pathImages->at(i));
            //QImage image(pathImages->at(i));
            //imageGrande->setPixmap(QPixmap::fromImage(image));
            imageGrandeLayout->addWidget(imageGrande);
    }
     
    monLabel::monLabel(QWidget * parent,Qt::WindowFlags f) : QLabel(parent,f)
    {
    	m_var=-1;
    }
     
    void monLabel::mouseReleaseEvent(QMouseEvent *)
    {
        	emit onClicked(m_var);
    }
     
    void monLabel::setValue(int var)
    {
    	m_var=var;
    }
     
    int monLabel::getValue()
    {
    	return m_var;
    }
    Merci d'avance ;-)

  6. #26
    yan
    yan est déconnecté
    Rédacteur
    Avatar de yan
    Homme Profil pro
    Ingénieur expert
    Inscrit en
    Mars 2004
    Messages
    10 035
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    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 035
    Par défaut
    Citation Envoyé par peuf23 Voir le message
    Salut,

    J'ai eu un peu le temps de reprendre, mais je me heurte à un problème. Voici mon code actuel, mais lorsque je clique sur l'image, le programme quitte purement et simplement, sans même indiquer un run time error...

    Pourrais-tu jeter un coup d'oeil?
    utilise tu le debugger?
    je veut bien jeter un coup d'œil, mais faudrait,si possible, un version compilable

  7. #27
    Membre confirmé
    Profil pro
    Inscrit en
    Juillet 2005
    Messages
    102
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 102
    Par défaut
    ok, merci...
    Heu oui il me semble que j'utilise le debuger. Enfin, j'ai eu droit à d'autres erreurs avant que j'arrive à compiler.

    voici le tout:

    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
     
    #include <QApplication>
    #include <QTranslator>
    #include <QLocale>
    #include <QLibraryInfo>
    #include "FenPrincipale.h"
    //  #include "main.moc"
     
    int main(int argc, char* argv[])
    {
        QApplication app(argc, argv);
     
        // Traduction des chaînes prédéfinies par Qt dans notre langue
        QString locale = QLocale::system().name();
        QTranslator translator;
        translator.load(QString("qt_") + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
        app.installTranslator(&translator);
     
        // Ouverture de la fenêtre principale du navigateur
        FenPrincipale principale;
        principale.show();
     
        return app.exec();
    }
    FenPrincipale.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
     
    #include "FenPrincipale.h"
     
    FenPrincipale::FenPrincipale()
    {
        // Génération des widgets de la fenêtre principale
        creerActions();
        creerMenus();
        //creerBarresOutils();
     
        // Génération des onglets et chargement de la page d'accueil
        //onglets = new QTabWidget;
    	//connect(onglets, SIGNAL(currentChanged(int)), this, SLOT(changementOnglet(int)));
     
        // Définition de quelques propriétés de la fenêtre
        setMinimumSize(500, 500);
        //setWindowIcon(QIcon("images/VoPhotos.png"));
        setWindowTitle(tr("VoPhotos"));
     
        QWidget *w = new QWidget;
        mainLayout = new QHBoxLayout;
        w->setLayout(mainLayout);
     
        setCentralWidget(w);
        //setWidgetResizable (true);
    }
     
    void FenPrincipale::creerActions()
    {
        //Fichier
        actionOuvrirRep = new QAction(tr("&Définir un répertoire racine"), this);
        //actionAPropos->setIcon(QIcon("images/information.png"));    
        connect(actionOuvrirRep, SIGNAL(triggered()), this, SLOT(traitementImages()));
        //actionAPropos->setShortcut(QKeySequence::HelpContents);
     
        //Autres...
        actionAPropos = new QAction(tr("&A propos..."), this);
        //actionAPropos->setIcon(QIcon("images/information.png"));    
        connect(actionAPropos, SIGNAL(triggered()), this, SLOT(aPropos()));
        actionAPropos->setShortcut(QKeySequence::HelpContents);
     
        actionQuitter = new QAction(tr("&Quitter"), this);
        //actionQuitter->setIcon(QIcon("images/quitter.png"));    
        actionQuitter->setShortcut(tr("Ctrl+Q"));
        connect(actionQuitter, SIGNAL(triggered()), qApp, SLOT(quit()));
    }
     
    void FenPrincipale::creerMenus()
    {
        //Fichier
        QMenu *menuFichier = menuBar()->addMenu(tr("&Fichier"));
        menuFichier->addAction(actionOuvrirRep);
        menuFichier->addAction(actionQuitter);
     
        //Aide
        QMenu *menuAide = menuBar()->addMenu(tr("&?"));
    	menuAide->addAction(actionAPropos);
    }
     
    //void FenPrincipale::creerBarresOutils()
    //{
        //QToolBar *toolBarCommande = addToolBar(tr("XXXX"));
        //toolBarCommande->addAction(actionXXXX);
    //}
     
     
    //bool FenPrincipale::no_onglet(QString nom)
    //{
    //	bool test=true;
    //	for(int i=0;i<onglets->count();i++)
    //	{
    //		if(onglets->tabText(i) == nom)
    //		{
    //			test=false;
    //		}
    //	}
    //	return test;
    //}
     
    //void FenPrincipale::changementOnglet(int index)
    //{
    //}
     
     
    void FenPrincipale::aPropos()
    {
        QMessageBox::information(this, tr("A propos..."), tr("VoPhotos est un projet réalisé pour le tri et le référencement des photos. Il utilise les métadonnées inclus dans la plupart des formats de fichiers photos pour référencer l'ensemble des photos dans une base de donnée.<br /> Ce programme a été réalisé par V.Maurer entre le 28/11/2008 et le 00/00/0000.<br /> Version (beta): 0.0.0.<br />"));
    }
    FenPrincipale.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
    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
     
    #ifndef HEADER_FENPRINCIPALE
    #define HEADER_FENPRINCIPALE
     
    #include <QtGui>
    #include <QtSql>
     
    class monLabel : public QLabel
    {
    	Q_OBJECT
        public:
            monLabel(QWidget * parent=0,Qt::WindowFlags f = 0);
            void setValue(int var);
            int getValue();
        protected:
            void mouseReleaseEvent(QMouseEvent *);
        signals:
        	void onClicked(int var);
        private	:
        	int m_var;
    };
     
    class FenPrincipale : public QMainWindow
    {
        Q_OBJECT
    	QLayout *mainLayout;
     
        public:
            FenPrincipale();
        private:
            void creerActions();
            void creerMenus();
            QLabel *label;
            QHBoxLayout *miniLayout;
            QHBoxLayout *imageGrandeLayout;
            QStringList *pathImages;
            //QHBoxLayout *layout;
            //QScrollArea *scrollArea;
            //QStringList *files;
            //void creerBarresOutils();
    		//Onglets
            //QTabWidget *onglets;
            //void *creerAfficherOnglets(QVBoxLayout layout, QString nom);
    		//bool FenPrincipale::no_onglet(QString nom);			
     
        private slots:
     
            void aPropos();
            //void changementOnglet(int index);
            //Fichier 
            void traitementImages();
            void charger();
            void afficheImageGrand(int i);
            void newImage(int index);
     
        private:
            //Fichier
            QAction *actionOuvrirRep;
            QAction *actionQuitter;
            QAction *actionAPropos;
     
    };
     
    #endif
    affiche.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
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
     
    #include "FenPrincipale.h"
    #include <qtconcurrentmap.h>
     
     QImage scale(const QString &name)
     {
        QImage image(name);
        return image.scaled(100, 100,Qt::KeepAspectRatio);
     }
     
    void FenPrincipale::traitementImages()
    {
    	    QTimer::singleShot(0 , this , SLOT( charger() ));
     
    	    miniLayout = new QHBoxLayout;
    	    QGroupBox *groupMiniatures = new QGroupBox("Miniatures:");
        	groupMiniatures->setLayout(miniLayout);
     
            imageGrandeLayout = new QHBoxLayout;
         	QGroupBox *groupImageGrande = new QGroupBox("Image:");       
        	groupImageGrande->setLayout(imageGrandeLayout);
     
        	QLabel *metaData = new QLabel;
        	QHBoxLayout *metaDataLayout = new QHBoxLayout;
            metaDataLayout->addWidget(metaData);
        	QGroupBox *groupMetaData = new QGroupBox("Métadonnées:");
        	groupMetaData->setLayout(metaDataLayout);
     
     
        	QGridLayout *triLayout = new QGridLayout;
    		triLayout->addWidget(groupMetaData,0,0,1,1);
        	triLayout->addWidget(groupImageGrande,0,1,1,1);
        	triLayout->addWidget(groupMiniatures,1,0,1,2);
     
    		QWidget *w = new QWidget;
    		w->setLayout(triLayout);
    		mainLayout->addWidget(w);
    }
     
     
    void FenPrincipale::charger()
    {	    
     
        /*recupere un repertoire*/
        QString s = QFileDialog::getExistingDirectory(this);
        if(s.isEmpty()) return;
        QDir  imageDir(s);
        QStringList fileFilter;
        /*recupere toute les nom d'image*/
        fileFilter << "*.png" << "*.jpg" <<"*.gif" << "*.bmp" << "*.ppm" << "*.pgm";
    	QStringList lImage = imageDir.entryList(fileFilter,QDir::Files);        
     
        /*ajoute le path des images*/
        for(int i=0;i<lImage.size();++i)
        {
            lImage[i] = imageDir.absolutePath() + "/" + lImage[i];
        }
    	pathImages = new QStringList;
    	pathImages = &lImage;
        /*dialog avec bar de progression*/
        QProgressDialog dialog
                (
                        QString("Progression utilisant %1 thread(s)...").arg(QThread::idealThreadCount()),
                        "Stop",
                        0,100
                );
     
        /*futurewatcher recuperant l'avancement et le resultat du mapped*/
        QFutureWatcher<QImage> futureWatcher;
        QObject::connect(&futureWatcher, SIGNAL(finished()), &dialog, SLOT(reset()));
        QObject::connect(&dialog, SIGNAL(canceled()), &futureWatcher, SLOT(cancel()));
        QObject::connect(&futureWatcher, SIGNAL(progressRangeChanged(int, int)), &dialog, SLOT(setRange(int, int)));
        QObject::connect(&futureWatcher, SIGNAL(progressValueChanged(int)), &dialog, SLOT(setValue(int)));
     
        /*a chaque nouvelle imagette genere on l'affiche*/
        QObject::connect(&futureWatcher, SIGNAL(resultReadyAt ( int  )),this,SLOT(newImage(int)));
     
        /*lancement du mapped*/
        futureWatcher.setFuture(QtConcurrent::mapped(lImage,scale ));
     
        /*permet de certifier que futureWatcher et lImage ne sont pas détruit avant la fin du mapped*/
        dialog.exec();
     
        /*attend la fin des traitement en cours*/
        futureWatcher.waitForFinished();
     
    }
     
    void FenPrincipale::newImage(int index)
    {
        /*on récuper le sender du signal connecte*/
         QFutureWatcher<QImage> * watcher =static_cast< QFutureWatcher<QImage> * >(sender());
         if (!watcher) return;
     
         /*creation d'un QLabel et ajout dans le layout d'image*/
         monLabel *label = new monLabel;
         label->setPixmap( QPixmap::fromImage(watcher->resultAt (index)) );
         label->setValue(index);
         miniLayout->addWidget(label);
         connect(label, SIGNAL(onClicked(int)), this, SLOT(afficheImageGrand(int)));
    }
     
    void FenPrincipale::afficheImageGrand(int i)
    {
        	QLabel *imageGrande = new QLabel;
        	QMessageBox::critical(this, "test", pathImages->at(i));
            //QImage image(pathImages->at(i));
            //imageGrande->setPixmap(QPixmap::fromImage(image));
            imageGrandeLayout->addWidget(imageGrande);
    }
     
    monLabel::monLabel(QWidget * parent,Qt::WindowFlags f) : QLabel(parent,f)
    {
    	m_var=-1;
    }
     
    void monLabel::mouseReleaseEvent(QMouseEvent *)
    {
        	emit onClicked(m_var);
    }
     
    void monLabel::setValue(int var)
    {
    	m_var=var;
    }
     
    int monLabel::getValue()
    {
    	return m_var;
    }

    Voilà, j'espère que ca va t'aider....

  8. #28
    yan
    yan est déconnecté
    Rédacteur
    Avatar de yan
    Homme Profil pro
    Ingénieur expert
    Inscrit en
    Mars 2004
    Messages
    10 035
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    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 035
    Par défaut
    pourauoi pathImages est un pointeur????
    ton plantage vien de là.
    Tu initialise ce pointeur avec une QStringList qui va être détruite => plantage

+ Répondre à la discussion
Cette discussion est résolue.
Page 2 sur 2 PremièrePremière 12

Discussions similaires

  1. [NET4.0] Binding event lors du click sur une Image
    Par aram2 dans le forum Windows Presentation Foundation
    Réponses: 5
    Dernier message: 08/06/2010, 09h19
  2. Réponses: 1
    Dernier message: 21/07/2009, 22h18
  3. Réponses: 6
    Dernier message: 15/03/2006, 17h10
  4. Débutant - deux on click sur une image
    Par Space Cowboy dans le forum Général JavaScript
    Réponses: 5
    Dernier message: 27/01/2006, 15h25
  5. Gestion des évènements lors d'un clique sur une image.
    Par yoghisan dans le forum Débuter
    Réponses: 7
    Dernier message: 23/06/2005, 19h04

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