0

当我尝试显示文件选择器对话框时,它缺少操作按钮:

let dialog = FileChooserDialog::new(Some("Open File"), Some(&window), FileChooserAction::Open);
dialog.run();

缺少操作按钮

我从另一个项目中找到了另一种方法:

let dialog = FileChooserDialog::new_with_buttons::<ApplicationWindow>(
    Some("Open File"),
    Some(&window),
    FileChooserAction::Open,
    &[
        ("_Cancel", ResponseType::Cancel),
        ("_Open", ResponseType::Accept),
    ],
);

错误信息是:

no function or associated item named `new_with_buttons` found for type `gtk::FileChooserDialog` in the current scope
4

1 回答 1

0

我想您需要add_button在创建对话框之后和显示它之前使用添加按钮:

let dialog = FileChooserDialog::new(Some("Open File"), Some(&window), FileChooserAction::Open);
dialog.add_button("_Cancel", ResponseType::Cancel);
dialog.add_button("_Open", ResponseType::Accept);
dialog.run();
于 2018-01-04T14:17:01.283 回答