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

📄 qwerty-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 - qwerty/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>Simple HTML Browser</h1><br clear="all">  ???  <hr>  Header file: <pre>/****************************************************************************** &#36;Id&#58; qt/examples/qwerty/qwerty.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 QWERTY_H#define QWERTY_H#include &lt;<a href="qwidget-h.html">qwidget.h</a>&gt;#include &lt;<a href="qmenubar-h.html">qmenubar.h</a>&gt;#include &lt;<a href="qmultilineedit-h.html">qmultilineedit.h</a>&gt;#include &lt;<a href="qprinter-h.html">qprinter.h</a>&gt;class Editor : public QWidget{    Q_OBJECTpublic:    Editor( <a href="qwidget.html">QWidget</a> *parent=0, const char *name="qwerty" );   ~Editor();    void load( const QString&amp; fileName, int code=-1 );public slots:    void newDoc();    void load();    bool save();    void print();    void addEncoding();    void toUpper();    void toLower();protected:    void resizeEvent( <a href="qresizeevent.html">QResizeEvent</a> * );    void closeEvent( <a href="qcloseevent.html">QCloseEvent</a> * );private slots:    void saveAsEncoding( int );    void openAsEncoding( int );    void textChanged();private:    bool saveAs( const QString&amp; fileName, int code=-1 );    void rebuildCodecList();    <a href="qmenubar.html">QMenuBar</a>       *m;    <a href="qmultilineedit.html">QMultiLineEdit</a> *e;#ifndef QT_NO_PRINTER    <a href="qprinter.html">QPrinter</a>        printer;#endif    <a href="qpopupmenu.html">QPopupMenu</a>     *save_as;    <a href="qpopupmenu.html">QPopupMenu</a>     *open_as;    bool changed;};#endif // QWERTY_H</pre>  <hr>  Implementation: <pre>/****************************************************************************** &#36;Id&#58; qt/examples/qwerty/qwerty.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 "qwerty.h"#include &lt;<a href="qapplication-h.html">qapplication.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;qkeycode.h&gt;#include &lt;<a href="qpopupmenu-h.html">qpopupmenu.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="qmessagebox-h.html">qmessagebox.h</a>&gt;#include &lt;<a href="qpaintdevicemetrics-h.html">qpaintdevicemetrics.h</a>&gt;#include &lt;<a href="qlist-h.html">qlist.h</a>&gt;#include &lt;<a href="qtextcodec-h.html">qtextcodec.h</a>&gt;const bool no_writing = FALSE;static QList&lt;<a href="qtextcodec.html">QTextCodec</a>&gt; *codecList = 0;enum { Uni = 0, MBug = 1, Lat1 = 2, Local = 3, Guess = 4, Codec = 5 };Editor::Editor( <a href="qwidget.html">QWidget</a> * parent , const char * name )    : <a href="qwidget.html">QWidget</a>( parent, name, WDestructiveClose ){    m = new <a href="qmenubar.html">QMenuBar</a>( this, "menu" );    <a href="qpopupmenu.html">QPopupMenu</a> * file = new <a href="qpopupmenu.html">QPopupMenu</a>();    CHECK_PTR( file );    m-&gt;insertItem( "&amp;File", file );    file-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "&amp;New",   this, SLOT(<a href=#2>newDoc</a>()),   ALT+Key_N );    file-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "&amp;Open",  this, SLOT(<a href=#4>load</a>()),     ALT+Key_O );    file-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "&amp;Save",  this, SLOT(<a href=#6>save</a>()),     ALT+Key_S );    file-&gt;<a href="qmenudata.html#e34b79">insertSeparator</a>();    open_as = new <a href="qpopupmenu.html">QPopupMenu</a>();    file-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "Open &amp;as",  open_as );    save_as = new <a href="qpopupmenu.html">QPopupMenu</a>();    file-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "Save &amp;as",  save_as );    file-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "Add &amp;encoding", this, SLOT(<a href=#8>addEncoding</a>()) );#ifndef QT_NO_PRINTER    file-&gt;<a href="qmenudata.html#e34b79">insertSeparator</a>();    file-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "&amp;Print", this, SLOT(<a href=#10>print</a>()),    ALT+Key_P );#endif    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>()),ALT+Key_W );    file-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "&amp;Quit",  qApp, SLOT(closeAllWindows()),     ALT+Key_Q );    <a href="qobject.html#fbde73">connect</a>( save_as, SIGNAL(activated(int)), this, SLOT(<a href=#7>saveAsEncoding</a>(int)) );    <a href="qobject.html#fbde73">connect</a>( open_as, SIGNAL(activated(int)), this, SLOT(<a href=#5>openAsEncoding</a>(int)) );    <a href=#1>rebuildCodecList</a>();    <a href="qpopupmenu.html">QPopupMenu</a> * edit = new <a href="qpopupmenu.html">QPopupMenu</a>();    CHECK_PTR( edit );    m-&gt;insertItem( "&amp;Edit", edit );    edit-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "To &amp;uppercase",   this, SLOT(<a href=#13>toUpper</a>()),   ALT+Key_U );    edit-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "To &amp;lowercase",   this, SLOT(<a href=#14>toLower</a>()),   ALT+Key_L );    changed = FALSE;    e = new <a href="qmultilineedit.html">QMultiLineEdit</a>( this, "editor" );    <a href="qobject.html#fbde73">connect</a>( e, SIGNAL( <a href=#15>textChanged</a>() ), this, SLOT( <a href=#15>textChanged</a>() ) );    // We use Unifont - if you have it installed you'll see all    // Unicode character glyphs.    //    // Unifont only comes in one pixel size, so we cannot let    // it change pixel size as the display DPI changes.    //    <a href="qfont.html">QFont</a> unifont("unifont",16,50); unifont.<a href="qfont.html#9d3b04">setPixelSize</a>(16);    e-&gt;setFont( unifont );    e-&gt;setFocus();}Editor::~Editor(){}void <a name="1"></a>Editor::rebuildCodecList(){    delete codecList;    codecList = new <a href="qlist.html">QList</a>&lt;<a href="qtextcodec.html">QTextCodec</a>&gt;;    <a href="qtextcodec.html">QTextCodec</a> *codec;    int i;    for (i = 0; (codec = QTextCodec::codecForIndex(i)); i++)        codecList-&gt;append( codec );    int n = codecList-&gt;count();    for (int pm=0; pm&lt;2; pm++) {        <a href="qpopupmenu.html">QPopupMenu</a>* menu = pm ? open_as : save_as;        menu-&gt;<a href="qmenudata.html#4bd5e3">clear</a>();        <a href="qstring.html">QString</a> local = "Local (";        local += QTextCodec::codecForLocale()-&gt;name();        local += ")";        menu-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( local, Local );        menu-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "Unicode", Uni );        menu-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "Latin1", Lat1 );        menu-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "Microsoft Unicode", MBug );        if ( pm )            menu-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "[guess]", Guess );        for ( i = 0; i &lt; n; i++ )            menu-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( codecList-&gt;at(i)-&gt;name(), Codec + i );    }}void <a name="2"></a>Editor::newDoc(){    Editor *ed = new Editor;    if ( qApp-&gt;desktop()-&gt;size().width() &lt; 450          || qApp-&gt;desktop()-&gt;size().height() &lt; 450 ) {        ed-&gt;<a href="qwidget.html#b6e000">showMaximized</a>();    } else {        ed-&gt;<a href="qwidget.html#8fcbbe">resize</a>( 400, 400 );        ed-&gt;<a href="qwidget.html#200ee5">show</a>();    }}void <a name="4"></a>Editor::load(){#ifndef QT_NO_FILEDIALOG    <a href="qstring.html">QString</a> fn = QFileDialog::getOpenFileName( QString::null, QString::null, this );    if ( !fn.<a href="qstring.html#c62623">isEmpty</a>() )        <a href=#4>load</a>( fn, -1 );#endif    }void <a name="4"></a>Editor::load( const QString&amp; fileName, int code ){    <a href="qfile.html">QFile</a> f( fileName );    if ( !f.<a href="qfile.html#255995">open</a>( IO_ReadOnly ) )        return;    e-&gt;setAutoUpdate( FALSE );    <a href="qtextstream.html">QTextStream</a> t(&amp;f);

⌨️ 快捷键说明

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