Changeset 561 for trunk/doc/src/examples/tablet.qdoc
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/doc/src/examples/tablet.qdoc
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the documentation of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 49 49 50 50 When you use a tablet with Qt applications, \l{QTabletEvent}s are 51 gen arated. You need to reimplement the51 generated. You need to reimplement the 52 52 \l{QWidget::}{tabletEvent()} event handler if you want to handle 53 53 tablet events. Events are generated when the device used for … … 80 80 \o The \c TabletCanvas class inherits QWidget and 81 81 receives tablet events. It uses the events to paint on a 82 QImage, which it draws onto itself.82 offscreen pixmap, which it draws onto itself. 83 83 \o The \c TabletApplication class inherits QApplication. This 84 84 class handles tablet events that are not sent to \c tabletEvent(). … … 215 215 which we provide access functions for. 216 216 217 We draw on a Q Imagewith \c myPen and \c myBrush using \c217 We draw on a QPixmap with \c myPen and \c myBrush using \c 218 218 myColor. The \c saveImage() and \c loadImage() saves and loads 219 the Q Image to disk. The imageis drawn on the widget in \c219 the QPixmap to disk. The pixmap is drawn on the widget in \c 220 220 paintEvent(). The \c pointerType and \c deviceType keeps the type 221 221 of pointer, which is either a pen or an eraser, and device … … 224 224 225 225 The interpretation of events from the tablet is done in \c 226 tabletEvent(); \c paint Image(), \c updateBrush(), and \c226 tabletEvent(); \c paintPixmap(), \c updateBrush(), and \c 227 227 brushPattern() are helper functions used by \c tabletEvent(). 228 228 … … 235 235 236 236 In the constructor we initialize our class variables. We need 237 to draw the background of our image, as the default is gray.237 to draw the background of our pixmap, as the default is gray. 238 238 239 239 Here is the implementation of \c saveImage(): … … 241 241 \snippet examples/widgets/tablet/tabletcanvas.cpp 1 242 242 243 Q Imageimplements functionality to save itself to disk, so we244 simply call \l{Q Image::}{save()}.243 QPixmap implements functionality to save itself to disk, so we 244 simply call \l{QPixmap::}{save()}. 245 245 246 246 Here is the implementation of \c loadImage(): … … 248 248 \snippet examples/widgets/tablet/tabletcanvas.cpp 2 249 249 250 We simply call \l{Q Image::}{load()}, which loads the image in \a250 We simply call \l{QPixmap::}{load()}, which loads the image in \a 251 251 file. 252 252 … … 260 260 deviceDown to true when a device is pressed down on the tablet; 261 261 we then know when we should draw when we receive move events. We 262 have implemented the \c updateBrush() and \c paint Image() helper262 have implemented the \c updateBrush() and \c paintPixmap() helper 263 263 functions to update \c myBrush and \c myPen after the state of \c 264 264 alphaChannelType, \c colorSaturationType, and \c lineWidthType. … … 268 268 \snippet examples/widgets/tablet/tabletcanvas.cpp 4 269 269 270 We simply draw the imageto the top left of the widget.271 272 Here is the implementation of \c paint Image():270 We simply draw the pixmap to the top left of the widget. 271 272 Here is the implementation of \c paintPixmap(): 273 273 274 274 \snippet examples/widgets/tablet/tabletcanvas.cpp 5 275 275 276 In this function we draw on the imagebased on the movement of the276 In this function we draw on the pixmap based on the movement of the 277 277 device. If the device used on the tablet is a stylus we want to draw a 278 line between the positions of the stylus recorded in \c polyLine. 278 line between the positions of the stylus recorded in \c polyLine. We 279 also assume that this is a reasonable handling of any unknown device, 280 but update the statusbar with a warning so that the user can see that 281 for his tablet he might have to implement special handling. 279 282 If it is an airbrush we want to draw a circle of points with a 280 283 point density based on the tangential pressure, which is the position … … 332 335 We finally check wether the pointer is the stylus or the eraser. 333 336 If it is the eraser, we set the color to the background color of 334 the imagean let the pressure decide the pen width, else we set337 the pixmap an let the pressure decide the pen width, else we set 335 338 the colors we have set up previously in the function. 336 339
Note:
See TracChangeset
for help on using the changeset viewer.