User Tools

Site Tools



* Home

Documentation & help

LibreCAD Community

Help on DokuWiki

Temporary shorcuts


Main Window Menu GUI API Functions

Github Link

 namespace lc::ui::api 

Add Menu


Add a menu to the MenuBar of the Main Window. Menu is an instance of the Menu GUI class. Will not add if another menu of the same label already exists in the menu bar.
Note :- Menu of same label may exist in a menu inside a menu of the menu bar i.e. more than one level away from the menu bar.

  • Menu Name - string
  • Pointer to Menu GUI object - menu gui object


  •  local menu1 = mainWindow:addMenu("Test") 
  •  local menu1 = gui.Menu("Test")

Get Menu


Return pointer to menu of the given name or position present in the menu bar. Returns nullptr if not present.

  • Menu Label - string
  • Menu Position - int (Starting from 0 on the left most menu)


  •  local menu1 = mainWindow:menuByName("Test") 
  •  local menu2 = mainWindow:menuByPosition(2) 

Remove Menu


Remove menu of the given name or at the given position from the menu bar. Does nothing if menu does not exist in the menu bar.

  • Menu Label - string
  • Menu Position - int (Starting from 0 as the left most menu)


  •  mainWindow:removeMenu("Test") 
  •  mainWindow:removeMenu(2) 

Find Menu Item


Find and return the first menu item found of the given label/object name present in any of the menus recursively (menu bar as well as menus inside other menus).

  • Menu Item Label - string
  • Menu Item Qt Object Name - string


  •  local item1 = mainWindow:findMenuItem("Ellipse") 
  •  local item2 = mainWindow:findMenuItemByObjectName("actionNew") 

dev/v3/gui_api/menu/main_window.txt · Last modified: 2020/07/06 14:39 by jedi18