problem building a FileChooser dialog



Hi

I followed the example given in
http://developer.gnome.org/gtkmm-tutorial/3.4/sec-dialogs-filechooserdialog.html.en
for making a FileChooser Dialog.

However, my compiler complains:
IQWin.cpp: In member function 'virtual void IQWin::on_button_load_clicked()':
IQWin.cpp:219: error: 'create' is not a member of 'Gtk::FileFilter'
IQWin.cpp:222: error: no matching function for call to
'Gtk::FileChooserDialog::add_filter(Glib::RefPtr<Gtk::FileFilter>&)'
/usr/include/gtkmm-2.4/gtkmm/filechooser.h:910: note: candidates are:
void Gtk::FileChooser::add_filter(const Gtk::FileFilter&)

These complaints refer to this part of the code:
   Gtk::FileChooserDialog dialog("Please choose a file",
                                  Gtk::FILE_CHOOSER_ACTION_OPEN);
//some other lines
    Glib::RefPtr<Gtk::FileFilter> filter_any = Gtk::FileFilter::create();
    filter_any->set_name("Any files");
    filter_any->add_pattern("*");
    dialog.add_filter(filter_any);

The error message seems to indicate that add_filter does not want a
pointer to FileFIlter, but a reference to it.
When i do
    Gtk::FileFilter *filter_any = Gtk::FileFilter::create();
    filter_any->set_name("Any files");
    filter_any->add_pattern("*");
    dialog.add_filter(*filter_any);
The error for "add_filter" disappears, but the FileFilter::create() still fails.

Can anybody tell me how to get the example going?
Thank You
  Jody


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]