Re: Need help with Combo Boxes



On 7/26/07, Allen <allen saucier cas-inc com> wrote:
Hi all,

I am trying to build a combo box's content on the fly but I'm missing
something & I don't know what it is.  Would someone please help me? I am
able to add a Row to the Combo Box.  I am able to set the value of that
row.  But the value does NOT  APPEAR  when I click the combo box down
arrow button.  Just a BLANK  ROW  appears.   Here is the code that I'm
using:

In the HEADER:

    class CFireButtonMortarTrajModelColumns : public
Gtk::TreeModel::ColumnRecord
    {
      public:
        CFireButtonMortarTrajModelColumns()
        {
          //add(m_colRowNumber);                     // position 0
          add(m_colFireButtonToMortarTrajLineName);
        }; ///< ctor

        ~CFireButtonMortarTrajModelColumns() {;}; ///< dtor

      public:
            Gtk::TreeModelColumn<int>  m_colRowNumber; ///< Row Number
            Gtk::TreeModelColumn<int>  m_colFireButtonToMortarTrajLineName;
    }; // class CFireButtonMortarTrajModelColumns

Gtk::ComboBox    *m_comboboxFireMortar1TrajName;
CFireButtonMortarTrajModelColumns  m_cFireButtonMortarTrajModelColumns;
Glib::RefPtr<Gtk::ListStore>
m_glsFireButton1MortarTrajConnectionComboBoxList;


IN the CPP:

m_refGlade->get_widget("combobox_fireMortar1TrajName",
m_comboboxFireMortar1TrajName);
m_glsFireButton1MortarTrajConnectionComboBoxList =
Gtk::ListStore::create( m_cFireButtonMortarTrajModelColumns );
m_comboboxFireMortar1TrajName->set_model(m_glsFireButton1MortarTrajConnectionComboBoxList);

m_glsFireButton1MortarTrajConnectionComboBoxList->append()->set_value(m_cFireButtonMortarTrajModelColumns.m_colFireButtonToMortarTrajLineName,
p_iTrajectoryLineNumberToAdd);

This code produces a BLANK  ROW  in my combo box.  What am I not doing
that is preventing me from seeing the value displayed?

Thanks everyone.  I really appreciate your help.

m_comboboxFireMortar1TrajName->pack_start(m_cFireButtonMortarTrajModelColumns.m_colFireButtonToMortarTrajLineName)

you need to pack columns into the combobox as well.  This allows you
to specify that you only want certain of the model columns actually
displayed in the widget.  It's the same basic concept as a TreeView.

--
jonner



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