User Tools

Site Tools


Sidebar

Introduction

* Home

Documentation & help

LibreCAD Community

Help on DokuWiki

Temporary shorcuts

dev:v3:gui_api:menu:main_window

This is an old revision of the document!


Main Window Menu GUI API Functions

Github Link

 namespace lc::ui::api 

Add Menu


Description

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.

  •  lc::ui::api::Menu* addMenu(const std::string& menuName); 
    • Parameters :-
      1. Menu Name - Name/Label of the menu to be added.
    • Returns :-
      • Pointer to the menu added to the menu bar.
  •  void addMenu(lc::ui::api::Menu* menu); 
    • Parameters :-
      1. Pointer to menu to be added.

Examples

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

Get Menu


Description

Return pointer to menu of the given name or position present in the menu bar.

  •  lc::ui::api::Menu* menuByName(const std::string& menuName) 
    • Get menu by name/label
    • Parameters :-
      1. Menu Name - Name/Label of the menu to be returned.
    • Returns :-
      • Pointer to the menu of the given name in the menu bar.
  •  lc::ui::api::Menu* menuByPosition(int pos) 
    • Get menu by position
    • Parameters :-
      1. Position (int) - Position of the menu in the menu bar (Starting from 0 on the left most menu)
    • Returns :-
      1. Pointer to menu of the given position in the menu bar.

Examples

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

Remove Menu


Description

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.

  •  void removeMenu(const char* menuLabel) 
    • Remove menu of the given name/label
    • Parameters :-
      1. Menu Name - Name/Label of the menu to be removed.
  •  void removeMenu(int position) 
    • Remove menu at the given position in the menu bar.
    • Parameters :-
      1. Position (int) - Position of the menu in the menu bar (Starting from 0 on the left most menu)

Examples

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

Find Menu Item


Description

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).

  •  lc::ui::api::MenuItem* findMenuItem(std::string label) 
    • Find menu item of the given label
    • Parameters :-
      1. Menu Item Name - Name/Label of the menu item to be found.
    • Returns :-
      1. Pointer to menu item found of the given label.
  •  lc::ui::api::MenuItem* findMenuItemByObjectName(std::string objectName) 
    • Find menu item of the given qt object name.
    • Parameters :-
      1. Object name - Qt object name of the menu item to be found.
    • Returns :-
      1. Pointer to menu item found of the given object name.

Examples

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

dev/v3/gui_api/menu/main_window.1594014819.txt.gz · Last modified: 2020/07/06 05:53 by jedi18