Jump from a panel to another panel and handover parameters

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
In need of some credit
In need of some credit
Posts: 1
Joined: Sat Feb 03, 2018 3:14 pm

Jump from a panel to another panel and handover parameters

Postby StepOn » Thu Jun 28, 2018 9:28 pm

Hi there,
this is my very first post to a forum and I hope nobody will laugh about my maybe simple question.
I wrote a long programme recognizing stamps in C++ using open cv. But to be honest I think I still miss some deep basics of C++.
I started to build a gui for my programme, with wxwidgets.
I created a frame with a notebook that contains many panels.

Code: Select all

Frame2::Frame2(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxFrame(parent, id, title, pos, size, style)
   this->SetSizeHints(wxDefaultSize, wxDefaultSize);

   wxBoxSizer* bSizer3;
   bSizer3 = new wxBoxSizer(wxVERTICAL);

   m_notebook1 = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0);
   m_panel1 = new MyPanel1(m_notebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
   m_panel1->SetMaxSize(wxSize(-1, 20));
   m_notebook1->AddPage(m_panel1, wxT("Marke suchen"), true);
   m_panel2 = new MyPanel2(m_notebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
   m_notebook1->AddPage(m_panel2, wxT("Marke editieren"), false);
   m_panel3 = new wxPanel(m_notebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
   m_notebook1->AddPage(m_panel3, wxT("Marke ergaenzen"), false);

Each panel uses an own class.
Now the question :
How can I access the m_panel2 from a function in m_panel1?

Code: Select all

void MyPanel1::openpicturedetails(wxCommandEvent& event)
   int t;
   t = event.GetId() - 11000;

m_panel2 is not known in this function.
And also the m_staticTextPanel02_T01 is part of m_panel2 and therefore also not known here.

This is the screen of m_panel1:
And when I click on a stamp I want to open the panel "Marke editieren" and handover some data to this panel.
But I really don't have a clue how to achieve that.
The function is already reacting correctly on the mouseclick and the content is stored correctly in variable t.

I hope my problem got clear. And I assume solution will be pretty easy.

But I don't have a clue how to find a solution for this in google or in my C++ bible.

Thanks for any advice

User avatar
Posts: 12424
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Jump from a panel to another panel and handover parameters

Postby doublemax » Thu Jun 28, 2018 9:42 pm

Theoretically you could just add a method like SetPanel2Pointer( MyPanel2 *) to MyPanel1, and inside the method you store the pointer so you can access it later. But that would become pretty ugly if several panels need to talk to each other.

In this case it would be better to have some methods in an object that's higher up in the hierarchy, e.g. Frame2.
So you have a a method like Frame2::EditStamp( ... parameters ...) and that method doesn't do any work itself, it only delegates the call to MyPanel2.
Use the source, Luke!

Return to “General Development”

Who is online

Users browsing this forum: No registered users and 1 guest