Hi, I created my own widget and when I'm trying to set something inside - Qt always crash. Do you know where is the problem?

main.cpp

...
Qt Code:
  1. MyWidget *w1 = new MyWidget();
  2. QString text = "text";
  3. w1->setText(text); //this always cause crash
To copy to clipboard, switch view to plain text mode 

mywidget.h

Qt Code:
  1. #ifndef MYWIDGET_H
  2. #define MYWIDGET_H
  3.  
  4. #include <QWidget>
  5. #include <QLabel>
  6. #include <QGridLayout>
  7.  
  8. class MyWidget : public QWidget
  9. {
  10. Q_OBJECT
  11. public:
  12. explicit MyWidget(QWidget *parent = 0);
  13. void SetText(QString text);
  14.  
  15. signals:
  16.  
  17. public slots:
  18.  
  19. private:
  20. QLabel *label1;
  21. };
To copy to clipboard, switch view to plain text mode 

mywidget.cpp

Qt Code:
  1. include "mywidget.h"
  2.  
  3. MyWidget::MyWidget(QWidget *parent) :
  4. QWidget(parent)
  5. {
  6. QGridLayout *layout = new QGridLayout();
  7. QLabel *label1 = new QLabel("Name");
  8. layout->addWidget(label1, 0, 0);
  9. setLayout(layout);
  10. }
  11.  
  12. void MyWidget::setText(QString text) {
  13. label1->setText(text);
  14. }
To copy to clipboard, switch view to plain text mode