title: Displaying a checker board with each square as an object - C++ QT
body: <p>I'm new to Qt but not too C++. I'm trying to create a checker/chess board where each square is an object. What I'm trying to figure out is how to have each square object be a part of the board object I'm declaring and display that on the screen. I can display a widget on the screen by using MyWidget.show() in the main class. But I want to do something like Board.show() and have all of the square objects that are members of that class(that have a height, width, and color) show up. With the code I tried nothing showed up, although I was able to get a square to show up that was NOT in the board class.</p>
  
  <p>main.cpp</p>
  
  <pre><code>#include &lt;qtgui&gt;
  #include "square.h"
  #include "board.h"
  
  int main(int argc, char *argv[])
  {
      QApplication app(argc, argv);
      //Square square;
      //square.show();
      Board board;
      board.show();
      return app.exec();
  }
  </code></pre>
  
  <p>board.h and board.cpp</p>
  
  <pre><code>#ifndef BOARD_H
  #define BOARD_H
  
  #include &lt;QWidget&gt;
  
  class Board : public QWidget
  {
  public:
      Board();
  };
  
  #endif // BOARD_H
  
  #include "board.h"
  #include "square.h"
  
  Board::Board()
  {
      Square square;
      //square.show();
  }
  </code></pre>
  
  <p>square.h and square.cpp</p>
  
  <pre><code>#ifndef SQUARE_H
  #define SQUARE_H
  
  #include &lt;QWidget&gt;
  
  class Square : public QWidget
  {
  public:
      Square();
  
  protected:
      void paintEvent(QPaintEvent *);
  };
  
  #endif // SQUARE_H
  
  #include "square.h"
  #include &lt;QtGui&gt;
  
  Square::Square()
  {
      QPalette palette(Square::palette());
      palette.setColor(backgroundRole(), Qt::white);
      setPalette(palette);
  }
  
  void Square::paintEvent(QPaintEvent *)
  {
      QPainter painter(this);
      painter.setRenderHint(QPainter::Antialiasing);
      painter.setBrush(QBrush("#c56c00"));
      painter.drawRect(10, 15, 90, 60);
  }
  </code></pre>
  
  <p>Again, I'm a noob with Qt, so most of what my code was guess work and what I could find on google.</p>