本文整理汇总了C++中ToolBar::addAction方法的典型用法代码示例。如果您正苦于以下问题:C++ ToolBar::addAction方法的具体用法?C++ ToolBar::addAction怎么用?C++ ToolBar::addAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ToolBar
的用法示例。
在下文中一共展示了ToolBar::addAction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QMainWindow
/*
* Constructs a TextViewer which is a child of 'parent', with the
* name 'name' and widget flags set to 'f'
*/
TextViewer::TextViewer( QWidget *parent, Qt::WFlags f )
: QMainWindow( parent, f )
{
textArea = new QTextEdit(this);
textArea->setReadOnly(true);
setCentralWidget(textArea);
docSelector = new QDocumentSelector();
QAction *actionOpen = new QAction(tr("Open Document"), this );
connect(actionOpen, SIGNAL(triggered()), this, SLOT(openDocument()));
#ifdef QTOPIA_PHONE
QMenu* menu = QSoftMenuBar::menuFor(textArea);
menu->addAction(actionOpen);
#else
ToolBar *toolbar = new QToolBar(this);
toolbar->setMovable(false);
addToolBar(toolbar);
toolbar->addAction(actionOpen);
#endif
connect(docSelector, SIGNAL(documentSelected(QContent)), this, SLOT(documentSelected(QContent)));
}
示例2: QDialog
PrintPreviewDialog::PrintPreviewDialog(QPrinter *printer, QWidget *parent)
: QDialog(parent)
{
m_initialized = false;
QVBoxLayout *mainLayout = new QVBoxLayout;
m_printPreviewWidget = new QPrintPreviewWidget(printer, this);
connect(m_printPreviewWidget, SIGNAL(paintRequested(QPrinter*)), this, SIGNAL(paintRequested(QPrinter*)));
connect(m_printPreviewWidget, SIGNAL(previewChanged()), this, SLOT(updateZoomFactor()));
ToolBar *toolBar = new ToolBar("printpreview_toolbar", this);
Action *action = new Action(Icon("zoom-fit-width"), tr("Fit &width"), this, "printpreview_fit_width");
connect(action, SIGNAL(triggered()), m_printPreviewWidget, SLOT(fitToWidth()));
toolBar->addAction(action);
action = new Action(Icon("zoom-fit-best"), tr("Fit p&age"), this, "printpreview_fit_page");
connect(action, SIGNAL(triggered()), m_printPreviewWidget, SLOT(fitInView()));
toolBar->addAction(action);
m_zoomToAction = new ZoomAction(Icon("zoom-original"), tr("&Zoom"), this, "printpreview_zoom_to");
connect(m_zoomToAction, SIGNAL(zoomFactorAdded(qreal)), this, SLOT(setZoomFactor(qreal)));
toolBar->addAction(m_zoomToAction);
toolBar->addAction(StandardAction::zoomIn(this, SLOT(zoomIn()), this));
toolBar->addAction(StandardAction::zoomOut(this, SLOT(zoomOut()), this));
action = new Action(Icon("document-print"), tr("&Print"), this, "printpreview_print");
connect(action, SIGNAL(triggered()), this, SLOT(print()));
toolBar->addAction(action);
action = new Action(Icon("window-close"), tr("&Close"), this, "printpreview_close");
connect(action, SIGNAL(triggered()), this, SLOT(reject()));
toolBar->addAction(action);
mainLayout->addWidget(toolBar);
mainLayout->addWidget(m_printPreviewWidget);
setLayout(mainLayout);
m_zoomToAction->setZoomFactor(1.0);
}