Close all panes in wxAuiManager

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
georgeplusplus
Knows some wx things
Knows some wx things
Posts: 25
Joined: Tue May 11, 2021 1:49 pm

Close all panes in wxAuiManager

Post by georgeplusplus »

I am trying to close all panes using the GetAllPanes() method , but when I try to iterate over the panes, it tells me

Severity Code Description Project File Line Suppression State
Error C2247 'wxVector<T>::at' not accessible because 'wxBaseObjectArray<wxAuiPaneInfo,wxObjectArrayTraitsForwxAuiPaneInfoArray>' uses 'private' to inherit from 'wxBaseArray<T *,wxSortedArray_SortFunction<wxAuiPaneInfo*>>' \src\MainWindow.cpp 134

Severity Code Description Project File Line Suppression State
Error (active) E0265 function "wxVector<T>::begin() [with T=wxAuiPaneInfo *]" (declared at line 500 of "C:\wxWidgets-3.1.4\include\wx\vector.h") is inaccessible src\MainWindow.cpp 133

Code: Select all

		
		if (m_tree_view)
		{
			
			auto panes = m_mgr.GetAllPanes();
			for (auto& pane : panes)
			{
				pane->DestroyOnClose();
				m_mgr.ClosePane(pane);
			}
			
		}
What am I doing wrong here? Is there another way to close all the panes?
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Close all panes in wxAuiManager

Post by doublemax »

Try wxAuiPaneInfoArray& instead of auto.
Use the source, Luke!
georgeplusplus
Knows some wx things
Knows some wx things
Posts: 25
Joined: Tue May 11, 2021 1:49 pm

Re: Close all panes in wxAuiManager

Post by georgeplusplus »

Code: Select all

void MainWindow::CloseAllPanes()
{
	auto panes = m_mgr.GetAllPanes();
	for (size_t i = 0; i < panes.size(); i++)
	{
		wxLogDebug(panes[i].name);
		auto pane = panes[i];
		pane.DestroyOnClose();
		m_mgr.ClosePane(pane);
	}
}
I got it to work with this.
Post Reply