c++ gtk打开多个窗口
我仍在处理此链接中的示例:gtkmm statusicon 创建后退出 我以这种方式更改了功能以打开托盘栏不同的窗口,但不显示任何内容。
void Tray::on_statusicon_popup(guint button, guint activate_time) {
printf("popup!\n");
Gtk::Window w;
w.show();
}
我尝试使用“Gtk::Main::run(w);”运行每个窗口它有效,但我不想为每个窗口运行主循环。
I'm still working on the example at this link: gtkmm statusicon quits after creation
I changed the function in this way to open the traybar different windows, but does not show anything.
void Tray::on_statusicon_popup(guint button, guint activate_time) {
printf("popup!\n");
Gtk::Window w;
w.show();
}
I tried to run every window with "Gtk::Main::run(w);" and it works, but I would like to not run a main loop for each window.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在堆栈上创建窗口对象,因此它会在
on_statusicon_popup()
返回后立即被销毁。如果您希望窗口比函数调用更持久,则需要在堆上创建它并连接到其“隐藏”信号(或类似信号)并从那里删除对象。You're creating the window object on the stack, so it gets destroyed immediately after
on_statusicon_popup()
returns. If you want the window to outlast the function call, you'll need to create it on the heap and connect to its 'hide' signal (or similar) and delete the object from there.