Hi.
I need a help.
I have a variable int bit2, which is a mainwindow.h.
In main.cpp I calculate her value, and I want to send this value to mainwindow.cpp. Is this possible?
I include part of the cod:

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


main.cpp
Qt Code:
  1. int main(int argc, char **argv)
  2. {
  3. QApplication a(argc, argv);
  4. MainWindow w;
  5. w.show();
  6. ...
  7. ...
  8. w.zapisz(51);
To copy to clipboard, switch view to plain text mode 

mainwindow.cpp
Qt Code:
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3.  
  4.  
  5. MainWindow::MainWindow(QWidget *parent) :
  6. QMainWindow(parent),
  7. ui(new Ui::MainWindow)
  8. {
  9. ui->setupUi(this);
  10. QPixmap pix("/home/bananapi/wizu-build-desktop-Qt_4_8_2__System__Release/new_grn.bmp");
  11. QPixmap pix2("/home/bananapi/wizu-build-desktop-Qt_4_8_2__System__Release/new_red.bmp");
  12.  
  13. ui->label->setPixmap(pix);
  14. ui->label_2->setPixmap(pix);
  15. ui->label_3->setPixmap(pix);
  16. ui->label_4->setPixmap(pix);
  17. flag=0;
  18. int bit;
  19. bit=bit2;//TU JEST BLAD ;/
  20. ...
  21. ...
  22. void MainWindow::zapisz(int wartosc)
  23. {
  24. bit2=wartosc;
  25. }
To copy to clipboard, switch view to plain text mode 

When I write in mainwindow.cpp ¨bit=51¨ (value which I want calculate in main.cpp) programm is working. In my opinion bit2 in main.cpp and bit2 in mainwindow.cpp is different variable. Can someone help? There is any way to send value from main.cpp to mainwindow.cpp?