⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 application-main-cpp.html

📁 qtopiaphone英文帮助,用于初学者和开发人员,初学者可以用来学习,开发人员可以用来资料查询.
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!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 - application/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 Complete Application Window</h1><br clear="all">  This example program looks like a complete modern application.  It  has a menu bar, it has a tool bar, it has a status bar and works  like a simple text editor.  There is a <a href="simple-application.html">walkthrough</a> of  this example.  <hr>  Header file: <pre>/****************************************************************************** &#36;Id&#58; qt/examples/application/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 &lt;<a href="qmainwindow-h.html">qmainwindow.h</a>&gt;class QMultiLineEdit;class QToolBar;class QPopupMenu;class ApplicationWindow: public QMainWindow{    Q_OBJECTpublic:    ApplicationWindow();    ~ApplicationWindow();protected:    void closeEvent( <a href="qcloseevent.html">QCloseEvent</a>* );private slots:    void newDoc();    void load();    void load( const char *fileName );    void save();    void saveAs();    void print();    void about();    void aboutQt();private:    <a href="qprinter.html">QPrinter</a> *printer;    <a href="qmultilineedit.html">QMultiLineEdit</a> *e;    <a href="qtoolbar.html">QToolBar</a> *fileTools;    <a href="qstring.html">QString</a> filename;};#endif</pre>  <hr>  Implementation: <pre>/****************************************************************************** &#36;Id&#58; qt/examples/application/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 &lt;<a href="qimage-h.html">qimage.h</a>&gt;#include &lt;<a href="qpixmap-h.html">qpixmap.h</a>&gt;#include &lt;<a href="qtoolbar-h.html">qtoolbar.h</a>&gt;#include &lt;<a href="qtoolbutton-h.html">qtoolbutton.h</a>&gt;#include &lt;<a href="qpopupmenu-h.html">qpopupmenu.h</a>&gt;#include &lt;<a href="qmenubar-h.html">qmenubar.h</a>&gt;#include &lt;qkeycode.h&gt;#include &lt;<a href="qmultilineedit-h.html">qmultilineedit.h</a>&gt;#include &lt;<a href="qfile-h.html">qfile.h</a>&gt;#include &lt;<a href="qfiledialog-h.html">qfiledialog.h</a>&gt;#include &lt;<a href="qstatusbar-h.html">qstatusbar.h</a>&gt;#include &lt;<a href="qmessagebox-h.html">qmessagebox.h</a>&gt;#include &lt;<a href="qprinter-h.html">qprinter.h</a>&gt;#include &lt;<a href="qapplication-h.html">qapplication.h</a>&gt;#include &lt;<a href="qaccel-h.html">qaccel.h</a>&gt;#include &lt;<a href="qtextstream-h.html">qtextstream.h</a>&gt;#include &lt;<a href="qpainter-h.html">qpainter.h</a>&gt;#include &lt;<a href="qpaintdevicemetrics-h.html">qpaintdevicemetrics.h</a>&gt;#include &lt;<a href="qwhatsthis-h.html">qwhatsthis.h</a>&gt;#include "filesave.xpm"#include "fileopen.xpm"#include "fileprint.xpm"const char * fileOpenText = "&lt;img source=\"fileopen\"&gt; ""Click this button to open a &lt;em&gt;new file&lt;/em&gt;. &lt;br&gt;&lt;br&gt;""You can also select the &lt;b&gt;Open command&lt;/b&gt; 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;    printer = new <a href="qprinter.html">QPrinter</a>;    <a href="qpixmap.html">QPixmap</a> openIcon, saveIcon, printIcon;    fileTools = new <a href="qtoolbar.html">QToolBar</a>( this, "file operations" );    fileTools-&gt;setLabel( <a href="qobject.html#2418a9">tr</a>( "File Operations" ) );    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=#433>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=#434>save</a>()), fileTools, "save file" );    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=#436>print</a>()), fileTools, "print file" );    (void)QWhatsThis::whatsThisButton( fileTools );    <a href="qwhatsthis.html#dfcd18">QWhatsThis::add</a>( fileOpen, fileOpenText );    <a href="qmimesourcefactory.html#5c7072">QMimeSourceFactory::defaultFactory</a>()-&gt;setPixmap( "fileopen", openIcon );    <a href="qwhatsthis.html#dfcd18">QWhatsThis::add</a>( fileSave, fileSaveText );    <a href="qwhatsthis.html#dfcd18">QWhatsThis::add</a>( filePrint, filePrintText );    <a href="qpopupmenu.html">QPopupMenu</a> * file = new <a href="qpopupmenu.html">QPopupMenu</a>( this );    <a href="qmainwindow.html#0eb7bc">menuBar</a>()-&gt;insertItem( "&amp;File", file );    file-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "&amp;New", this, SLOT(<a href=#431>newDoc</a>()), CTRL+Key_N );    id = file-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( openIcon, "&amp;Open",                           this, SLOT(<a href=#433>load</a>()), CTRL+Key_O );    file-&gt;<a href="qmenudata.html#88eb55">setWhatsThis</a>( id, fileOpenText );    id = file-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( saveIcon, "&amp;Save",                           this, SLOT(<a href=#434>save</a>()), CTRL+Key_S );    file-&gt;<a href="qmenudata.html#88eb55">setWhatsThis</a>( id, fileSaveText );    id = file-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "Save &amp;as...", this, SLOT(<a href=#435>saveAs</a>()) );    file-&gt;<a href="qmenudata.html#88eb55">setWhatsThis</a>( id, fileSaveText );    file-&gt;<a href="qmenudata.html#e34b79">insertSeparator</a>();    id = file-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( printIcon, "&amp;Print",                           this, SLOT(<a href=#436>print</a>()), CTRL+Key_P );    file-&gt;<a href="qmenudata.html#88eb55">setWhatsThis</a>( id, filePrintText );    file-&gt;<a href="qmenudata.html#e34b79">insertSeparator</a>();    file-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "&amp;Close", this, SLOT(<a href="qwidget.html#3d9c87">close</a>()), CTRL+Key_W );    file-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "&amp;Quit", qApp, SLOT( closeAllWindows() ), CTRL+Key_Q );    <a href="qpopupmenu.html">QPopupMenu</a> * help = new <a href="qpopupmenu.html">QPopupMenu</a>( this );    <a href="qmainwindow.html#0eb7bc">menuBar</a>()-&gt;insertSeparator();    <a href="qmainwindow.html#0eb7bc">menuBar</a>()-&gt;insertItem( "&amp;Help", help );    help-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "&amp;About", this, SLOT(<a href=#438>about</a>()), Key_F1 );    help-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "About &amp;<a href="qt.html">Qt</a>", this, SLOT(<a href=#439>aboutQt</a>()) );    help-&gt;<a href="qmenudata.html#e34b79">insertSeparator</a>();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -