Hi everyone. I have a problem, I'm creating a simple Image Processing app, at part of brightness adjustment i can't run this function, when it's called then app will be crashed. I have two forms, one of form is mainwindow, one else is sub form to adjust brightness.

Qt Code:
  1. //mainwindow.cpp
  2.  
  3. void MainWindow::brightnessProcessing(int value)
  4. {
  5. QImage image = imageLabel->pixmap()->toImage();
  6. int w = image.width();
  7. int h = image.height();
  8. QColor c;
  9. int r, g, b;
  10. for(int i=0; i<h; i++)
  11. for(int j=0; j<w; j++) {
  12. c = image.pixel(i, j);
  13. r = c.red()+value;
  14. g = c.green()+value;
  15. b = c.blue()+value;
  16. image.setPixel(i, j, qRgb(r, g, b));
  17. }
  18. imageLabel->setPixmap(QPixmap::fromImage(image));
  19. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. //mainwindow.h
  2.  
  3. #ifndef MAINWINDOW_H
  4. #define MAINWINDOW_H
  5.  
  6. #include <QMainWindow>
  7. #include <QtWidgets>
  8.  
  9. namespace Ui {
  10. class MainWindow;
  11. }
  12.  
  13. class MainWindow : public QMainWindow
  14. {
  15. Q_OBJECT
  16.  
  17. public:
  18. explicit MainWindow(QWidget *parent = 0);
  19. ~MainWindow();
  20. void brightnessProcessing(int value);
  21.  
  22. private slots:
  23. ..........
  24.  
  25. private:
  26. Ui::MainWindow *ui;
  27. QImage *image;
  28. QLabel *imageLabel;
  29. QScrollArea *scrollArea;
  30. QScrollBar *scrollBar;
  31. double scaleFactor;
  32.  
  33. void scaleImage(double factor);
  34. void adjustScrollBar(QScrollBar *scrollBar, double factor);
  35. };
  36.  
  37. #endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. //brightnesscontrast.cpp
  2.  
  3. void BrightnessContrast::on_horizontalSliderBrightness_valueChanged(int value)
  4. {
  5. ui->lineEditBrightness->setText(QString::number(value));
  6. respond.brightnessProcessing(value);
  7. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. //brightnesscontrast.h
  2.  
  3. #ifndef BRIGHTNESSCONTRAST_H
  4. #define BRIGHTNESSCONTRAST_H
  5.  
  6. #include <QDialog>
  7. #include <QtWidgets>
  8. #include "mainwindow.h"
  9.  
  10. namespace Ui {
  11. class BrightnessContrast;
  12. }
  13.  
  14. class BrightnessContrast : public QDialog
  15. {
  16. Q_OBJECT
  17.  
  18. public:
  19. explicit BrightnessContrast(QWidget *parent = 0);
  20. ~BrightnessContrast();
  21.  
  22. private slots:
  23. void on_horizontalSliderBrightness_valueChanged(int value);
  24.  
  25. void on_horizontalSliderContrast_valueChanged(int value);
  26.  
  27. private:
  28. Ui::BrightnessContrast *ui;
  29. MainWindow respond;
  30. };
  31.  
  32. #endif // BRIGHTNESSCONTRAST_H
To copy to clipboard, switch view to plain text mode 

anyhelp!