-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathComboBoxWithModelView.cpp
48 lines (38 loc) · 1.46 KB
/
ComboBoxWithModelView.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <gtkmm.h>
using namespace Glib;
using namespace Gtk;
class Form : public Window {
public:
Form() {
this->add(this->scrolledWindow);
this->scrolledWindow.add(this->fixed);
this->fixed.add(this->comboBox1);
this->fixed.child_property_x(this->comboBox1) = 10;
this->fixed.child_property_y(this->comboBox1) = 10;
this->comboBox1.set_size_request(121, 30);
this->treeModelColumnRecord.add(this->treeModelColumnString);
this->listStore = ListStore::create(this->treeModelColumnRecord);
this->comboBox1.set_model(this->listStore);
this->comboBox1.pack_start(this->treeModelColumnString);
(*this->listStore->append())[this->treeModelColumnString] = "item1";
(*this->listStore->append())[this->treeModelColumnString] = "item2";
(*this->listStore->append())[this->treeModelColumnString] = "item3";
this->comboBox1.set_active(1);
this->set_title("ComboBox example");
this->set_size_request(300, 300);
this->show_all();
}
private:
Fixed fixed;
ScrolledWindow scrolledWindow;
ComboBox comboBox1;
TreeModelColumn<ustring> treeModelColumnString;
TreeModelColumnRecord treeModelColumnRecord;
RefPtr<ListStore> listStore;
};
int main(int argc, char* argv[]) {
RefPtr<Application> application = Application::create(argc, argv);
Form form;
return application->run(form);
}
// see https://developer.gnome.org/gtkmm-tutorial/stable/combobox-example-full.html.en for more information