我知道这是一个基本的 c++ 问题,但我可以知道如何使用朋友函数在 bada 中将函数/传递值(elementId)从一个类调用到另一个类吗?
在我的表单类中,我有一个 listView,当单击 listView 中的项目时,我想将 elementId 传递给 detailForm 以在标签中显示信息(在 detailForm 中)。在我的 form.h 和 .cpp 中,我包含了 detailForm.h,我可以知道如何访问 detailForm 中的函数来显示信息吗?在form.h中,我还声明了
friend class detailedForm;
当我尝试在我的表单类中使用 detailForm 中的函数之一时,即 displayInfo(); 表单类有一个错误说 displayInfo() 没有被声明。
表格.h
...
public:
friend class ChartFormDetail;
这是我的 form.cpp 代码
#include "Form.h"
#include "ChartFormDetail.h"
...
void
Form::OnGroupedListViewItemStateChanged(Osp::Ui::Controls::GroupedListView &listView, int groupIndex, int itemIndex, int elementId, Osp::Ui::Controls::ListItemStatus state)
{
Frame* pFrame = Osp::App::Application::GetInstance()->GetAppFrame()->GetFrame();
FormMgr* pFormMgr = dynamic_cast<FormMgr*> (pFrame->GetControl("FormMgr"));
if(pFormMgr == null)
return;
pFormMgr->SendUserEvent(FormMgr::REQUEST_DETAILFORM, null);
//pFormMgr->SendUserEvent(elementId, null);
switch(elementId)
{
case ID_FORMAT_STRING_M12:
DisplayLabel();
break;
...
case ID_FORMAT_STRING_F19:
DisplayLabel();
break;
}
}
详细表格.h
public:
...
void DisplayLabel(void);
detailForm.cpp 的代码
void
ChartFormDetail::DisplayInfo(void)
{
pLabel->SetText("Text here");
RequestRedraw();
}