[gtkmm] ComboxText : remove a string ?
- From: Gauthier <oogothoo yahoo fr>
- To: gtkmm <gtkmm-list gnome org>
- Subject: [gtkmm] ComboxText : remove a string ?
- Date: Sat, 18 Sep 2004 20:00:04 +0200
Hi all,
I use Gtk::ComboBoxText widget from Gtkmm-2.4 an I want to delete a
string (or all). What function use to delete ? get_model() and use
TreeModel to delete but how ?
I enclose an example of program.
Gauthier.
// g++ toto.cc `pkg-config --libs --cflags gtkmm-2.4`
#include <gtkmm.h>
class MyDialog : public Gtk::Dialog
{
public:
MyDialog();
virtual ~MyDialog() {}
private:
void on_combo1_changed();
void on_combo2_changed();
Gtk::HBox m_hbox;
Gtk::ComboBoxText m_combo1;
Gtk::ComboBoxText m_combo2;
};
MyDialog::MyDialog()
{
m_hbox.add(m_combo1);
m_hbox.add(m_combo2);
get_vbox()->add(m_hbox);
m_combo1.append_text("1");
m_combo1.append_text("2");
m_combo1.set_active(0);
on_combo1_changed();
m_combo1.signal_changed().connect(
sigc::mem_fun(*this, &MyDialog::on_combo1_changed));
m_combo2.signal_changed().connect(
sigc::mem_fun(*this, &MyDialog::on_combo2_changed));
show_all();
}
void MyDialog::on_combo1_changed()
{
// HOWTO CLEAN m_combo2 ?
if (m_combo1.get_active_text() == "1") {
m_combo2.append_text("1 bis");
m_combo2.append_text("2 bis");
m_combo2.append_text("3 bis");
} else {
m_combo2.append_text("1 ok");
m_combo2.append_text("2 ok");
m_combo2.append_text("3 ok");
m_combo2.append_text("4 ok");
m_combo2.append_text("5 ok");
m_combo2.append_text("6 ok");
m_combo2.append_text("7 ok");
m_combo2.append_text("8 ok");
}
m_combo2.set_active(0);
}
void MyDialog::on_combo2_changed()
{
g_print("on_combo2_changed %s\n", m_combo2.get_active_text().c_str());
}
int main(int argc, char** argv)
{
Gtk::Main app(&argc, &argv);
MyDialog dial;
app.run(dial);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]