>i'm expecting the column header to be the text of myLabel...
Then why don't you do a "treeView_.append_column ("Hello World", columns_.col_item);" instead of "treeView_.append_column ("Item", columns_.col_item);" ? Date: Fri, 10 Sep 2010 09:44:06 -0600 Subject: Re: TreeView question From: mwhite gwmail gwu edu To: sledgehammer_999 hotmail com CC: gtkmm-list gnome org thanks for that, i have now made "myLabel" an instance variable of the class. the error that was being printed on the command line is now gone. however, the label in the treeview is still blank. i'm expecting the column header to be the text of myLabel... below are the changes i've made. ---inventory_window.h---- #ifndef INVENTORY_WINDOW_H_ #define INVENTORY_WINDOW_H_ #include <gtkmm.h>
class InventoryWindow : public Gtk::Window { public: InventoryWindow (); virtual ~InventoryWindow (); protected: // tree model columns
class TreeModelColumns : public Gtk::TreeModel::ColumnRecord { public: TreeModelColumns () { add (col_item); add (col_location); add (col_amount);
} Gtk::TreeModelColumn <Glib::ustring> col_item; Gtk::TreeModelColumn <Glib::ustring> col_location; Gtk::TreeModelColumn <Glib::ustring> col_amount;
}; TreeModelColumns columns_; Gtk::ScrolledWindow scrolledWindow_; Gtk::TreeView treeView_; Glib::RefPtr<Gtk::ListStore> refTreeModel_;
Gtk::Table table_; Glib::RefPtr<Gtk::ActionGroup> refActionGroup_; Glib::RefPtr<Gtk::UIManager> refUIManager_; Gtk::VBox vBox_; Gtk::Label myLabel;
}; #endif /* INVENTORY_WINDOW_H_ */ ---inventory_window.h---- ---inventory_window.cpp---- #include <iostream> #include "inventory_window.h"
InventoryWindow::InventoryWindow () : table_(2, 2, false), myLabel ("hello world") { set_title ("My test program"); set_default_size (380, 250);
add (vBox_); scrolledWindow_.add (treeView_); scrolledWindow_.set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); table_.attach (scrolledWindow_, 0, 1, 0, 1);
vBox_.add (table_); refTreeModel_ = Gtk::ListStore::create (columns_); treeView_.set_model (refTreeModel_); treeView_.set_hover_selection (true); Gtk::TreeModel::Row row; row = *(refTreeModel_->append ()); row[columns_.col_item] = "First Item"; row[columns_.col_location] = "5110";
row[columns_.col_amount] = "10"; row = *(refTreeModel_->append ()); row[columns_.col_item] = "Second Item"; row[columns_.col_location] = "1234";
row[columns_.col_amount] = "2"; row = *(refTreeModel_->append ()); row[columns_.col_item] = "Third Item"; row[columns_.col_location] = "9876";
row[columns_.col_amount] = "53"; treeView_.append_column ("Item", columns_.col_item); treeView_.append_column ("Location", columns_.col_location);
treeView_.append_column ("Amount", columns_.col_amount); // replace the "default" widget with a Gtk::Label for column 0 // the first column header is blank. i was expecting it to say "hello world"
// any ideas? treeView_.get_column (0)->set_widget (myLabel); show_all_children (); } InventoryWindow::~InventoryWindow () {
} ---inventory_window.cpp---- 2010/9/10 sledge hammer <sledgehammer_999 hotmail com>
|