[gtkmm] Where did my TreeView go?!



I created a TreeView widget in my code and showed it, but it does not appear when I run
the compiled program. I have no idea whether this is my fault or some fault of gtkmm so I'm
posting this. Here is all the relevant code:

in file mainWindow.h


#include <gtkmm/button.h>
#include <gtkmm/window.h>
#include <gtkmm/box.h>
#include <gtkmm/entry.h>
#include <gtkmm/treeview.h>
#include <gtkmm/treemodel.h>
#include <gtkmm/liststore.h>

class MainWindow : public Gtk::Window
{

public:
  MainWindow();
  virtual ~MainWindow();

protected:
  //Signal handler for the newGateway button
  void newGatewayPressed();
  void newBuddy();

  //Woo. a column.
  class modelColumn : public Gtk::TreeModel::ColumnRecord
    {
    public:

      modelColumn()
        { add(m_col_name); }

      Gtk::TreeModelColumn<Glib::ustring> m_col_name;
    };
  
  modelColumn column;

  //widgets in our window
  Gtk::TreeView treeView;
  Glib::RefPtr<Gtk::ListStore> treeModel;
  Gtk::VBox vBox;
  Gtk::Button newGatewayButton;
  Gtk::Entry newBuddyEntry;
};

in file mainWindow.cc

#include "mainWindow.h"
// #include <jabber.h>
void MainWindow::newGatewayPressed()
{

}

void MainWindow::newBuddy()
{

}

MainWindow::MainWindow()
: newGatewayButton("Connect to Gateway")
{
  set_title("GIC");
  set_border_width(0);

  add(vBox);

  vBox.pack_start(newGatewayButton);

  newGatewayButton.signal_clicked().connect(SigC::slot(*this,&MainWindow::newGatewayPressed));
  
  
  newBuddyEntry.signal_activate().connect(SigC::slot(*this,&MainWindow::newBuddy));
  vBox.pack_start(newBuddyEntry);
  
  treeModel = Gtk::ListStore::create(column);
  treeView.set_model(treeModel);
  
  Gtk::TreeModel::Row row = *(treeModel->append());
  row[column.m_col_name] = "Fakedata";


  vBox.pack_start(treeView);
 
  show_all_children();
}
MainWindow::~MainWindow()
{

}


in file main.cc

#include <gtkmm/main.h>
#include "mainWindow.h"

int main(int argc,char *argv[])
{
  Gtk::Main kit(argc,argv);

  MainWindow mainWin;
  Gtk::Main::run(mainWin);

  return 0;
}

all my code compiles fine with no warnings but my TreeView is mysteriously missing.

Thanks in advance,
Nick Nolan

Attachment: pgpEDbXmSVINa.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]