QMenu* menu = new QMenu(this); QAction* action1 = new QAction("Action 1", this); QAction* action2 = new QAction("Action 2", this); QAction* separator = new QAction(this); separator->setSeparator(true); menu->addAction(action1); menu->addAction(separator); menu->addAction(action2);
QToolBar* toolbar = new QToolBar(this); QAction* action1 = new QAction("Action 1", this); QAction* action2 = new QAction("Action 2", this); QAction* separator = toolbar->addSeparator(); toolbar->addAction(action1); toolbar->addAction(separator); toolbar->addAction(action2);In this example, we create a toolbar with two actions and a separator between them. The addSeparator() function is called on the QToolBar object to add a separator to the toolbar. Package library: QtGui