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

📄 qmag-qmag-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 - qmag/qmag.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>QMag</h1><br clear="all">  This is a simple magnifier-type program.  It shows how one can do  some quite low-level operations portably using Qt.  Run it, click in the magnifier window, then click where you want to  magnify or drag out a rectangle.  Two combo boxes let you select  amplification and refresh frequency, a text label tells you the color  of the pixel the cursor is on, and a button lets you save the  magnified area as a .bmp file.  <hr>  Implementation:<pre>/****************************************************************************** &#36;Id&#58; qt/examples/qmag/qmag.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 &lt;<a name="qcombobox.h"></a><a href="qcombobox-h.html">qcombobox.h</a>&gt;#include &lt;<a name="qpushbutton.h"></a><a href="qpushbutton-h.html">qpushbutton.h</a>&gt;#include &lt;<a name="qpixmap.h"></a><a href="qpixmap-h.html">qpixmap.h</a>&gt;#include &lt;<a name="qimage.h"></a><a href="qimage-h.html">qimage.h</a>&gt;#include &lt;<a name="qlabel.h"></a><a href="qlabel-h.html">qlabel.h</a>&gt;#include &lt;<a name="qfiledialog.h"></a><a href="qfiledialog-h.html">qfiledialog.h</a>&gt;#include &lt;<a name="qregexp.h"></a><a href="qregexp-h.html">qregexp.h</a>&gt;#include &lt;<a name="qapplication.h"></a><a href="qapplication-h.html">qapplication.h</a>&gt;#include &lt;<a name="qpainter.h"></a><a href="qpainter-h.html">qpainter.h</a>&gt;#include &lt;<a name="qwmatrix.h"></a><a href="qwmatrix-h.html">qwmatrix.h</a>&gt;class MagWidget : public QWidget{    Q_OBJECTpublic:    MagWidget( <a name="QWidget"></a><a href="qwidget.html">QWidget</a> *parent=0, const char *name=0 );public slots:    void        setZoom( int );    void        setRefresh( int );    void        save();    void        multiSave();protected:    void        paintEvent( <a name="QPaintEvent"></a><a href="qpaintevent.html">QPaintEvent</a> * );    void        mousePressEvent( <a name="QMouseEvent"></a><a href="qmouseevent.html">QMouseEvent</a> * );    void        mouseReleaseEvent( <a href="qmouseevent.html">QMouseEvent</a> * );    void        mouseMoveEvent( <a href="qmouseevent.html">QMouseEvent</a> * );    void        focusOutEvent( <a name="QFocusEvent"></a><a href="qfocusevent.html">QFocusEvent</a> * );    void        timerEvent( <a name="QTimerEvent"></a><a href="qtimerevent.html">QTimerEvent</a> * );    void        resizeEvent( <a name="QResizeEvent"></a><a href="qresizeevent.html">QResizeEvent</a> * );private:    void        grabAround(<a name="QPoint"></a><a href="qpoint.html">QPoint</a> pos);    void        grab();    <a name="QComboBox"></a><a href="qcombobox.html">QComboBox</a>   *zoom;    <a href="qcombobox.html">QComboBox</a>   *refresh;    <a name="QPushButton"></a><a href="qpushbutton.html">QPushButton</a> *saveButton;    <a href="qpushbutton.html">QPushButton</a> *multiSaveButton;    <a href="qpushbutton.html">QPushButton</a> *quitButton;    <a name="QPixmap"></a><a href="qpixmap.html">QPixmap</a>     pm;             // pixmap, magnified    <a href="qpixmap.html">QPixmap</a>     p;              // pixmap    <a name="QImage"></a><a href="qimage.html">QImage</a>      image;          // image of pixmap (for RGB)    <a name="QLabel"></a><a href="qlabel.html">QLabel</a>      *rgb;    int         yoffset;        // pixels in addition to the actual picture    int         z;              // magnification factor    int         r;              // autorefresh rate (index into refreshrates)    bool        grabbing;       // TRUE if qmag is currently grabbing    int         grabx, graby;    <a name="QString"></a><a href="qstring.html">QString</a>     multifn;        // filename for multisave};#ifdef COMPLEX_GUIstatic const char *zoomfactors[] = {    "100%", "200%", "300%", "400%", "500%",    "600%", "700%", "800%", "1600%", 0 };static const char *refreshrates[] = {    "No autorefresh", "50 per second", "4 per second", "3 per second", "2 per second",    "Every second", "Every two seconds", "Every three seconds",    "Every five seconds", "Every ten seconds", 0 };#endifstatic const int timer[] = {    0, 20, 250, 333, 500, 1000, 2000, 3000, 5000, 10000 };MagWidget::MagWidget( <a href="qwidget.html">QWidget</a> *parent, const char *name )    : <a href="qwidget.html">QWidget</a>( parent, name){    z = 1;                      // default zoom (100%)    r = 0;                      // default refresh (none)#ifdef COMPLEX_GUI    int w=0, x=0, n;    zoom = new <a href="qcombobox.html">QComboBox</a>( FALSE, this );    CHECK_PTR(zoom);    zoom-&gt;<a name="insertStrList"></a><a href="qcombobox.html#ae9e6b">insertStrList</a>( zoomfactors, 9 );    <a name="connect"></a><a href="qobject.html#fbde73">connect</a>( zoom, SIGNAL(activated(int)), SLOT(<a name="setZoom"></a><a href="#299">setZoom</a>(int)) );    refresh = new <a href="qcombobox.html">QComboBox</a>( FALSE, this );    CHECK_PTR(refresh);    refresh-&gt;<a href="qcombobox.html#ae9e6b">insertStrList</a>( refreshrates, 9 );    <a href="qobject.html#fbde73">connect</a>( refresh, SIGNAL(activated(int)), SLOT(<a name="setRefresh"></a><a href="#300">setRefresh</a>(int)) );    for( n=0; n&lt;9; n++) {        int w2 = zoom-&gt;<a name="fontMetrics"></a><a href="qwidget.html#386569">fontMetrics</a>().width( zoomfactors[n] );        w = QMAX(w2, w);    }    zoom-&gt;<a name="setGeometry"></a><a href="qwidget.html#9ede68">setGeometry</a>( 2, 2, w+30, 20 );    x = w+34;    w = 0;    for( n=0; n&lt;9; n++) {        int w2 = refresh-&gt;<a href="qwidget.html#386569">fontMetrics</a>().width( refreshrates[n] );        w = QMAX(w2, w);    }    refresh-&gt;<a href="qwidget.html#9ede68">setGeometry</a>( x, 2, w+30, 20 );    saveButton = new <a href="qpushbutton.html">QPushButton</a>( this );    CHECK_PTR(saveButton);    <a href="qobject.html#fbde73">connect</a>( saveButton, SIGNAL(clicked()), this, SLOT(<a name="save"></a><a href="#301">save</a>()) );    saveButton-&gt;<a name="setText"></a><a href="qbutton.html#989f4f">setText</a>( "Save" );    saveButton-&gt;<a name="setGeometry"></a><a href="qpushbutton.html#c9b88e">setGeometry</a>( x+w+30+2, 2,                             10+saveButton-&gt;<a href="qwidget.html#386569">fontMetrics</a>().width("Save"), 20 );    multiSaveButton = new <a href="qpushbutton.html">QPushButton</a>( this );    multiSaveButton-&gt;<a name="setToggleButton"></a><a href="qpushbutton.html#cf550e">setToggleButton</a>(TRUE);    CHECK_PTR(multiSaveButton);    <a href="qobject.html#fbde73">connect</a>( multiSaveButton, SIGNAL(clicked()), this, SLOT(<a name="multiSave"></a><a href="#302">multiSave</a>()) );    multiSaveButton-&gt;<a href="qbutton.html#989f4f">setText</a>( "MultiSave" );    multiSaveButton-&gt;<a href="qpushbutton.html#c9b88e">setGeometry</a>( saveButton-&gt;<a name="geometry"></a><a href="qwidget.html#e515c8">geometry</a>().right() + 2, 2,                             10+multiSaveButton-&gt;<a href="qwidget.html#386569">fontMetrics</a>().width("MultiSave"), 20 );    quitButton = new <a href="qpushbutton.html">QPushButton</a>( this );    CHECK_PTR(quitButton);    <a href="qobject.html#fbde73">connect</a>( quitButton, SIGNAL(clicked()), qApp, SLOT(quit()) );    quitButton-&gt;<a href="qbutton.html#989f4f">setText</a>( "Quit" );    quitButton-&gt;<a href="qpushbutton.html#c9b88e">setGeometry</a>( multiSaveButton-&gt;<a href="qwidget.html#e515c8">geometry</a>().right() + 2, 2,                             10+quitButton-&gt;<a href="qwidget.html#386569">fontMetrics</a>().width("Quit"), 20 );#else    zoom = 0;    multiSaveButton = 0;#endif    <a href=#300>setRefresh</a>(1);    <a href=#299>setZoom</a>(5);    rgb = new <a href="qlabel.html">QLabel</a>( this );    CHECK_PTR( rgb );    rgb-&gt;<a name="setText"></a><a href="qlabel.html#bc5ea6">setText</a>( "" );    rgb-&gt;<a name="setAlignment"></a><a href="qlabel.html#4743c8">setAlignment</a>( AlignVCenter );    rgb-&gt;<a name="resize"></a><a href="qwidget.html#ff9d07">resize</a>( <a name="width"></a><a href="qwidget.html#2edab1">width</a>(), rgb-&gt;<a href="qwidget.html#386569">fontMetrics</a>().height() + 4 );#ifdef COMPLEX_GUI    yoffset = zoom-&gt;<a name="height"></a><a href="qwidget.html#e3c588">height</a>()    // top buttons        + 4                     // space around top buttons        + rgb-&gt;<a href="qwidget.html#e3c588">height</a>();        // color-value text height    <a name="setMinimumSize"></a><a href="qwidget.html#c0b5fb">setMinimumSize</a>( quitButton-&gt;<a name="pos"></a><a href="qwidget.html#2691c9">pos</a>().x(), yoffset+20 );    <a name="resize"></a><a href="qwidget.html#8fcbbe">resize</a>( quitButton-&gt;<a href="qwidget.html#e515c8">geometry</a>().topRight().x() + 2, yoffset+60 );#else    yoffset = 0;    <a href="qwidget.html#8fcbbe">resize</a>(350,350);#endif    grabx = graby = -1;    grabbing = FALSE;    <a name="setMouseTracking"></a><a href="qwidget.html#36406c">setMouseTracking</a>( TRUE );   // and do let me know what pixel I'm at, eh?    <a name="grabAround"></a><a href="#307">grabAround</a>( <a href="qpoint.html">QPoint</a>(grabx=qApp-&gt;desktop()-&gt;width()/2, graby=qApp-&gt;desktop()-&gt;height()/2) );}void <a name="299"></a>MagWidget::setZoom( int index ){    if (index == 8)

⌨️ 快捷键说明

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