使用FileChooserDialog打开多文件

单文件比较简单,
看到这个函数的原型是这样的:
Glib::SListHandle<Glib::ustring> Gtk::FileChooser::get_filenames ( ) const
因此,就以为要使用这样的变量来进行声明:
Glib::SListHandle<Glib::ustring> filenames =dialog.get_filenames();
for(int i=0;i<filenames.size();i++)
{
//Notice that this is a std::string, not a Glib::ustring.
//std::string filename = dialog.get_filename();
std::cout << "File selected: " << filenames[i] << std::endl;
}

结果发现编译不通过,再仔细看看,Glib::SListHandle并没有重载[]操作符。
再网络上搜索后发现有人和我的问题相同:

That looks like a case where the GLib documentation was automatically
converted to glibmm documentation, but it doesn't really make sense.
SListHandle and ListHandle types are 'intermediate' types that you
shouldn't ever really need to use. They just provide handy
conversions to any of the standard containers. So, you should just be
able to use either std::list<> or std::vector<> or something like
that. So something like the following:

std::list<Glib::ustring> filenames = chooser.get_filenames();

而且,紧跟的一个邮件说明需要使用std::string来声明,就是应该这样:
std::vector<std::string> filenames=chooser.get_filenames();
恩,这样就清楚了。

参考:http://mail.gnome.org/archives/gtkmm-list/2007-May/msg00178.html

This entry was posted in Program and tagged , , . Bookmark the permalink.

2 Responses to 使用FileChooserDialog打开多文件

  1. eric says:

    你好,我看了你的文章,了解到你解决过skype在ubuntu出现过的话筒没有声音的问题,希望你可以帮到我。我在ubuntu7.04安装了 skype1.5,安装过做测音,只听到,而不能说,而我在WIN里用是正常的,请问怎么解决,谢谢

  2. wlx [微博 ] says:

    skype出来了1.5版本了么?好像最新的是1.4.0.94阿
    首先确认一下,你的话筒在别的程序里是否正常?

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Please copy the string 8OwAOC to the field below:

以新浪微博帐号登录