简体   繁体   English

C ++-如何在gtkmm中的对话框中显示图标

[英]C++ - How to display an icon in a dialog in gtkmm

I have several Dialog in my program that tells the users various things, from errors, to confirmation. 我的程序中有几个对话框,可以告诉用户从错误到确认的各种信息。

The sample in the documentation tells me to use this to have an icon set depending on the dialog (warning, information, question mark...): 文档中的示例告诉我可以使用它来根据对话框设置图标集(警告,信息,问号...):

Gtk::MessageDialog dialog(*this, "This is a QUESTION MessageDialog",
    false /* use_markup */, Gtk::MESSAGE_QUESTION,
    Gtk::BUTTONS_OK_CANCEL);

However, I do not get any icon in the dialog, I am only able to change the icon in the top bar, using this : 但是,对话框中没有任何图标,我只能使用以下命令更改顶部栏中的图标:

Gtk::MessageDialog dialog(*this,~     
    "Please select something first.",
    false,                        
    Gtk::MESSAGE_ERROR,           
    Gtk::BUTTONS_OK);             
dialog.set_icon_name("dialog-error"); 
dialog.run();                         

I get no error, no warning, this compile and execute just fine, but the resulting message box doesn't have any icon in it. 我没有错误,也没有警告,此编译和执行效果很好,但是结果消息框中没有任何图标。 How can I get an icon to display properly INSIDE my dialog box ? 如何在对话框中获取图标以正确显示? I also tried the other MESSAGE_* available, without success. 我也尝试了其他可用的MESSAGE_ *,但没有成功。

According to the Gtk3 documentation one should use GtkDialog to create dialogs with images. 根据Gtk3文档,应该使用GtkDialog创建带有图像的对话框。

You may use set_image but it is deprecated since 3.12. 您可以使用set_image但自3.12起不推荐使用。

More concrete: 更具体:

void Gtk::MessageDialog::set_image(Widget& image) 无效Gtk :: MessageDialog :: set_image(Widget&image)

Sets the dialog's image to image. 将对话框的图像设置为image。

Since gtkmm 2.10: Deprecated: 3.12: Use Gtk::Dialog to create dialogs with images 从gtkmm 2.10开始:不推荐使用:3.12:使用Gtk :: Dialog创建带有图像的对话框

Deprecated: Use Dialog to create dialogs with images. 不推荐使用:使用对话框创建带有图像的对话框。

Parameters image The image. 参数image图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM