我想知道如何在 PyQGIS 中完全删除工具栏,这样工具栏不仅在工具栏区域不再可见,而且不再列在“视图”菜单(“视图”>“工具栏”)下或右键单击时工具栏区域。
使用 . 从主窗口工具栏区域删除工具栏很容易iface.mainWindow().removeToolBar(toolbar)
。这也将从右键单击工具栏区域时显示的列表中删除它。但是,它不会从视图/工具栏菜单中删除工具栏。
toolbar = QToolBar('Test Toolbar')
# Add to main window & to 'View' menu
iface.addToolBar(toolbar)
# Remove from main window
iface.mainWindow().removeToolBar(toolbar)
# 'Test toolbar' is still visible in 'View' menu
如何使工具栏不再可以从 UI 访问?