将向量<double>设置为wxComboBox的选择值
Setting vector<double> as choice values of wxComboBox
我正在用GUI创建我的第一个C 程序。我正在使用代码:: blocks v16.01和wxwidgets v3.03。我发现在WXCOMBOBOX类构造函数中,代表选择的类型是WxArrayString。我试图将向量转换为向量,然后将其转换为向量和wxarraystring,但失败了...
我的问题是如何设置WXCOMBOBOX对象的默认选择值?最好是我希望它们在程序执行过程中创建的向量值填充。
这是代码:
#include <iostream>
#include <vector>
#include <fstream>
#include <sstream>
using namespace std;
vector <double> vector_double;
vector <string> vector_string;
vector <wxString> vector_wxstring;
void convert_double_to_string(vector<double> &dbl, vector <string> &str)
{
for (int i = 0; i < dbl.size(); i++)
{
ostringstream stream;
stream << dbl[i];
str.push_back(stream.str());
}
}
void convert_string_to_wxString(vector<string> & str, vector <wxString> &wxstr);
{
for (int i = 0; i < str.size(); i++)
{
wxstr.push_back(_(str[i]));
}
}
void main()
{
/////////
// here setting vector_double's values
//////////
convert_double_to_string(vector_double, vector_string);
convert_string_to_wxString(vector<string> vector_string, vector_wxstring);
}
这就是我所拥有的。但是,字符串转换为WXSTRING不起作用。即使可以的话,我也不知道如何将其插入wxarraystring。
与这些行:
wxComboBox * cbo = new wxComboBox( ... );
wxArrayString as;
for ( auto& s : vector_string )
as.Add( s );
cbo->Set( as );
相关文章:
- 如何使用默认参数等选择模板专业化
- 如何(从固定列表中)选择一个数字序列,该序列将与目标数字相加
- 选择要调用的构造函数
- C++选择排序算法中的逻辑错误
- QTreeView幻灯片多选后无法使用单击选择
- 无法获取菜单选择以运行函数.C++
- Qt C++静态thread_local QNetworkAccessManager是线程应用程序的好选择吗
- 在C++中,如何通过几种类型从元组中选择多个元素
- 讨论 - 创建矩阵时的数组与向量的向量 - 什么是最实用的选择
- 对可变参数使用声明.如何选择正确的功能
- 选择选举获胜者的程序
- 如何选择在 csv 文件中输出的位置
- 根据用户回答声明"Players"。用户选择玩家数量。播放器是结构体
- 程序在尝试猜测它选择的随机数时进入无限循环?
- 选择和修改嵌套向量中的条目的最佳实践
- 在PostgreSQL中根据它们的ID选择大量行的最快方法是什么?
- 表达式 SFINAE:如何根据类型是否包含具有一个或多个参数的函数来选择模板版本
- 在运行时选择父类的实现
- 数数并选择 sqlite 中的前三名
- 将向量<double>设置为wxComboBox的选择值