我想按下按钮时再拨打另一个窗口 " on_btn_janelaCriarSessao_clicked",我的窗口代码是这样的:
JanelaCriarSessao::JanelaCriarSessao(){
/* JANELA CRIAR SESSAO */
windowCriarSessao = gtk_window_new(GTK_WINDOW_TOPLEVEL);
//
gtk_window_set_default_size(GTK_WINDOW(windowCriarSessao), 400, 250);
gtk_window_set_title(GTK_WINDOW(windowCriarSessao), "Criar Sessao");
gtk_window_set_position(GTK_WINDOW(windowCriarSessao), GTK_WIN_POS_CENTER_ALWAYS);
gtk_window_set_resizable(GTK_WINDOW(windowCriarSessao), FALSE);
textoInformativo = gtk_label_new("Digite a chave(ID) da sessao abaixo: ");
entry_IDSESSAO = gtk_entry_new ();
btn_cadastrarSessao = gtk_button_new_with_label("Cadastrar");
caixaWidgets = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
//empacotamento dos widgets na janela
gtk_box_pack_start(GTK_BOX(caixaWidgets), textoInformativo, TRUE, TRUE, 3);
gtk_box_pack_start(GTK_BOX(caixaWidgets), entry_IDSESSAO, TRUE, TRUE, 3);
gtk_box_pack_end(GTK_BOX(caixaWidgets), btn_cadastrarSessao, TRUE, TRUE, 3);
g_signal_connect (GTK_ENTRY(entry_IDSESSAO), "activate",
G_CALLBACK(entry_activate), textoInformativo);
//Connects GCallback function gtk_main_quit to "destroy" signal for "window"
g_signal_connect(G_OBJECT(windowCriarSessao), "destroy",
G_CALLBACK(gtk_main_quit), NULL);
gtk_container_add(GTK_CONTAINER(windowCriarSessao), caixaWidgets);}
按钮的代码是:
void JanelaPrincipal::mostrar(){
//mostra a janela principal
gtk_widget_show_all(window);}
void on_btn_janelaCriarSessao_clicked(GtkWidget *widget, JanelaPrincipal *data){ JanelaCriarSessao obj;
obj.mostrar();}
但是,当我按下按钮时,他打开窗口,但没有任何小部件,一个空白的窗口,只有我放入的标题。 我的main.cpp的代码:
gtk_init(&argc, &argv);
JanelaPrincipal obj;
obj.mostrar();
gtk_main();
return 0;}
答案 0 :(得分:0)
btn_cadastrarSessao = gtk_button_new_with_label("Cadastrar");
我认为缺少与clicked
事件的关联:
g_signal_connect(G_OBJECT(btn_cadastrarSessao), "clicked", ...