如何使用向量< myObject>使用Imgui :: ListBox?
我正在尝试在列表框中显示对象的向量,该对象将在每个帧中都会动态渲染。
这是我的班级,我想在列表框中显示每个属性:
class Waypoint {
public:
int x, y, z;
char action;
};
我现在尝试的是我真的不知道的是:
Waypoint wp1;
wp1.action = 'R';
wp1.x = 100;
wp1.y = 100;
wp1.z = 7;
Waypoint wp2;
wp2.action = 'S';
wp2.x = 100;
wp2.y = 100;
wp2.z = 6;
std::vector<Waypoint> listbox_items { wp1, wp2 };
static int listbox_item_current = 1;
ImGui::ListBox("listbox::Cavebot", &listbox_item_current, listbox_items);
当然这是不起作用的,我遇到了这个错误:
E0304 no instance of overloaded function "ImGui::ListBox" matches the argument list
我该如何在列表框中动态显示我所有的对象属性?
I'm trying to display a vector of objects in a listbox that will be rendered dynamically in every frame.
This is my class and I want to display every attribute later in the listbox:
class Waypoint {
public:
int x, y, z;
char action;
};
What I'm trying now as I don't really know is this:
Waypoint wp1;
wp1.action = 'R';
wp1.x = 100;
wp1.y = 100;
wp1.z = 7;
Waypoint wp2;
wp2.action = 'S';
wp2.x = 100;
wp2.y = 100;
wp2.z = 6;
std::vector<Waypoint> listbox_items { wp1, wp2 };
static int listbox_item_current = 1;
ImGui::ListBox("listbox::Cavebot", &listbox_item_current, listbox_items);
Of course this is not working, and I'm getting this error:
E0304 no instance of overloaded function "ImGui::ListBox" matches the argument list
How can I display dynamically all my objects attributes in the listbox?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
imgui :: ListBox
将char*
作为显示的文本,因此您无法使用单个char> char
。您应该像这样重新设计课程:然后使用此功能:
示例:
ImGui::ListBox
takes achar*
as a displayed text, so you could not use a singlechar
. You should re-design your class like this:Then use this function:
Example: