[190] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
| 2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/examples/scribble/scribble.doc:5 -->
|
---|
| 3 | <html>
|
---|
| 4 | <head>
|
---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
| 6 | <title>Simple Painting Application</title>
|
---|
| 7 | <style type="text/css"><!--
|
---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
| 9 | a:link { color: #004faf; text-decoration: none }
|
---|
| 10 | a:visited { color: #672967; text-decoration: none }
|
---|
| 11 | body { background: #ffffff; color: black; }
|
---|
| 12 | --></style>
|
---|
| 13 | </head>
|
---|
| 14 | <body>
|
---|
| 15 |
|
---|
| 16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
| 17 | <tr bgcolor="#E5E5E5">
|
---|
| 18 | <td valign=center>
|
---|
| 19 | <a href="index.html">
|
---|
| 20 | <font color="#004faf">Home</font></a>
|
---|
| 21 | | <a href="classes.html">
|
---|
| 22 | <font color="#004faf">All Classes</font></a>
|
---|
| 23 | | <a href="mainclasses.html">
|
---|
| 24 | <font color="#004faf">Main Classes</font></a>
|
---|
| 25 | | <a href="annotated.html">
|
---|
| 26 | <font color="#004faf">Annotated</font></a>
|
---|
| 27 | | <a href="groups.html">
|
---|
| 28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
| 29 | | <a href="functions.html">
|
---|
| 30 | <font color="#004faf">Functions</font></a>
|
---|
| 31 | </td>
|
---|
| 32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>Simple Painting Application</h1>
|
---|
| 33 |
|
---|
| 34 |
|
---|
| 35 | <p>
|
---|
| 36 | This example implements the famous scribble example. You can draw around
|
---|
| 37 | in the canvas with different pens and save the result as picture.
|
---|
| 38 | <p> <hr>
|
---|
| 39 | <p> Header file:
|
---|
| 40 | <p> <pre>/****************************************************************************
|
---|
| 41 | ** $Id: scribble-example.html 2051 2007-02-21 10:04:20Z chehrlic $
|
---|
| 42 | **
|
---|
| 43 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
|
---|
| 44 | **
|
---|
| 45 | ** This file is part of an example program for Qt. This example
|
---|
| 46 | ** program may be used, distributed and modified without limitation.
|
---|
| 47 | **
|
---|
| 48 | *****************************************************************************/
|
---|
| 49 |
|
---|
| 50 | #ifndef SCRIBBLE_H
|
---|
| 51 | #define SCRIBBLE_H
|
---|
| 52 |
|
---|
| 53 | #include <<a href="qmainwindow-h.html">qmainwindow.h</a>>
|
---|
| 54 | #include <<a href="qpen-h.html">qpen.h</a>>
|
---|
| 55 | #include <<a href="qpoint-h.html">qpoint.h</a>>
|
---|
| 56 | #include <<a href="qpixmap-h.html">qpixmap.h</a>>
|
---|
| 57 | #include <<a href="qwidget-h.html">qwidget.h</a>>
|
---|
| 58 | #include <<a href="qstring-h.html">qstring.h</a>>
|
---|
| 59 | #include <<a href="qpointarray-h.html">qpointarray.h</a>>
|
---|
| 60 |
|
---|
| 61 | class QMouseEvent;
|
---|
| 62 | class QResizeEvent;
|
---|
| 63 | class QPaintEvent;
|
---|
| 64 | class QToolButton;
|
---|
| 65 | class QSpinBox;
|
---|
| 66 |
|
---|
| 67 | class Canvas : public <a href="qwidget.html">QWidget</a>
|
---|
| 68 | {
|
---|
| 69 | <a href="metaobjects.html#Q_OBJECT">Q_OBJECT</a>
|
---|
| 70 |
|
---|
| 71 | public:
|
---|
| 72 | Canvas( <a href="qwidget.html">QWidget</a> *parent = 0, const char *name = 0 );
|
---|
| 73 |
|
---|
| 74 | void setPenColor( const <a href="qcolor.html">QColor</a> &c )
|
---|
| 75 | <a name="x903"></a> { pen.<a href="qpen.html#setColor">setColor</a>( c ); }
|
---|
| 76 |
|
---|
| 77 | void setPenWidth( int w )
|
---|
| 78 | <a name="x904"></a> { pen.<a href="qpen.html#setWidth">setWidth</a>( w ); }
|
---|
| 79 |
|
---|
| 80 | <a href="qcolor.html">QColor</a> penColor()
|
---|
| 81 | <a name="x902"></a> { return pen.<a href="qpen.html#color">color</a>(); }
|
---|
| 82 |
|
---|
| 83 | int penWidth()
|
---|
| 84 | <a name="x905"></a> { return pen.<a href="qpen.html#width">width</a>(); }
|
---|
| 85 |
|
---|
| 86 | void save( const <a href="qstring.html">QString</a> &filename, const <a href="qstring.html">QString</a> &format );
|
---|
| 87 |
|
---|
| 88 | void clearScreen();
|
---|
| 89 |
|
---|
| 90 | protected:
|
---|
| 91 | void mousePressEvent( <a href="qmouseevent.html">QMouseEvent</a> *e );
|
---|
| 92 | void mouseReleaseEvent( <a href="qmouseevent.html">QMouseEvent</a> *e );
|
---|
| 93 | void mouseMoveEvent( <a href="qmouseevent.html">QMouseEvent</a> *e );
|
---|
| 94 | void resizeEvent( <a href="qresizeevent.html">QResizeEvent</a> *e );
|
---|
| 95 | void paintEvent( <a href="qpaintevent.html">QPaintEvent</a> *e );
|
---|
| 96 |
|
---|
| 97 | <a href="qpen.html">QPen</a> pen;
|
---|
| 98 | <a href="qpointarray.html">QPointArray</a> polyline;
|
---|
| 99 |
|
---|
| 100 | bool mousePressed;
|
---|
| 101 |
|
---|
| 102 | <a href="qpixmap.html">QPixmap</a> buffer;
|
---|
| 103 |
|
---|
| 104 | };
|
---|
| 105 |
|
---|
| 106 | class Scribble : public <a href="qmainwindow.html">QMainWindow</a>
|
---|
| 107 | {
|
---|
| 108 | Q_OBJECT
|
---|
| 109 |
|
---|
| 110 | public:
|
---|
| 111 | Scribble( <a href="qwidget.html">QWidget</a> *parent = 0, const char *name = 0 );
|
---|
| 112 |
|
---|
| 113 | protected:
|
---|
| 114 | Canvas* canvas;
|
---|
| 115 |
|
---|
| 116 | <a href="qspinbox.html">QSpinBox</a> *bPWidth;
|
---|
| 117 | <a href="qtoolbutton.html">QToolButton</a> *bPColor, *bSave, *bClear;
|
---|
| 118 |
|
---|
| 119 | protected slots:
|
---|
| 120 | void slotSave();
|
---|
| 121 | void slotColor();
|
---|
| 122 | void slotWidth( int );
|
---|
| 123 | void slotClear();
|
---|
| 124 |
|
---|
| 125 | };
|
---|
| 126 |
|
---|
| 127 | #endif
|
---|
| 128 | </pre>
|
---|
| 129 |
|
---|
| 130 | <p> <hr>
|
---|
| 131 | <p> Implementation:
|
---|
| 132 | <p> <pre>/****************************************************************************
|
---|
| 133 | ** $Id: scribble-example.html 2051 2007-02-21 10:04:20Z chehrlic $
|
---|
| 134 | **
|
---|
| 135 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
|
---|
| 136 | **
|
---|
| 137 | ** This file is part of an example program for Qt. This example
|
---|
| 138 | ** program may be used, distributed and modified without limitation.
|
---|
| 139 | **
|
---|
| 140 | *****************************************************************************/
|
---|
| 141 |
|
---|
| 142 | #include "scribble.h"
|
---|
| 143 |
|
---|
| 144 | #include <<a href="qapplication-h.html">qapplication.h</a>>
|
---|
| 145 | #include <<a href="qevent-h.html">qevent.h</a>>
|
---|
| 146 | #include <<a href="qpainter-h.html">qpainter.h</a>>
|
---|
| 147 | #include <<a href="qtoolbar-h.html">qtoolbar.h</a>>
|
---|
| 148 | #include <<a href="qtoolbutton-h.html">qtoolbutton.h</a>>
|
---|
| 149 | #include <<a href="qspinbox-h.html">qspinbox.h</a>>
|
---|
| 150 | #include <<a href="qtooltip-h.html">qtooltip.h</a>>
|
---|
| 151 | #include <<a href="qrect-h.html">qrect.h</a>>
|
---|
| 152 | #include <<a href="qpoint-h.html">qpoint.h</a>>
|
---|
| 153 | #include <<a href="qcolordialog-h.html">qcolordialog.h</a>>
|
---|
| 154 | #include <<a href="qfiledialog-h.html">qfiledialog.h</a>>
|
---|
| 155 | #include <<a href="qcursor-h.html">qcursor.h</a>>
|
---|
| 156 | #include <<a href="qimage-h.html">qimage.h</a>>
|
---|
| 157 | #include <<a href="qstrlist-h.html">qstrlist.h</a>>
|
---|
| 158 | #include <<a href="qpopupmenu-h.html">qpopupmenu.h</a>>
|
---|
| 159 | #include <<a href="qintdict-h.html">qintdict.h</a>>
|
---|
| 160 |
|
---|
| 161 | const bool no_writing = FALSE;
|
---|
| 162 |
|
---|
| 163 | <a name="f338"></a>Canvas::Canvas( <a href="qwidget.html">QWidget</a> *parent, const char *name )
|
---|
| 164 | : <a href="qwidget.html">QWidget</a>( parent, name, WStaticContents ), pen( Qt::red, 3 ), polyline(3),
|
---|
| 165 | mousePressed( FALSE ), buffer( <a href="qwidget.html#width">width</a>(), height() )
|
---|
| 166 | {
|
---|
| 167 |
|
---|
| 168 | <a name="x907"></a><a name="x906"></a> if ((qApp-><a href="qapplication.html#argc">argc</a>() > 0) && !buffer.load(qApp-><a href="qapplication.html#argv">argv</a>()[1]))
|
---|
| 169 | buffer.fill( <a href="qwidget.html#colorGroup">colorGroup</a>().base() );
|
---|
| 170 | <a href="qwidget.html#setBackgroundMode">setBackgroundMode</a>( QWidget::PaletteBase );
|
---|
| 171 | #ifndef QT_NO_CURSOR
|
---|
| 172 | <a href="qwidget.html#setCursor">setCursor</a>( Qt::crossCursor );
|
---|
| 173 | #endif
|
---|
| 174 | }
|
---|
| 175 |
|
---|
| 176 | void <a name="f339"></a>Canvas::save( const <a href="qstring.html">QString</a> &filename, const <a href="qstring.html">QString</a> &format )
|
---|
| 177 | {
|
---|
| 178 | if ( !no_writing )
|
---|
| 179 | <a name="x942"></a> buffer.save( filename, format.<a href="qstring.html#upper">upper</a>() );
|
---|
| 180 | }
|
---|
| 181 |
|
---|
| 182 | void <a name="f340"></a>Canvas::clearScreen()
|
---|
| 183 | {
|
---|
| 184 | buffer.fill( <a href="qwidget.html#colorGroup">colorGroup</a>().base() );
|
---|
| 185 | <a href="qwidget.html#repaint">repaint</a>( FALSE );
|
---|
| 186 | }
|
---|
| 187 |
|
---|
| 188 | <a name="x949"></a>void Canvas::<a href="qwidget.html#mousePressEvent">mousePressEvent</a>( <a href="qmouseevent.html">QMouseEvent</a> *e )
|
---|
| 189 | {
|
---|
| 190 | mousePressed = TRUE;
|
---|
| 191 | polyline[2] = polyline[1] = polyline[0] = e-><a href="qmouseevent.html#pos">pos</a>();
|
---|
| 192 | }
|
---|
| 193 |
|
---|
| 194 | <a name="x950"></a>void Canvas::<a href="qwidget.html#mouseReleaseEvent">mouseReleaseEvent</a>( <a href="qmouseevent.html">QMouseEvent</a> * )
|
---|
| 195 | {
|
---|
| 196 | mousePressed = FALSE;
|
---|
| 197 | }
|
---|
| 198 |
|
---|
| 199 | <a name="x948"></a>void Canvas::<a href="qwidget.html#mouseMoveEvent">mouseMoveEvent</a>( <a href="qmouseevent.html">QMouseEvent</a> *e )
|
---|
| 200 | {
|
---|
| 201 | if ( mousePressed ) {
|
---|
| 202 | <a href="qpainter.html">QPainter</a> painter;
|
---|
| 203 | painter.<a href="qpainter.html#begin">begin</a>( &buffer );
|
---|
| 204 | painter.<a href="qpainter.html#setPen">setPen</a>( pen );
|
---|
| 205 | polyline[2] = polyline[1];
|
---|
| 206 | polyline[1] = polyline[0];
|
---|
| 207 | polyline[0] = e-><a href="qmouseevent.html#pos">pos</a>();
|
---|
| 208 | <a name="x917"></a> painter.<a href="qpainter.html#drawPolyline">drawPolyline</a>( polyline );
|
---|
| 209 | <a name="x918"></a> painter.<a href="qpainter.html#end">end</a>();
|
---|
| 210 |
|
---|
| 211 | <a href="qrect.html">QRect</a> r = polyline.boundingRect();
|
---|
| 212 | <a name="x928"></a> r = r.<a href="qrect.html#normalize">normalize</a>();
|
---|
| 213 | <a name="x931"></a><a name="x927"></a> r.<a href="qrect.html#setLeft">setLeft</a>( r.<a href="qrect.html#left">left</a>() - penWidth() );
|
---|
| 214 | <a name="x934"></a><a name="x933"></a> r.<a href="qrect.html#setTop">setTop</a>( r.<a href="qrect.html#top">top</a>() - penWidth() );
|
---|
| 215 | <a name="x932"></a><a name="x929"></a> r.<a href="qrect.html#setRight">setRight</a>( r.<a href="qrect.html#right">right</a>() + penWidth() );
|
---|
| 216 | <a name="x930"></a><a name="x925"></a> r.<a href="qrect.html#setBottom">setBottom</a>( r.<a href="qrect.html#bottom">bottom</a>() + penWidth() );
|
---|
| 217 |
|
---|
| 218 | <a name="x937"></a><a name="x936"></a><a name="x926"></a> <a href="qimage.html#bitBlt">bitBlt</a>( this, r.<a href="qrect.html#x">x</a>(), r.<a href="qrect.html#y">y</a>(), &buffer, r.<a href="qrect.html#x">x</a>(), r.<a href="qrect.html#y">y</a>(), r.<a href="qrect.html#width">width</a>(), r.<a href="qrect.html#height">height</a>() );
|
---|
| 219 | }
|
---|
| 220 | }
|
---|
| 221 |
|
---|
| 222 | <a name="x952"></a>void Canvas::<a href="qwidget.html#resizeEvent">resizeEvent</a>( <a href="qresizeevent.html">QResizeEvent</a> *e )
|
---|
| 223 | {
|
---|
| 224 | QWidget::<a href="qwidget.html#resizeEvent">resizeEvent</a>( e );
|
---|
| 225 |
|
---|
| 226 | int w = <a href="qwidget.html#width">width</a>() > buffer.width() ?
|
---|
| 227 | <a href="qwidget.html#width">width</a>() : buffer.width();
|
---|
| 228 | int h = <a href="qwidget.html#height">height</a>() > buffer.height() ?
|
---|
| 229 | <a href="qwidget.html#height">height</a>() : buffer.height();
|
---|
| 230 |
|
---|
| 231 | <a href="qpixmap.html">QPixmap</a> tmp( buffer );
|
---|
| 232 | buffer.resize( w, h );
|
---|
| 233 | buffer.fill( <a href="qwidget.html#colorGroup">colorGroup</a>().base() );
|
---|
| 234 | <a name="x922"></a><a name="x921"></a> <a href="qimage.html#bitBlt">bitBlt</a>( &buffer, 0, 0, &tmp, 0, 0, tmp.<a href="qpixmap.html#width">width</a>(), tmp.<a href="qpixmap.html#height">height</a>() );
|
---|
| 235 | }
|
---|
| 236 |
|
---|
| 237 | <a name="x951"></a>void Canvas::<a href="qwidget.html#paintEvent">paintEvent</a>( <a href="qpaintevent.html">QPaintEvent</a> *e )
|
---|
| 238 | {
|
---|
| 239 | QWidget::<a href="qwidget.html#paintEvent">paintEvent</a>( e );
|
---|
| 240 |
|
---|
| 241 | <a name="x920"></a> <a href="qmemarray.html">QMemArray</a><QRect> rects = e-><a href="qpaintevent.html#region">region</a>().rects();
|
---|
| 242 | <a name="x913"></a> for ( uint i = 0; i < rects.<a href="qmemarray.html#count">count</a>(); i++ ) {
|
---|
| 243 | <a href="qrect.html">QRect</a> r = rects[(int)i];
|
---|
| 244 | <a href="qimage.html#bitBlt">bitBlt</a>( this, r.<a href="qrect.html#x">x</a>(), r.<a href="qrect.html#y">y</a>(), &buffer, r.<a href="qrect.html#x">x</a>(), r.<a href="qrect.html#y">y</a>(), r.<a href="qrect.html#width">width</a>(), r.<a href="qrect.html#height">height</a>() );
|
---|
| 245 | }
|
---|
| 246 | }
|
---|
| 247 |
|
---|
| 248 | //------------------------------------------------------
|
---|
| 249 |
|
---|
| 250 | <a name="f341"></a>Scribble::Scribble( <a href="qwidget.html">QWidget</a> *parent, const char *name )
|
---|
| 251 | : <a href="qmainwindow.html">QMainWindow</a>( parent, name )
|
---|
| 252 | {
|
---|
| 253 | canvas = new Canvas( this );
|
---|
| 254 | <a href="qmainwindow.html#setCentralWidget">setCentralWidget</a>( canvas );
|
---|
| 255 |
|
---|
| 256 | <a href="qtoolbar.html">QToolBar</a> *tools = new <a href="qtoolbar.html">QToolBar</a>( this );
|
---|
| 257 |
|
---|
| 258 | bSave = new <a href="qtoolbutton.html">QToolButton</a>( QPixmap(), "Save", "Save as PNG image", this, SLOT( slotSave() ), tools );
|
---|
| 259 | <a name="x944"></a> bSave-><a href="qbutton.html#setText">setText</a>( "Save as..." );
|
---|
| 260 |
|
---|
| 261 | <a name="x943"></a> tools-><a href="qtoolbar.html#addSeparator">addSeparator</a>();
|
---|
| 262 |
|
---|
| 263 | bPColor = new <a href="qtoolbutton.html">QToolButton</a>( QPixmap(), "Choose Pen Color", "Choose Pen Color", this, SLOT( slotColor() ), tools );
|
---|
| 264 | bPColor-><a href="qbutton.html#setText">setText</a>( "Choose Pen Color..." );
|
---|
| 265 |
|
---|
| 266 | tools-><a href="qtoolbar.html#addSeparator">addSeparator</a>();
|
---|
| 267 |
|
---|
| 268 | bPWidth = new <a href="qspinbox.html">QSpinBox</a>( 1, 20, 1, tools );
|
---|
| 269 | <a name="x945"></a> QToolTip::<a href="qtooltip.html#add">add</a>( bPWidth, "Choose Pen Width" );
|
---|
| 270 | <a name="x939"></a> <a href="qobject.html#connect">connect</a>( bPWidth, SIGNAL( <a href="qspinbox.html#valueChanged">valueChanged</a>( int ) ), this, SLOT( slotWidth( int ) ) );
|
---|
| 271 | <a name="x938"></a> bPWidth-><a href="qspinbox.html#setValue">setValue</a>( 3 );
|
---|
| 272 |
|
---|
| 273 | tools-><a href="qtoolbar.html#addSeparator">addSeparator</a>();
|
---|
| 274 |
|
---|
| 275 | bClear = new <a href="qtoolbutton.html">QToolButton</a>( QPixmap(), "Clear Screen", "Clear Screen", this, SLOT( slotClear() ), tools );
|
---|
| 276 | bClear-><a href="qbutton.html#setText">setText</a>( "Clear Screen" );
|
---|
| 277 | }
|
---|
| 278 |
|
---|
| 279 | void <a name="f342"></a>Scribble::slotSave()
|
---|
| 280 | {
|
---|
| 281 | <a href="qpopupmenu.html">QPopupMenu</a> *menu = new <a href="qpopupmenu.html">QPopupMenu</a>( 0 );
|
---|
| 282 | <a href="qintdict.html">QIntDict</a><QString> formats;
|
---|
| 283 | <a name="x924"></a> formats.<a href="qptrcollection.html#setAutoDelete">setAutoDelete</a>( TRUE );
|
---|
| 284 |
|
---|
| 285 | for ( unsigned int i = 0; i < QImageIO::<a href="qimageio.html#outputFormats">outputFormats</a>().count(); i++ ) {
|
---|
| 286 | <a name="x911"></a> <a href="qstring.html">QString</a> str = QString( QImageIO::<a href="qimageio.html#outputFormats">outputFormats</a>().at( i ) );
|
---|
| 287 | <a name="x912"></a> formats.<a href="qintdict.html#insert">insert</a>( menu-><a href="qmenudata.html#insertItem">insertItem</a>( QString( "%1..." ).arg( str ) ), new <a href="qstring.html">QString</a>( str ) );
|
---|
| 288 | }
|
---|
| 289 |
|
---|
| 290 | <a name="x953"></a> menu-><a href="qwidget.html#setMouseTracking">setMouseTracking</a>( TRUE );
|
---|
| 291 | <a name="x947"></a><a name="x946"></a><a name="x923"></a> int id = menu-><a href="qpopupmenu.html#exec">exec</a>( bSave-><a href="qwidget.html#mapToGlobal">mapToGlobal</a>( QPoint( 0, bSave-><a href="qwidget.html#height">height</a>() + 1 ) ) );
|
---|
| 292 |
|
---|
| 293 | if ( id != -1 ) {
|
---|
| 294 | <a href="qstring.html">QString</a> format = *formats[ id ];
|
---|
| 295 |
|
---|
| 296 | <a name="x941"></a> <a href="qstring.html">QString</a> filename = QFileDialog::<a href="qfiledialog.html#getSaveFileName">getSaveFileName</a>( <a href="qstring.html#QString-null">QString::null</a>, QString( "*.%1" ).arg( format.<a href="qstring.html#lower">lower</a>() ), this );
|
---|
| 297 | if ( !filename.<a href="qstring.html#isEmpty">isEmpty</a>() )
|
---|
| 298 | canvas->save( filename, format );
|
---|
| 299 | }
|
---|
| 300 |
|
---|
| 301 | delete menu;
|
---|
| 302 | }
|
---|
| 303 |
|
---|
| 304 | void <a name="f343"></a>Scribble::slotColor()
|
---|
| 305 | {
|
---|
| 306 | <a name="x909"></a> <a href="qcolor.html">QColor</a> c = QColorDialog::<a href="qcolordialog.html#getColor">getColor</a>( canvas->penColor(), this );
|
---|
| 307 | <a name="x908"></a> if ( c.<a href="qcolor.html#isValid">isValid</a>() )
|
---|
| 308 | canvas->setPenColor( c );
|
---|
| 309 | }
|
---|
| 310 |
|
---|
| 311 | void <a name="f344"></a>Scribble::slotWidth( int w )
|
---|
| 312 | {
|
---|
| 313 | canvas->setPenWidth( w );
|
---|
| 314 | }
|
---|
| 315 |
|
---|
| 316 | void <a name="f345"></a>Scribble::slotClear()
|
---|
| 317 | {
|
---|
| 318 | canvas->clearScreen();
|
---|
| 319 | }
|
---|
| 320 | </pre>
|
---|
| 321 |
|
---|
| 322 | <p> <hr>
|
---|
| 323 | <p> Main:
|
---|
| 324 | <p> <pre>/****************************************************************************
|
---|
| 325 | ** $Id: scribble-example.html 2051 2007-02-21 10:04:20Z chehrlic $
|
---|
| 326 | **
|
---|
| 327 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
|
---|
| 328 | **
|
---|
| 329 | ** This file is part of an example program for Qt. This example
|
---|
| 330 | ** program may be used, distributed and modified without limitation.
|
---|
| 331 | **
|
---|
| 332 | *****************************************************************************/
|
---|
| 333 |
|
---|
| 334 | #include "scribble.h"
|
---|
| 335 | #include <<a href="qapplication-h.html">qapplication.h</a>>
|
---|
| 336 |
|
---|
| 337 |
|
---|
| 338 | int main( int argc, char **argv )
|
---|
| 339 | {
|
---|
| 340 | <a href="qapplication.html">QApplication</a> a( argc, argv );
|
---|
| 341 |
|
---|
| 342 | Scribble scribble;
|
---|
| 343 |
|
---|
| 344 | scribble.<a href="qwidget.html#resize">resize</a>( 500, 350 );
|
---|
| 345 | scribble.<a href="qwidget.html#setCaption">setCaption</a>("Qt Example - Scribble");
|
---|
| 346 | a.<a href="qapplication.html#setMainWidget">setMainWidget</a>( &scribble );
|
---|
| 347 | <a name="x954"></a> if ( QApplication::<a href="qapplication.html#desktop">desktop</a>()->width() > 550
|
---|
| 348 | && QApplication::<a href="qapplication.html#desktop">desktop</a>()->height() > 366 )
|
---|
| 349 | scribble.<a href="qwidget.html#show">show</a>();
|
---|
| 350 | else
|
---|
| 351 | <a name="x960"></a> scribble.<a href="qwidget.html#showMaximized">showMaximized</a>();
|
---|
| 352 | return a.<a href="qapplication.html#exec">exec</a>();
|
---|
| 353 | }
|
---|
| 354 | </pre>
|
---|
| 355 |
|
---|
| 356 | <p>See also <a href="examples.html">Examples</a>.
|
---|
| 357 |
|
---|
| 358 | <!-- eof -->
|
---|
| 359 | <p><address><hr><div align=center>
|
---|
| 360 | <table width=100% cellspacing=0 border=0><tr>
|
---|
| 361 | <td>Copyright © 2007
|
---|
| 362 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
| 363 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
| 364 | </table></div></address></body>
|
---|
| 365 | </html>
|
---|