Hi again.
I was writing simple software,which have one big window. 2 Qpushbutton in this window. Parent is main window.
when mouse cursor is approaching one of the button,button is moved at the other randomly got coordinate,and so on.

I get .exe I get all neccessary .DLL files. in folder where exe is placed. Then I create folder: "platforms". There are "qwindows.dll".
Everything seems all right but when I launch .exe file,suddenly it crashes.

Then I created simple program, just big window. Did the same thing and then launched without any crashes.
I think in code I have bug,which causes Segmentation fault.
But I dont have any idea where are my mistake:

.pro
Qt Code:
  1. QT += widgets
  2.  
  3. HEADERS += \
  4. dialog.h
  5.  
  6. SOURCES += \
  7. dialog.cpp \
  8. main.cpp
To copy to clipboard, switch view to plain text mode 

Dialog.h
Qt Code:
  1. #ifndef DIALOG_H
  2. #define DIALOG_H
  3.  
  4. #include <QWidget>
  5. #include <QPushButton>
  6. #include <QPoint>
  7.  
  8. class Dialog : public QWidget
  9. {
  10. Q_OBJECT
  11. public:
  12. explicit Dialog(QWidget *parent = 0);
  13.  
  14. signals:
  15. void PositionChanged();
  16.  
  17. public slots:
  18. void getNewPosition();
  19.  
  20. private:
  21. QPushButton *button1;
  22. QPushButton *button2;
  23. QPoint point1; //button1 position
  24. QPoint point2; //button2 position
  25. bool SecondButton;
  26. bool FirstButton;
  27.  
  28. protected:
  29. void mouseMoveEvent(QMouseEvent *);
  30.  
  31. };
  32.  
  33. #endif // DIALOG_H
To copy to clipboard, switch view to plain text mode 

Dialog.cpp
Qt Code:
  1. #include "dialog.h"
  2. #include <QPushButton>
  3. #include <QWidgetItem>
  4. #include <QPoint>
  5. #include <QKeyEvent>
  6. Dialog::Dialog(QWidget *parent) :
  7. QWidget(parent)
  8. {
  9. //main window size
  10. setFixedSize(650,440);
  11.  
  12. //button1 related things
  13. button1 = new QPushButton(this);
  14. button1->setGeometry(QRect(200,200,75,23));
  15. button1->setText("one");
  16.  
  17. //button2 related things
  18. button2 = new QPushButton(this);
  19. button2->setGeometry(QRect(300,200,75,23));
  20. button2->setText("two");
  21. point1 = button1->pos();
  22. point2 = button2->pos();
  23.  
  24. connect(this,SIGNAL(PositionChanged()),this,SLOT(getNewPosition()));
  25.  
  26. setMouseTracking(true);
  27. SecondButton = true;
  28. FirstButton = true;
  29. }
  30. void Dialog::getNewPosition()
  31. {
  32. point1 = button1->pos();
  33. point2 = button2->pos();
  34. }
  35. void Dialog::mouseMoveEvent(QMouseEvent *event)
  36. {
  37. if(FirstButton && (( event->x() > point1.x() - 30 && event->x() < point1.x() + 105 )
  38. && (event->y() > point1.y() - 30 && event->y() < point1.y() + 54)))
  39. {
  40. //get random (x,y) coordinate
  41. int x = rand() % 550;
  42. int y = rand() % 400;
  43. button1->setGeometry(QRect(x,y,75,23));
  44. emit PositionChanged();
  45. SecondButton = false;
  46. }
  47. else if(SecondButton && ((event->y() > point2.y()-30 && event->y() < point2.y()+54)
  48. && ( event->x() > point2.x()-30 && event->x() < point2.x() + 105)))
  49. {
  50. //get random (x,y) coordinate
  51. int x = rand() % 550;
  52. int y = rand() % 400;
  53. button2->setGeometry(QRect(x,y,75,23));
  54. emit PositionChanged();
  55. FirstButton = false;
  56. }
  57. }
To copy to clipboard, switch view to plain text mode 

main.cpp
Qt Code:
  1. #include <QApplication>
  2. #include "dialog.h"
  3.  
  4. int main(int argc,char *argv[])
  5. {
  6. QApplication app(argc,argv);
  7.  
  8.  
  9. Dialog dg;
  10. dg.show();
  11.  
  12. return app.exec();
  13. }
To copy to clipboard, switch view to plain text mode 


Any Ideas?

P.S sorry for my English. It isn't my native language