mdi-main-cpp.html
来自「qtopiaphone英文帮助,用于初学者和开发人员,初学者可以用来学习,开发人」· HTML 代码 · 共 506 行 · 第 1/2 页
HTML
506 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Qt Toolkit - mdi/main.cpp example file</title><style type="text/css"><!--h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }a:link { color: #004faf; text-decoration: none }a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }--></style></head><body bgcolor="#ffffff"><table width="100%"><tr><td><a href="index.html"><img width="100" height="100" src="qtlogo.png"alt="Home" border="0"><img width="100"height="100" src="face.png" alt="Home" border="0"></a><td valign="top"><div align="right"><img src="dochead.png" width="472" height="27"><br><a href="classes.html"><b>Classes</b></a>- <a href="annotated.html">Annotated</a>- <a href="hierarchy.html">Tree</a>- <a href="functions.html">Functions</a>- <a href="index.html">Home</a>- <a href="topicals.html"><b>Structure</b> <font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" align="center" size=32>Qte</font></a></div></table><h1 align=center>A MDI Application</h1><br clear="all"> This example program is just like the application example, but designed as Multiple Document Interface (MDI). <hr> Header file: <pre>/****************************************************************************** $Id: qt/examples/mdi/application.h 2.3.8 edited 2004-05-12 $**** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.**** This file is part of an example program for Qt. This example** program may be used, distributed and modified without limitation.*******************************************************************************/#ifndef APPLICATION_H#define APPLICATION_H#include <<a href="qmainwindow-h.html">qmainwindow.h</a>>#include <<a href="qlist-h.html">qlist.h</a>>class QMultiLineEdit;class QToolBar;class QPopupMenu;class QWorkspace;class QPopupMenu;class QMovie;class MDIWindow: public QMainWindow{ Q_OBJECTpublic: MDIWindow( <a href="qwidget.html">QWidget</a>* parent, const char* name, int wflags ); ~MDIWindow(); void load( const QString& fn ); void save(); void saveAs(); void print( <a href="qprinter.html">QPrinter</a>* );signals: void message(const QString&, int );private: <a href="qmultilineedit.html">QMultiLineEdit</a>* medit; <a href="qmovie.html">QMovie</a> * mmovie; <a href="qstring.html">QString</a> filename;};class ApplicationWindow: public QMainWindow{ Q_OBJECTpublic: ApplicationWindow(); ~ApplicationWindow();private slots: MDIWindow* newDoc(); void load(); void save(); void saveAs(); void print(); void closeWindow(); void about(); void aboutQt(); void windowsMenuAboutToShow(); void windowsMenuActivated( int id );private: <a href="qprinter.html">QPrinter</a> *printer; <a href="qworkspace.html">QWorkspace</a>* ws; <a href="qtoolbar.html">QToolBar</a> *fileTools; <a href="qpopupmenu.html">QPopupMenu</a>* windowsMenu;};#endif</pre> <hr> Implementation: <pre>/****************************************************************************** $Id: qt/examples/mdi/application.cpp 2.3.8 edited 2004-05-12 $**** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.**** This file is part of an example program for Qt. This example** program may be used, distributed and modified without limitation.*******************************************************************************/#include "application.h"#include <<a href="qworkspace-h.html">qworkspace.h</a>>#include <<a href="qimage-h.html">qimage.h</a>>#include <<a href="qpixmap-h.html">qpixmap.h</a>>#include <<a href="qtoolbar-h.html">qtoolbar.h</a>>#include <<a href="qtoolbutton-h.html">qtoolbutton.h</a>>#include <<a href="qpopupmenu-h.html">qpopupmenu.h</a>>#include <<a href="qmenubar-h.html">qmenubar.h</a>>#include <qkeycode.h>#include <<a href="qmovie-h.html">qmovie.h</a>>#include <<a href="qmultilineedit-h.html">qmultilineedit.h</a>>#include <<a href="qfile-h.html">qfile.h</a>>#include <<a href="qfiledialog-h.html">qfiledialog.h</a>>#include <<a href="qlabel-h.html">qlabel.h</a>>#include <<a href="qstatusbar-h.html">qstatusbar.h</a>>#include <<a href="qmessagebox-h.html">qmessagebox.h</a>>#include <<a href="qprinter-h.html">qprinter.h</a>>#include <<a href="qapplication-h.html">qapplication.h</a>>#include <<a href="qpushbutton-h.html">qpushbutton.h</a>>#include <<a href="qaccel-h.html">qaccel.h</a>>#include <<a href="qtextstream-h.html">qtextstream.h</a>>#include <<a href="qpainter-h.html">qpainter.h</a>>#include <<a href="qpaintdevicemetrics-h.html">qpaintdevicemetrics.h</a>>#include <<a href="qwhatsthis-h.html">qwhatsthis.h</a>>#include <qobjectlist.h>#include <<a href="qvbox-h.html">qvbox.h</a>>#include "filesave.xpm"#include "fileopen.xpm"#include "fileprint.xpm"const char * fileOpenText = "Click this button to open a <em>new file</em>. <br><br>""You can also select the <b>Open command</b> from the File menu.";const char * fileSaveText = "Click this button to save the file you are ""editing. You will be prompted for a file name.\n\n""You can also select the Save command from the File menu.\n\n""Note that implementing this function is left as an exercise for the reader.";const char * filePrintText = "Click this button to print the file you ""are editing.\n\n""You can also select the Print command from the File menu.";ApplicationWindow::ApplicationWindow() : <a href="qmainwindow.html">QMainWindow</a>( 0, "example application main window", WDestructiveClose ){ int id; <a href="qpixmap.html">QPixmap</a> openIcon, saveIcon; fileTools = new <a href="qtoolbar.html">QToolBar</a>( this, "file operations" ); <a href="qmainwindow.html#cf504f">addToolBar</a>( fileTools, <a href="qobject.html#2418a9">tr</a>( "File Operations" ), Top, TRUE ); openIcon = QPixmap( fileopen ); <a href="qtoolbutton.html">QToolButton</a> * fileOpen = new <a href="qtoolbutton.html">QToolButton</a>( openIcon, "Open File", QString::null, this, SLOT(<a href=#163>load</a>()), fileTools, "open file" ); saveIcon = QPixmap( filesave ); <a href="qtoolbutton.html">QToolButton</a> * fileSave = new <a href="qtoolbutton.html">QToolButton</a>( saveIcon, "Save File", QString::null, this, SLOT(<a href=#164>save</a>()), fileTools, "save file" );#ifndef QT_NO_PRINTER printer = new <a href="qprinter.html">QPrinter</a>; <a href="qpixmap.html">QPixmap</a> printIcon; printIcon = QPixmap( fileprint ); <a href="qtoolbutton.html">QToolButton</a> * filePrint = new <a href="qtoolbutton.html">QToolButton</a>( printIcon, "Print File", QString::null, this, SLOT(<a href=#166>print</a>()), fileTools, "print file" ); <a href="qwhatsthis.html#dfcd18">QWhatsThis::add</a>( filePrint, filePrintText );#endif (void)QWhatsThis::whatsThisButton( fileTools ); <a href="qwhatsthis.html#dfcd18">QWhatsThis::add</a>( fileOpen, fileOpenText ); <a href="qwhatsthis.html#dfcd18">QWhatsThis::add</a>( fileSave, fileSaveText ); <a href="qpopupmenu.html">QPopupMenu</a> * file = new <a href="qpopupmenu.html">QPopupMenu</a>( this ); <a href="qmainwindow.html#0eb7bc">menuBar</a>()->insertItem( "&File", file ); file-><a href="qmenudata.html#deddb9">insertItem</a>( "&New", this, SLOT(<a href=#162>newDoc</a>()), CTRL+Key_N ); id = file-><a href="qmenudata.html#deddb9">insertItem</a>( openIcon, "&Open", this, SLOT(<a href=#163>load</a>()), CTRL+Key_O ); file-><a href="qmenudata.html#88eb55">setWhatsThis</a>( id, fileOpenText ); id = file-><a href="qmenudata.html#deddb9">insertItem</a>( saveIcon, "&Save", this, SLOT(<a href=#164>save</a>()), CTRL+Key_S ); file-><a href="qmenudata.html#88eb55">setWhatsThis</a>( id, fileSaveText ); id = file-><a href="qmenudata.html#deddb9">insertItem</a>( "Save &as...", this, SLOT(<a href=#165>saveAs</a>()) ); file-><a href="qmenudata.html#88eb55">setWhatsThis</a>( id, fileSaveText );#ifndef QT_NO_PRINTER file-><a href="qmenudata.html#e34b79">insertSeparator</a>(); id = file-><a href="qmenudata.html#deddb9">insertItem</a>( printIcon, "&Print", this, SLOT(<a href=#166>print</a>()), CTRL+Key_P ); file-><a href="qmenudata.html#88eb55">setWhatsThis</a>( id, filePrintText );#endif file-><a href="qmenudata.html#e34b79">insertSeparator</a>(); file-><a href="qmenudata.html#deddb9">insertItem</a>( "&Close", this, SLOT(<a href=#167>closeWindow</a>()), CTRL+Key_W ); file-><a href="qmenudata.html#deddb9">insertItem</a>( "&Quit", qApp, SLOT( closeAllWindows() ), CTRL+Key_Q ); windowsMenu = new <a href="qpopupmenu.html">QPopupMenu</a>( this ); windowsMenu->setCheckable( TRUE ); <a href="qobject.html#fbde73">connect</a>( windowsMenu, SIGNAL( aboutToShow() ), this, SLOT( <a href=#170>windowsMenuAboutToShow</a>() ) ); <a href="qmainwindow.html#0eb7bc">menuBar</a>()->insertItem( "&Windows", windowsMenu ); <a href="qmainwindow.html#0eb7bc">menuBar</a>()->insertSeparator(); <a href="qpopupmenu.html">QPopupMenu</a> * help = new <a href="qpopupmenu.html">QPopupMenu</a>( this ); <a href="qmainwindow.html#0eb7bc">menuBar</a>()->insertItem( "&Help", help ); help-><a href="qmenudata.html#deddb9">insertItem</a>( "&About", this, SLOT(<a href=#168>about</a>()), Key_F1); help-><a href="qmenudata.html#deddb9">insertItem</a>( "About &<a href="qt.html">Qt</a>", this, SLOT(<a href=#169>aboutQt</a>())); help-><a href="qmenudata.html#e34b79">insertSeparator</a>(); help-><a href="qmenudata.html#deddb9">insertItem</a>( "What's &This", this, SLOT(<a href="qmainwindow.html#f50ce2">whatsThis</a>()), SHIFT+Key_F1); <a href="qvbox.html">QVBox</a>* vb = new <a href="qvbox.html">QVBox</a>( this ); vb-><a href="qframe.html#558f79">setFrameStyle</a>( QFrame::StyledPanel | QFrame::Sunken ); ws = new <a href="qworkspace.html">QWorkspace</a>( vb ); <a href="qmainwindow.html#fce9ba">setCentralWidget</a>( vb ); <a href="qmainwindow.html#530937">statusBar</a>()->message( "Ready", 2000 );}ApplicationWindow::~ApplicationWindow(){#ifndef QT_NO_PRINTER delete printer;#endif}MDIWindow* <a name="162"></a>ApplicationWindow::newDoc()
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?