public mainwindow() { QMenu fileMenu = new QMenu(tr("File")); QAction quitAction = fileMenu.addAction(tr("Exit")); quitAction.setShortcut(tr("Ctrl+Q")); QMenu tableMenu = new QMenu(tr("Table")); QAction tableWidthAction = tableMenu.addAction(tr("Change Table Width")); QAction tableHeightAction = tableMenu.addAction(tr("Change Table Height")); menuBar().addMenu(fileMenu); menuBar().addMenu(tableMenu); // ! [0] tableWidget = new QTableWidget(this); // ! [0] tableWidget.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection); quitAction.triggered.connect(this, "close()"); tableWidthAction.triggered.connect(this, "changeWidth()"); tableHeightAction.triggered.connect(this, "changeHeight()"); setupTableItems(); setCentralWidget(tableWidget); setWindowTitle(tr("Table Widget Resizing")); }
private void createMenus() { saveAsMenu = new QMenu(tr("&Save As"), this); for (QAction action : saveAsActs) saveAsMenu.addAction(action); fileMenu = new QMenu(tr("&File"), this); fileMenu.addAction(openAct); fileMenu.addMenu(saveAsMenu); fileMenu.addAction(printAct); fileMenu.addSeparator(); fileMenu.addAction(exitAct); optionMenu = new QMenu(tr("&Options"), this); optionMenu.addAction(penColorAct); optionMenu.addAction(penWidthAct); optionMenu.addSeparator(); optionMenu.addAction(clearScreenAct); helpMenu = new QMenu(tr("&Help"), this); helpMenu.addAction(aboutAct); helpMenu.addAction(aboutQtAct); menuBar().addMenu(fileMenu); menuBar().addMenu(optionMenu); menuBar().addMenu(helpMenu); }
private void createMenus() { fileMenu = menuBar().addMenu(tr("&File")); fileMenu.addAction(addImagesAct); fileMenu.addAction(removeAllImagesAct); fileMenu.addSeparator(); fileMenu.addAction(exitAct); viewMenu = menuBar().addMenu(tr("&View")); for (QAction action : styleActionGroup.actions()) viewMenu.addAction(action); viewMenu.addSeparator(); viewMenu.addAction(guessModeStateAct); menuBar().addSeparator(); helpMenu = menuBar().addMenu(tr("&Help")); helpMenu.addAction(aboutAct); helpMenu.addAction(aboutQtAct); }