- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 GUI 创建我的第一个 C++ 程序。我正在使用 Code::Blocks v16.01 和 wxWidgets v3.03。我发现在wxComboBox类构造函数中,代表选择的类型是wxArrayString。我曾尝试将 vector 转换为 vector ,然后再转换为 vector 和 wxArrayString,但失败得很惨......
我的问题是如何设置 wxComboBox 对象的默认选择值?最好我希望它们充满在程序执行期间创建的 vector 值。
代码如下:
#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++ - 将 vector<double> 设置为 wxComboBox 的选择值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47873069/
我的 wxComboBox 有问题。我用 wxString 设置了两个值(P 01 和 P 03)。现在我用 开始一个事件 Connect(ID_DEV, wxEVT_COMMAND_COMBOBOX
我如何动态地填充 wxComboBox 中的值,我知道我们可以在像这样初始化它时填充它,但我想这样做,例如当用户点击按钮时 wxArrayString m_arrItems; // Create
我一直在尝试制作一个 ComboBox,它会在您键入时提供选项建议,很像 IDE 的代码建议/代码感知,或者在您输入搜索时提供 google 的建议。 建议是 ComboBox 下拉列表中的项目,其中
我希望我的问题不是本地化的......但我认为其他人会遇到这个或类似的问题。 我想创建一个 vector ,其中包含我系统中的所有可用端口(这适用于控制台应用程序)。之后我想复制 wxString-A
我正在使用 GUI 创建我的第一个 C++ 程序。我正在使用 Code::Blocks v16.01 和 wxWidgets v3.03。我发现在wxComboBox类构造函数中,代表选择的类型是wx
我是一名优秀的程序员,十分优秀!