title: Accessing a container child widget dimensions in a constructor
body: <p>Let's say I have a class with two <code>Gtk::Containers</code> like so:</p>
  
  <pre><code>class Example : public Gtk::VBox
  {
  public:
      Example();
      virtual ~Example();
  
  private:
      Gtk::HBox m_c1; // First container
      Gtk::Grid m_c2; // Second container
  };
  </code></pre>
  
  <p>Constructing an <code>Example</code> is implemented this way:</p>
  
  <pre><code>Example::Example()
  {
      const int nbRows{6};
      const int nbColumns{7};
  
      for(int col{0}; col &lt; nbColumns; ++col)
      {
          Gtk::Button* btn {new Gtk::Button("A")};
  
          m_c1.pack_start(*btn);
      }
  
      for(int row{0}; row &lt; nbRows; ++row)
      {
          for(int col{0}; col &lt; nbColumns; ++col)
          {
              Gtk::Button* btn {new Gtk::Button("A")};
  
              m_c2.attach(*btn, col, row, 1, 1);
          }
      }
  
      // Layout setup:
      pack_start(m_c1);
      pack_start(m_c2);
  
      show_all();
  }
  </code></pre>
  
  <p>What I want to do is to make sure the child widgets in <code>m_c2</code> are the same size as the child widget in <code>m_c1</code>, to ensure visual consistency between the two containers. Otherwise, it looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/pI9uDm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pI9uDm.png" alt="Inconsistent sizes"></a></p>
  
  <p>Just to make sure, I do not want <code>m_c1</code> to be made a <code>Gtk::Grid</code>.</p>
  
  <p>Here's what I have tried so far: I used the <code>get_child_at()</code> method available from the <code>Gtk::HBox</code> <code>m_c1</code> to get a reference to its first child. I then called <code>get_width()</code> and <code>get_height()</code> on that child. The idea was to feed <code>m_c2</code>'s child widgets these dimensions. The problem is that the returned reference is a <code>nullptr</code>.</p>
  
  <p>From some posts I have read, it seems my widgets may no yet be realized, and that would explain my difficulties. How could I achieve this?</p>