在listview中调用listview
bada Programming - Call listview within a listview
我目前有一个包含4个项目的listview,在其中一个listview项目中,我想实现另一个listview,我是否必须做另一个表单管理器?或者我该怎么做呢?另外,如何在另一个类中调用一个类的函数?还是使用引用(指针)将信息从一个类传递到另一个类?
我不确定我完全理解了这个问题。
简而言之,您需要从一个列表视图指向另一个列表视图的指针。如果是在表单中,那么一个指向列表视图的本地指针就足够了。
同样适用于引用类实例:
class Apple() {
private Basket* basket;
public Apple() {
basket = null;
}
public void setBasket(Basket* basket) {
this->basket = basket;
}
public Basket* getBasket() {
return this->basket;
}
}
class Basket() {
private Apple* apple;
public Basket() {
apple = null;
}
public setApple(Apple* apple) {
this->apple = apple;
this->apple->setBasket(this);
}
}
...
Apple* apple = new Apple();
Basket* basket = new Basket()
basket->setApple(apple);
希望对你有帮助。
好的,我在这里添加了更多的代码,看看它是否有帮助它没有经过测试,在飞行中编写以显示主体:
FormA.h
class FormA :
public Osp::Ui::Controls::Form,
public Osp::Ui::IItemEventListener
{
// Other stuff including list
protected:
void OnItemStateChanged (const Osp::Ui::Control &source, int index, int itemId, Osp::Ui::ItemStatus status);
}
FormA.cpp
// Other stuff including constructor and list control creation/population
void FormA::OnItemStateChanged (const Osp::Ui::Control &source, int index, int itemId, Osp::Ui::ItemStatus status) {
// Construct and show other form
FormB* b = new FormB(itemId);
// Add to frame and set formb as current
}
FormB.h
class FormA :
public Osp::Ui::Controls::Form,
public Osp::Ui::IItemEventListener
{
private int itemId;
public:
FormA(int itemId);
}
FormB.cpp
FormA::FormA(int itemId) {
this->itemId = itemId;
}
// Now somewhere in your form initialization read the itemId
// value (this->itemId) and decide what you want to show in the form's list view
相关文章:
- 什么时候调用组成单元对象的析构函数
- 对RValue对象调用的LValue ref限定成员函数
- 为什么使用 "this" 指针调用派生成员函数?
- 函数调用中参数的顺序重要吗
- OpenGL - 在抛出"__gnu_cxx::recursive_init_error"实例后终止调用?
- 基于另一个成员参数将函数调用从类传递给它的一个成员
- 为什么我的C#代码在调用回C++COM直到Task时会暂停.等待/线程.加入
- 在c++类上调用void函数
- 为什么 std::unique 不调用 std::sort?
- 调用专用模板时出错"no matching function for call to [...]"
- 选择要调用的构造函数
- C++为什么尽管我调用了void函数,它却不起作用
- 构造函数正在调用一个使用当前类类型的函数
- 变量没有改变?通过向量的函数调用
- 没有为自己的结构调用列表推回方法
- 调用'begin(int [n])'没有匹配函数
- 什么时候调用析构函数
- 如何用参数值调用函数(仅在运行时已知)
- Qt/QML:将 WebEngineView 放在 ListView 中并调用 loadHtml()
- 在listview中调用listview