我想知道如何在 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 訪問?
uj5u.com熱心網友回復:
呼叫deleteLater()工具列物件將其安排為洗掉,并將其從view -> toolbars選單中完全洗掉。請注意,此后您將無法進一步使用工具列,例如重新添加它iface.addToolBar(toolbar)不起作用。
toolbar = QToolBar('Test Toolbar')
# Add to main window & to 'View' menu
iface.addToolBar(toolbar)
# Remove from main window & 'View' menu
toolbar.deleteLater()
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/331235.html
標籤:Python qt pyqt 地理信息系统 pyqgis
