title: setChecked() not working in class
body: <p>I was making a small test program in Qt 5, and tried implementing a check box class with the default being the box is checked. However, whenever I run the program, it seems that the checkbox is not checked. Here is the following code:</p>
  
  <p>checkbox.h:</p>
  
  <pre><code>    #ifndef CHECKBOX
      #define CHECKBOX
  
      #include &lt;QCheckBox&gt;
      #include &lt;QWidget&gt;
  
  
  
     class checkbox : public QCheckBox
     {
     public:
  
          checkbox(QWidget *parent = 0) : QCheckBox(parent)
          {
              QCheckBox *cBox = new QCheckBox;
             cBox-&gt;setChecked(true);
          }
      };
  
      #endif // CHECKBOX
  </code></pre>
  
  <p>main.cpp:</p>
  
  <pre><code>    #include "mainwindow.h"
      #include &lt;QApplication&gt;
      #include &lt;QAction&gt;
      #include &lt;QtWidgets&gt;
      #include &lt;checkbox.h&gt;
  
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          QWidget *window = new QWidget;
  
          window-&gt;setWindowTitle("test");
          checkbox *box = new checkbox;
  
          QHBoxLayout *mainLayout = new QHBoxLayout;
          mainLayout-&gt;addWidget(box);
  
         window-&gt;setLayout(mainLayout);
         window-&gt;show();
  
         return a.exec();
      }
  </code></pre>
  
  <p>Funny thing is though, if I call setChecked with box in main, it ouputs a checked box. </p>
  
  <p>any help is greatly appreciated</p>