1
<?xml version="1.0" encoding="iso-8859-1"?>
3
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
<title>Qt 4.6: menus.cpp Example File (activeqt/menus/menus.cpp)</title>
7
<link href="classic.css" rel="stylesheet" type="text/css" />
10
<table border="0" cellpadding="0" cellspacing="0" width="100%">
12
<td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td>
13
<td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="functions.html"><font color="#004faf">All Functions</font></a> · <a href="overviews.html"><font color="#004faf">Overviews</font></a></td><td class="searchBar" align="right" valign="center"><form action="http://www.google.com/cse" id="cse-search-box"><div><input type="hidden" name="cx" value="000136343326384750312:dhbxnqlakyu" /><input type="hidden" name="ie" value="UTF-8" /><input type="text" name="q" size="31" /><input type="submit" name="sa" value="Search" /></div></form></td>
14
</tr></table><h1 class="title">menus.cpp Example File<br /><span class="small-subtitle">activeqt/menus/menus.cpp</span>
16
<pre><span class="comment"> /****************************************************************************
18
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
19
** All rights reserved.
20
** Contact: Nokia Corporation (qt-info@nokia.com)
22
** This file is part of the examples of the Qt Toolkit.
24
** $QT_BEGIN_LICENSE:LGPL$
25
** No Commercial Usage
26
** This file contains pre-release code and may not be distributed.
27
** You may use this file in accordance with the terms and conditions
28
** contained in the Technology Preview License Agreement accompanying
31
** GNU Lesser General Public License Usage
32
** Alternatively, this file may be used under the terms of the GNU Lesser
33
** General Public License version 2.1 as published by the Free Software
34
** Foundation and appearing in the file LICENSE.LGPL included in the
35
** packaging of this file. Please review the following information to
36
** ensure the GNU Lesser General Public License version 2.1 requirements
37
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
39
** In addition, as a special exception, Nokia gives you certain additional
40
** rights. These rights are described in the Nokia Qt LGPL Exception
41
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
43
** If you have questions regarding the use of this file, please contact
44
** Nokia at qt-info@nokia.com.
55
****************************************************************************/</span>
57
#include "menus.h"
58
#include <QAction>
59
#include <QAxFactory>
60
#include <QMenuBar>
61
#include <QMessageBox>
62
#include <QTextEdit>
63
#include <QPixmap>
65
#include "fileopen.xpm"
66
#include "filesave.xpm"
68
QMenus::QMenus(QWidget *parent)
69
: QMainWindow(parent, 0) <span class="comment">// QMainWindow's default flag is WType_TopLevel</span>
73
QMenu *file = new QMenu(this);
75
action = new QAction(QPixmap((const char**)fileopen), "&Open", this);
76
action->setShortcut(tr("CTRL+O"));
77
connect(action, SIGNAL(triggered()), this, SLOT(fileOpen()));
78
file->addAction(action);
80
action = new QAction(QPixmap((const char**)filesave),"&Save", this);
81
action->setShortcut(tr("CTRL+S"));
82
connect(action, SIGNAL(triggered()), this, SLOT(fileSave()));
83
file->addAction(action);
85
QMenu *edit = new QMenu(this);
87
action = new QAction("&Normal", this);
88
action->setShortcut(tr("CTRL+N"));
89
action->setToolTip("Normal");
90
action->setStatusTip("Toggles Normal");
91
action->setCheckable(true);
92
connect(action, SIGNAL(triggered()), this, SLOT(editNormal()));
93
edit->addAction(action);
95
action = new QAction("&Bold", this);
96
action->setShortcut(tr("CTRL+B"));
97
action->setCheckable(true);
98
connect(action, SIGNAL(triggered()), this, SLOT(editBold()));
99
edit->addAction(action);
101
action = new QAction("&Underline", this);
102
action->setShortcut(tr("CTRL+U"));
103
action->setCheckable(true);
104
connect(action, SIGNAL(triggered()), this, SLOT(editUnderline()));
105
edit->addAction(action);
107
QMenu *advanced = new QMenu(this);
108
action = new QAction("&Font...", this);
109
connect(action, SIGNAL(triggered()), this, SLOT(editAdvancedFont()));
110
advanced->addAction(action);
112
action = new QAction("&Style...", this);
113
connect(action, SIGNAL(triggered()), this, SLOT(editAdvancedStyle()));
114
advanced->addAction(action);
116
edit->addMenu(advanced)->setText("&Advanced");
118
edit->addSeparator();
120
action = new QAction("Una&vailable", this);
121
action->setShortcut(tr("CTRL+V"));
122
action->setCheckable(true);
123
action->setEnabled(false);
124
connect(action, SIGNAL(triggered()), this, SLOT(editUnderline()));
125
edit->addAction(action);
127
QMenu *help = new QMenu(this);
129
action = new QAction("&About...", this);
130
action->setShortcut(tr("F1"));
131
connect(action, SIGNAL(triggered()), this, SLOT(helpAbout()));
132
help->addAction(action);
134
action = new QAction("&About Qt...", this);
135
connect(action, SIGNAL(triggered()), this, SLOT(helpAboutQt()));
136
help->addAction(action);
138
if (!QAxFactory::isServer())
139
menuBar()->addMenu(file)->setText("&File");
140
menuBar()->addMenu(edit)->setText("&Edit");
141
menuBar()->addMenu(help)->setText("&Help");
143
editor = new QTextEdit(this);
144
setCentralWidget(editor);
149
void QMenus::fileOpen()
151
editor->append("File Open selected.");
154
void QMenus::fileSave()
156
editor->append("File Save selected.");
159
void QMenus::editNormal()
161
editor->append("Edit Normal selected.");
164
void QMenus::editBold()
166
editor->append("Edit Bold selected.");
169
void QMenus::editUnderline()
171
editor->append("Edit Underline selected.");
174
void QMenus::editAdvancedFont()
176
editor->append("Edit Advanced Font selected.");
179
void QMenus::editAdvancedStyle()
181
editor->append("Edit Advanced Style selected.");
184
void QMenus::helpAbout()
186
QMessageBox::about(this, "About QMenus",
187
"This example implements an in-place ActiveX control with menus and status messages.");
190
void QMenus::helpAboutQt()
192
QMessageBox::aboutQt(this);
194
<p /><address><hr /><div align="center">
195
<table width="100%" cellspacing="0" border="0"><tr class="address">
196
<td width="40%" align="left">Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies)</td>
197
<td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td>
198
<td width="40%" align="right"><div align="right">Qt 4.6.0</div></td>
199
<script type="text/javascript" src="http://www.google.com/jsapi"></script><script type="text/javascript">google.load("elements", "1", {packages: "transliteration"});</script><script type="text/javascript" src="http://www.google.com/coop/cse/t13n?form=cse-search-box&t13n_langs=en"></script><script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script></tr></table></div></address></body>