2021-11-22 04:34 AM
Hi,
I created custom container for spesific purpose and I want to see USB connection status there. Therefore, I have to update the value of status continuously. Custom containers does not have presenter.cpp file and I do not refresh the value simultaneously.
Thanks.
2022-01-03 11:33 PM
If I understand you correctly, you'd like to be able to access the presenter pointer from within a custom container that belongs to the relevant view class?
I use this technique a lot. Basically in your custom container you just need a data member of type 'pointer to Presenter' and a function to set the data member eg
// in eg UsbContainer.hpp
class UsbContainer : public UsbContainerBase
{
public:
...
void setPresenter(MyPresenter* presenter)
{
presenter_ = presenter;
}
void display()
{
...
int state = presenter_->getUsbState();
show(state);
...
}
...
protected:
...
MyPresenter* presenter_{nullptr};
...
};
// in eg MyView.cpp
void MyView::setupScreen()
{
MyViewBase::setupScreen();
usbContainer.setPresenter(presenter);
usbContainer.display();
}