rafik
24th January 2016, 20:46
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)
#ifndef FENETREPRINCIPALE_H
#define FENETREPRINCIPALE_H
#include <QtWidgets>
#include "traitement.h"
class FenetrePrincipale : public QMainWindow
{
Q_OBJECT
public :
FenetrePrincipale();
public slots :
void ouvrir();
void traiter();
void traiterOtsu();
private:
QString nomFichier;
QWidget fentroi;
QWidget fenSec;
};
#endif // FENETREPRINCIPALE_H
fenetrePricipale.cpp
#include "traitement.h"
#include "otsu.h"
#include "fenetreprincipale.h"
FenetrePrincipale::FenetrePrincipale(): QMainWindow()
{
QMenu *menuFichier = menuBar()->addMenu("Fichier");
QAction *actionOuvrir = new QAction("Ouvrir", this);
QAction *actionQuitter = new QAction("Quitter", this);
menuFichier->addAction(actionOuvrir);
menuFichier->addAction(actionQuitter);
QMenu *menuTraitement = menuBar()->addMenu("Traitement");
QAction *actionBinarisation = new QAction("Binarisation", this);
menuTraitement->addAction(actionBinarisation);
QObject::connect(actionOuvrir, SIGNAL(triggered(bool)), this, SLOT(ouvrir()));
QObject::connect(actionQuitter, SIGNAL(triggered(bool)), this, SLOT(close()));
QObject::connect(actionBinarisation, SIGNAL(triggered(bool)), this, SLOT(traiterOtsu()));
QObject::connect(this, SIGNAL(changer()), this, SLOT(afficher()));
}
void FenetrePrincipale::ouvrir()
{
nomFichier = QFileDialog::getOpenFileName(this, tr("Open File"),"C:/Users/amine/Downloads");
QLabel *label =new QLabel(&fentroi);
label->setGeometry(100,100,400,400);
QImage image1(nomFichier);
QPixmap pixmap;
pixmap.convertFromImage(image1);
label->setPixmap(pixmap);
fentroi.show(); // fentroi (fenetre qui affiche l'image) attribut de fenetre principale
label->update();
}
void FenetrePrincipale::traiterOtsu()
{
OtsuAlgo traitement(nomFichier);
traitement.binarisation();
QImage *im = new QImage(traitement.getImage());
QLabel *label = new QLabel(&fenSec);
label->setGeometry(100,100, 400, 400);
label->setPixmap(QPixmap::fromImage(*im));
QLCDNumber *lcd = new QLCDNumber(&fenSec);
lcd->move(70,70);
lcd->setSegmentStyle(QLCDNumber::Flat);
lcd->display(traitement.getSeuil());
fenSec.show();
}
please if someone can help me and thanks
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)
#ifndef FENETREPRINCIPALE_H
#define FENETREPRINCIPALE_H
#include <QtWidgets>
#include "traitement.h"
class FenetrePrincipale : public QMainWindow
{
Q_OBJECT
public :
FenetrePrincipale();
public slots :
void ouvrir();
void traiter();
void traiterOtsu();
private:
QString nomFichier;
QWidget fentroi;
QWidget fenSec;
};
#endif // FENETREPRINCIPALE_H
fenetrePricipale.cpp
#include "traitement.h"
#include "otsu.h"
#include "fenetreprincipale.h"
FenetrePrincipale::FenetrePrincipale(): QMainWindow()
{
QMenu *menuFichier = menuBar()->addMenu("Fichier");
QAction *actionOuvrir = new QAction("Ouvrir", this);
QAction *actionQuitter = new QAction("Quitter", this);
menuFichier->addAction(actionOuvrir);
menuFichier->addAction(actionQuitter);
QMenu *menuTraitement = menuBar()->addMenu("Traitement");
QAction *actionBinarisation = new QAction("Binarisation", this);
menuTraitement->addAction(actionBinarisation);
QObject::connect(actionOuvrir, SIGNAL(triggered(bool)), this, SLOT(ouvrir()));
QObject::connect(actionQuitter, SIGNAL(triggered(bool)), this, SLOT(close()));
QObject::connect(actionBinarisation, SIGNAL(triggered(bool)), this, SLOT(traiterOtsu()));
QObject::connect(this, SIGNAL(changer()), this, SLOT(afficher()));
}
void FenetrePrincipale::ouvrir()
{
nomFichier = QFileDialog::getOpenFileName(this, tr("Open File"),"C:/Users/amine/Downloads");
QLabel *label =new QLabel(&fentroi);
label->setGeometry(100,100,400,400);
QImage image1(nomFichier);
QPixmap pixmap;
pixmap.convertFromImage(image1);
label->setPixmap(pixmap);
fentroi.show(); // fentroi (fenetre qui affiche l'image) attribut de fenetre principale
label->update();
}
void FenetrePrincipale::traiterOtsu()
{
OtsuAlgo traitement(nomFichier);
traitement.binarisation();
QImage *im = new QImage(traitement.getImage());
QLabel *label = new QLabel(&fenSec);
label->setGeometry(100,100, 400, 400);
label->setPixmap(QPixmap::fromImage(*im));
QLCDNumber *lcd = new QLCDNumber(&fenSec);
lcd->move(70,70);
lcd->setSegmentStyle(QLCDNumber::Flat);
lcd->display(traitement.getSeuil());
fenSec.show();
}
please if someone can help me and thanks