当前位置: 首页>>代码示例>>C++>>正文


C++ ToolBar::addAction方法代码示例

本文整理汇总了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)));
}
开发者ID:GodFox,项目名称:qtopia-ezx,代码行数:25,代码来源:textviewer.cpp

示例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);
}
开发者ID:KarateSnowMachine,项目名称:qtikz-svn,代码行数:36,代码来源:printpreviewdialog.cpp


注:本文中的ToolBar::addAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。