[英]How i call another “window” in C with GTK3
i want to call another window when i press the button "on_btn_janelaCriarSessao_clicked", my code of the window is this: 我想在按下按钮“ 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);}
and the code of button is this: 按钮的代码是这样的:
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();}
But, when i press the button, he open the window but without any widget, a blank Window just with the title i put in. The code of my main.cpp: 但是,当我按下按钮时,他打开了一个窗口,但没有任何小部件,一个空白窗口仅带有我输入的标题。main.cpp的代码:
gtk_init(&argc, &argv);
JanelaPrincipal obj;
obj.mostrar();
gtk_main();
return 0;}
btn_cadastrarSessao = gtk_button_new_with_label("Cadastrar");
我认为缺少与clicked
事件的连接:
g_signal_connect(G_OBJECT(btn_cadastrarSessao), "clicked", ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.