title: signals and slots qt close slot
body: <p>I made a window and a button in it. I want the button to close the window when clicked, BUT I want to do it by a public slot that I created and which contains the close slot of the <code>QWidget</code>, instead of doing it using the default <code>QWidget::close()</code>. Here is my code.</p>
  
  <p>window.h</p>
  
  <pre><code>#ifndef FENETRE_H
  #define FENETRE_H
  
  #include &lt;QObject&gt;
  #include &lt;QWidget&gt;
  #include &lt;QPushButton&gt;
  
  class fenetre: public QWidget
  {
  Q_OBJECT
  public:
      fenetre();
  
  public slots:
      void another();
  
  private:
      QPushButton *button1;
  };
  
  #endif // FENETRE_H
  </code></pre>
  
  <p>window.cpp</p>
  
  <pre><code>#include "fenetre.h"
  
  fenetre::fenetre():QWidget()
  {
      setFixedSize(300,300);
      button1=new QPushButton("click",this);
  
      connect(button1,SIGNAL(clicked()),this,SLOT(another()));
  }
  
  void fenetre::another()
  {
      fenetre().close();
  }
  </code></pre>
  
  <p>main.cpp</p>
  
  <pre><code>#include &lt;QApplication&gt;
  #include &lt;QWidget&gt;
  #include &lt;QPushButton&gt;
  #include "fenetre.h"
  
  int main(int argc , char *argv[])
  {
      QApplication app(argc,argv);
  
      fenetre fen;
      fen.show();
  
      return app.exec();
  }
  </code></pre>