我在gtkmm 2中开发应用程序并学习如何使用标签。现在我不知道如何在创建实际标签的append-function的签名中添加框架或V_Box。
m_Notebook.append_page(m_Label1, "First");
以下是如何添加名为m_label1的标签的示例。但是,如果我想添加一个包含入口字段和其他标签等子项目的框,该怎么办呢?我该如何实现?
ExampleWindow::ExampleWindow()
: m_Label1("Contents of tab 1"),
m_Label2("Contents of tab 2"),
m_Button_Quit("Quit")
{
set_title("Gtk::Notebook example");
set_border_width(10);
set_default_size(400, 200);
//MyButton myButton;
add(m_VBox);
//Add the Notebook, with the button underneath:
m_Notebook.set_border_width(10);
m_VBox.pack_start(m_Notebook);
m_VBox.pack_start(m_ButtonBox, Gtk::PACK_SHRINK);
m_ButtonBox.pack_start(m_Button_Quit, Gtk::PACK_SHRINK);
m_Button_Quit.signal_clicked().connect(sigc::mem_fun(*this,
&ExampleWindow::on_button_quit) );
//Add the Notebook pages:
//m_Notebook.append_page(m_Label1, "First");
m_Notebook.append_page(m_Label1, "First");
m_Notebook.append_page(m_Label2, "Second");
m_Notebook.signal_switch_page().connect(sigc::mem_fun(*this,
&ExampleWindow::on_notebook_switch_page) );
show_all_children();
}
ExampleWindow::~ExampleWindow()
{
}
void ExampleWindow::on_button_quit()
{
hide();
}
void ExampleWindow::on_notebook_switch_page(GtkNotebookPage* /* page */, guint page_num)
{
std::cout << "Switched to tab with index " << page_num << std::endl;
//You can also use m_Notebook.get_current_page() to get this index.
}
答案 0 :(得分:2)
您只需添加框而不是标签。例如:
m_Notebook.append_page(first_box,“First”);
将子窗口小部件添加到该框中。