Re: ComboBoxText and getting the index



Hey Sean:

Since Gtk::ComboBoxText is descended from Gtk::ComboBox, you can use
"Gtk::ComboBox::get_active_row_number" which returns the index you seek.

Bob

Sean Kelley wrote:

> Hi,
>
> I am porting my Qt application to Gtkmm in order to learn more about
> Gtkmm.  I am not particularly clear on how to get an index into my
> ComboBoxText.  So if I have a combo box of a number of text items, in
> my case Irish Gaelic prepositions, how do get the index on a changed
> signal?
>
>     //Child widgets:
>     Gtk::ComboBoxText    m_pronBox;
>     Gtk::ComboBoxText    m_prepBox;
>
> ....
>
>       //Fill the combo:
>       m_prepBox.append_text("ag");
>       m_prepBox.append_text("ar");
>       m_prepBox.append_text("as");
>       m_prepBox.append_text("chun");
>  ...
>       //Connect signal handler:
>     m_prepBox.signal_changed().connect( sigc::mem_fun(*this,
> &IrishPrep::on_combobox_changed) );
> ...
>
> All I can get from the combo box is the text selected.  In Qt I had
> used a QtComboBox, where I could access the member function
> currentItem.  I would rather have the actual index into it and not the
> string.
>
> Thanks in advance!
>
> Sean
>
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>gtkmm-list mailing list
>gtkmm-list gnome org
>http://mail.gnome.org/mailman/listinfo/gtkmm-list
>  
>



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