Hello,
i have a serious problem, when i choose an image to display in a Qwidget (fentroi), it is displayed but the problem when i choose another it can't refresh and it can't display the new image, ,and im working on binarisation and the threshold didn't refresh too i assume that because the QImage that i load is the cause because it dosen't refresh too.

here my code
fenetrePrincipale.h (MainWindow)
Qt Code:
  1. #ifndef FENETREPRINCIPALE_H
  2. #define FENETREPRINCIPALE_H
  3. #include <QtWidgets>
  4. #include "traitement.h"
  5. class FenetrePrincipale : public QMainWindow
  6. {
  7. Q_OBJECT
  8. public :
  9. FenetrePrincipale();
  10. public slots :
  11. void ouvrir();
  12. void traiter();
  13. void traiterOtsu();
  14. private:
  15. QString nomFichier;
  16. QWidget fentroi;
  17. QWidget fenSec;
  18.  
  19.  
  20.  
  21. };
  22.  
  23. #endif // FENETREPRINCIPALE_H
To copy to clipboard, switch view to plain text mode 

fenetrePricipale.cpp
Qt Code:
  1. #include "traitement.h"
  2. #include "otsu.h"
  3. #include "fenetreprincipale.h"
  4.  
  5. FenetrePrincipale::FenetrePrincipale(): QMainWindow()
  6. {
  7.  
  8.  
  9. QMenu *menuFichier = menuBar()->addMenu("Fichier");
  10. QAction *actionOuvrir = new QAction("Ouvrir", this);
  11. QAction *actionQuitter = new QAction("Quitter", this);
  12. menuFichier->addAction(actionOuvrir);
  13. menuFichier->addAction(actionQuitter);
  14.  
  15. QMenu *menuTraitement = menuBar()->addMenu("Traitement");
  16. QAction *actionBinarisation = new QAction("Binarisation", this);
  17. menuTraitement->addAction(actionBinarisation);
  18.  
  19. QObject::connect(actionOuvrir, SIGNAL(triggered(bool)), this, SLOT(ouvrir()));
  20. QObject::connect(actionQuitter, SIGNAL(triggered(bool)), this, SLOT(close()));
  21.  
  22. QObject::connect(actionBinarisation, SIGNAL(triggered(bool)), this, SLOT(traiterOtsu()));
  23. QObject::connect(this, SIGNAL(changer()), this, SLOT(afficher()));
  24. }
  25. void FenetrePrincipale::ouvrir()
  26. {
  27. nomFichier = QFileDialog::getOpenFileName(this, tr("Open File"),"C:/Users/amine/Downloads");
  28.  
  29. QLabel *label =new QLabel(&fentroi);
  30. label->setGeometry(100,100,400,400);
  31. QImage image1(nomFichier);
  32. QPixmap pixmap;
  33. pixmap.convertFromImage(image1);
  34. label->setPixmap(pixmap);
  35. fentroi.show(); // fentroi (fenetre qui affiche l'image) attribut de fenetre principale
  36. label->update();
  37.  
  38. }
  39.  
  40. void FenetrePrincipale::traiterOtsu()
  41. {
  42. OtsuAlgo traitement(nomFichier);
  43. traitement.binarisation();
  44. QImage *im = new QImage(traitement.getImage());
  45. QLabel *label = new QLabel(&fenSec);
  46. label->setGeometry(100,100, 400, 400);
  47. label->setPixmap(QPixmap::fromImage(*im));
  48. QLCDNumber *lcd = new QLCDNumber(&fenSec);
  49. lcd->move(70,70);
  50. lcd->setSegmentStyle(QLCDNumber::Flat);
  51. lcd->display(traitement.getSeuil());
  52. fenSec.show();
  53. }
To copy to clipboard, switch view to plain text mode 
please if someone can help me and thanks