From cfdc5628b1fc2cbafa2aebca38995e5718fcb0de Mon Sep 17 00:00:00 2001 From: Casper van Donderen Date: Mon, 7 May 2012 15:50:31 +0200 Subject: Doc: Modularize QtGui documentation. This change moves the snippets and images to the modularized directories. Change-Id: I5f86f598fbe7c47d632c613b85d94ced89ba2c29 Reviewed-by: Marius Storm-Olsen --- src/gui/doc/images/brush-outline.png | Bin 0 -> 452 bytes src/gui/doc/images/brush-styles.png | Bin 0 -> 13980 bytes .../doc/images/coordinatesystem-analogclock.png | Bin 0 -> 9762 bytes .../doc/images/coordinatesystem-line-antialias.png | Bin 0 -> 17979 bytes .../doc/images/coordinatesystem-line-raster.png | Bin 0 -> 18152 bytes src/gui/doc/images/coordinatesystem-line.png | Bin 0 -> 26694 bytes .../doc/images/coordinatesystem-rect-antialias.png | Bin 0 -> 19058 bytes .../doc/images/coordinatesystem-rect-raster.png | Bin 0 -> 18455 bytes src/gui/doc/images/coordinatesystem-rect.png | Bin 0 -> 32307 bytes .../images/coordinatesystem-transformations.png | Bin 0 -> 59180 bytes src/gui/doc/images/cursor-arrow.png | Bin 0 -> 171 bytes src/gui/doc/images/cursor-busy.png | Bin 0 -> 201 bytes src/gui/doc/images/cursor-closedhand.png | Bin 0 -> 147 bytes src/gui/doc/images/cursor-cross.png | Bin 0 -> 130 bytes src/gui/doc/images/cursor-forbidden.png | Bin 0 -> 199 bytes src/gui/doc/images/cursor-hand.png | Bin 0 -> 159 bytes src/gui/doc/images/cursor-hsplit.png | Bin 0 -> 155 bytes src/gui/doc/images/cursor-ibeam.png | Bin 0 -> 124 bytes src/gui/doc/images/cursor-openhand.png | Bin 0 -> 160 bytes src/gui/doc/images/cursor-sizeall.png | Bin 0 -> 174 bytes src/gui/doc/images/cursor-sizeb.png | Bin 0 -> 161 bytes src/gui/doc/images/cursor-sizef.png | Bin 0 -> 161 bytes src/gui/doc/images/cursor-sizeh.png | Bin 0 -> 145 bytes src/gui/doc/images/cursor-sizev.png | Bin 0 -> 141 bytes src/gui/doc/images/cursor-uparrow.png | Bin 0 -> 132 bytes src/gui/doc/images/cursor-vsplit.png | Bin 0 -> 161 bytes src/gui/doc/images/cursor-wait.png | Bin 0 -> 172 bytes src/gui/doc/images/cursor-whatsthis.png | Bin 0 -> 191 bytes src/gui/doc/images/hoverevents.png | Bin 0 -> 3210 bytes src/gui/doc/images/paintsystem-antialiasing.png | Bin 0 -> 995 bytes src/gui/doc/images/paintsystem-core.png | Bin 0 -> 22101 bytes src/gui/doc/images/paintsystem-devices.png | Bin 0 -> 47404 bytes src/gui/doc/images/paintsystem-fancygradient.png | Bin 0 -> 39213 bytes src/gui/doc/images/paintsystem-gradients.png | Bin 0 -> 16931 bytes src/gui/doc/images/paintsystem-icon.png | Bin 0 -> 5458 bytes src/gui/doc/images/paintsystem-movie.png | Bin 0 -> 4992 bytes src/gui/doc/images/paintsystem-painterpath.png | Bin 0 -> 7503 bytes src/gui/doc/images/paintsystem-stylepainter.png | Bin 0 -> 16572 bytes src/gui/doc/images/paintsystem-svg.png | Bin 0 -> 66692 bytes src/gui/doc/images/qcolor-cmyk.png | Bin 0 -> 18878 bytes src/gui/doc/images/qcolor-hsv.png | Bin 0 -> 21046 bytes src/gui/doc/images/qcolor-hue.png | Bin 0 -> 26820 bytes src/gui/doc/images/qcolor-rgb.png | Bin 0 -> 17798 bytes src/gui/doc/images/qcolor-saturation.png | Bin 0 -> 2150 bytes src/gui/doc/images/qcolor-value.png | Bin 0 -> 1241 bytes src/gui/doc/images/qconicalgradient.png | Bin 0 -> 52823 bytes src/gui/doc/images/qgradient-conical.png | Bin 0 -> 3995 bytes src/gui/doc/images/qgradient-linear.png | Bin 0 -> 714 bytes src/gui/doc/images/qgradient-radial.png | Bin 0 -> 2352 bytes src/gui/doc/images/qimage-32bit_scaled.png | Bin 0 -> 25098 bytes src/gui/doc/images/qimage-8bit_scaled.png | Bin 0 -> 24761 bytes src/gui/doc/images/qimage-scaling.png | Bin 0 -> 34785 bytes src/gui/doc/images/qlineargradient-pad.png | Bin 0 -> 2260 bytes src/gui/doc/images/qlineargradient-reflect.png | Bin 0 -> 2746 bytes src/gui/doc/images/qlineargradient-repeat.png | Bin 0 -> 2590 bytes .../doc/images/qmatrix-combinedtransformation.png | Bin 0 -> 1707 bytes src/gui/doc/images/qmatrix-representation.png | Bin 0 -> 10410 bytes .../doc/images/qmatrix-simpletransformation.png | Bin 0 -> 2047 bytes .../doc/images/qpainter-affinetransformations.png | Bin 0 -> 66241 bytes src/gui/doc/images/qpainter-arc.png | Bin 0 -> 635 bytes src/gui/doc/images/qpainter-basicdrawing.png | Bin 0 -> 18164 bytes src/gui/doc/images/qpainter-chord.png | Bin 0 -> 632 bytes src/gui/doc/images/qpainter-clock.png | Bin 0 -> 3128 bytes src/gui/doc/images/qpainter-compositiondemo.png | Bin 0 -> 61015 bytes src/gui/doc/images/qpainter-compositionmode1.png | Bin 0 -> 2418 bytes src/gui/doc/images/qpainter-compositionmode2.png | Bin 0 -> 2131 bytes src/gui/doc/images/qpainter-concentriccircles.png | Bin 0 -> 31294 bytes src/gui/doc/images/qpainter-ellipse.png | Bin 0 -> 1022 bytes src/gui/doc/images/qpainter-gradients.png | Bin 0 -> 24231 bytes src/gui/doc/images/qpainter-line.png | Bin 0 -> 759 bytes src/gui/doc/images/qpainter-painterpaths.png | Bin 0 -> 31985 bytes src/gui/doc/images/qpainter-path.png | Bin 0 -> 963 bytes src/gui/doc/images/qpainter-pathstroking.png | Bin 0 -> 30794 bytes src/gui/doc/images/qpainter-pie.png | Bin 0 -> 1018 bytes src/gui/doc/images/qpainter-polygon.png | Bin 0 -> 699 bytes src/gui/doc/images/qpainter-rectangle.png | Bin 0 -> 194 bytes src/gui/doc/images/qpainter-rotation.png | Bin 0 -> 3768 bytes src/gui/doc/images/qpainter-roundrect.png | Bin 0 -> 433 bytes src/gui/doc/images/qpainter-scale.png | Bin 0 -> 2828 bytes src/gui/doc/images/qpainter-text.png | Bin 0 -> 1391 bytes src/gui/doc/images/qpainter-translation.png | Bin 0 -> 3909 bytes src/gui/doc/images/qpainter-vectordeformation.png | Bin 0 -> 30591 bytes src/gui/doc/images/qpainterpath-addellipse.png | Bin 0 -> 3509 bytes src/gui/doc/images/qpainterpath-addpolygon.png | Bin 0 -> 7625 bytes src/gui/doc/images/qpainterpath-addrectangle.png | Bin 0 -> 1839 bytes src/gui/doc/images/qpainterpath-addtext.png | Bin 0 -> 7406 bytes src/gui/doc/images/qpainterpath-arcto.png | Bin 0 -> 5063 bytes src/gui/doc/images/qpainterpath-construction.png | Bin 0 -> 2523 bytes src/gui/doc/images/qpainterpath-cubicto.png | Bin 0 -> 4749 bytes src/gui/doc/images/qpainterpath-demo.png | Bin 0 -> 51334 bytes src/gui/doc/images/qpainterpath-example.png | Bin 0 -> 38746 bytes src/gui/doc/images/qpen-bevel.png | Bin 0 -> 11527 bytes src/gui/doc/images/qpen-custom.png | Bin 0 -> 6254 bytes src/gui/doc/images/qpen-dash.png | Bin 0 -> 8221 bytes src/gui/doc/images/qpen-dashdot.png | Bin 0 -> 5961 bytes src/gui/doc/images/qpen-dashdotdot.png | Bin 0 -> 5999 bytes src/gui/doc/images/qpen-dashpattern.png | Bin 0 -> 1605 bytes src/gui/doc/images/qpen-demo.png | Bin 0 -> 49784 bytes src/gui/doc/images/qpen-dot.png | Bin 0 -> 5386 bytes src/gui/doc/images/qpen-flat.png | Bin 0 -> 1885 bytes src/gui/doc/images/qpen-miter.png | Bin 0 -> 11734 bytes src/gui/doc/images/qpen-miterlimit.png | Bin 0 -> 24816 bytes src/gui/doc/images/qpen-roundcap.png | Bin 0 -> 1920 bytes src/gui/doc/images/qpen-roundjoin.png | Bin 0 -> 11878 bytes src/gui/doc/images/qpen-solid.png | Bin 0 -> 7416 bytes src/gui/doc/images/qpen-square.png | Bin 0 -> 2651 bytes src/gui/doc/images/qradialgradient-pad.png | Bin 0 -> 11385 bytes src/gui/doc/images/qradialgradient-reflect.png | Bin 0 -> 33668 bytes src/gui/doc/images/qradialgradient-repeat.png | Bin 0 -> 40528 bytes src/gui/doc/images/qstatustipevent-action.png | Bin 0 -> 10741 bytes src/gui/doc/images/qstatustipevent-widget.png | Bin 0 -> 9417 bytes src/gui/doc/images/qt-fillrule-oddeven.png | Bin 0 -> 7057 bytes src/gui/doc/images/qt-fillrule-winding.png | Bin 0 -> 7205 bytes src/gui/doc/images/qtexttableformat-cell.png | Bin 0 -> 24454 bytes .../images/qtransform-combinedtransformation.png | Bin 0 -> 935 bytes .../images/qtransform-combinedtransformation2.png | Bin 0 -> 930 bytes src/gui/doc/images/qtransform-representation.png | Bin 0 -> 17385 bytes .../doc/images/qtransform-simpletransformation.png | Bin 0 -> 1201 bytes src/gui/doc/images/texttable-merge.png | Bin 0 -> 746 bytes src/gui/doc/images/texttable-split.png | Bin 0 -> 753 bytes src/gui/doc/qtgui.qdocconf | 92 ++++ src/gui/doc/snippets/brush/brush.cpp | 86 ++++ .../doc/snippets/brush/gradientcreationsnippet.cpp | 62 +++ src/gui/doc/snippets/code/doc_src_qtgui.pro | 3 + .../code/src_gui_accessible_qaccessible.cpp | 43 ++ src/gui/doc/snippets/code/src_gui_image_qimage.cpp | 82 +++ .../snippets/code/src_gui_image_qimagereader.cpp | 66 +++ .../snippets/code/src_gui_image_qimagewriter.cpp | 59 +++ src/gui/doc/snippets/code/src_gui_image_qmovie.cpp | 53 ++ .../doc/snippets/code/src_gui_image_qpixmap.cpp | 58 +++ .../snippets/code/src_gui_image_qpixmapcache.cpp | 61 +++ .../snippets/code/src_gui_kernel_qapplication.cpp | 183 +++++++ .../code/src_gui_kernel_qapplication_x11.cpp | 45 ++ .../snippets/code/src_gui_kernel_qclipboard.cpp | 53 ++ .../doc/snippets/code/src_gui_kernel_qevent.cpp | 56 +++ .../snippets/code/src_gui_kernel_qkeysequence.cpp | 59 +++ .../snippets/code/src_gui_kernel_qshortcutmap.cpp | 43 ++ .../doc/snippets/code/src_gui_painting_qbrush.cpp | 51 ++ .../doc/snippets/code/src_gui_painting_qcolor.cpp | 49 ++ .../doc/snippets/code/src_gui_painting_qmatrix.cpp | 62 +++ .../snippets/code/src_gui_painting_qpainter.cpp | 259 ++++++++++ .../code/src_gui_painting_qpainterpath.cpp | 149 ++++++ .../doc/snippets/code/src_gui_painting_qpen.cpp | 81 +++ .../doc/snippets/code/src_gui_painting_qregion.cpp | 53 ++ .../code/src_gui_painting_qregion_unix.cpp | 54 ++ .../snippets/code/src_gui_painting_qtransform.cpp | 82 +++ .../snippets/code/src_gui_qopenglshaderprogram.cpp | 94 ++++ src/gui/doc/snippets/code/src_gui_text_qfont.cpp | 67 +++ .../snippets/code/src_gui_text_qfontmetrics.cpp | 54 ++ .../code/src_gui_text_qsyntaxhighlighter.cpp | 126 +++++ .../doc/snippets/code/src_gui_text_qtextcursor.cpp | 80 +++ .../snippets/code/src_gui_text_qtextdocument.cpp | 43 ++ .../code/src_gui_text_qtextdocumentwriter.cpp | 45 ++ .../doc/snippets/code/src_gui_text_qtextlayout.cpp | 62 +++ .../code/src_gui_util_qdesktopservices.cpp | 60 +++ .../doc/snippets/code/src_gui_util_qvalidator.cpp | 135 +++++ src/gui/doc/snippets/dragging/mainwindow.cpp | 110 ++++ src/gui/doc/snippets/droparea.cpp | 140 ++++++ src/gui/doc/snippets/image/image.cpp | 104 ++++ src/gui/doc/snippets/image/supportedformat.cpp | 52 ++ src/gui/doc/snippets/matrix/matrix.cpp | 140 ++++++ src/gui/doc/snippets/picture/picture.cpp | 151 ++++++ src/gui/doc/snippets/polygon/polygon.cpp | 112 +++++ src/gui/doc/snippets/qfontdatabase/main.cpp | 74 +++ src/gui/doc/snippets/qstatustipevent/main.cpp | 82 +++ src/gui/doc/snippets/separations/finalwidget.cpp | 126 +++++ .../doc/snippets/textblock-fragments/xmlwriter.cpp | 117 +++++ src/gui/doc/snippets/textdocument-css/main.cpp | 59 +++ .../snippets/textdocument-listitemstyles/main.cpp | 52 ++ .../textdocument-listitemstyles/mainwindow.cpp | 84 ++++ .../textdocument-listitemstyles/mainwindow.h | 65 +++ .../textdocument-listitemstyles.pro | 3 + .../doc/snippets/textdocument-lists/mainwindow.cpp | 192 +++++++ .../doc/snippets/textdocument-resources/main.cpp | 83 +++ .../textdocument-resources.pro | 1 + .../snippets/textdocument-tables/mainwindow.cpp | 204 ++++++++ .../doc/snippets/textdocument-texttable/main.cpp | 84 ++++ src/gui/doc/snippets/textdocumentendsnippet.cpp | 56 +++ src/gui/doc/snippets/transform/main.cpp | 140 ++++++ src/gui/doc/src/coordsys.qdoc | 461 +++++++++++++++++ src/gui/doc/src/paintsystem.qdoc | 560 +++++++++++++++++++++ src/gui/doc/src/qtgui.qdoc | 39 ++ 182 files changed, 6001 insertions(+) create mode 100644 src/gui/doc/images/brush-outline.png create mode 100644 src/gui/doc/images/brush-styles.png create mode 100644 src/gui/doc/images/coordinatesystem-analogclock.png create mode 100644 src/gui/doc/images/coordinatesystem-line-antialias.png create mode 100644 src/gui/doc/images/coordinatesystem-line-raster.png create mode 100644 src/gui/doc/images/coordinatesystem-line.png create mode 100644 src/gui/doc/images/coordinatesystem-rect-antialias.png create mode 100644 src/gui/doc/images/coordinatesystem-rect-raster.png create mode 100644 src/gui/doc/images/coordinatesystem-rect.png create mode 100644 src/gui/doc/images/coordinatesystem-transformations.png create mode 100644 src/gui/doc/images/cursor-arrow.png create mode 100644 src/gui/doc/images/cursor-busy.png create mode 100644 src/gui/doc/images/cursor-closedhand.png create mode 100644 src/gui/doc/images/cursor-cross.png create mode 100644 src/gui/doc/images/cursor-forbidden.png create mode 100644 src/gui/doc/images/cursor-hand.png create mode 100644 src/gui/doc/images/cursor-hsplit.png create mode 100644 src/gui/doc/images/cursor-ibeam.png create mode 100644 src/gui/doc/images/cursor-openhand.png create mode 100644 src/gui/doc/images/cursor-sizeall.png create mode 100644 src/gui/doc/images/cursor-sizeb.png create mode 100644 src/gui/doc/images/cursor-sizef.png create mode 100644 src/gui/doc/images/cursor-sizeh.png create mode 100644 src/gui/doc/images/cursor-sizev.png create mode 100644 src/gui/doc/images/cursor-uparrow.png create mode 100644 src/gui/doc/images/cursor-vsplit.png create mode 100644 src/gui/doc/images/cursor-wait.png create mode 100644 src/gui/doc/images/cursor-whatsthis.png create mode 100644 src/gui/doc/images/hoverevents.png create mode 100644 src/gui/doc/images/paintsystem-antialiasing.png create mode 100644 src/gui/doc/images/paintsystem-core.png create mode 100644 src/gui/doc/images/paintsystem-devices.png create mode 100644 src/gui/doc/images/paintsystem-fancygradient.png create mode 100644 src/gui/doc/images/paintsystem-gradients.png create mode 100644 src/gui/doc/images/paintsystem-icon.png create mode 100644 src/gui/doc/images/paintsystem-movie.png create mode 100644 src/gui/doc/images/paintsystem-painterpath.png create mode 100644 src/gui/doc/images/paintsystem-stylepainter.png create mode 100644 src/gui/doc/images/paintsystem-svg.png create mode 100644 src/gui/doc/images/qcolor-cmyk.png create mode 100644 src/gui/doc/images/qcolor-hsv.png create mode 100644 src/gui/doc/images/qcolor-hue.png create mode 100644 src/gui/doc/images/qcolor-rgb.png create mode 100644 src/gui/doc/images/qcolor-saturation.png create mode 100644 src/gui/doc/images/qcolor-value.png create mode 100644 src/gui/doc/images/qconicalgradient.png create mode 100644 src/gui/doc/images/qgradient-conical.png create mode 100644 src/gui/doc/images/qgradient-linear.png create mode 100644 src/gui/doc/images/qgradient-radial.png create mode 100644 src/gui/doc/images/qimage-32bit_scaled.png create mode 100644 src/gui/doc/images/qimage-8bit_scaled.png create mode 100644 src/gui/doc/images/qimage-scaling.png create mode 100644 src/gui/doc/images/qlineargradient-pad.png create mode 100644 src/gui/doc/images/qlineargradient-reflect.png create mode 100644 src/gui/doc/images/qlineargradient-repeat.png create mode 100644 src/gui/doc/images/qmatrix-combinedtransformation.png create mode 100644 src/gui/doc/images/qmatrix-representation.png create mode 100644 src/gui/doc/images/qmatrix-simpletransformation.png create mode 100644 src/gui/doc/images/qpainter-affinetransformations.png create mode 100644 src/gui/doc/images/qpainter-arc.png create mode 100644 src/gui/doc/images/qpainter-basicdrawing.png create mode 100644 src/gui/doc/images/qpainter-chord.png create mode 100644 src/gui/doc/images/qpainter-clock.png create mode 100644 src/gui/doc/images/qpainter-compositiondemo.png create mode 100644 src/gui/doc/images/qpainter-compositionmode1.png create mode 100644 src/gui/doc/images/qpainter-compositionmode2.png create mode 100644 src/gui/doc/images/qpainter-concentriccircles.png create mode 100644 src/gui/doc/images/qpainter-ellipse.png create mode 100644 src/gui/doc/images/qpainter-gradients.png create mode 100644 src/gui/doc/images/qpainter-line.png create mode 100644 src/gui/doc/images/qpainter-painterpaths.png create mode 100644 src/gui/doc/images/qpainter-path.png create mode 100644 src/gui/doc/images/qpainter-pathstroking.png create mode 100644 src/gui/doc/images/qpainter-pie.png create mode 100644 src/gui/doc/images/qpainter-polygon.png create mode 100644 src/gui/doc/images/qpainter-rectangle.png create mode 100644 src/gui/doc/images/qpainter-rotation.png create mode 100644 src/gui/doc/images/qpainter-roundrect.png create mode 100644 src/gui/doc/images/qpainter-scale.png create mode 100644 src/gui/doc/images/qpainter-text.png create mode 100644 src/gui/doc/images/qpainter-translation.png create mode 100644 src/gui/doc/images/qpainter-vectordeformation.png create mode 100644 src/gui/doc/images/qpainterpath-addellipse.png create mode 100644 src/gui/doc/images/qpainterpath-addpolygon.png create mode 100644 src/gui/doc/images/qpainterpath-addrectangle.png create mode 100644 src/gui/doc/images/qpainterpath-addtext.png create mode 100644 src/gui/doc/images/qpainterpath-arcto.png create mode 100644 src/gui/doc/images/qpainterpath-construction.png create mode 100644 src/gui/doc/images/qpainterpath-cubicto.png create mode 100644 src/gui/doc/images/qpainterpath-demo.png create mode 100644 src/gui/doc/images/qpainterpath-example.png create mode 100644 src/gui/doc/images/qpen-bevel.png create mode 100644 src/gui/doc/images/qpen-custom.png create mode 100644 src/gui/doc/images/qpen-dash.png create mode 100644 src/gui/doc/images/qpen-dashdot.png create mode 100644 src/gui/doc/images/qpen-dashdotdot.png create mode 100644 src/gui/doc/images/qpen-dashpattern.png create mode 100644 src/gui/doc/images/qpen-demo.png create mode 100644 src/gui/doc/images/qpen-dot.png create mode 100644 src/gui/doc/images/qpen-flat.png create mode 100644 src/gui/doc/images/qpen-miter.png create mode 100644 src/gui/doc/images/qpen-miterlimit.png create mode 100644 src/gui/doc/images/qpen-roundcap.png create mode 100644 src/gui/doc/images/qpen-roundjoin.png create mode 100644 src/gui/doc/images/qpen-solid.png create mode 100644 src/gui/doc/images/qpen-square.png create mode 100644 src/gui/doc/images/qradialgradient-pad.png create mode 100644 src/gui/doc/images/qradialgradient-reflect.png create mode 100644 src/gui/doc/images/qradialgradient-repeat.png create mode 100644 src/gui/doc/images/qstatustipevent-action.png create mode 100644 src/gui/doc/images/qstatustipevent-widget.png create mode 100644 src/gui/doc/images/qt-fillrule-oddeven.png create mode 100644 src/gui/doc/images/qt-fillrule-winding.png create mode 100644 src/gui/doc/images/qtexttableformat-cell.png create mode 100644 src/gui/doc/images/qtransform-combinedtransformation.png create mode 100644 src/gui/doc/images/qtransform-combinedtransformation2.png create mode 100644 src/gui/doc/images/qtransform-representation.png create mode 100644 src/gui/doc/images/qtransform-simpletransformation.png create mode 100644 src/gui/doc/images/texttable-merge.png create mode 100644 src/gui/doc/images/texttable-split.png create mode 100644 src/gui/doc/qtgui.qdocconf create mode 100644 src/gui/doc/snippets/brush/brush.cpp create mode 100644 src/gui/doc/snippets/brush/gradientcreationsnippet.cpp create mode 100644 src/gui/doc/snippets/code/doc_src_qtgui.pro create mode 100644 src/gui/doc/snippets/code/src_gui_accessible_qaccessible.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_image_qimage.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_image_qimagereader.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_image_qimagewriter.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_image_qmovie.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_image_qpixmap.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_image_qpixmapcache.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_kernel_qapplication.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_kernel_qapplication_x11.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_kernel_qclipboard.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_kernel_qevent.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_kernel_qkeysequence.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_kernel_qshortcutmap.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_painting_qbrush.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_painting_qcolor.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_painting_qmatrix.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_painting_qpainter.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_painting_qpainterpath.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_painting_qpen.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_painting_qregion.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_painting_qregion_unix.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_painting_qtransform.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_qopenglshaderprogram.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_text_qfont.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_text_qfontmetrics.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_text_qsyntaxhighlighter.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_text_qtextcursor.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_text_qtextdocument.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_text_qtextdocumentwriter.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_text_qtextlayout.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_util_qdesktopservices.cpp create mode 100644 src/gui/doc/snippets/code/src_gui_util_qvalidator.cpp create mode 100644 src/gui/doc/snippets/dragging/mainwindow.cpp create mode 100644 src/gui/doc/snippets/droparea.cpp create mode 100644 src/gui/doc/snippets/image/image.cpp create mode 100644 src/gui/doc/snippets/image/supportedformat.cpp create mode 100644 src/gui/doc/snippets/matrix/matrix.cpp create mode 100644 src/gui/doc/snippets/picture/picture.cpp create mode 100644 src/gui/doc/snippets/polygon/polygon.cpp create mode 100644 src/gui/doc/snippets/qfontdatabase/main.cpp create mode 100644 src/gui/doc/snippets/qstatustipevent/main.cpp create mode 100644 src/gui/doc/snippets/separations/finalwidget.cpp create mode 100644 src/gui/doc/snippets/textblock-fragments/xmlwriter.cpp create mode 100644 src/gui/doc/snippets/textdocument-css/main.cpp create mode 100644 src/gui/doc/snippets/textdocument-listitemstyles/main.cpp create mode 100644 src/gui/doc/snippets/textdocument-listitemstyles/mainwindow.cpp create mode 100644 src/gui/doc/snippets/textdocument-listitemstyles/mainwindow.h create mode 100644 src/gui/doc/snippets/textdocument-listitemstyles/textdocument-listitemstyles.pro create mode 100644 src/gui/doc/snippets/textdocument-lists/mainwindow.cpp create mode 100644 src/gui/doc/snippets/textdocument-resources/main.cpp create mode 100644 src/gui/doc/snippets/textdocument-resources/textdocument-resources.pro create mode 100644 src/gui/doc/snippets/textdocument-tables/mainwindow.cpp create mode 100644 src/gui/doc/snippets/textdocument-texttable/main.cpp create mode 100644 src/gui/doc/snippets/textdocumentendsnippet.cpp create mode 100644 src/gui/doc/snippets/transform/main.cpp create mode 100644 src/gui/doc/src/coordsys.qdoc create mode 100644 src/gui/doc/src/paintsystem.qdoc create mode 100644 src/gui/doc/src/qtgui.qdoc (limited to 'src/gui/doc') diff --git a/src/gui/doc/images/brush-outline.png b/src/gui/doc/images/brush-outline.png new file mode 100644 index 0000000000..f560c9faf5 Binary files /dev/null and b/src/gui/doc/images/brush-outline.png differ diff --git a/src/gui/doc/images/brush-styles.png b/src/gui/doc/images/brush-styles.png new file mode 100644 index 0000000000..eecb006af1 Binary files /dev/null and b/src/gui/doc/images/brush-styles.png differ diff --git a/src/gui/doc/images/coordinatesystem-analogclock.png b/src/gui/doc/images/coordinatesystem-analogclock.png new file mode 100644 index 0000000000..16e3091b77 Binary files /dev/null and b/src/gui/doc/images/coordinatesystem-analogclock.png differ diff --git a/src/gui/doc/images/coordinatesystem-line-antialias.png b/src/gui/doc/images/coordinatesystem-line-antialias.png new file mode 100644 index 0000000000..90dfa8730e Binary files /dev/null and b/src/gui/doc/images/coordinatesystem-line-antialias.png differ diff --git a/src/gui/doc/images/coordinatesystem-line-raster.png b/src/gui/doc/images/coordinatesystem-line-raster.png new file mode 100644 index 0000000000..65201bde9f Binary files /dev/null and b/src/gui/doc/images/coordinatesystem-line-raster.png differ diff --git a/src/gui/doc/images/coordinatesystem-line.png b/src/gui/doc/images/coordinatesystem-line.png new file mode 100644 index 0000000000..fbf6873084 Binary files /dev/null and b/src/gui/doc/images/coordinatesystem-line.png differ diff --git a/src/gui/doc/images/coordinatesystem-rect-antialias.png b/src/gui/doc/images/coordinatesystem-rect-antialias.png new file mode 100644 index 0000000000..162e1df9cb Binary files /dev/null and b/src/gui/doc/images/coordinatesystem-rect-antialias.png differ diff --git a/src/gui/doc/images/coordinatesystem-rect-raster.png b/src/gui/doc/images/coordinatesystem-rect-raster.png new file mode 100644 index 0000000000..be3690d6ad Binary files /dev/null and b/src/gui/doc/images/coordinatesystem-rect-raster.png differ diff --git a/src/gui/doc/images/coordinatesystem-rect.png b/src/gui/doc/images/coordinatesystem-rect.png new file mode 100644 index 0000000000..76c06befd6 Binary files /dev/null and b/src/gui/doc/images/coordinatesystem-rect.png differ diff --git a/src/gui/doc/images/coordinatesystem-transformations.png b/src/gui/doc/images/coordinatesystem-transformations.png new file mode 100644 index 0000000000..2736213c07 Binary files /dev/null and b/src/gui/doc/images/coordinatesystem-transformations.png differ diff --git a/src/gui/doc/images/cursor-arrow.png b/src/gui/doc/images/cursor-arrow.png new file mode 100644 index 0000000000..a69ef4eb61 Binary files /dev/null and b/src/gui/doc/images/cursor-arrow.png differ diff --git a/src/gui/doc/images/cursor-busy.png b/src/gui/doc/images/cursor-busy.png new file mode 100644 index 0000000000..53717e4992 Binary files /dev/null and b/src/gui/doc/images/cursor-busy.png differ diff --git a/src/gui/doc/images/cursor-closedhand.png b/src/gui/doc/images/cursor-closedhand.png new file mode 100644 index 0000000000..b78dd1dac5 Binary files /dev/null and b/src/gui/doc/images/cursor-closedhand.png differ diff --git a/src/gui/doc/images/cursor-cross.png b/src/gui/doc/images/cursor-cross.png new file mode 100644 index 0000000000..fe38e74480 Binary files /dev/null and b/src/gui/doc/images/cursor-cross.png differ diff --git a/src/gui/doc/images/cursor-forbidden.png b/src/gui/doc/images/cursor-forbidden.png new file mode 100644 index 0000000000..2b08c4e2a3 Binary files /dev/null and b/src/gui/doc/images/cursor-forbidden.png differ diff --git a/src/gui/doc/images/cursor-hand.png b/src/gui/doc/images/cursor-hand.png new file mode 100644 index 0000000000..d2004aefa7 Binary files /dev/null and b/src/gui/doc/images/cursor-hand.png differ diff --git a/src/gui/doc/images/cursor-hsplit.png b/src/gui/doc/images/cursor-hsplit.png new file mode 100644 index 0000000000..a5667e3ffb Binary files /dev/null and b/src/gui/doc/images/cursor-hsplit.png differ diff --git a/src/gui/doc/images/cursor-ibeam.png b/src/gui/doc/images/cursor-ibeam.png new file mode 100644 index 0000000000..097fc5fa72 Binary files /dev/null and b/src/gui/doc/images/cursor-ibeam.png differ diff --git a/src/gui/doc/images/cursor-openhand.png b/src/gui/doc/images/cursor-openhand.png new file mode 100644 index 0000000000..9181c859ed Binary files /dev/null and b/src/gui/doc/images/cursor-openhand.png differ diff --git a/src/gui/doc/images/cursor-sizeall.png b/src/gui/doc/images/cursor-sizeall.png new file mode 100644 index 0000000000..69f13eb347 Binary files /dev/null and b/src/gui/doc/images/cursor-sizeall.png differ diff --git a/src/gui/doc/images/cursor-sizeb.png b/src/gui/doc/images/cursor-sizeb.png new file mode 100644 index 0000000000..f37d7b91e8 Binary files /dev/null and b/src/gui/doc/images/cursor-sizeb.png differ diff --git a/src/gui/doc/images/cursor-sizef.png b/src/gui/doc/images/cursor-sizef.png new file mode 100644 index 0000000000..3b127a05d3 Binary files /dev/null and b/src/gui/doc/images/cursor-sizef.png differ diff --git a/src/gui/doc/images/cursor-sizeh.png b/src/gui/doc/images/cursor-sizeh.png new file mode 100644 index 0000000000..a9f40cbc3d Binary files /dev/null and b/src/gui/doc/images/cursor-sizeh.png differ diff --git a/src/gui/doc/images/cursor-sizev.png b/src/gui/doc/images/cursor-sizev.png new file mode 100644 index 0000000000..1edbab27a5 Binary files /dev/null and b/src/gui/doc/images/cursor-sizev.png differ diff --git a/src/gui/doc/images/cursor-uparrow.png b/src/gui/doc/images/cursor-uparrow.png new file mode 100644 index 0000000000..d3e70ef4c2 Binary files /dev/null and b/src/gui/doc/images/cursor-uparrow.png differ diff --git a/src/gui/doc/images/cursor-vsplit.png b/src/gui/doc/images/cursor-vsplit.png new file mode 100644 index 0000000000..1beda2570e Binary files /dev/null and b/src/gui/doc/images/cursor-vsplit.png differ diff --git a/src/gui/doc/images/cursor-wait.png b/src/gui/doc/images/cursor-wait.png new file mode 100644 index 0000000000..69056c479e Binary files /dev/null and b/src/gui/doc/images/cursor-wait.png differ diff --git a/src/gui/doc/images/cursor-whatsthis.png b/src/gui/doc/images/cursor-whatsthis.png new file mode 100644 index 0000000000..b47601c378 Binary files /dev/null and b/src/gui/doc/images/cursor-whatsthis.png differ diff --git a/src/gui/doc/images/hoverevents.png b/src/gui/doc/images/hoverevents.png new file mode 100644 index 0000000000..ccc079bdf1 Binary files /dev/null and b/src/gui/doc/images/hoverevents.png differ diff --git a/src/gui/doc/images/paintsystem-antialiasing.png b/src/gui/doc/images/paintsystem-antialiasing.png new file mode 100644 index 0000000000..1275841b93 Binary files /dev/null and b/src/gui/doc/images/paintsystem-antialiasing.png differ diff --git a/src/gui/doc/images/paintsystem-core.png b/src/gui/doc/images/paintsystem-core.png new file mode 100644 index 0000000000..7d6a8e591b Binary files /dev/null and b/src/gui/doc/images/paintsystem-core.png differ diff --git a/src/gui/doc/images/paintsystem-devices.png b/src/gui/doc/images/paintsystem-devices.png new file mode 100644 index 0000000000..7b81b7cbb8 Binary files /dev/null and b/src/gui/doc/images/paintsystem-devices.png differ diff --git a/src/gui/doc/images/paintsystem-fancygradient.png b/src/gui/doc/images/paintsystem-fancygradient.png new file mode 100644 index 0000000000..701df29e42 Binary files /dev/null and b/src/gui/doc/images/paintsystem-fancygradient.png differ diff --git a/src/gui/doc/images/paintsystem-gradients.png b/src/gui/doc/images/paintsystem-gradients.png new file mode 100644 index 0000000000..50b2ed3671 Binary files /dev/null and b/src/gui/doc/images/paintsystem-gradients.png differ diff --git a/src/gui/doc/images/paintsystem-icon.png b/src/gui/doc/images/paintsystem-icon.png new file mode 100644 index 0000000000..4623db0761 Binary files /dev/null and b/src/gui/doc/images/paintsystem-icon.png differ diff --git a/src/gui/doc/images/paintsystem-movie.png b/src/gui/doc/images/paintsystem-movie.png new file mode 100644 index 0000000000..992ea9edd4 Binary files /dev/null and b/src/gui/doc/images/paintsystem-movie.png differ diff --git a/src/gui/doc/images/paintsystem-painterpath.png b/src/gui/doc/images/paintsystem-painterpath.png new file mode 100644 index 0000000000..f8154f2634 Binary files /dev/null and b/src/gui/doc/images/paintsystem-painterpath.png differ diff --git a/src/gui/doc/images/paintsystem-stylepainter.png b/src/gui/doc/images/paintsystem-stylepainter.png new file mode 100644 index 0000000000..a67c6c5afc Binary files /dev/null and b/src/gui/doc/images/paintsystem-stylepainter.png differ diff --git a/src/gui/doc/images/paintsystem-svg.png b/src/gui/doc/images/paintsystem-svg.png new file mode 100644 index 0000000000..ecc8ef8f97 Binary files /dev/null and b/src/gui/doc/images/paintsystem-svg.png differ diff --git a/src/gui/doc/images/qcolor-cmyk.png b/src/gui/doc/images/qcolor-cmyk.png new file mode 100644 index 0000000000..dfe8f67a31 Binary files /dev/null and b/src/gui/doc/images/qcolor-cmyk.png differ diff --git a/src/gui/doc/images/qcolor-hsv.png b/src/gui/doc/images/qcolor-hsv.png new file mode 100644 index 0000000000..49fdf77222 Binary files /dev/null and b/src/gui/doc/images/qcolor-hsv.png differ diff --git a/src/gui/doc/images/qcolor-hue.png b/src/gui/doc/images/qcolor-hue.png new file mode 100644 index 0000000000..144b27c87a Binary files /dev/null and b/src/gui/doc/images/qcolor-hue.png differ diff --git a/src/gui/doc/images/qcolor-rgb.png b/src/gui/doc/images/qcolor-rgb.png new file mode 100644 index 0000000000..fea4c63fd7 Binary files /dev/null and b/src/gui/doc/images/qcolor-rgb.png differ diff --git a/src/gui/doc/images/qcolor-saturation.png b/src/gui/doc/images/qcolor-saturation.png new file mode 100644 index 0000000000..f28776aff5 Binary files /dev/null and b/src/gui/doc/images/qcolor-saturation.png differ diff --git a/src/gui/doc/images/qcolor-value.png b/src/gui/doc/images/qcolor-value.png new file mode 100644 index 0000000000..0e069123a9 Binary files /dev/null and b/src/gui/doc/images/qcolor-value.png differ diff --git a/src/gui/doc/images/qconicalgradient.png b/src/gui/doc/images/qconicalgradient.png new file mode 100644 index 0000000000..82603066fb Binary files /dev/null and b/src/gui/doc/images/qconicalgradient.png differ diff --git a/src/gui/doc/images/qgradient-conical.png b/src/gui/doc/images/qgradient-conical.png new file mode 100644 index 0000000000..cf06b70db6 Binary files /dev/null and b/src/gui/doc/images/qgradient-conical.png differ diff --git a/src/gui/doc/images/qgradient-linear.png b/src/gui/doc/images/qgradient-linear.png new file mode 100644 index 0000000000..5a5e880de7 Binary files /dev/null and b/src/gui/doc/images/qgradient-linear.png differ diff --git a/src/gui/doc/images/qgradient-radial.png b/src/gui/doc/images/qgradient-radial.png new file mode 100644 index 0000000000..95b9e9c3c9 Binary files /dev/null and b/src/gui/doc/images/qgradient-radial.png differ diff --git a/src/gui/doc/images/qimage-32bit_scaled.png b/src/gui/doc/images/qimage-32bit_scaled.png new file mode 100644 index 0000000000..6932327456 Binary files /dev/null and b/src/gui/doc/images/qimage-32bit_scaled.png differ diff --git a/src/gui/doc/images/qimage-8bit_scaled.png b/src/gui/doc/images/qimage-8bit_scaled.png new file mode 100644 index 0000000000..7cbf0f1e29 Binary files /dev/null and b/src/gui/doc/images/qimage-8bit_scaled.png differ diff --git a/src/gui/doc/images/qimage-scaling.png b/src/gui/doc/images/qimage-scaling.png new file mode 100644 index 0000000000..fcd71448f0 Binary files /dev/null and b/src/gui/doc/images/qimage-scaling.png differ diff --git a/src/gui/doc/images/qlineargradient-pad.png b/src/gui/doc/images/qlineargradient-pad.png new file mode 100644 index 0000000000..d77eb3dc3d Binary files /dev/null and b/src/gui/doc/images/qlineargradient-pad.png differ diff --git a/src/gui/doc/images/qlineargradient-reflect.png b/src/gui/doc/images/qlineargradient-reflect.png new file mode 100644 index 0000000000..dd12665051 Binary files /dev/null and b/src/gui/doc/images/qlineargradient-reflect.png differ diff --git a/src/gui/doc/images/qlineargradient-repeat.png b/src/gui/doc/images/qlineargradient-repeat.png new file mode 100644 index 0000000000..e38203c438 Binary files /dev/null and b/src/gui/doc/images/qlineargradient-repeat.png differ diff --git a/src/gui/doc/images/qmatrix-combinedtransformation.png b/src/gui/doc/images/qmatrix-combinedtransformation.png new file mode 100644 index 0000000000..f791bfa917 Binary files /dev/null and b/src/gui/doc/images/qmatrix-combinedtransformation.png differ diff --git a/src/gui/doc/images/qmatrix-representation.png b/src/gui/doc/images/qmatrix-representation.png new file mode 100644 index 0000000000..2e3efd33fc Binary files /dev/null and b/src/gui/doc/images/qmatrix-representation.png differ diff --git a/src/gui/doc/images/qmatrix-simpletransformation.png b/src/gui/doc/images/qmatrix-simpletransformation.png new file mode 100644 index 0000000000..dde8f4bc58 Binary files /dev/null and b/src/gui/doc/images/qmatrix-simpletransformation.png differ diff --git a/src/gui/doc/images/qpainter-affinetransformations.png b/src/gui/doc/images/qpainter-affinetransformations.png new file mode 100644 index 0000000000..fe2f9a072b Binary files /dev/null and b/src/gui/doc/images/qpainter-affinetransformations.png differ diff --git a/src/gui/doc/images/qpainter-arc.png b/src/gui/doc/images/qpainter-arc.png new file mode 100644 index 0000000000..8cb9cec96b Binary files /dev/null and b/src/gui/doc/images/qpainter-arc.png differ diff --git a/src/gui/doc/images/qpainter-basicdrawing.png b/src/gui/doc/images/qpainter-basicdrawing.png new file mode 100644 index 0000000000..3be48c8737 Binary files /dev/null and b/src/gui/doc/images/qpainter-basicdrawing.png differ diff --git a/src/gui/doc/images/qpainter-chord.png b/src/gui/doc/images/qpainter-chord.png new file mode 100644 index 0000000000..a8090861a0 Binary files /dev/null and b/src/gui/doc/images/qpainter-chord.png differ diff --git a/src/gui/doc/images/qpainter-clock.png b/src/gui/doc/images/qpainter-clock.png new file mode 100644 index 0000000000..3634754161 Binary files /dev/null and b/src/gui/doc/images/qpainter-clock.png differ diff --git a/src/gui/doc/images/qpainter-compositiondemo.png b/src/gui/doc/images/qpainter-compositiondemo.png new file mode 100644 index 0000000000..40f62c75be Binary files /dev/null and b/src/gui/doc/images/qpainter-compositiondemo.png differ diff --git a/src/gui/doc/images/qpainter-compositionmode1.png b/src/gui/doc/images/qpainter-compositionmode1.png new file mode 100644 index 0000000000..6753093521 Binary files /dev/null and b/src/gui/doc/images/qpainter-compositionmode1.png differ diff --git a/src/gui/doc/images/qpainter-compositionmode2.png b/src/gui/doc/images/qpainter-compositionmode2.png new file mode 100644 index 0000000000..fc05afbd8c Binary files /dev/null and b/src/gui/doc/images/qpainter-compositionmode2.png differ diff --git a/src/gui/doc/images/qpainter-concentriccircles.png b/src/gui/doc/images/qpainter-concentriccircles.png new file mode 100644 index 0000000000..4889dcd76d Binary files /dev/null and b/src/gui/doc/images/qpainter-concentriccircles.png differ diff --git a/src/gui/doc/images/qpainter-ellipse.png b/src/gui/doc/images/qpainter-ellipse.png new file mode 100644 index 0000000000..e7e78c3dac Binary files /dev/null and b/src/gui/doc/images/qpainter-ellipse.png differ diff --git a/src/gui/doc/images/qpainter-gradients.png b/src/gui/doc/images/qpainter-gradients.png new file mode 100644 index 0000000000..b7bc6a3270 Binary files /dev/null and b/src/gui/doc/images/qpainter-gradients.png differ diff --git a/src/gui/doc/images/qpainter-line.png b/src/gui/doc/images/qpainter-line.png new file mode 100644 index 0000000000..5f1cd97eff Binary files /dev/null and b/src/gui/doc/images/qpainter-line.png differ diff --git a/src/gui/doc/images/qpainter-painterpaths.png b/src/gui/doc/images/qpainter-painterpaths.png new file mode 100644 index 0000000000..0762ca93f3 Binary files /dev/null and b/src/gui/doc/images/qpainter-painterpaths.png differ diff --git a/src/gui/doc/images/qpainter-path.png b/src/gui/doc/images/qpainter-path.png new file mode 100644 index 0000000000..3570b16d7a Binary files /dev/null and b/src/gui/doc/images/qpainter-path.png differ diff --git a/src/gui/doc/images/qpainter-pathstroking.png b/src/gui/doc/images/qpainter-pathstroking.png new file mode 100644 index 0000000000..ab73c6ae01 Binary files /dev/null and b/src/gui/doc/images/qpainter-pathstroking.png differ diff --git a/src/gui/doc/images/qpainter-pie.png b/src/gui/doc/images/qpainter-pie.png new file mode 100644 index 0000000000..78039013e0 Binary files /dev/null and b/src/gui/doc/images/qpainter-pie.png differ diff --git a/src/gui/doc/images/qpainter-polygon.png b/src/gui/doc/images/qpainter-polygon.png new file mode 100644 index 0000000000..3b6ea3c797 Binary files /dev/null and b/src/gui/doc/images/qpainter-polygon.png differ diff --git a/src/gui/doc/images/qpainter-rectangle.png b/src/gui/doc/images/qpainter-rectangle.png new file mode 100644 index 0000000000..05fdc88300 Binary files /dev/null and b/src/gui/doc/images/qpainter-rectangle.png differ diff --git a/src/gui/doc/images/qpainter-rotation.png b/src/gui/doc/images/qpainter-rotation.png new file mode 100644 index 0000000000..6e24a0e040 Binary files /dev/null and b/src/gui/doc/images/qpainter-rotation.png differ diff --git a/src/gui/doc/images/qpainter-roundrect.png b/src/gui/doc/images/qpainter-roundrect.png new file mode 100644 index 0000000000..876a277811 Binary files /dev/null and b/src/gui/doc/images/qpainter-roundrect.png differ diff --git a/src/gui/doc/images/qpainter-scale.png b/src/gui/doc/images/qpainter-scale.png new file mode 100644 index 0000000000..4fe582eb13 Binary files /dev/null and b/src/gui/doc/images/qpainter-scale.png differ diff --git a/src/gui/doc/images/qpainter-text.png b/src/gui/doc/images/qpainter-text.png new file mode 100644 index 0000000000..e95c965d7b Binary files /dev/null and b/src/gui/doc/images/qpainter-text.png differ diff --git a/src/gui/doc/images/qpainter-translation.png b/src/gui/doc/images/qpainter-translation.png new file mode 100644 index 0000000000..b3716ca3f6 Binary files /dev/null and b/src/gui/doc/images/qpainter-translation.png differ diff --git a/src/gui/doc/images/qpainter-vectordeformation.png b/src/gui/doc/images/qpainter-vectordeformation.png new file mode 100644 index 0000000000..aff95f404c Binary files /dev/null and b/src/gui/doc/images/qpainter-vectordeformation.png differ diff --git a/src/gui/doc/images/qpainterpath-addellipse.png b/src/gui/doc/images/qpainterpath-addellipse.png new file mode 100644 index 0000000000..98f85174ef Binary files /dev/null and b/src/gui/doc/images/qpainterpath-addellipse.png differ diff --git a/src/gui/doc/images/qpainterpath-addpolygon.png b/src/gui/doc/images/qpainterpath-addpolygon.png new file mode 100644 index 0000000000..d36bde8ada Binary files /dev/null and b/src/gui/doc/images/qpainterpath-addpolygon.png differ diff --git a/src/gui/doc/images/qpainterpath-addrectangle.png b/src/gui/doc/images/qpainterpath-addrectangle.png new file mode 100644 index 0000000000..be9283e46d Binary files /dev/null and b/src/gui/doc/images/qpainterpath-addrectangle.png differ diff --git a/src/gui/doc/images/qpainterpath-addtext.png b/src/gui/doc/images/qpainterpath-addtext.png new file mode 100644 index 0000000000..803a9581ac Binary files /dev/null and b/src/gui/doc/images/qpainterpath-addtext.png differ diff --git a/src/gui/doc/images/qpainterpath-arcto.png b/src/gui/doc/images/qpainterpath-arcto.png new file mode 100644 index 0000000000..fe60b08d31 Binary files /dev/null and b/src/gui/doc/images/qpainterpath-arcto.png differ diff --git a/src/gui/doc/images/qpainterpath-construction.png b/src/gui/doc/images/qpainterpath-construction.png new file mode 100644 index 0000000000..4beeba1dd8 Binary files /dev/null and b/src/gui/doc/images/qpainterpath-construction.png differ diff --git a/src/gui/doc/images/qpainterpath-cubicto.png b/src/gui/doc/images/qpainterpath-cubicto.png new file mode 100644 index 0000000000..465bfeca29 Binary files /dev/null and b/src/gui/doc/images/qpainterpath-cubicto.png differ diff --git a/src/gui/doc/images/qpainterpath-demo.png b/src/gui/doc/images/qpainterpath-demo.png new file mode 100644 index 0000000000..ceeed2f170 Binary files /dev/null and b/src/gui/doc/images/qpainterpath-demo.png differ diff --git a/src/gui/doc/images/qpainterpath-example.png b/src/gui/doc/images/qpainterpath-example.png new file mode 100644 index 0000000000..f2bd359aba Binary files /dev/null and b/src/gui/doc/images/qpainterpath-example.png differ diff --git a/src/gui/doc/images/qpen-bevel.png b/src/gui/doc/images/qpen-bevel.png new file mode 100644 index 0000000000..8a30779e3b Binary files /dev/null and b/src/gui/doc/images/qpen-bevel.png differ diff --git a/src/gui/doc/images/qpen-custom.png b/src/gui/doc/images/qpen-custom.png new file mode 100644 index 0000000000..a2a038abe0 Binary files /dev/null and b/src/gui/doc/images/qpen-custom.png differ diff --git a/src/gui/doc/images/qpen-dash.png b/src/gui/doc/images/qpen-dash.png new file mode 100644 index 0000000000..67082c3758 Binary files /dev/null and b/src/gui/doc/images/qpen-dash.png differ diff --git a/src/gui/doc/images/qpen-dashdot.png b/src/gui/doc/images/qpen-dashdot.png new file mode 100644 index 0000000000..64b384660f Binary files /dev/null and b/src/gui/doc/images/qpen-dashdot.png differ diff --git a/src/gui/doc/images/qpen-dashdotdot.png b/src/gui/doc/images/qpen-dashdotdot.png new file mode 100644 index 0000000000..ff1b2e69cd Binary files /dev/null and b/src/gui/doc/images/qpen-dashdotdot.png differ diff --git a/src/gui/doc/images/qpen-dashpattern.png b/src/gui/doc/images/qpen-dashpattern.png new file mode 100644 index 0000000000..e33cf58d49 Binary files /dev/null and b/src/gui/doc/images/qpen-dashpattern.png differ diff --git a/src/gui/doc/images/qpen-demo.png b/src/gui/doc/images/qpen-demo.png new file mode 100644 index 0000000000..3ea5108802 Binary files /dev/null and b/src/gui/doc/images/qpen-demo.png differ diff --git a/src/gui/doc/images/qpen-dot.png b/src/gui/doc/images/qpen-dot.png new file mode 100644 index 0000000000..54e81c9469 Binary files /dev/null and b/src/gui/doc/images/qpen-dot.png differ diff --git a/src/gui/doc/images/qpen-flat.png b/src/gui/doc/images/qpen-flat.png new file mode 100644 index 0000000000..06e2195f73 Binary files /dev/null and b/src/gui/doc/images/qpen-flat.png differ diff --git a/src/gui/doc/images/qpen-miter.png b/src/gui/doc/images/qpen-miter.png new file mode 100644 index 0000000000..025e003979 Binary files /dev/null and b/src/gui/doc/images/qpen-miter.png differ diff --git a/src/gui/doc/images/qpen-miterlimit.png b/src/gui/doc/images/qpen-miterlimit.png new file mode 100644 index 0000000000..17a90725fb Binary files /dev/null and b/src/gui/doc/images/qpen-miterlimit.png differ diff --git a/src/gui/doc/images/qpen-roundcap.png b/src/gui/doc/images/qpen-roundcap.png new file mode 100644 index 0000000000..77b22b2bab Binary files /dev/null and b/src/gui/doc/images/qpen-roundcap.png differ diff --git a/src/gui/doc/images/qpen-roundjoin.png b/src/gui/doc/images/qpen-roundjoin.png new file mode 100644 index 0000000000..155e2aa8cc Binary files /dev/null and b/src/gui/doc/images/qpen-roundjoin.png differ diff --git a/src/gui/doc/images/qpen-solid.png b/src/gui/doc/images/qpen-solid.png new file mode 100644 index 0000000000..e042b18017 Binary files /dev/null and b/src/gui/doc/images/qpen-solid.png differ diff --git a/src/gui/doc/images/qpen-square.png b/src/gui/doc/images/qpen-square.png new file mode 100644 index 0000000000..ebc5d1e329 Binary files /dev/null and b/src/gui/doc/images/qpen-square.png differ diff --git a/src/gui/doc/images/qradialgradient-pad.png b/src/gui/doc/images/qradialgradient-pad.png new file mode 100644 index 0000000000..6c1a6cb268 Binary files /dev/null and b/src/gui/doc/images/qradialgradient-pad.png differ diff --git a/src/gui/doc/images/qradialgradient-reflect.png b/src/gui/doc/images/qradialgradient-reflect.png new file mode 100644 index 0000000000..5122b180b1 Binary files /dev/null and b/src/gui/doc/images/qradialgradient-reflect.png differ diff --git a/src/gui/doc/images/qradialgradient-repeat.png b/src/gui/doc/images/qradialgradient-repeat.png new file mode 100644 index 0000000000..aa639b7779 Binary files /dev/null and b/src/gui/doc/images/qradialgradient-repeat.png differ diff --git a/src/gui/doc/images/qstatustipevent-action.png b/src/gui/doc/images/qstatustipevent-action.png new file mode 100644 index 0000000000..c5dcfd25f5 Binary files /dev/null and b/src/gui/doc/images/qstatustipevent-action.png differ diff --git a/src/gui/doc/images/qstatustipevent-widget.png b/src/gui/doc/images/qstatustipevent-widget.png new file mode 100644 index 0000000000..3cc0a1f01b Binary files /dev/null and b/src/gui/doc/images/qstatustipevent-widget.png differ diff --git a/src/gui/doc/images/qt-fillrule-oddeven.png b/src/gui/doc/images/qt-fillrule-oddeven.png new file mode 100644 index 0000000000..f39d1056f5 Binary files /dev/null and b/src/gui/doc/images/qt-fillrule-oddeven.png differ diff --git a/src/gui/doc/images/qt-fillrule-winding.png b/src/gui/doc/images/qt-fillrule-winding.png new file mode 100644 index 0000000000..8018248331 Binary files /dev/null and b/src/gui/doc/images/qt-fillrule-winding.png differ diff --git a/src/gui/doc/images/qtexttableformat-cell.png b/src/gui/doc/images/qtexttableformat-cell.png new file mode 100644 index 0000000000..bbf85ffe46 Binary files /dev/null and b/src/gui/doc/images/qtexttableformat-cell.png differ diff --git a/src/gui/doc/images/qtransform-combinedtransformation.png b/src/gui/doc/images/qtransform-combinedtransformation.png new file mode 100644 index 0000000000..df1e226746 Binary files /dev/null and b/src/gui/doc/images/qtransform-combinedtransformation.png differ diff --git a/src/gui/doc/images/qtransform-combinedtransformation2.png b/src/gui/doc/images/qtransform-combinedtransformation2.png new file mode 100644 index 0000000000..c037a0d565 Binary files /dev/null and b/src/gui/doc/images/qtransform-combinedtransformation2.png differ diff --git a/src/gui/doc/images/qtransform-representation.png b/src/gui/doc/images/qtransform-representation.png new file mode 100644 index 0000000000..883d5dc487 Binary files /dev/null and b/src/gui/doc/images/qtransform-representation.png differ diff --git a/src/gui/doc/images/qtransform-simpletransformation.png b/src/gui/doc/images/qtransform-simpletransformation.png new file mode 100644 index 0000000000..743e4e3e07 Binary files /dev/null and b/src/gui/doc/images/qtransform-simpletransformation.png differ diff --git a/src/gui/doc/images/texttable-merge.png b/src/gui/doc/images/texttable-merge.png new file mode 100644 index 0000000000..3b32239a42 Binary files /dev/null and b/src/gui/doc/images/texttable-merge.png differ diff --git a/src/gui/doc/images/texttable-split.png b/src/gui/doc/images/texttable-split.png new file mode 100644 index 0000000000..2fa17b85a3 Binary files /dev/null and b/src/gui/doc/images/texttable-split.png differ diff --git a/src/gui/doc/qtgui.qdocconf b/src/gui/doc/qtgui.qdocconf new file mode 100644 index 0000000000..85772bbc3e --- /dev/null +++ b/src/gui/doc/qtgui.qdocconf @@ -0,0 +1,92 @@ +include(../../../doc/global/qt-cpp-ignore.qdocconf) + +project = QtGui +description = Qt GUI Reference Documentation +url = http://qt-project.org/doc/qt-5.0/qtgui +version = 5.0.0 + +sourceencoding = UTF-8 +outputencoding = UTF-8 +naturallanguage = en_US +qhp.projects = QtGui + +qhp.QtGui.file = qtgui.qhp +qhp.QtGui.namespace = org.qt-project.qtgui.500 +qhp.QtGui.virtualFolder = qdoc +qhp.QtGui.indexTitle = Qt GUI Reference Documentation +qhp.QtGui.indexRoot = + +qhp.QtGui.filterAttributes = qtgui 5.0.0 qtrefdoc +qhp.QtGui.customFilters.Qt.name = Qtgui 5.0.0 +qhp.QtGui.customFilters.Qt.filterAttributes = qtgui 5.0.0 +qhp.QtGui.subprojects = classes overviews examples +qhp.QtGui.subprojects.classes.title = Classes +qhp.QtGui.subprojects.classes.indexTitle = Qt GUI's Classes +qhp.QtGui.subprojects.classes.selectors = class fake:headerfile +qhp.QtGui.subprojects.classes.sortPages = true +qhp.QtGui.subprojects.overviews.title = Overviews +qhp.QtGui.subprojects.overviews.indexTitle = All Overviews and HOWTOs +qhp.QtGui.subprojects.overviews.selectors = fake:page,group,module +qhp.QtGui.subprojects.examples.title = Qt GUI Examples +qhp.QtGui.subprojects.examples.indexTitle = Qt GUI Examples +qhp.QtGui.subprojects.examples.selectors = fake:example + +dita.metadata.default.author = Qt Project +dita.metadata.default.permissions = all +dita.metadata.default.publisher = Qt Project +dita.metadata.default.copyryear = 2012 +dita.metadata.default.copyrholder = Nokia +dita.metadata.default.audience = programmer + +sources.fileextensions = "*.c++ *.cc *.cpp *.cxx *.mm *.qml *.qdoc" +headers.fileextensions = "*.ch *.h *.h++ *.hh *.hpp *.hxx" + +examples.fileextensions = "*.cpp *.h *.js *.xq *.svg *.xml *.ui *.qhp *.qhcp *.qml *.css" +examples.imageextensions = "*.png" + +outputdir = ../../../doc/qtgui +tagfile = ../../../doc/qtgui/qtgui.tags + +HTML.generatemacrefs = "true" +HTML.nobreadcrumbs = "true" + +HTML.templatedir = . + +HTML.stylesheets = ../../../doc/global/style/offline.css + +HTML.headerstyles = \ + " \n" + +HTML.endheader = \ + "\n" \ + +defines = Q_QDOC \ + QT_.*_SUPPORT \ + QT_.*_LIB \ + QT_COMPAT \ + QT_KEYPAD_NAVIGATION \ + QT_NO_EGL \ + Q_WS_.* \ + Q_OS_.* \ + Q_BYTE_ORDER \ + QT_DEPRECATED \ + QT_DEPRECATED_* \ + Q_NO_USING_KEYWORD \ + __cplusplus \ + Q_COMPILER_INITIALIZER_LISTS + +versionsym = QT_VERSION_STR + +codeindent = 1 + +depends += qtcore + +headerdirs += .. + +sourcedirs += .. + +exampledirs += ../../../examples \ + ../ \ + snippets + +imagedirs += images diff --git a/src/gui/doc/snippets/brush/brush.cpp b/src/gui/doc/snippets/brush/brush.cpp new file mode 100644 index 0000000000..a92223ee93 --- /dev/null +++ b/src/gui/doc/snippets/brush/brush.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +int main() +{ + QWidget anyPaintDevice; + { + // PEN SNIPPET + QPainter painter; + QPen pen(Qt::red, 2); // red solid line, 2 pixels wide + painter.begin(&anyPaintDevice); // paint something + painter.setPen(pen); // set the red, wide pen + painter.drawRect(40,30, 200,100); // draw a rectangle + painter.setPen(Qt::blue); // set blue pen, 0 pixel width + painter.drawLine(40,30, 240,130); // draw a diagonal in rectangle + painter.end(); // painting done + } + + { + // BRUSH SNIPPET + QPainter painter; + QBrush brush(Qt::yellow); // yellow solid pattern + painter.begin(&anyPaintDevice); // paint something + painter.setBrush(brush); // set the yellow brush + painter.setPen(Qt::NoPen); // do not draw outline + painter.drawRect(40,30, 200,100); // draw filled rectangle + painter.setBrush(Qt::NoBrush); // do not fill + painter.setPen(Qt::black); // set black pen, 0 pixel width + painter.drawRect(10,10, 30,20); // draw rectangle outline + painter.end(); // painting done + } + + // LINEAR +//! [0] + QLinearGradient linearGrad(QPointF(100, 100), QPointF(200, 200)); + linearGrad.setColorAt(0, Qt::black); + linearGrad.setColorAt(1, Qt::white); +//! [0] + + // RADIAL +//! [1] + QRadialGradient radialGrad(QPointF(100, 100), 100); + radialGrad.setColorAt(0, Qt::red); + radialGrad.setColorAt(0.5, Qt::blue); + radialGrad.setColorAt(1, Qt::green); +//! [1] +} diff --git a/src/gui/doc/snippets/brush/gradientcreationsnippet.cpp b/src/gui/doc/snippets/brush/gradientcreationsnippet.cpp new file mode 100644 index 0000000000..9ec8c3f07a --- /dev/null +++ b/src/gui/doc/snippets/brush/gradientcreationsnippet.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +int main(int argv, char **args) +{ + QApplication app(argv, args); + +//! [0] + QRadialGradient gradient(50, 50, 50, 50, 50); + gradient.setColorAt(0, QColor::fromRgbF(0, 1, 0, 1)); + gradient.setColorAt(1, QColor::fromRgbF(0, 0, 0, 0)); + + QBrush brush(gradient); +//! [0] + + QWidget widget; + QPalette palette; + palette.setBrush(widget.backgroundRole(), brush); + widget.setPalette(palette); + widget.show(); + + return app.exec(); +} diff --git a/src/gui/doc/snippets/code/doc_src_qtgui.pro b/src/gui/doc/snippets/code/doc_src_qtgui.pro new file mode 100644 index 0000000000..51bb6c74ff --- /dev/null +++ b/src/gui/doc/snippets/code/doc_src_qtgui.pro @@ -0,0 +1,3 @@ +#! [0] +#include +#! [0] diff --git a/src/gui/doc/snippets/code/src_gui_accessible_qaccessible.cpp b/src/gui/doc/snippets/code/src_gui_accessible_qaccessible.cpp new file mode 100644 index 0000000000..f12f55051e --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_accessible_qaccessible.cpp @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [1] +typedef QAccessibleInterface* myFactoryFunction(const QString &key, QObject *); +//! [1] diff --git a/src/gui/doc/snippets/code/src_gui_image_qimage.cpp b/src/gui/doc/snippets/code/src_gui_image_qimage.cpp new file mode 100644 index 0000000000..0c39e22eb6 --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_image_qimage.cpp @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +QImage image(3, 3, QImage::Format_RGB32); +QRgb value; + +value = qRgb(189, 149, 39); // 0xffbd9527 +image.setPixel(1, 1, value); + +value = qRgb(122, 163, 39); // 0xff7aa327 +image.setPixel(0, 1, value); +image.setPixel(1, 0, value); + +value = qRgb(237, 187, 51); // 0xffedba31 +image.setPixel(2, 1, value); +//! [0] + + +//! [1] +QImage image(3, 3, QImage::Format_Indexed8); +QRgb value; + +value = qRgb(122, 163, 39); // 0xff7aa327 +image.setColor(0, value); + +value = qRgb(237, 187, 51); // 0xffedba31 +image.setColor(1, value); + +value = qRgb(189, 149, 39); // 0xffbd9527 +image.setColor(2, value); + +image.setPixel(0, 1, 0); +image.setPixel(1, 0, 0); +image.setPixel(1, 1, 2); +image.setPixel(2, 1, 1); +//! [1] + + +//! [2] +static const char * const start_xpm[] = { + "16 15 8 1", + "a c #cec6bd", +.... +//! [2] diff --git a/src/gui/doc/snippets/code/src_gui_image_qimagereader.cpp b/src/gui/doc/snippets/code/src_gui_image_qimagereader.cpp new file mode 100644 index 0000000000..92f528e6c0 --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_image_qimagereader.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +QImageReader reader; +reader.setFormat("png"); // same as reader.setFormat("PNG"); +//! [0] + + +//! [1] +QImageReader reader("image.png"); +// reader.format() == "png" +//! [1] + + +//! [2] +QImage icon(64, 64, QImage::Format_RGB32); +QImageReader reader("icon_64x64.bmp"); +if (reader.read(&icon)) { + // Display icon +} +//! [2] + + +//! [3] +QImageReader reader(":/image.png"); +if (reader.supportsOption(QImageIOHandler::Size)) + qDebug() << "Size:" << reader.size(); +//! [3] diff --git a/src/gui/doc/snippets/code/src_gui_image_qimagewriter.cpp b/src/gui/doc/snippets/code/src_gui_image_qimagewriter.cpp new file mode 100644 index 0000000000..d0f11929d3 --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_image_qimagewriter.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +QImageWriter writer; +writer.setFormat("png"); // same as writer.setFormat("PNG"); +//! [0] + + +//! [1] +QImage image("some/image.jpeg"); +QImageWriter writer("images/outimage.png", "png"); +writer.setText("Author", "John Smith"); +writer.write(image); +//! [1] + + +//! [2] +QImageWriter writer(fileName); +if (writer.supportsOption(QImageIOHandler::Description)) + writer.setText("Author", "John Smith"); +//! [2] diff --git a/src/gui/doc/snippets/code/src_gui_image_qmovie.cpp b/src/gui/doc/snippets/code/src_gui_image_qmovie.cpp new file mode 100644 index 0000000000..5d57d19204 --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_image_qmovie.cpp @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +QLabel label; +QMovie *movie = new QMovie("animations/fire.gif"); + +label.setMovie(movie); +movie->start(); +//! [0] + + +//! [1] +QMovie movie("racecar.gif"); +movie.setSpeed(200); // 2x speed +//! [1] diff --git a/src/gui/doc/snippets/code/src_gui_image_qpixmap.cpp b/src/gui/doc/snippets/code/src_gui_image_qpixmap.cpp new file mode 100644 index 0000000000..b8c0fcfbd5 --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_image_qpixmap.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +static const char * const start_xpm[]={ + "16 15 8 1", + "a c #cec6bd", +.... +//! [0] + + +//! [1] +QPixmap myPixmap; +myPixmap->setMask(myPixmap->createHeuristicMask()); +//! [1] + +//! [2] +QPixmap pixmap("background.png"); +QRegion exposed; +pixmap.scroll(10, 10, pixmap.rect(), &exposed); +//! [2] diff --git a/src/gui/doc/snippets/code/src_gui_image_qpixmapcache.cpp b/src/gui/doc/snippets/code/src_gui_image_qpixmapcache.cpp new file mode 100644 index 0000000000..9d42f6b330 --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_image_qpixmapcache.cpp @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +QPixmap* pp; +QPixmap p; +if ((pp=QPixmapCache::find("my_big_image", pm))) { + p = *pp; +} else { + p.load("bigimage.png"); + QPixmapCache::insert("my_big_image", new QPixmap(p)); +} +painter->drawPixmap(0, 0, p); +//! [0] + + +//! [1] +QPixmap pm; +if (!QPixmapCache::find("my_big_image", &pm)) { + pm.load("bigimage.png"); + QPixmapCache::insert("my_big_image", pm); +} +painter->drawPixmap(0, 0, pm); +//! [1] diff --git a/src/gui/doc/snippets/code/src_gui_kernel_qapplication.cpp b/src/gui/doc/snippets/code/src_gui_kernel_qapplication.cpp new file mode 100644 index 0000000000..b32e8c3f39 --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_kernel_qapplication.cpp @@ -0,0 +1,183 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +int main(int argc, char **argv) +{ +#ifdef Q_WS_X11 + bool useGUI = getenv("DISPLAY") != 0; +#else + bool useGUI = true; +#endif + QApplication app(argc, argv, useGUI); + + if (useGUI) { + // start GUI version + ... + } else { + // start non-GUI version + ... + } + return app.exec(); +} +//! [0] + + +//! [1] +QApplication::setStyle(new QWindowsStyle); +//! [1] + + +//! [2] +int main(int argc, char *argv[]) +{ + QApplication::setColorSpec(QApplication::ManyColor); + QApplication app(argc, argv); + ... + return app.exec(); +} +//! [2] + + +//! [3] +QSize MyWidget::sizeHint() const +{ + return QSize(80, 25).expandedTo(QApplication::globalStrut()); +} +//! [3] + + +//! [4] +void showAllHiddenTopLevelWidgets() +{ + foreach (QWidget *widget, QApplication::topLevelWidgets()) { + if (widget->isHidden()) + widget->show(); + } +} +//! [4] + + +//! [5] +void updateAllWidgets() +{ + foreach (QWidget *widget, QApplication::allWidgets()) + widget->update(); +} +//! [5] + + +//! [6] +int main(int argc, char *argv[]) +{ + QApplication::setDesktopSettingsAware(false); + QApplication app(argc, argv); + ... + return app.exec(); +} +//! [6] + + +//! [7] +if ((startPos - currentPos).manhattanLength() >= + QApplication::startDragDistance()) + startTheDrag(); +//! [7] + + +//! [8] +void MyApplication::commitData(QSessionManager& manager) +{ + if (manager.allowsInteraction()) { + int ret = QMessageBox::warning( + mainWindow, + tr("My Application"), + tr("Save changes to document?"), + QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); + + switch (ret) { + case QMessageBox::Save: + manager.release(); + if (!saveDocument()) + manager.cancel(); + break; + case QMessageBox::Discard: + break; + case QMessageBox::Cancel: + default: + manager.cancel(); + } + } else { + // we did not get permission to interact, then + // do something reasonable instead + } +} +//! [8] + + +//! [9] +appname -session id +//! [9] + + +//! [10] +foreach (const QString &command, mySession.restartCommand()) + do_something(command); +//! [10] + + +//! [11] +foreach (const QString &command, mySession.discardCommand()) + do_something(command); +//! [11] + + +//! [12] +QWidget *widget = qApp->widgetAt(x, y); +if (widget) + widget = widget->window(); +//! [12] + + +//! [13] +QWidget *widget = qApp->widgetAt(point); +if (widget) + widget = widget->window(); +//! [13] diff --git a/src/gui/doc/snippets/code/src_gui_kernel_qapplication_x11.cpp b/src/gui/doc/snippets/code/src_gui_kernel_qapplication_x11.cpp new file mode 100644 index 0000000000..1d37765e3c --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_kernel_qapplication_x11.cpp @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); +calculateHugeMandelbrot(); // lunch time... +QApplication::restoreOverrideCursor(); +//! [0] diff --git a/src/gui/doc/snippets/code/src_gui_kernel_qclipboard.cpp b/src/gui/doc/snippets/code/src_gui_kernel_qclipboard.cpp new file mode 100644 index 0000000000..4cf8f33c02 --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_kernel_qclipboard.cpp @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +QClipboard *clipboard = QApplication::clipboard(); +QString originalText = clipboard->text(); +... +clipboard->setText(newText); +//! [0] + + +//! [1] +QMimeData *data = new QMimeData; +data->setImageData(image); +clipboard->setMimeData(data, mode); +//! [1] diff --git a/src/gui/doc/snippets/code/src_gui_kernel_qevent.cpp b/src/gui/doc/snippets/code/src_gui_kernel_qevent.cpp new file mode 100644 index 0000000000..d8bdeebe84 --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_kernel_qevent.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +void MyWidget::wheelEvent(QWheelEvent *event) +{ + QPoint numPixels = envent->pixelDelta(); + QPoint numDegrees = envent->angleDelta() / 8; + + if (!numPixels.isNull()) { + scrollWithPixels(numpixels); + } else if (!numDegrees.isNull()) { + QPoint numSteps = numDegrees / 15; + scrollWithDegrees(numSteps); + } + + event->accept(); +} +//! [0] diff --git a/src/gui/doc/snippets/code/src_gui_kernel_qkeysequence.cpp b/src/gui/doc/snippets/code/src_gui_kernel_qkeysequence.cpp new file mode 100644 index 0000000000..79dc967cf3 --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_kernel_qkeysequence.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +QKeySequence(QKeySequence::Print); +QKeySequence(tr("Ctrl+P")); +QKeySequence(tr("Ctrl+p")); +QKeySequence(Qt::CTRL + Qt::Key_P); +//! [0] + + +//! [1] +QKeySequence(tr("Ctrl+X, Ctrl+C")); +QKeySequence(Qt::CTRL + Qt::Key_X, Qt::CTRL + Qt::Key_C); +//! [1] + + +//! [2] +QMenu *file = new QMenu(this); +file->addAction(tr("&Open..."), this, SLOT(open()), + QKeySequence(tr("Ctrl+O", "File|Open"))); +//! [2] diff --git a/src/gui/doc/snippets/code/src_gui_kernel_qshortcutmap.cpp b/src/gui/doc/snippets/code/src_gui_kernel_qshortcutmap.cpp new file mode 100644 index 0000000000..d761e31d3d --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_kernel_qshortcutmap.cpp @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +key = QKeySequence(); +//! [0] diff --git a/src/gui/doc/snippets/code/src_gui_painting_qbrush.cpp b/src/gui/doc/snippets/code/src_gui_painting_qbrush.cpp new file mode 100644 index 0000000000..8678c48d62 --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_painting_qbrush.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +QPainter painter(this); + +painter.setBrush(Qt::cyan); +painter.setPen(Qt::darkCyan); +painter.drawRect(0, 0, 100,100); + +painter.setBrush(Qt::NoBrush); +painter.setPen(Qt::darkGreen); +painter.drawRect(40, 40, 100, 100); +//! [0] diff --git a/src/gui/doc/snippets/code/src_gui_painting_qcolor.cpp b/src/gui/doc/snippets/code/src_gui_painting_qcolor.cpp new file mode 100644 index 0000000000..8954fed604 --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_painting_qcolor.cpp @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +// Specify semi-transparent red +painter.setBrush(QColor(255, 0, 0, 127)); +painter.drawRect(0, 0, width()/2, height()); + +// Specify semi-transparent blue +painter.setBrush(QColor(0, 0, 255, 127)); +painter.drawRect(0, 0, width(), height()/2); +//! [0] diff --git a/src/gui/doc/snippets/code/src_gui_painting_qmatrix.cpp b/src/gui/doc/snippets/code/src_gui_painting_qmatrix.cpp new file mode 100644 index 0000000000..d4e1b57b3c --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_painting_qmatrix.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +x' = m11*x + m21*y + dx +y' = m22*y + m12*x + dy +//! [0] + + +//! [1] +x' = m11*x + m21*y + dx +y' = m22*y + m12*x + dy +//! [1] + + +//! [2] +x' = m11*x + m21*y + dx +y' = m22*y + m12*x + dy +//! [2] + + +//! [3] +x' = m11*x + m21*y + dx +y' = m22*y + m12*x + dy +//! [3] diff --git a/src/gui/doc/snippets/code/src_gui_painting_qpainter.cpp b/src/gui/doc/snippets/code/src_gui_painting_qpainter.cpp new file mode 100644 index 0000000000..8caffa46f4 --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_painting_qpainter.cpp @@ -0,0 +1,259 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +void SimpleExampleWidget::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + painter.setPen(Qt::blue); + painter.setFont(QFont("Arial", 30)); + painter.drawText(rect(), Qt::AlignCenter, "Qt"); +} +//! [0] + + +//! [1] +void MyWidget::paintEvent(QPaintEvent *) +{ + QPainter p; + p.begin(this); + p.drawLine(...); // drawing code + p.end(); +} +//! [1] + + +//! [2] +void MyWidget::paintEvent(QPaintEvent *) +{ + QPainter p(this); + p.drawLine(...); // drawing code +} +//! [2] + + +//! [3] +painter->begin(0); // impossible - paint device cannot be 0 + +QPixmap image(0, 0); +painter->begin(&image); // impossible - image.isNull() == true; + +painter->begin(myWidget); +painter2->begin(myWidget); // impossible - only one painter at a time +//! [3] + + +//! [4] +void QPainter::rotate(qreal angle) +{ + QMatrix matrix; + matrix.rotate(angle); + setWorldMatrix(matrix, true); +} +//! [4] + + +//! [5] +QPainterPath path; +path.moveTo(20, 80); +path.lineTo(20, 30); +path.cubicTo(80, 0, 50, 50, 80, 80); + +QPainter painter(this); +painter.drawPath(path); +//! [5] + + +//! [6] +QLineF line(10.0, 80.0, 90.0, 20.0); + +QPainter(this); +painter.drawLine(line); +//! [6] + + +//! [7] +QRectF rectangle(10.0, 20.0, 80.0, 60.0); + +QPainter painter(this); +painter.drawRect(rectangle); +//! [7] + + +//! [8] +QRectF rectangle(10.0, 20.0, 80.0, 60.0); + +QPainter painter(this); +painter.drawRoundedRect(rectangle, 20.0, 15.0); +//! [8] + + +//! [9] +QRectF rectangle(10.0, 20.0, 80.0, 60.0); + +QPainter painter(this); +painter.drawEllipse(rectangle); +//! [9] + + +//! [10] +QRectF rectangle(10.0, 20.0, 80.0, 60.0); +int startAngle = 30 * 16; +int spanAngle = 120 * 16; + +QPainter painter(this); +painter.drawArc(rectangle, startAngle, spanAngle); +//! [10] + + +//! [11] +QRectF rectangle(10.0, 20.0, 80.0, 60.0); +int startAngle = 30 * 16; +int spanAngle = 120 * 16; + +QPainter painter(this); +painter.drawPie(rectangle, startAngle, spanAngle); +//! [11] + + +//! [12] +QRectF rectangle(10.0, 20.0, 80.0, 60.0); +int startAngle = 30 * 16; +int spanAngle = 120 * 16; + +QPainter painter(this); +painter.drawChord(rect, startAngle, spanAngle); +//! [12] + + +//! [13] +static const QPointF points[3] = { + QPointF(10.0, 80.0), + QPointF(20.0, 10.0), + QPointF(80.0, 30.0), +}; + +QPainter painter(this); +painter.drawPolyline(points, 3); +//! [13] + + +//! [14] +static const QPointF points[4] = { + QPointF(10.0, 80.0), + QPointF(20.0, 10.0), + QPointF(80.0, 30.0), + QPointF(90.0, 70.0) +}; + +QPainter painter(this); +painter.drawPolygon(points, 4); +//! [14] + + +//! [15] +static const QPointF points[4] = { + QPointF(10.0, 80.0), + QPointF(20.0, 10.0), + QPointF(80.0, 30.0), + QPointF(90.0, 70.0) +}; + +QPainter painter(this); +painter.drawConvexPolygon(points, 4); +//! [15] + + +//! [16] +QRectF target(10.0, 20.0, 80.0, 60.0); +QRectF source(0.0, 0.0, 70.0, 40.0); +QPixmap pixmap(":myPixmap.png"); + +QPainter(this); +painter.drawPixmap(target, image, source); +//! [16] + + +//! [17] +QPainter painter(this); +painter.drawText(rect, Qt::AlignCenter, tr("Qt by\nNokia")); +//! [17] + + +//! [18] +QPicture picture; +QPointF point(10.0, 20.0) +picture.load("drawing.pic"); + +QPainter painter(this); +painter.drawPicture(0, 0, picture); +//! [18] + + +//! [19] +fillRect(rectangle, background()). +//! [19] + + +//! [20] +QRectF target(10.0, 20.0, 80.0, 60.0); +QRectF source(0.0, 0.0, 70.0, 40.0); +QImage image(":/images/myImage.png"); + +QPainter painter(this); +painter.drawImage(target, image, source); +//! [20] + + +//! [21] +QPainter painter(this); +painter.fillRect(0, 0, 128, 128, Qt::green); +painter.beginNativePainting(); + +glEnable(GL_SCISSOR_TEST); +glScissor(0, 0, 64, 64); + +glClearColor(1, 0, 0, 1); +glClear(GL_COLOR_BUFFER_BIT); + +glDisable(GL_SCISSOR_TEST); + +painter.endNativePainting(); +//! [21] diff --git a/src/gui/doc/snippets/code/src_gui_painting_qpainterpath.cpp b/src/gui/doc/snippets/code/src_gui_painting_qpainterpath.cpp new file mode 100644 index 0000000000..b23f8cea23 --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_painting_qpainterpath.cpp @@ -0,0 +1,149 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +QPainterPath path; +path.addRect(20, 20, 60, 60); + +path.moveTo(0, 0); +path.cubicTo(99, 0, 50, 50, 99, 99); +path.cubicTo(0, 99, 50, 50, 0, 0); + +QPainter painter(this); +painter.fillRect(0, 0, 100, 100, Qt::white); +painter.setPen(QPen(QColor(79, 106, 25), 1, Qt::SolidLine, + Qt::FlatCap, Qt::MiterJoin)); +painter.setBrush(QColor(122, 163, 39)); + +painter.drawPath(path); +//! [0] + + +//! [1] +QLinearGradient myGradient; +QPen myPen; + +QPainterPath myPath; +myPath.cubicTo(c1, c2, endPoint); + +QPainter painter(this); +painter.setBrush(myGradient); +painter.setPen(myPen); +painter.drawPath(myPath); +//! [1] + + +//! [2] +QLinearGradient myGradient; +QPen myPen; + +QPointF center, startPoint; + +QPainterPath myPath; +myPath.moveTo(center); +myPath.arcTo(boundingRect, startAngle, + sweepLength); + +QPainter painter(this); +painter.setBrush(myGradient); +painter.setPen(myPen); +painter.drawPath(myPath); +//! [2] + + +//! [3] +QLinearGradient myGradient; +QPen myPen; +QRectF myRectangle; + +QPainterPath myPath; +myPath.addRect(myRectangle); + +QPainter painter(this); +painter.setBrush(myGradient); +painter.setPen(myPen); +painter.drawPath(myPath); +//! [3] + + +//! [4] +QLinearGradient myGradient; +QPen myPen; +QPolygonF myPolygon; + +QPainterPath myPath; +myPath.addPolygon(myPolygon); + +QPainter painter(this); +painter.setBrush(myGradient); +painter.setPen(myPen); +painter.drawPath(myPath); +//! [4] + + +//! [5] +QLinearGradient myGradient; +QPen myPen; +QRectF boundingRectangle; + +QPainterPath myPath; +myPath.addEllipse(boundingRectangle); + +QPainter painter(this); +painter.setBrush(myGradient); +painter.setPen(myPen); +painter.drawPath(myPath); +//! [5] + + +//! [6] +QLinearGradient myGradient; +QPen myPen; +QFont myFont; +QPointF baseline(x, y); + +QPainterPath myPath; +myPath.addText(baseline, myFont, tr("Qt")); + +QPainter painter(this); +painter.setBrush(myGradient); +painter.setPen(myPen); +painter.drawPath(myPath); +//! [6] diff --git a/src/gui/doc/snippets/code/src_gui_painting_qpen.cpp b/src/gui/doc/snippets/code/src_gui_painting_qpen.cpp new file mode 100644 index 0000000000..4da729b88d --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_painting_qpen.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +QPainter painter(this); +QPen pen(Qt::green, 3, Qt::DashDotLine, Qt::RoundCap, Qt::RoundJoin); +painter.setPen(pen); +//! [0] + + +//! [1] +QPainter painter(this); +QPen pen; // creates a default pen + +pen.setStyle(Qt::DashDotLine); +pen.setWidth(3); +pen.setBrush(Qt::green); +pen.setCapStyle(Qt::RoundCap); +pen.setJoinStyle(Qt::RoundJoin); + +painter.setPen(pen); +//! [1] + + +//! [2] +QPen pen; +QVector dashes; +qreal space = 4; + +dashes << 1 << space << 3 << space << 9 << space + << 27 << space << 9 << space; + +pen.setDashPattern(dashes); +//! [2] + + +//! [3] +QPen pen; +QVector dashes; +qreal space = 4; +dashes << 1 << space << 3 << space << 9 << space + << 27 << space << 9 << space; +pen.setDashPattern(dashes); +//! [3] diff --git a/src/gui/doc/snippets/code/src_gui_painting_qregion.cpp b/src/gui/doc/snippets/code/src_gui_painting_qregion.cpp new file mode 100644 index 0000000000..8f334c5695 --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_painting_qregion.cpp @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +void MyWidget::paintEvent(QPaintEvent *) +{ + QRegion r1(QRect(100, 100, 200, 80), // r1: elliptic region + QRegion::Ellipse); + QRegion r2(QRect(100, 120, 90, 30)); // r2: rectangular region + QRegion r3 = r1.intersected(r2); // r3: intersection + + QPainter painter(this); + painter.setClipRegion(r3); + ... // paint clipped graphics +} +//! [0] diff --git a/src/gui/doc/snippets/code/src_gui_painting_qregion_unix.cpp b/src/gui/doc/snippets/code/src_gui_painting_qregion_unix.cpp new file mode 100644 index 0000000000..63b9de19d1 --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_painting_qregion_unix.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +QRegion r1(10, 10, 20, 20); +r1.isEmpty(); // false + +QRegion r3; +r3.isEmpty(); // true + +QRegion r2(40, 40, 20, 20); +r3 = r1.intersected(r2); // r3: intersection of r1 and r2 +r3.isEmpty(); // true + +r3 = r1.united(r2); // r3: union of r1 and r2 +r3.isEmpty(); // false +//! [0] diff --git a/src/gui/doc/snippets/code/src_gui_painting_qtransform.cpp b/src/gui/doc/snippets/code/src_gui_painting_qtransform.cpp new file mode 100644 index 0000000000..f54e0a07ca --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_painting_qtransform.cpp @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +x' = m11*x + m21*y + dx +y' = m22*y + m12*x + dy +if (is not affine) { + w' = m13*x + m23*y + m33 + x' /= w' + y' /= w' +} +//! [0] + + +//! [1] +x' = m11*x + m21*y + dx +y' = m22*y + m12*x + dy +if (is not affine) { + w' = m13*x + m23*y + m33 + x' /= w' + y' /= w' +} +//! [1] + + +//! [2] +x' = m11*x + m21*y + dx +y' = m22*y + m12*x + dy +if (is not affine) { + w' = m13*x + m23*y + m33 + x' /= w' + y' /= w' +} +//! [2] + + +//! [3] +x' = m11*x + m21*y + dx +y' = m22*y + m12*x + dy +if (is not affine) { + w' = m13*x + m23*y + m33 + x' /= w' + y' /= w' +} +//! [3] diff --git a/src/gui/doc/snippets/code/src_gui_qopenglshaderprogram.cpp b/src/gui/doc/snippets/code/src_gui_qopenglshaderprogram.cpp new file mode 100644 index 0000000000..637527036f --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_qopenglshaderprogram.cpp @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +QOpenGLShader shader(QOpenGLShader::Vertex); +shader.compileSourceCode(code); + +QOpenGLShaderProgram program(context); +program.addShader(shader); +program.link(); + +program.bind(); +//! [0] + +//! [1] +program.addShaderFromSourceCode(QOpenGLShader::Vertex, + "attribute highp vec4 vertex;\n" + "uniform highp mat4 matrix;\n" + "void main(void)\n" + "{\n" + " gl_Position = matrix * vertex;\n" + "}"); +program.addShaderFromSourceCode(QOpenGLShader::Fragment, + "uniform mediump vec4 color;\n" + "void main(void)\n" + "{\n" + " gl_FragColor = color;\n" + "}"); +program.link(); +program.bind(); + +int vertexLocation = program.attributeLocation("vertex"); +int matrixLocation = program.uniformLocation("matrix"); +int colorLocation = program.uniformLocation("color"); +//! [1] + +//! [2] +static GLfloat const triangleVertices[] = { + 60.0f, 10.0f, 0.0f, + 110.0f, 110.0f, 0.0f, + 10.0f, 110.0f, 0.0f +}; + +QColor color(0, 255, 0, 255); + +QMatrix4x4 pmvMatrix; +pmvMatrix.ortho(rect()); + +program.enableAttributeArray(vertexLocation); +program.setAttributeArray(vertexLocation, triangleVertices, 3); +program.setUniformValue(matrixLocation, pmvMatrix); +program.setUniformValue(colorLocation, color); + +glDrawArrays(GL_TRIANGLES, 0, 3); + +program.disableAttributeArray(vertexLocation); +//! [2] diff --git a/src/gui/doc/snippets/code/src_gui_text_qfont.cpp b/src/gui/doc/snippets/code/src_gui_text_qfont.cpp new file mode 100644 index 0000000000..fab550cbc7 --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_text_qfont.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +QFont serifFont("Times", 10, QFont::Bold); +QFont sansFont("Helvetica [Cronyx]", 12); +//! [0] + + +//! [1] +QFont f("Helvetica"); +//! [1] + + +//! [2] +QFont f("Helvetica [Cronyx]"); +//! [2] + + +//! [3] +QFontInfo info(f1); +QString family = info.family(); +//! [3] + + +//! [4] +QFontMetrics fm(f1); +int textWidthInPixels = fm.width("How many pixels wide is this text?"); +int textHeightInPixels = fm.height(); +//! [4] diff --git a/src/gui/doc/snippets/code/src_gui_text_qfontmetrics.cpp b/src/gui/doc/snippets/code/src_gui_text_qfontmetrics.cpp new file mode 100644 index 0000000000..b864b4ddcc --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_text_qfontmetrics.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +QFont font("times", 24); +QFontMetrics fm(font); +int pixelsWide = fm.width("What's the width of this text?"); +int pixelsHigh = fm.height(); +//! [0] + + +//! [1] +QFont font("times", 24); +QFontMetricsF fm(font); +qreal pixelsWide = fm.width("What's the width of this text?"); +qreal pixelsHigh = fm.height(); +//! [1] diff --git a/src/gui/doc/snippets/code/src_gui_text_qsyntaxhighlighter.cpp b/src/gui/doc/snippets/code/src_gui_text_qsyntaxhighlighter.cpp new file mode 100644 index 0000000000..3fb6b35bb9 --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_text_qsyntaxhighlighter.cpp @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +QTextEdit *editor = new QTextEdit; +MyHighlighter *highlighter = new MyHighlighter(editor->document()); +//! [0] + + +//! [1] +void MyHighlighter::highlightBlock(const QString &text) +{ + QTextCharFormat myClassFormat; + myClassFormat.setFontWeight(QFont::Bold); + myClassFormat.setForeground(Qt::darkMagenta); + QString pattern = "\\bMy[A-Za-z]+\\b"; + + QRegExp expression(pattern); + int index = text.indexOf(expression); + while (index >= 0) { + int length = expression.matchedLength(); + setFormat(index, length, myClassFormat); + index = text.indexOf(expression, index + length); + } +} +//! [1] + + +//! [2] +QTextCharFormat multiLineCommentFormat; +multiLineCommentFormat.setForeground(Qt::red); + +QRegExp startExpression("/\\*"); +QRegExp endExpression("\\*/"); + +setCurrentBlockState(0); + +int startIndex = 0; +if (previousBlockState() != 1) + startIndex = text.indexOf(startExpression); + +while (startIndex >= 0) { + int endIndex = text.indexOf(endExpression, startIndex); + int commentLength; + if (endIndex == -1) { + setCurrentBlockState(1); + commentLength = text.length() - startIndex; + } else { + commentLength = endIndex - startIndex + + endExpression.matchedLength(); + } + setFormat(startIndex, commentLength, multiLineCommentFormat); + startIndex = text.indexOf(startExpression, + startIndex + commentLength); +} +//! [2] + + +//! [3] +void MyHighlighter::highlightBlock(const QString &text) +{ + QTextCharFormat myClassFormat; + myClassFormat.setFontWeight(QFont::Bold); + myClassFormat.setForeground(Qt::darkMagenta); + QString pattern = "\\bMy[A-Za-z]+\\b"; + + QRegExp expression(pattern); + int index = text.indexOf(expression); + while (index >= 0) { + int length = expression.matchedLength(); + setFormat(index, length, myClassFormat); + index = text.indexOf(expression, index + length); + } + } +//! [3] + + +//! [4] +struct ParenthesisInfo +{ + QChar char; + int position; +}; + +struct BlockData : public QTextBlockUserData +{ + QVector parentheses; +}; +//! [4] diff --git a/src/gui/doc/snippets/code/src_gui_text_qtextcursor.cpp b/src/gui/doc/snippets/code/src_gui_text_qtextcursor.cpp new file mode 100644 index 0000000000..7954f66cbd --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_text_qtextcursor.cpp @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +cursor.clearSelection(); +cursor.movePosition(QTextCursor::NextWord, QTextCursor::KeepAnchor); +cursor.insertText("Hello World"); +//! [0] + + +//! [1] +QImage img = ... +textDocument->addResource(QTextDocument::ImageResource, QUrl("myimage"), img); +cursor.insertImage("myimage"); +//! [1] + + +//! [2] +QTextCursor cursor(textDocument); +cursor.beginEditBlock(); +cursor.insertText("Hello"); +cursor.insertText("World"); +cursor.endEditBlock(); + +textDocument->undo(); +//! [2] + + +//! [3] +QTextCursor cursor(textDocument); +cursor.beginEditBlock(); +cursor.insertText("Hello"); +cursor.insertText("World"); +cursor.endEditBlock(); + +... + +cursor.joinPreviousEditBlock(); +cursor.insertText("Hey"); +cursor.endEditBlock(); + +textDocument->undo(); +//! [3] diff --git a/src/gui/doc/snippets/code/src_gui_text_qtextdocument.cpp b/src/gui/doc/snippets/code/src_gui_text_qtextdocument.cpp new file mode 100644 index 0000000000..23ebf8b2d2 --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_text_qtextdocument.cpp @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +... +//! [0] diff --git a/src/gui/doc/snippets/code/src_gui_text_qtextdocumentwriter.cpp b/src/gui/doc/snippets/code/src_gui_text_qtextdocumentwriter.cpp new file mode 100644 index 0000000000..59ef46c422 --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_text_qtextdocumentwriter.cpp @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] + QTextDocumentWriter writer; + writer.setFormat("odf"); // same as writer.setFormat("ODF"); +//! [0] + diff --git a/src/gui/doc/snippets/code/src_gui_text_qtextlayout.cpp b/src/gui/doc/snippets/code/src_gui_text_qtextlayout.cpp new file mode 100644 index 0000000000..c8e1d2e010 --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_text_qtextlayout.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +int leading = fontMetrics.leading(); +qreal height = 0; +textLayout.beginLayout(); +while (1) { + QTextLine line = textLayout.createLine(); + if (!line.isValid()) + break; + + line.setLineWidth(lineWidth); + height += leading; + line.setPosition(QPointF(0, height)); + height += line.height(); +} +textLayout.endLayout(); +//! [0] + + +//! [1] +QPainter painter(this); +textLayout.draw(&painter, QPoint(0, 0)); +//! [1] diff --git a/src/gui/doc/snippets/code/src_gui_util_qdesktopservices.cpp b/src/gui/doc/snippets/code/src_gui_util_qdesktopservices.cpp new file mode 100644 index 0000000000..0b4739841b --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_util_qdesktopservices.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +class MyHelpHandler : public QObject +{ + Q_OBJECT +public: + ... +public slots: + void showHelp(const QUrl &url); +}; + +QDesktopServices::setUrlHandler("help", helpInstance, "showHelp"); +//! [0] + +//! [1] +mailto:user@foo.com?subject=Test&body=Just a test +//! [1] + +//! [2] +QDesktopServices::openUrl(QUrl("file:///C:/Documents and Settings/All Users/Desktop", QUrl::TolerantMode)); +//! [2] diff --git a/src/gui/doc/snippets/code/src_gui_util_qvalidator.cpp b/src/gui/doc/snippets/code/src_gui_util_qvalidator.cpp new file mode 100644 index 0000000000..2f769c5860 --- /dev/null +++ b/src/gui/doc/snippets/code/src_gui_util_qvalidator.cpp @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +QValidator *validator = new QIntValidator(100, 999, this); +QLineEdit *edit = new QLineEdit(this); + +// the edit lineedit will only accept integers between 100 and 999 +edit->setValidator(validator); +//! [0] + + +//! [1] +QString str; +int pos = 0; +QIntValidator v(100, 900, this); + +str = "1"; +v.validate(str, pos); // returns Intermediate +str = "012"; +v.validate(str, pos); // returns Intermediate + +str = "123"; +v.validate(str, pos); // returns Acceptable +str = "678"; +v.validate(str, pos); // returns Acceptable + +str = "999"; +v.validate(str, pos); // returns Intermediate + +str = "1234"; +v.validate(str, pos); // returns Invalid +str = "-123"; +v.validate(str, pos); // returns Invalid +str = "abc"; +v.validate(str, pos); // returns Invalid +str = "12cm"; +v.validate(str, pos); // returns Invalid +//! [1] + + +//! [2] +int pos = 0; + +s = "abc"; +v.validate(s, pos); // returns Invalid + +s = "5"; +v.validate(s, pos); // returns Intermediate + +s = "50"; +v.validate(s, pos); // returns Acceptable +//! [2] + + +//! [3] +// regexp: optional '-' followed by between 1 and 3 digits +QRegExp rx("-?\\d{1,3}"); +QValidator *validator = new QRegExpValidator(rx, this); + +QLineEdit *edit = new QLineEdit(this); +edit->setValidator(validator); +//! [3] + + +//! [4] +// integers 1 to 9999 +QRegExp rx("[1-9]\\d{0,3}"); +// the validator treats the regexp as "^[1-9]\\d{0,3}$" +QRegExpValidator v(rx, 0); +QString s; +int pos = 0; + +s = "0"; v.validate(s, pos); // returns Invalid +s = "12345"; v.validate(s, pos); // returns Invalid +s = "1"; v.validate(s, pos); // returns Acceptable + +rx.setPattern("\\S+"); // one or more non-whitespace characters +v.setRegExp(rx); +s = "myfile.txt"; v.validate(s, pos); // Returns Acceptable +s = "my file.txt"; v.validate(s, pos); // Returns Invalid + +// A, B or C followed by exactly five digits followed by W, X, Y or Z +rx.setPattern("[A-C]\\d{5}[W-Z]"); +v.setRegExp(rx); +s = "a12345Z"; v.validate(s, pos); // Returns Invalid +s = "A12345Z"; v.validate(s, pos); // Returns Acceptable +s = "B12"; v.validate(s, pos); // Returns Intermediate + +// match most 'readme' files +rx.setPattern("read\\S?me(\.(txt|asc|1st))?"); +rx.setCaseSensitive(false); +v.setRegExp(rx); +s = "readme"; v.validate(s, pos); // Returns Acceptable +s = "README.1ST"; v.validate(s, pos); // Returns Acceptable +s = "read me.txt"; v.validate(s, pos); // Returns Invalid +s = "readm"; v.validate(s, pos); // Returns Intermediate +//! [4] diff --git a/src/gui/doc/snippets/dragging/mainwindow.cpp b/src/gui/doc/snippets/dragging/mainwindow.cpp new file mode 100644 index 0000000000..57f1abc22d --- /dev/null +++ b/src/gui/doc/snippets/dragging/mainwindow.cpp @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) +{ + QFrame *centralFrame = new QFrame(this); + + QLabel *nameLabel = new QLabel(tr("Comment:"), centralFrame); + commentEdit = new QTextEdit(centralFrame); + QLabel *dragLabel = new QLabel(tr("

Drag the icon to a filer " + "window or the desktop background:

"), + centralFrame); + iconLabel = new QLabel(centralFrame); + iconPixmap.load(":/images/file.png"); + iconLabel->setPixmap(iconPixmap); + + QGridLayout *grid = new QGridLayout(centralFrame); + grid->addWidget(nameLabel, 0, 0); + grid->addWidget(commentEdit, 1, 0, 1, 2); + grid->addWidget(dragLabel, 2, 0); + grid->addWidget(iconLabel, 2, 1); + + statusBar(); + setCentralWidget(centralFrame); + setWindowTitle(tr("Dragging")); +} + +//! [0] +void MainWindow::mousePressEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton + && iconLabel->geometry().contains(event->pos())) { + +//! [1] + QDrag *drag = new QDrag(this); + QMimeData *mimeData = new QMimeData; + + mimeData->setText(commentEdit->toPlainText()); + drag->setMimeData(mimeData); +//! [1] + drag->setPixmap(iconPixmap); + + Qt::DropAction dropAction = drag->exec(); +//! [0] + + QString actionText; + switch (dropAction) { + case Qt::CopyAction: + actionText = tr("The text was copied."); + break; + case Qt::MoveAction: + actionText = tr("The text was moved."); + break; + case Qt::LinkAction: + actionText = tr("The text was linked."); + break; + case Qt::IgnoreAction: + actionText = tr("The drag was ignored."); + break; + default: + actionText = tr("Unknown action."); + break; + } + statusBar()->showMessage(actionText); +//! [2] + } +} +//! [2] diff --git a/src/gui/doc/snippets/droparea.cpp b/src/gui/doc/snippets/droparea.cpp new file mode 100644 index 0000000000..27d52d1b89 --- /dev/null +++ b/src/gui/doc/snippets/droparea.cpp @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "droparea.h" + +DropArea::DropArea(QWidget *parent) + : QLabel(parent) +{ + setMinimumSize(200, 200); + setFrameStyle(QFrame::Sunken | QFrame::StyledPanel); + setAlignment(Qt::AlignCenter); + setAcceptDrops(true); + setAutoFillBackground(true); + clear(); +} + +void DropArea::dragEnterEvent(QDragEnterEvent *event) +{ + setText(tr("")); + setBackgroundRole(QPalette::Highlight); + + event->acceptProposedAction(); + emit changed(event->mimeData()); +} + +void DropArea::dragMoveEvent(QDragMoveEvent *event) +{ + event->acceptProposedAction(); +} + +void DropArea::dropEvent(QDropEvent *event) +{ + const QMimeData *mimeData = event->mimeData(); + + if (mimeData->hasImage()) { + setPixmap(qvariant_cast(mimeData->imageData())); + } else if (mimeData->hasHtml()) { + setText(mimeData->html()); + setTextFormat(Qt::RichText); + } else if (mimeData->hasText()) { + setText(mimeData->text()); + setTextFormat(Qt::PlainText); + } else { + setText(tr("Cannot display data")); + } + + setBackgroundRole(QPalette::Dark); + event->acceptProposedAction(); +} + +//![0] +void DropArea::paste() +{ + const QClipboard *clipboard = QApplication::clipboard(); + const QMimeData *mimeData = clipboard->mimeData(); + + if (mimeData->hasImage()) { + setPixmap(qvariant_cast(mimeData->imageData())); + } else if (mimeData->hasHtml()) { + setText(mimeData->html()); + setTextFormat(Qt::RichText); + } else if (mimeData->hasText()) { + setText(mimeData->text()); + setTextFormat(Qt::PlainText); + } else { + setText(tr("Cannot display data")); + } +//![0] + + emit changed(mimeData); + setBackgroundRole(QPalette::Dark); + //event->acceptProposedAction(); +} + +void DropArea::dragLeaveEvent(QDragLeaveEvent *event) +{ + clear(); + event->accept(); +} + +void DropArea::clear() +{ + setText(tr("")); + setBackgroundRole(QPalette::Dark); + + emit changed(); +} + +QPixmap DropArea::extractPixmap(const QByteArray &data, const QString &format) +{ + QList imageFormats = QImageReader::supportedImageFormats(); + QPixmap pixmap; + + foreach (const QByteArray &imageFormat, imageFormats) { + if (format.mid(6) == QString(imageFormat)) { + pixmap.loadFromData(data, imageFormat); + break; + } + } + return pixmap; +} diff --git a/src/gui/doc/snippets/image/image.cpp b/src/gui/doc/snippets/image/image.cpp new file mode 100644 index 0000000000..1dfe41f8cd --- /dev/null +++ b/src/gui/doc/snippets/image/image.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +int main() +{ + int x, y; + { + // BIT ACCESS + QImage image; + // sets bit at (x, y) to 1 + if (image.format() == QImage::Format_MonoLSB) + image.scanLine(y)[x >> 3] |= 1 << (x & 7); + else + image.scanLine(y)[x >> 3] |= 1 << (7 - (x & 7)); + } + + { + // 8-BIT ACCESS + QImage image; + // set entry 19 in the color table to yellow + image.setColor(19, qRgb(255, 255, 0)); + + // set 8 bit pixel at (x,y) to value yellow (in color table) + image.scanLine(y)[x] = 19; + } + + { + // 32-BIT + QImage image; + // sets 32 bit pixel at (x,y) to yellow. + uint *ptr = reinterpret_cast(image.scanLine(y)) + x; + *ptr = qRgb(255, 255, 0); + } + + { + // SAVE +//! [0] + QImage image; + QByteArray ba; + QBuffer buffer(&ba); + buffer.open(QIODevice::WriteOnly); + image.save(&buffer, "PNG"); // writes image into ba in PNG format +//! [0] + } + + { + // PIX SAVE +//! [1] + QPixmap pixmap; + QByteArray bytes; + QBuffer buffer(&bytes); + buffer.open(QIODevice::WriteOnly); + pixmap.save(&buffer, "PNG"); // writes pixmap into bytes in PNG format +//! [1] + } + + { + // MASK +//! [2] + QPixmap alpha("image-with-alpha.png"); + QPixmap alphacopy = alpha; + alphacopy.setMask(alphacopy.mask()); +//! [2] + } +} diff --git a/src/gui/doc/snippets/image/supportedformat.cpp b/src/gui/doc/snippets/image/supportedformat.cpp new file mode 100644 index 0000000000..6d481908e8 --- /dev/null +++ b/src/gui/doc/snippets/image/supportedformat.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +int main(int argv, char **args) +{ +//! [0] + QImageWriter writer; + writer.setFormat("png"); + if (writer.supportsOption(QImageIOHandler::Description)) + qDebug() << "Png supports embedded text"; +//! [0] + return 0; +} diff --git a/src/gui/doc/snippets/matrix/matrix.cpp b/src/gui/doc/snippets/matrix/matrix.cpp new file mode 100644 index 0000000000..2aa2606fc6 --- /dev/null +++ b/src/gui/doc/snippets/matrix/matrix.cpp @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +class SimpleTransformation : public QWidget +{ + void paintEvent(QPaintEvent *); +}; + +//! [0] +void SimpleTransformation::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + painter.setPen(QPen(Qt::blue, 1, Qt::DashLine)); + painter.drawRect(0, 0, 100, 100); + + painter.rotate(45); + + painter.setFont(QFont("Helvetica", 24)); + painter.setPen(QPen(Qt::black, 1)); + painter.drawText(20, 10, "QMatrix"); +} +//! [0] + +class CombinedTransformation : public QWidget +{ + void paintEvent(QPaintEvent *); +}; + +//! [1] +void CombinedTransformation::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + painter.setPen(QPen(Qt::blue, 1, Qt::DashLine)); + painter.drawRect(0, 0, 100, 100); + + QMatrix matrix; + matrix.translate(50, 50); + matrix.rotate(45); + matrix.scale(0.5, 1.0); + painter.setMatrix(matrix); + + painter.setFont(QFont("Helvetica", 24)); + painter.setPen(QPen(Qt::black, 1)); + painter.drawText(20, 10, "QMatrix"); +} +//! [1] + +class BasicOperations : public QWidget +{ + void paintEvent(QPaintEvent *); +}; + +//! [2] +void BasicOperations::paintEvent(QPaintEvent *) +{ + double pi = 3.14; + + double a = pi/180 * 45.0; + double sina = sin(a); + double cosa = cos(a); + + QMatrix translationMatrix(1, 0, 0, 1, 50.0, 50.0); + QMatrix rotationMatrix(cosa, sina, -sina, cosa, 0, 0); + QMatrix scalingMatrix(0.5, 0, 0, 1.0, 0, 0); + + QMatrix matrix; + matrix = scalingMatrix * rotationMatrix * translationMatrix; + + QPainter painter(this); + painter.setPen(QPen(Qt::blue, 1, Qt::DashLine)); + painter.drawRect(0, 0, 100, 100); + + painter.setMatrix(matrix); + + painter.setFont(QFont("Helvetica", 24)); + painter.setPen(QPen(Qt::black, 1)); + painter.drawText(20, 10, "QMatrix"); +} +//! [2] + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + QWidget widget; + + SimpleTransformation *simpleWidget = new SimpleTransformation; + CombinedTransformation *combinedWidget = new CombinedTransformation; + BasicOperations *basicWidget = new BasicOperations; + + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(simpleWidget); + layout->addWidget(combinedWidget); + layout->addWidget(basicWidget); + widget.setLayout(layout); + + widget.show(); + widget.resize(130, 350); + return app.exec(); +} diff --git a/src/gui/doc/snippets/picture/picture.cpp b/src/gui/doc/snippets/picture/picture.cpp new file mode 100644 index 0000000000..8de5e32323 --- /dev/null +++ b/src/gui/doc/snippets/picture/picture.cpp @@ -0,0 +1,151 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +void myProcessing(const QString &) +{ +} + +int main() +{ + QWidget myWidget; + { + // RECORD +//! [0] + QPicture picture; + QPainter painter; + painter.begin(&picture); // paint in picture + painter.drawEllipse(10,20, 80,70); // draw an ellipse + painter.end(); // painting done + picture.save("drawing.pic"); // save picture +//! [0] + } + + { + // REPLAY +//! [1] + QPicture picture; + picture.load("drawing.pic"); // load picture + QPainter painter; + painter.begin(&myImage); // paint in myImage + painter.drawPicture(0, 0, picture); // draw the picture at (0,0) + painter.end(); // painting done +//! [1] + } + + QPicture myPicture; + { + // FORMATS +//! [2] + QStringList list = QPicture::inputFormatList(); + foreach (const QString &string, list) + myProcessing(string); +//! [2] + } + + { + // OUTPUT +//! [3] + QStringList list = QPicture::outputFormatList(); + foreach (const QString &string, list) + myProcessing(string); +//! [3] + } + + { + // PIC READ +//! [4] + QPictureIO iio; + QPixmap pixmap; + iio.setFileName("vegeburger.pic"); + if (iio.read()) { // OK + QPicture picture = iio.picture(); + QPainter painter(&pixmap); + painter.drawPicture(0, 0, picture); + } +//! [4] + } + + { + QPixmap pixmap; + // PIC WRITE +//! [5] + QPictureIO iio; + QPicture picture; + QPainter painter(&picture); + painter.drawPixmap(0, 0, pixmap); + iio.setPicture(picture); + iio.setFileName("vegeburger.pic"); + iio.setFormat("PIC"); + if (iio.write()) + return true; // returned true if written successfully +//! [5] + } + +} + +// SVG READ +//! [6] +void readSVG(QPictureIO *picture) +{ + // read the picture using the picture->ioDevice() +} +//! [6] + +// SVG WRITE +//! [7] +void writeSVG(QPictureIO *picture) +{ + // write the picture using the picture->ioDevice() +} +//! [7] + +// USE SVG +void foo() { + +//! [8] + // add the SVG picture handler + // ... +//! [8] + QPictureIO::defineIOHandler("SVG", 0, 0, readSVG, writeSVG); + // ... + +} diff --git a/src/gui/doc/snippets/polygon/polygon.cpp b/src/gui/doc/snippets/polygon/polygon.cpp new file mode 100644 index 0000000000..432156f8e6 --- /dev/null +++ b/src/gui/doc/snippets/polygon/polygon.cpp @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +int main() +{ + { + // STREAM +//! [0] + QPolygon polygon; + polygon << QPoint(10, 20) << QPoint(20, 30); +//! [0] + } + + { + // STREAMF +//! [1] + QPolygonF polygon; + polygon << QPointF(10.4, 20.5) << QPointF(20.2, 30.2); +//! [1] + } + + { + // SETPOINTS +//! [2] + static const int points[] = { 10, 20, 30, 40 }; + QPolygon polygon; + polygon.setPoints(2, points); +//! [2] + } + + { + // SETPOINTS2 +//! [3] + QPolygon polygon; + polygon.setPoints(2, 10, 20, 30, 40); +//! [3] + } + + { + // PUTPOINTS +//! [4] + QPolygon polygon(1); + polygon[0] = QPoint(4, 5); + polygon.putPoints(1, 2, 6,7, 8,9); +//! [4] + } + + { + // PUTPOINTS2 +//! [5] + QPolygon polygon(3); + polygon.putPoints(0, 3, 4,5, 0,0, 8,9); + polygon.putPoints(1, 1, 6,7); +//! [5] + } + + { + // PUTPOINTS3 +//! [6] + QPolygon polygon1; + polygon1.putPoints(0, 3, 1,2, 0,0, 5,6); + // polygon1 is now the three-point polygon(1,2, 0,0, 5,6); + + QPolygon polygon2; + polygon2.putPoints(0, 3, 4,4, 5,5, 6,6); + // polygon2 is now (4,4, 5,5, 6,6); + + polygon1.putPoints(2, 3, polygon2); + // polygon1 is now the five-point polygon(1,2, 0,0, 4,4, 5,5, 6,6); +//! [6] + } + return 0; +} diff --git a/src/gui/doc/snippets/qfontdatabase/main.cpp b/src/gui/doc/snippets/qfontdatabase/main.cpp new file mode 100644 index 0000000000..8e98e309a0 --- /dev/null +++ b/src/gui/doc/snippets/qfontdatabase/main.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + +//! [0] + QFontDatabase database; + QTreeWidget fontTree; + fontTree.setColumnCount(2); + fontTree.setHeaderLabels(QStringList() << "Font" << "Smooth Sizes"); + + foreach (const QString &family, database.families()) { + QTreeWidgetItem *familyItem = new QTreeWidgetItem(&fontTree); + familyItem->setText(0, family); + + foreach (const QString &style, database.styles(family)) { + QTreeWidgetItem *styleItem = new QTreeWidgetItem(familyItem); + styleItem->setText(0, style); + + QString sizes; + foreach (int points, database.smoothSizes(family, style)) + sizes += QString::number(points) + " "; + + styleItem->setText(1, sizes.trimmed()); + } +//! [0] //! [1] + } +//! [1] + + fontTree.resizeColumnToContents(0); + fontTree.show(); + return app.exec(); +} diff --git a/src/gui/doc/snippets/qstatustipevent/main.cpp b/src/gui/doc/snippets/qstatustipevent/main.cpp new file mode 100644 index 0000000000..9a1948f4e8 --- /dev/null +++ b/src/gui/doc/snippets/qstatustipevent/main.cpp @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +class MainWindow : public QMainWindow +{ +public: + MainWindow(QWidget *parent = 0); +}; + +//! [0] //! [1] +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) +{ +//! [0] + QWidget *myWidget = new QWidget; + myWidget->setStatusTip(tr("This is my widget.")); + + setCentralWidget(myWidget); +//! [1] + +//! [2] + QMenu *fileMenu = menuBar()->addMenu(tr("File")); + + QAction *newAct = new QAction(tr("&New"), this); + newAct->setStatusTip(tr("Create a new file.")); + fileMenu->addAction(newAct); +//! [2] + + statusBar()->showMessage(tr("Ready")); + setWindowTitle(tr("QStatusTipEvent")); +//! [3] +} +//! [3] + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + MainWindow window; + window.show(); + return app.exec(); +} + diff --git a/src/gui/doc/snippets/separations/finalwidget.cpp b/src/gui/doc/snippets/separations/finalwidget.cpp new file mode 100644 index 0000000000..81a4aa1c42 --- /dev/null +++ b/src/gui/doc/snippets/separations/finalwidget.cpp @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/* +finalwidget.cpp + +A widget to display an image and a label containing a description. +*/ + +#include +#include "finalwidget.h" + +FinalWidget::FinalWidget(QWidget *parent, const QString &name, + const QSize &labelSize) + : QFrame(parent) +{ + hasImage = false; + imageLabel = new QLabel; + imageLabel->setFrameShadow(QFrame::Sunken); + imageLabel->setFrameShape(QFrame::StyledPanel); + imageLabel->setMinimumSize(labelSize); + nameLabel = new QLabel(name); + + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(imageLabel, 1); + layout->addWidget(nameLabel, 0); + setLayout(layout); +} + +/*! + If the mouse moves far enough when the left mouse button is held down, + start a drag and drop operation. +*/ + +void FinalWidget::mouseMoveEvent(QMouseEvent *event) +{ + if (!(event->buttons() & Qt::LeftButton)) + return; + if ((event->pos() - dragStartPosition).manhattanLength() + < QApplication::startDragDistance()) + return; + if (!hasImage) + return; + + QDrag *drag = new QDrag(this); + QMimeData *mimeData = new QMimeData; + +//! [0] + QByteArray output; + QBuffer outputBuffer(&output); + outputBuffer.open(QIODevice::WriteOnly); + imageLabel->pixmap()->toImage().save(&outputBuffer, "PNG"); + mimeData->setData("image/png", output); +//! [0] +/* +//! [1] + mimeData->setImageData(QVariant(*imageLabel->pixmap())); +//! [1] +*/ + drag->setMimeData(mimeData); + drag->setPixmap(imageLabel->pixmap()->scaled(64, 64, Qt::KeepAspectRatio)); +//! [2] + drag->setHotSpot(QPoint(drag->pixmap().width()/2, + drag->pixmap().height())); +//! [2] + + drag->start(); +} + +/*! + Check for left mouse button presses in order to enable drag and drop. +*/ + +void FinalWidget::mousePressEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) + dragStartPosition = event->pos(); +} + +const QPixmap* FinalWidget::pixmap() const +{ + return imageLabel->pixmap(); +} + +void FinalWidget::setPixmap(const QPixmap &pixmap) +{ + imageLabel->setPixmap(pixmap); + hasImage = true; +} diff --git a/src/gui/doc/snippets/textblock-fragments/xmlwriter.cpp b/src/gui/doc/snippets/textblock-fragments/xmlwriter.cpp new file mode 100644 index 0000000000..cd9beadd00 --- /dev/null +++ b/src/gui/doc/snippets/textblock-fragments/xmlwriter.cpp @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "xmlwriter.h" + +QDomDocument *XmlWriter::toXml() +{ + QDomImplementation implementation; + QDomDocumentType docType = implementation.createDocumentType( + "scribe-document", "scribe", "qt.nokia.com/scribe"); + + document = new QDomDocument(docType); + + // ### This processing instruction is required to ensure that any kind + // of encoding is given when the document is written. + QDomProcessingInstruction process = document->createProcessingInstruction( + "xml", "version=\"1.0\" encoding=\"utf-8\""); + document->appendChild(process); + + QDomElement documentElement = document->createElement("document"); + document->appendChild(documentElement); + +//! [0] + QTextBlock currentBlock = textDocument->begin(); + + while (currentBlock.isValid()) { +//! [0] + QDomElement blockElement = document->createElement("block"); + document->appendChild(blockElement); + + readFragment(currentBlock, blockElement, document); + +//! [1] + processBlock(currentBlock); +//! [1] + +//! [2] + currentBlock = currentBlock.next(); + } +//! [2] + + return document; +} + +void XmlWriter::readFragment(const QTextBlock ¤tBlock, + QDomElement blockElement, + QDomDocument *document) +{ +//! [3] //! [4] + QTextBlock::iterator it; + for (it = currentBlock.begin(); !(it.atEnd()); ++it) { + QTextFragment currentFragment = it.fragment(); + if (currentFragment.isValid()) +//! [3] //! [5] + processFragment(currentFragment); +//! [4] //! [5] + + if (currentFragment.isValid()) { + QDomElement fragmentElement = document->createElement("fragment"); + blockElement.appendChild(fragmentElement); + + fragmentElement.setAttribute("length", currentFragment.length()); + QDomText fragmentText = document->createTextNode(currentFragment.text()); + + fragmentElement.appendChild(fragmentText); + } +//! [6] //! [7] + } +//! [7] //! [6] +} + +void XmlWriter::processBlock(const QTextBlock ¤tBlock) +{ +} + +void XmlWriter::processFragment(const QTextFragment ¤tFragment) +{ +} diff --git a/src/gui/doc/snippets/textdocument-css/main.cpp b/src/gui/doc/snippets/textdocument-css/main.cpp new file mode 100644 index 0000000000..55b8571224 --- /dev/null +++ b/src/gui/doc/snippets/textdocument-css/main.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + +//! [0] + QTextBrowser browser; + QColor linkColor(Qt::red); + QString sheet = QString::fromLatin1("a { text-decoration: underline; color: %1 }").arg(linkColor.name()); + browser.document()->setDefaultStyleSheet(sheet); +//! [0] + browser.setSource(QUrl("../../../html/index.html")); + browser.resize(800, 600); + browser.show(); + + return app.exec(); +} + diff --git a/src/gui/doc/snippets/textdocument-listitemstyles/main.cpp b/src/gui/doc/snippets/textdocument-listitemstyles/main.cpp new file mode 100644 index 0000000000..223ec22bae --- /dev/null +++ b/src/gui/doc/snippets/textdocument-listitemstyles/main.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "mainwindow.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + MainWindow *window = new MainWindow; + window->resize(640, 480); + window->show(); + return app.exec(); +} diff --git a/src/gui/doc/snippets/textdocument-listitemstyles/mainwindow.cpp b/src/gui/doc/snippets/textdocument-listitemstyles/mainwindow.cpp new file mode 100644 index 0000000000..029695eca3 --- /dev/null +++ b/src/gui/doc/snippets/textdocument-listitemstyles/mainwindow.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "mainwindow.h" + +MainWindow::MainWindow() +{ + QMenu *fileMenu = new QMenu(tr("&File")); + + fileMenu->addAction(tr("E&xit"), this, SLOT(close()), + QKeySequence(tr("Ctrl+Q", "File|Exit"))); + + QMenu *insertMenu = new QMenu(tr("&Insert")); + + insertMenu->addAction(tr("&List"), this, SLOT(insertList()), + QKeySequence(tr("Ctrl+L", "Insert|List"))); + + menuBar()->addMenu(fileMenu); + menuBar()->addMenu(insertMenu); + + editor = new QTextEdit(this); + document = new QTextDocument(this); + editor->setDocument(document); + + setCentralWidget(editor); + setWindowTitle(tr("Text Document List Item Styles")); +} + +void MainWindow::insertList() +{ + QTextCursor cursor = editor->textCursor(); + cursor.beginEditBlock(); + + //! [add a styled, ordered list] + QTextListFormat listFormat; + + listFormat.setStyle(QTextListFormat::ListDecimal); + listFormat.setNumberPrefix("("); + listFormat.setNumberSuffix(")"); + + cursor.insertList(listFormat); + //! [add a styled, ordered list] + + cursor.endEditBlock(); +} diff --git a/src/gui/doc/snippets/textdocument-listitemstyles/mainwindow.h b/src/gui/doc/snippets/textdocument-listitemstyles/mainwindow.h new file mode 100644 index 0000000000..fc5c6db2a7 --- /dev/null +++ b/src/gui/doc/snippets/textdocument-listitemstyles/mainwindow.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WINDOW_H +#define WINDOW_H + +#include + +class QTextDocument; +class QTextEdit; + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(); + +public slots: + void insertList(); + +private: + QString currentFile; + QTextEdit *editor; + QTextDocument *document; +}; + +#endif diff --git a/src/gui/doc/snippets/textdocument-listitemstyles/textdocument-listitemstyles.pro b/src/gui/doc/snippets/textdocument-listitemstyles/textdocument-listitemstyles.pro new file mode 100644 index 0000000000..5da8d6e1a1 --- /dev/null +++ b/src/gui/doc/snippets/textdocument-listitemstyles/textdocument-listitemstyles.pro @@ -0,0 +1,3 @@ +HEADERS = mainwindow.h +SOURCES = main.cpp \ + mainwindow.cpp diff --git a/src/gui/doc/snippets/textdocument-lists/mainwindow.cpp b/src/gui/doc/snippets/textdocument-lists/mainwindow.cpp new file mode 100644 index 0000000000..7ae36b0ced --- /dev/null +++ b/src/gui/doc/snippets/textdocument-lists/mainwindow.cpp @@ -0,0 +1,192 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "mainwindow.h" + +MainWindow::MainWindow() +{ + QMenu *fileMenu = new QMenu(tr("&File")); + + fileMenu->addAction(tr("E&xit"), this, SLOT(close()), + QKeySequence(tr("Ctrl+Q", "File|Exit"))); + + QMenu *editMenu = new QMenu(tr("&Edit")); + + cutAction = editMenu->addAction(tr("Cu&t"), this, SLOT(cutSelection()), + QKeySequence(tr("Ctrl+X", "Edit|Cut"))); + copyAction = editMenu->addAction(tr("&Copy"), this, SLOT(copySelection()), + QKeySequence(tr("Ctrl+C", "Edit|Copy"))); + pasteAction = editMenu->addAction(tr("&Paste"), this, + SLOT(pasteSelection()), QKeySequence(tr("Ctrl+V", "Edit|Paste"))); + + QMenu *selectMenu = new QMenu(tr("&Select")); + selectMenu->addAction(tr("&Word"), this, SLOT(selectWord())); + selectMenu->addAction(tr("&Line"), this, SLOT(selectLine())); + selectMenu->addAction(tr("&Block"), this, SLOT(selectBlock())); + selectMenu->addAction(tr("&Frame"), this, SLOT(selectFrame())); + + QMenu *insertMenu = new QMenu(tr("&Insert")); + + insertMenu->addAction(tr("&List"), this, SLOT(insertList()), + QKeySequence(tr("Ctrl+L", "Insert|List"))); + + menuBar()->addMenu(fileMenu); + menuBar()->addMenu(editMenu); + menuBar()->addMenu(selectMenu); + menuBar()->addMenu(insertMenu); + + editor = new QTextEdit(this); + document = new QTextDocument(this); + editor->setDocument(document); + + connect(editor, SIGNAL(selectionChanged()), this, SLOT(updateMenus())); + + updateMenus(); + + setCentralWidget(editor); + setWindowTitle(tr("Text Document Writer")); +} + +void MainWindow::cutSelection() +{ + QTextCursor cursor = editor->textCursor(); + if (cursor.hasSelection()) { + selection = cursor.selection(); + cursor.removeSelectedText(); + } +} + +void MainWindow::copySelection() +{ + QTextCursor cursor = editor->textCursor(); + if (cursor.hasSelection()) { + selection = cursor.selection(); + cursor.clearSelection(); + } +} + +void MainWindow::pasteSelection() +{ + QTextCursor cursor = editor->textCursor(); + cursor.insertFragment(selection); +} + +void MainWindow::selectWord() +{ + QTextCursor cursor = editor->textCursor(); + QTextBlock block = cursor.block(); + + cursor.beginEditBlock(); + cursor.movePosition(QTextCursor::StartOfWord); + cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor); + cursor.endEditBlock(); + + editor->setTextCursor(cursor); +} + +void MainWindow::selectLine() +{ + QTextCursor cursor = editor->textCursor(); + QTextBlock block = cursor.block(); + + cursor.beginEditBlock(); + cursor.movePosition(QTextCursor::StartOfLine); + cursor.movePosition(QTextCursor::EndOfLine, QTextCursor::KeepAnchor); + cursor.endEditBlock(); + + editor->setTextCursor(cursor); +} + +void MainWindow::selectBlock() +{ + QTextCursor cursor = editor->textCursor(); + QTextBlock block = cursor.block(); + + cursor.beginEditBlock(); + cursor.movePosition(QTextCursor::StartOfBlock); + cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); + cursor.endEditBlock(); + + editor->setTextCursor(cursor); +} + +void MainWindow::selectFrame() +{ + QTextCursor cursor = editor->textCursor(); + QTextFrame *frame = cursor.currentFrame(); + + cursor.beginEditBlock(); + cursor.setPosition(frame->firstPosition()); + cursor.setPosition(frame->lastPosition(), QTextCursor::KeepAnchor); + cursor.endEditBlock(); + + editor->setTextCursor(cursor); +} + +void MainWindow::insertList() +{ + QTextCursor cursor = editor->textCursor(); + cursor.beginEditBlock(); + + QTextList *list = cursor.currentList(); +//! [0] + QTextListFormat listFormat; + if (list) { + listFormat = list->format(); + listFormat.setIndent(listFormat.indent() + 1); + } + + listFormat.setStyle(QTextListFormat::ListDisc); + cursor.insertList(listFormat); +//! [0] + + cursor.endEditBlock(); +} + +void MainWindow::updateMenus() +{ + QTextCursor cursor = editor->textCursor(); + cutAction->setEnabled(cursor.hasSelection()); + copyAction->setEnabled(cursor.hasSelection()); + + pasteAction->setEnabled(!selection.isEmpty()); +} diff --git a/src/gui/doc/snippets/textdocument-resources/main.cpp b/src/gui/doc/snippets/textdocument-resources/main.cpp new file mode 100644 index 0000000000..ed26793d78 --- /dev/null +++ b/src/gui/doc/snippets/textdocument-resources/main.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +QString tr(const char *text) +{ + return QApplication::translate(text, text); +} + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + QTextEdit *editor = new QTextEdit; + + QTextDocument *document = new QTextDocument(editor); + QTextCursor cursor(document); + + QImage image(64, 64, QImage::Format_RGB32); + image.fill(qRgb(255, 160, 128)); + +//! [Adding a resource] + document->addResource(QTextDocument::ImageResource, + QUrl("mydata://image.png"), QVariant(image)); +//! [Adding a resource] + +//! [Inserting an image with a cursor] + QTextImageFormat imageFormat; + imageFormat.setName("mydata://image.png"); + cursor.insertImage(imageFormat); +//! [Inserting an image with a cursor] + + cursor.insertBlock(); + cursor.insertText("Code less. Create more."); + + editor->setDocument(document); + editor->setWindowTitle(tr("Text Document Images")); + editor->resize(320, 480); + editor->show(); + +//! [Inserting an image using HTML] + editor->append(""); +//! [Inserting an image using HTML] + + return app.exec(); +} diff --git a/src/gui/doc/snippets/textdocument-resources/textdocument-resources.pro b/src/gui/doc/snippets/textdocument-resources/textdocument-resources.pro new file mode 100644 index 0000000000..16181f21cf --- /dev/null +++ b/src/gui/doc/snippets/textdocument-resources/textdocument-resources.pro @@ -0,0 +1 @@ +SOURCES = main.cpp diff --git a/src/gui/doc/snippets/textdocument-tables/mainwindow.cpp b/src/gui/doc/snippets/textdocument-tables/mainwindow.cpp new file mode 100644 index 0000000000..79e5f03df4 --- /dev/null +++ b/src/gui/doc/snippets/textdocument-tables/mainwindow.cpp @@ -0,0 +1,204 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "mainwindow.h" +#include "xmlwriter.h" + +MainWindow::MainWindow() +{ + QMenu *fileMenu = new QMenu(tr("&File")); + + QAction *saveAction = fileMenu->addAction(tr("&Save...")); + saveAction->setShortcut(tr("Ctrl+S")); + QAction *quitAction = fileMenu->addAction(tr("E&xit")); + quitAction->setShortcut(tr("Ctrl+Q")); + + QMenu *showMenu = new QMenu(tr("&Show")); + + QAction *showTableAction = showMenu->addAction(tr("&Table")); + + menuBar()->addMenu(fileMenu); + menuBar()->addMenu(showMenu); + + editor = new QTextEdit(); + +//! [0] //! [1] + QTextCursor cursor(editor->textCursor()); +//! [0] + cursor.movePosition(QTextCursor::Start); +//! [1] + + int rows = 11; + int columns = 4; + +//! [2] + QTextTableFormat tableFormat; + tableFormat.setBackground(QColor("#e0e0e0")); + QVector constraints; + constraints << QTextLength(QTextLength::PercentageLength, 16); + constraints << QTextLength(QTextLength::PercentageLength, 28); + constraints << QTextLength(QTextLength::PercentageLength, 28); + constraints << QTextLength(QTextLength::PercentageLength, 28); + tableFormat.setColumnWidthConstraints(constraints); +//! [3] + QTextTable *table = cursor.insertTable(rows, columns, tableFormat); +//! [2] //! [3] + + int column; + int row; + QTextTableCell cell; + QTextCursor cellCursor; + + QTextCharFormat charFormat; + charFormat.setForeground(Qt::black); + +//! [4] + cell = table->cellAt(0, 0); + cellCursor = cell.firstCursorPosition(); + cellCursor.insertText(tr("Week"), charFormat); +//! [4] + +//! [5] + for (column = 1; column < columns; ++column) { + cell = table->cellAt(0, column); + cellCursor = cell.firstCursorPosition(); + cellCursor.insertText(tr("Team %1").arg(column), charFormat); + } + + for (row = 1; row < rows; ++row) { + cell = table->cellAt(row, 0); + cellCursor = cell.firstCursorPosition(); + cellCursor.insertText(tr("%1").arg(row), charFormat); + + for (column = 1; column < columns; ++column) { + if ((row-1) % 3 == column-1) { +//! [5] //! [6] + cell = table->cellAt(row, column); + QTextCursor cellCursor = cell.firstCursorPosition(); + cellCursor.insertText(tr("On duty"), charFormat); + } +//! [6] //! [7] + } +//! [7] //! [8] + } +//! [8] + + connect(saveAction, SIGNAL(triggered()), this, SLOT(saveFile())); + connect(quitAction, SIGNAL(triggered()), this, SLOT(close())); + connect(showTableAction, SIGNAL(triggered()), this, SLOT(showTable())); + + setCentralWidget(editor); + setWindowTitle(tr("Text Document Tables")); +} + +void MainWindow::saveFile() +{ + QString fileName = QFileDialog::getSaveFileName(this, + tr("Save document as:"), "", tr("XML (*.xml)")); + + if (!fileName.isEmpty()) { + if (writeXml(fileName)) + setWindowTitle(fileName); + else + QMessageBox::warning(this, tr("Warning"), + tr("Failed to save the document."), QMessageBox::Cancel, + QMessageBox::NoButton); + } +} + +void MainWindow::showTable() +{ + QTextCursor cursor = editor->textCursor(); + QTextTable *table = cursor.currentTable(); + + if (!table) + return; + + QTableWidget *tableWidget = new QTableWidget(table->rows(), table->columns()); + +//! [9] + for (int row = 0; row < table->rows(); ++row) { + for (int column = 0; column < table->columns(); ++column) { + QTextTableCell tableCell = table->cellAt(row, column); +//! [9] + QTextFrame::iterator it; + QString text; + for (it = tableCell.begin(); !(it.atEnd()); ++it) { + QTextBlock childBlock = it.currentBlock(); + if (childBlock.isValid()) + text += childBlock.text(); + } + QTableWidgetItem *newItem = new QTableWidgetItem(text); + tableWidget->setItem(row, column, newItem); + /* +//! [10] + processTableCell(tableCell); +//! [10] + */ +//! [11] + } +//! [11] //! [12] + } +//! [12] + + tableWidget->setWindowTitle(tr("Table Contents")); + tableWidget->show(); +} + +bool MainWindow::writeXml(const QString &fileName) +{ + XmlWriter documentWriter(editor->document()); + + QDomDocument *domDocument = documentWriter.toXml(); + QFile file(fileName); + + if (file.open(QFile::WriteOnly)) { + QTextStream textStream(&file); + textStream.setCodec(QTextCodec::codecForName("UTF-8")); + + textStream << domDocument->toString(1).toUtf8(); + file.close(); + return true; + } + else + return false; +} diff --git a/src/gui/doc/snippets/textdocument-texttable/main.cpp b/src/gui/doc/snippets/textdocument-texttable/main.cpp new file mode 100644 index 0000000000..ca5338533c --- /dev/null +++ b/src/gui/doc/snippets/textdocument-texttable/main.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +int main(int argc, char * argv[]) +{ + int rows = 6; + int columns = 2; + + QApplication app(argc, argv); + QTextEdit *textEdit = new QTextEdit; + QTextCursor cursor(textEdit->textCursor()); + cursor.movePosition(QTextCursor::Start); + + QTextTableFormat tableFormat; + tableFormat.setAlignment(Qt::AlignHCenter); + tableFormat.setCellPadding(2); + tableFormat.setCellSpacing(2); + QTextTable *table = cursor.insertTable(rows, columns); + table->setFormat(tableFormat); + + QTextCharFormat boldFormat; + boldFormat.setFontWeight(QFont::Bold); + + QTextBlockFormat centerFormat; + centerFormat.setAlignment(Qt::AlignHCenter); + cursor.mergeBlockFormat(centerFormat); + + cursor = table->cellAt(0, 0).firstCursorPosition(); + cursor.insertText(("Details"), boldFormat); + + cursor = table->cellAt(1, 0).firstCursorPosition(); + cursor.insertText("Alan"); + + cursor = table->cellAt(1, 1).firstCursorPosition(); + cursor.insertText("5, Pickety Street"); + +//! [0] + table->mergeCells(0, 0, 1, 2); +//! [0] //! [1] + table->splitCell(0, 0, 1, 1); +//! [1] + + textEdit->show(); + return app.exec(); +} diff --git a/src/gui/doc/snippets/textdocumentendsnippet.cpp b/src/gui/doc/snippets/textdocumentendsnippet.cpp new file mode 100644 index 0000000000..caec20dc9b --- /dev/null +++ b/src/gui/doc/snippets/textdocumentendsnippet.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +int main(int argv, char **args) +{ + QString contentString("One\nTwp\nThree"); + + QTextDocument *doc = new QTextDocument(contentString); + +//! [0] + for (QTextBlock it = doc->begin(); it != doc->end(); it = it.next()) + cout << it.text().toStdString() << endl; +//! [0] + + return 0; +} diff --git a/src/gui/doc/snippets/transform/main.cpp b/src/gui/doc/snippets/transform/main.cpp new file mode 100644 index 0000000000..d1c600828d --- /dev/null +++ b/src/gui/doc/snippets/transform/main.cpp @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +class SimpleTransformation : public QWidget +{ + void paintEvent(QPaintEvent *); +}; + +//! [0] +void SimpleTransformation::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + painter.setPen(QPen(Qt::blue, 1, Qt::DashLine)); + painter.drawRect(0, 0, 100, 100); + + painter.rotate(45); + + painter.setFont(QFont("Helvetica", 24)); + painter.setPen(QPen(Qt::black, 1)); + painter.drawText(20, 10, "QTransform"); +} +//! [0] + +class CombinedTransformation : public QWidget +{ + void paintEvent(QPaintEvent *); +}; + +//! [1] +void CombinedTransformation::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + painter.setPen(QPen(Qt::blue, 1, Qt::DashLine)); + painter.drawRect(0, 0, 100, 100); + + QTransform transform; + transform.translate(50, 50); + transform.rotate(45); + transform.scale(0.5, 1.0); + painter.setTransform(transform); + + painter.setFont(QFont("Helvetica", 24)); + painter.setPen(QPen(Qt::black, 1)); + painter.drawText(20, 10, "QTransform"); +} +//! [1] + +class BasicOperations : public QWidget +{ + void paintEvent(QPaintEvent *); +}; + +//! [2] +void BasicOperations::paintEvent(QPaintEvent *) +{ + double pi = 3.14; + + double a = pi/180 * 45.0; + double sina = sin(a); + double cosa = cos(a); + + QTransform translationTransform(1, 0, 0, 1, 50.0, 50.0); + QTransform rotationTransform(cosa, sina, -sina, cosa, 0, 0); + QTransform scalingTransform(0.5, 0, 0, 1.0, 0, 0); + + QTransform transform; + transform = scalingTransform * rotationTransform * translationTransform; + + QPainter painter(this); + painter.setPen(QPen(Qt::blue, 1, Qt::DashLine)); + painter.drawRect(0, 0, 100, 100); + + painter.setTransform(transform); + + painter.setFont(QFont("Helvetica", 24)); + painter.setPen(QPen(Qt::black, 1)); + painter.drawText(20, 10, "QTransform"); +} +//! [2] + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + QWidget widget; + + SimpleTransformation *simpleWidget = new SimpleTransformation; + CombinedTransformation *combinedWidget = new CombinedTransformation; + BasicOperations *basicWidget = new BasicOperations; + + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(simpleWidget); + layout->addWidget(combinedWidget); + layout->addWidget(basicWidget); + widget.setLayout(layout); + + widget.show(); + widget.resize(130, 350); + return app.exec(); +} diff --git a/src/gui/doc/src/coordsys.qdoc b/src/gui/doc/src/coordsys.qdoc new file mode 100644 index 0000000000..655dbf7cf3 --- /dev/null +++ b/src/gui/doc/src/coordsys.qdoc @@ -0,0 +1,461 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms +** and conditions contained in a signed written agreement between you +** and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page coordsys.html + \title Coordinate System + \ingroup qt-graphics + \ingroup best-practices + \brief Information about the coordinate system used by the paint + system. + + The coordinate system is controlled by the QPainter + class. Together with the QPaintDevice and QPaintEngine classes, + QPainter form the basis of Qt's painting system, Arthur. QPainter + is used to perform drawing operations, QPaintDevice is an + abstraction of a two-dimensional space that can be painted on + using a QPainter, and QPaintEngine provides the interface that the + painter uses to draw onto different types of devices. + + The QPaintDevice class is the base class of objects that can be + painted: Its drawing capabilities are inherited by the QWidget, + QPixmap, QPicture, QImage, and QPrinter classes. The default + coordinate system of a paint device has its origin at the top-left + corner. The \e x values increase to the right and the \e y values + increase downwards. The default unit is one pixel on pixel-based + devices and one point (1/72 of an inch) on printers. + + The mapping of the logical QPainter coordinates to the physical + QPaintDevice coordinates are handled by QPainter's transformation + matrix, viewport and "window". The logical and physical coordinate + systems coincide by default. QPainter also supports coordinate + transformations (e.g. rotation and scaling). + + \tableofcontents + + \section1 Rendering + + \section2 Logical Representation + + The size (width and height) of a graphics primitive always + correspond to its mathematical model, ignoring the width of the + pen it is rendered with: + + \table + \row + \li \inlineimage coordinatesystem-rect.png + \li \inlineimage coordinatesystem-line.png + \row + \li QRect(1, 2, 6, 4) + \li QLine(2, 7, 6, 1) + \endtable + + \section2 Aliased Painting + + When drawing, the pixel rendering is controlled by the + QPainter::Antialiasing render hint. + + The \l {QPainter::RenderHint}{RenderHint} enum is used to specify + flags to QPainter that may or may not be respected by any given + engine. The QPainter::Antialiasing value indicates that the engine + should antialias edges of primitives if possible, i.e. smoothing + the edges by using different color intensities. + + But by default the painter is \e aliased and other rules apply: + When rendering with a one pixel wide pen the pixels will be + rendered to the \e {right and below the mathematically defined + points}. For example: + + \table + \row + \li \inlineimage coordinatesystem-rect-raster.png + \li \inlineimage coordinatesystem-line-raster.png + + \row + \li + \snippet doc/src/snippets/code/doc_src_coordsys.cpp 0 + + \li + \snippet doc/src/snippets/code/doc_src_coordsys.cpp 1 + \endtable + + When rendering with a pen with an even number of pixels, the + pixels will be rendered symetrically around the mathematical + defined points, while rendering with a pen with an odd number of + pixels, the spare pixel will be rendered to the right and below + the mathematical point as in the one pixel case. See the QRectF + diagrams below for concrete examples. + + \table + \header + \li {3,1} QRectF + \row + \li \inlineimage qrect-diagram-zero.png + \li \inlineimage qrectf-diagram-one.png + \row + \li Logical representation + \li One pixel wide pen + \row + \li \inlineimage qrectf-diagram-two.png + \li \inlineimage qrectf-diagram-three.png + \row + \li Two pixel wide pen + \li Three pixel wide pen + \endtable + + Note that for historical reasons the return value of the + QRect::right() and QRect::bottom() functions deviate from the true + bottom-right corner of the rectangle. + + QRect's \l {QRect::right()}{right()} function returns \l + {QRect::left()}{left()} + \l {QRect::width()}{width()} - 1 and the + \l {QRect::bottom()}{bottom()} function returns \l + {QRect::top()}{top()} + \l {QRect::height()}{height()} - 1. The + bottom-right green point in the diagrams shows the return + coordinates of these functions. + + We recommend that you simply use QRectF instead: The QRectF class + defines a rectangle in the plane using floating point coordinates + for accuracy (QRect uses integer coordinates), and the + QRectF::right() and QRectF::bottom() functions \e do return the + true bottom-right corner. + + Alternatively, using QRect, apply \l {QRect::x()}{x()} + \l + {QRect::width()}{width()} and \l {QRect::y()}{y()} + \l + {QRect::height()}{height()} to find the bottom-right corner, and + avoid the \l {QRect::right()}{right()} and \l + {QRect::bottom()}{bottom()} functions. + + \section2 Anti-aliased Painting + + If you set QPainter's \l {QPainter::Antialiasing}{anti-aliasing} + render hint, the pixels will be rendered symetrically on both + sides of the mathematically defined points: + + \table + \row + \li \inlineimage coordinatesystem-rect-antialias.png + \li \inlineimage coordinatesystem-line-antialias.png + \row + \li + + \snippet doc/src/snippets/code/doc_src_coordsys.cpp 2 + + \li + \snippet doc/src/snippets/code/doc_src_coordsys.cpp 3 + \endtable + + \section1 Transformations + + By default, the QPainter operates on the associated device's own + coordinate system, but it also has complete support for affine + coordinate transformations. + + You can scale the coordinate system by a given offset using the + QPainter::scale() function, you can rotate it clockwise using the + QPainter::rotate() function and you can translate it (i.e. adding + a given offset to the points) using the QPainter::translate() + function. + + \table + \row + \li \inlineimage qpainter-clock.png + \li \inlineimage qpainter-rotation.png + \li \inlineimage qpainter-scale.png + \li \inlineimage qpainter-translation.png + \row + \li nop + \li \l {QPainter::rotate()}{rotate()} + \li \l {QPainter::scale()}{scale()} + \li \l {QPainter::translate()}{translate()} + \endtable + + You can also twist the coordinate system around the origin using + the QPainter::shear() function. See the \l {painting/affine}{Affine + Transformations} example for a visualization of a sheared coordinate + system. All the transformation operations operate on QPainter's + transformation matrix that you can retrieve using the + QPainter::worldTransform() function. A matrix transforms a point + in the plane to another point. + + If you need the same transformations over and over, you can also + use QTransform objects and the QPainter::worldTransform() and + QPainter::setWorldTransform() functions. You can at any time save the + QPainter's transformation matrix by calling the QPainter::save() + function which saves the matrix on an internal stack. The + QPainter::restore() function pops it back. + + One frequent need for the transformation matrix is when reusing + the same drawing code on a variety of paint devices. Without + transformations, the results are tightly bound to the resolution + of the paint device. Printers have high resolution, e.g. 600 dots + per inch, whereas screens often have between 72 and 100 dots per + inch. + + \table 100% + \header + \li {2,1} Analog Clock Example + \row + \li \inlineimage coordinatesystem-analogclock.png + \li + The Analog Clock example shows how to draw the contents of a + custom widget using QPainter's transformation matrix. + + Qt's example directory provides a complete walk-through of the + example. Here, we will only review the example's \l + {QWidget::paintEvent()}{paintEvent()} function to see how we can + use the transformation matrix (i.e. QPainter's matrix functions) + to draw the clock's face. + + We recommend compiling and running this example before you read + any further. In particular, try resizing the window to different + sizes. + + \row + \li {2,1} + + \snippet examples/widgets/analogclock/analogclock.cpp 9 + + First, we set up the painter. We translate the coordinate system + so that point (0, 0) is in the widget's center, instead of being + at the top-left corner. We also scale the system by \c side / 100, + where \c side is either the widget's width or the height, + whichever is shortest. We want the clock to be square, even if the + device isn't. + + This will give us a 200 x 200 square area, with the origin (0, 0) + in the center, that we can draw on. What we draw will show up in + the largest possible square that will fit in the widget. + + See also the \l {Window-Viewport Conversion} section. + + \snippet examples/widgets/analogclock/analogclock.cpp 18 + + We draw the clock's hour hand by rotating the coordinate system + and calling QPainter::drawConvexPolygon(). Thank's to the + rotation, it's drawn pointed in the right direction. + + The polygon is specified as an array of alternating \e x, \e y + values, stored in the \c hourHand static variable (defined at the + beginning of the function), which corresponds to the four points + (2, 0), (0, 2), (-2, 0), and (0, -25). + + The calls to QPainter::save() and QPainter::restore() surrounding + the code guarantees that the code that follows won't be disturbed + by the transformations we've used. + + \snippet examples/widgets/analogclock/analogclock.cpp 24 + + We do the same for the clock's minute hand, which is defined by + the four points (1, 0), (0, 1), (-1, 0), and (0, -40). These + coordinates specify a hand that is thinner and longer than the + minute hand. + + \snippet examples/widgets/analogclock/analogclock.cpp 27 + + Finally, we draw the clock face, which consists of twelve short + lines at 30-degree intervals. At the end of that, the painter is + rotated in a way which isn't very useful, but we're done with + painting so that doesn't matter. + \endtable + + For a demonstation of Qt's ability to perform affine + transformations on painting operations, see the \l + {painting/affine}{Affine Transformations} example which allows the user + to experiment with the transformation operations. See also the \l + {painting/transformations}{Transformations} example which shows + how transformations influence the way that QPainter renders + graphics primitives. In particular, it shows how the order of + transformations affects the result. + + For more information about the transformation matrix, see the + QTransform documentation. + + \section1 Window-Viewport Conversion + + When drawing with QPainter, we specify points using logical + coordinates which then are converted into the physical coordinates + of the paint device. + + The mapping of the logical coordinates to the physical coordinates + are handled by QPainter's world transformation \l + {QPainter::worldTransform()}{worldTransform()} (described in the \l + Transformations section), and QPainter's \l + {QPainter::viewport()}{viewport()} and \l + {QPainter::window()}{window()}. The viewport represents the + physical coordinates specifying an arbitrary rectangle. The + "window" describes the same rectangle in logical coordinates. By + default the logical and physical coordinate systems coincide, and + are equivalent to the paint device's rectangle. + + Using window-viewport conversion you can make the logical + coordinate system fit your preferences. The mechanism can also be + used to make the drawing code independent of the paint device. You + can, for example, make the logical coordinates extend from (-50, + -50) to (50, 50) with (0, 0) in the center by calling the + QPainter::setWindow() function: + + \snippet doc/src/snippets/code/doc_src_coordsys.cpp 4 + + Now, the logical coordinates (-50,-50) correspond to the paint + device's physical coordinates (0, 0). Independent of the paint + device, your painting code will always operate on the specified + logical coordinates. + + By setting the "window" or viewport rectangle, you perform a + linear transformation of the coordinates. Note that each corner of + the "window" maps to the corresponding corner of the viewport, and + vice versa. For that reason it normally is a good idea to let the + viewport and "window" maintain the same aspect ratio to prevent + deformation: + + \snippet doc/src/snippets/code/doc_src_coordsys.cpp 5 + + If we make the logical coordinate system a square, we should also + make the viewport a square using the QPainter::setViewport() + function. In the example above we make it equivalent to the + largest square that fit into the paint device's rectangle. By + taking the paint device's size into consideration when setting the + window or viewport, it is possible to keep the drawing code + independent of the paint device. + + Note that the window-viewport conversion is only a linear + transformation, i.e. it does not perform clipping. This means that + if you paint outside the currently set "window", your painting is + still transformed to the viewport using the same linear algebraic + approach. + + \image coordinatesystem-transformations.png + + The viewport, "window" and transformation matrix determine how + logical QPainter coordinates map to the paint device's physical + coordinates. By default the world transformation matrix is the + identity matrix, and the "window" and viewport settings are + equivalent to the paint device's settings, i.e. the world, + "window" and device coordinate systems are equivalent, but as we + have seen, the systems can be manipulated using transformation + operations and window-viewport conversion. The illustration above + describes the process. + + \omit + \section1 Related Classes + + Qt's paint system, Arthur, is primarily based on the QPainter, + QPaintDevice, and QPaintEngine classes: + + \table + \header \li Class \li Description + \row + \li QPainter + \li + The QPainter class performs low-level painting on widgets and + other paint devices. QPainter can operate on any object that + inherits the QPaintDevice class, using the same code. + \row + \li QPaintDevice + \li + The QPaintDevice class is the base class of objects that can be + painted. Qt provides several devices: QWidget, QImage, QPixmap, + QPrinter and QPicture, and other devices can also be defined by + subclassing QPaintDevice. + \row + \li QPaintEngine + \li + The QPaintEngine class provides an abstract definition of how + QPainter draws to a given device on a given platform. Qt 4 + provides several premade implementations of QPaintEngine for the + different painter backends we support; it provides one paint + engine for each supported window system and painting + frameworkt. You normally don't need to use this class directly. + \endtable + + The 2D transformations of the coordinate system are specified + using the QTransform class: + + \table + \header \li Class \li Description + \row + \li QTransform + \li + A 3 x 3 transformation matrix. Use QTransform to rotate, shear, + scale, or translate the coordinate system. + \endtable + + In addition Qt provides several graphics primitive classes. Some + of these classes exist in two versions: an \c{int}-based version + and a \c{qreal}-based version. For these, the \c qreal version's + name is suffixed with an \c F. + + \table + \header \li Class \li Description + \row + \li \l{QPoint}(\l{QPointF}{F}) + \li + A single 2D point in the coordinate system. Most functions in Qt + that deal with points can accept either a QPoint, a QPointF, two + \c{int}s, or two \c{qreal}s. + \row + \li \l{QSize}(\l{QSizeF}{F}) + \li + A single 2D vector. Internally, QPoint and QSize are the same, but + a point is not the same as a size, so both classes exist. Again, + most functions accept either QSizeF, a QSize, two \c{int}s, or two + \c{qreal}s. + \row + \li \l{QRect}(\l{QRectF}{F}) + \li + A 2D rectangle. Most functions accept either a QRectF, a QRect, + four \c{int}s, or four \c {qreal}s. + \row + \li \l{QLine}(\l{QLineF}{F}) + \li + A 2D finite-length line, characterized by a start point and an end + point. + \row + \li \l{QPolygon}(\l{QPolygonF}{F}) + \li + A 2D polygon. A polygon is a vector of \c{QPoint(F)}s. If the + first and last points are the same, the polygon is closed. + \row + \li QPainterPath + \li + A vectorial specification of a 2D shape. Painter paths are the + ultimate painting primitive, in the sense that any shape + (rectange, ellipse, spline) or combination of shapes can be + expressed as a path. A path specifies both an outline and an area. + \row + \li QRegion + \li + An area in a paint device, expressed as a list of + \l{QRect}s. In general, we recommend using the vectorial + QPainterPath class instead of QRegion for specifying areas, + because QPainterPath handles painter transformations much better. + \endtable + \endomit + + \sa {Analog Clock Example}, {Transformations Example} +*/ diff --git a/src/gui/doc/src/paintsystem.qdoc b/src/gui/doc/src/paintsystem.qdoc new file mode 100644 index 0000000000..4b33e4fed3 --- /dev/null +++ b/src/gui/doc/src/paintsystem.qdoc @@ -0,0 +1,560 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms +** and conditions contained in a signed written agreement between you +** and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \group painting + \title Painting Classes + \ingroup groups + + \brief Classes that provide support for painting. + + See also this introduction to the \link coordsys.html Qt + coordinate system. \endlink +*/ + +/*! + \group painting-3D + \title Rendering in 3D + \ingroup groups + + \brief Classes that provide support for rendering in 3D. +*/ + +/*! + \page paintsystem.html + \title Paint System + \brief A system for painting on the screen or on print devices using the same API + \ingroup qt-graphics + \ingroup frameworks-technologies + \ingroup qt-basic-concepts + + + Qt's paint system enables painting on screen and print devices + using the same API, and is primarily based on the QPainter, + QPaintDevice, and QPaintEngine classes. + + QPainter is used to perform drawing operations, QPaintDevice is an + abstraction of a two-dimensional space that can be painted on + using a QPainter, and QPaintEngine provides the interface that the + painter uses to draw onto different types of devices. The + QPaintEngine class is used internally by QPainter and + QPaintDevice, and is hidden from application programmers unless + they create their own device type. + + \image paintsystem-core.png + + The main benefit of this approach is that all painting follows the + same painting pipeline making it easy to add support for new + features and providing default implementations for unsupported + ones. + + \section1 Topics + \list + \li \l{Classes for Painting} + \li \l{Paint Devices and Backends} + \li \l{Drawing and Filling} + \li \l{Coordinate System} + \li \l{Reading and Writing Image Files} + \li \l{Styling} + \li \l{Printing with Qt} + \endlist + + \section1 Classes for Painting + + These classes provide support for painting onto a paint device. + + \annotatedlist painting + + Alternatively, Qt provides the QtOpenGL module, offering classes + that makes it easy to use OpenGL in Qt applications. Among others, + the module provides an OpenGL widget class that can be used just + like any other Qt widget, except that it opens an OpenGL display + buffer where the OpenGL API can be used to render the contents. +*/ + + +/*! + \page paintsystem-devices.html + \title Paint Devices and Backends + + \contentspage The Paint System + \nextpage Drawing and Filling + + \section1 Creating a Paint Device + + The QPaintDevice class is the base class of objects that can be + painted, i.e. QPainter can draw on any QPaintDevice + subclass. QPaintDevice's drawing capabilities are currently + implemented by the QWidget, QImage, QPixmap, QGLWidget, + QGLPixelBuffer, QPicture and QPrinter subclasses. + + \image paintsystem-devices.png + + \table 100% + \row \li \b Widget + + The QWidget class is the base class of all user interface + objects. The widget is the atom of the user interface: it receives + mouse, keyboard and other events from the window system, and + paints a representation of itself on the screen. + + \row \li \b Image + + The QImage class provides a hardware-independent image + representation which is designed and optimized for I/O, and for + direct pixel access and manipulation. QImage supports several + image formats including monochrome, 8-bit, 32-bit and + alpha-blended images. + + One advantage of using QImage as a paint device is that it is + possible to guarantee the pixel exactness of any drawing operation + in a platform-independent way. Another benefit is that the + painting can be performed in another thread than the current GUI + thread. + + \row \li \b Pixmap + + The QPixmap class is an off-screen image representation which is + designed and optimized for showing images on screen. Unlike + QImage, the pixel data in a pixmap is internal and is managed by + the underlying window system, i.e. pixels can only be accessed + through QPainter functions or by converting the QPixmap to a + QImage. + + To optimize drawing with QPixmap, Qt provides the QPixmapCache + class which can be used to store temporary pixmaps that are + expensive to generate without using more storage space than the + cache limit. + + Qt also provides the QBitmap convenience class, inheriting + QPixmap. QBitmap guarantees monochrome (1-bit depth) pixmaps, and + is mainly used for creating custom QCursor and QBrush objects, + constructing QRegion objects, and for setting masks for pixmaps + and widgets. + + \row \li \b {OpenGL Widget} + + As mentioned previously, Qt provides the QtOpenGL module offering + classes that makes it easy to use OpenGL in Qt applications. For + example, the QGLWidget enables the OpenGL API for + rendering. + + But QGLWidget is also a QWidget subclass, and can be used by + QPainter as any other paint device. One huge benefit from this is + that it enables Qt to utilize the high performance of OpenGL for + most drawing operations, such as transformations and pixmap + drawing. + + \row \li \b {Pixel Buffer} + + The QtOpenGL module also provides the QGLPixelBuffer class which + inherits QPaintDevice directly. + + QGLPixelBuffer encapsulates an OpenGL pbuffer. Rendering into a + pbuffer is normally done using full hardware acceleration which + can be significantly faster than rendering into a QPixmap. + + \row \li \b {Framebuffer Object} + + The QtOpenGL module also provides the QGLFramebufferObject class + which inherits QPaintDevice directly. + + QGLFramebufferObject encapsulates an OpenGL framebuffer object. + Framebuffer objects can also be used for off-screen rendering, and + offer several advantages over pixel buffers for this purpose. + These are described in the QGLFramebufferObject class documentation. + + \row \li \b {Picture} + + The QPicture class is a paint device that records and replays + QPainter commands. A picture serializes painter commands to an IO + device in a platform-independent format. QPicture is also + resolution independent, i.e. a QPicture can be displayed on + different devices (for example svg, pdf, ps, printer and screen) + looking the same. + + Qt provides the QPicture::load() and QPicture::save() functions + as well as streaming operators for loading and saving pictures. + + \row \li \b {Printer} + + The QPrinter class is a paint device that paints on a printer. On + Windows or Mac OS X, QPrinter uses the built-in printer + drivers. On X11, QPrinter generates postscript and sends that to + lpr, lp, or another print program. QPrinter can also print to any + other QPrintEngine object. + + The QPrintEngine class defines an interface for how QPrinter + interacts with a given printing subsystem. The common case when + creating your own print engine, is to derive from both + QPaintEngine and QPrintEngine. + + The output format is by default determined by the platform the + printer is running on, but by explicitly setting the output format + to QPrinter::PdfFormat, QPrinter will generate its output as a PDF + file. + + \row \li \b {Custom Backends} + + Support for a new backend can be implemented by deriving from the + QPaintDevice class and reimplementing the virtual + QPaintDevice::paintEngine() function to tell QPainter which paint + engine should be used to draw on this particular device. To + actually be able to draw on the device, this paint engine must be + a custom paint engine created by deriving from the QPaintEngine + class. + + \endtable + + \section1 Selecting the Painting Backend + + Since Qt 4.5, it is possible to replace the paint engines and paint + devices used for widgets, pixmaps and the offscreen double buffer. By + default the backends are: + + \table + \row + \li Windows + \li Software Rasterizer + \row + \li X11 + \li X11 + \row + \li Mac OS X + \li CoreGraphics + \row + \li Embedded + \li Software Rasterizer + \endtable + + Passing a command line parameter to the application, such as, + \c{-graphicssystem raster}, specifies that Qt should use the software + rasterizer for this application. The Software rasterizer is fully + supported on all platforms. + + \code + > analogclock -graphicssystem raster + \endcode + + There is also a \c{-graphicssystem opengl} mode that uses OpenGL for + all drawing. Currently, this engine is experimental as it does not draw + everything correctly. + + Qt also supports being configured using \c {-graphicssystem + raster|opengl} in which case all applications will use the + specified graphics system for its graphics. +*/ + +/*! + \page paintsystem-drawing.html + \title Drawing and Filling + + \previouspage Paint Devices and Backends + \contentspage The Paint System + \nextpage Coordinate System + + \section1 Drawing + + QPainter provides highly optimized functions to do most of the + drawing GUI programs require. It can draw everything from simple + graphical primitives (represented by the QPoint, QLine, QRect, + QRegion and QPolygon classes) to complex shapes like vector + paths. In Qt vector paths are represented by the QPainterPath + class. QPainterPath provides a container for painting operations, + enabling graphical shapes to be constructed and reused. + + \table 100% + \row + \li \image paintsystem-painterpath.png + \li \b QPainterPath + + A painter path is an object composed of lines and curves. For + example, a rectangle is composed by lines and an ellipse is + composed by curves. + + The main advantage of painter paths over normal drawing operations + is that complex shapes only need to be created once; then they can + be drawn many times using only calls to the QPainter::drawPath() + function. + + A QPainterPath object can be used for filling, outlining, and + clipping. To generate fillable outlines for a given painter path, + use the QPainterPathStroker class. + + \endtable + + Lines and outlines are drawn using the QPen class. A pen is + defined by its style (i.e. its line-type), width, brush, how the + endpoints are drawn (cap-style) and how joins between two + connected lines are drawn (join-style). The pen's brush is a + QBrush object used to fill strokes generated with the pen, + i.e. the QBrush class defines the fill pattern. + + QPainter can also draw aligned text and pixmaps. + + When drawing text, the font is specified using the QFont class. Qt + will use the font with the specified attributes, or if no matching + font exists, Qt will use the closest matching installed font. The + attributes of the font that is actually used can be retrieved + using the QFontInfo class. In addition, the QFontMetrics class + provides the font measurements, and the QFontDatabase class + provides information about the fonts available in the underlying + window system. + + Normally, QPainter draws in a "natural" coordinate system, but it + is able to perform view and world transformations using the + QTransform class. For more information, see \l {Coordinate + System}, which also describes the rendering process, i.e. the + relation between the logical representation and the rendered + pixels, and the benefits of anti-aliased painting. + + \table 100% + \row \li + \b {Anti-Aliased Painting} + + When drawing, the pixel rendering is controlled by the + QPainter::Antialiasing render hint. The QPainter::RenderHint enum + is used to specify flags to QPainter that may or may not be + respected by any given engine. + + The QPainter::Antialiasing value indicates that the engine should + antialias edges of primitives if possible, i.e. smoothing the + edges by using different color intensities. + + \li \image paintsystem-antialiasing.png + + \endtable + + \section1 Filling + + Shapes are filled using the QBrush class. A brush is defined + by its color and its style (i.e. its fill pattern). + + Any color in Qt is represented by the QColor class which supports + the RGB, HSV and CMYK color models. QColor also support + alpha-blended outlining and filling (specifying the transparency + effect), and the class is platform and device independent (the + colors are mapped to hardware using the QColormap class). For more + information, see the QColor class documentation. + + When creating a new widget, it is recommend to use the colors in + the widget's palette rather than hard-coding specific colors. All + widgets in Qt contain a palette and use their palette to draw + themselves. A widget's palette is represented by the QPalette + class which contains color groups for each widget state. + + The available fill patterns are described by the Qt::BrushStyle + enum. These include basic patterns spanning from uniform color to + very sparse pattern, various line combinations, gradient fills and + textures. Qt provides the QGradient class to define custom + gradient fills, while texture patterns are specified using the + QPixmap class. + + \table 100% + \row + \li \image paintsystem-fancygradient.png + \li \b QGradient + + The QGradient class is used in combination with QBrush to specify + gradient fills. + + \image paintsystem-gradients.png + + Qt currently supports three types of gradient fills: Linear + gradients interpolate colors between start and end points, radial + gradients interpolate colors between a focal point and end points + on a circle surrounding it, and conical gradients interpolate + colors around a center point. + + \endtable +*/ + +/*! + \page paintsystem-images.html + \title Reading and Writing Image Files + + \previouspage Coordinate System + \contentspage The Paint System + \nextpage Styling + + The most common way to read images is through QImage and QPixmap's + constructors, or by calling the QImage::load() and QPixmap::load() + functions. In addition, Qt provides the QImageReader class which + gives more control over the process. Depending on the underlying + support in the image format, the functions provided by the class + can save memory and speed up loading of images. + + Likewise, Qt provides the QImageWriter class which supports + setting format specific options, such as the gamma level, + compression level and quality, prior to storing the image. If you + do not need such options, you can use QImage::save() or + QPixmap::save() instead. + + \table 100% + \row + \li \b QMovie + + QMovie is a convenience class for displaying animations, using the + QImageReader class internally. Once created, the QMovie class + provides various functions for both running and controlling the + given animation. + + \li \image paintsystem-movie.png + \endtable + + The QImageReader and QImageWriter classes rely on the + QImageIOHandler class which is the common image I/O interface for + all image formats in Qt. QImageIOHandler objects are used + internally by QImageReader and QImageWriter to add support for + different image formats to Qt. + + A list of the supported file formats are available through the + QImageReader::supportedImageFormats() and + QImageWriter::supportedImageFormats() functions. Qt supports + several file formats by default, and in addition new formats can + be added as plugins. The currently supported formats are listed in + the QImageReader and QImageWriter class documentation. + + Qt's plugin mechanism can also be used to write a custom image + format handler. This is done by deriving from the QImageIOHandler + class, and creating a QImageIOPlugin object which is a factory for + creating QImageIOHandler objects. When the plugin is installed, + QImageReader and QImageWriter will automatically load the plugin + and start using it. + + \section1 Rendering SVG files + + \table 100% + \row + \li \image paintsystem-svg.png + \li \b {SVG Rendering} + + Scalable Vector Graphics (SVG) is a language for describing two-dimensional + graphics and graphical applications in XML. SVG 1.1 is a W3C Recommendation + and forms the core of the current SVG developments in Qt. SVG 1.2 is the + specification currently being developed by the \l{SVG Working Group}, and it + is \l{http://www.w3.org/TR/SVG12/}{available in draft form}. + The \l{Mobile SVG Profiles} (SVG Basic and SVG Tiny) are aimed at + resource-limited devices and are part of the 3GPP platform for third generation + mobile phones. You can read more about SVG at \l{About SVG}. + + Qt supports the \l{SVG 1.2 Tiny Static Features}{static features} of + \l{SVG 1.2 Tiny}. ECMA scripts and DOM manipulation are currently not + supported. + + SVG drawings can be rendered onto any QPaintDevice subclass. This + approach gives developers the flexibility to experiment, in order + to find the best solution for each application. + + The easiest way to render SVG files is to construct a QSvgWidget and + load an SVG file using one of the QSvgWidget::load() functions. + + QSvgRenderer is the class responsible for rendering SVG files for + QSvgWidget, and it can be used directly to provide SVG support for + custom widgets. + To load an SVG file, construct a QSvgRenderer with a file name or the + contents of a file, or call QSvgRenderer::load() on an existing + renderer. If the SVG file has been loaded successfully the + QSvgRenderer::isValid() will return true. + + Once you have loaded the SVG file successfully, you can render it + with the QSvgRenderer::render() function. Note that this scheme allows + you to render SVG files on all paint devices supported by Qt, including + QWidget, QGLWidget, and QImage. See the \l{SVG Viewer Example}{SVG Viewer} + example for more details. + + \endtable +*/ + +/*! + \page paintsystem-styling.html + \title Styling + + \previouspage Reading and Writing Image Files + \contentspage The Paint System + \nextpage Printing with Qt + + Qt's built-in widgets use the QStyle class to perform nearly all + of their drawing. QStyle is an abstract base class that + encapsulates the look and feel of a GUI, and can be used to make + the widgets look exactly like the equivalent native widgets or to + give the widgets a custom look. + + Qt provides a set of QStyle subclasses that emulate the native + look of the different platforms supported by Qt (QWindowsStyle, + QMacStyle, QMotifStyle, etc.). These styles are built into the + QtGui library, other styles can be made available using Qt's + plugin mechansim. + + Most functions for drawing style elements take four arguments: + + \list + \li an enum value specifying which graphical element to draw + \li a QStyleOption object specifying how and where to render that element + \li a QPainter object that should be used to draw the element + \li a QWidget object on which the drawing is performed (optional) + \endlist + + The style gets all the information it needs to render the + graphical element from the QStyleOption class. The widget is + passed as the last argument in case the style needs it to perform + special effects (such as animated default buttons on Mac OS X), + but it isn't mandatory. In fact, QStyle can be used to draw on any + paint device (not just widgets), in which case the widget argument + is a zero pointer. + + \image paintsystem-stylepainter.png + + The paint system also provides the QStylePainter class inheriting + from QPainter. QStylePainter is a convenience class for drawing + QStyle elements inside a widget, and extends QPainter with a set + of high-level drawing functions implemented on top of QStyle's + API. The advantage of using QStylePainter is that the parameter + lists get considerably shorter. + + \table 100% + \row + \li \inlineimage paintsystem-icon.png + \li \b QIcon + + The QIcon class provides scalable icons in different modes and states. + + QIcon can generate pixmaps reflecting an icon's state, mode and + size. These pixmaps are generated from the set of pixmaps + made available to the icon, and are used by Qt widgets to show an + icon representing a particular action. + + The rendering of a QIcon object is handled by the QIconEngine + class. Each icon has a corresponding icon engine that is + responsible for drawing the icon with a requested size, mode and + state. + + \endtable + + For more information about widget styling and appearance, see the + \l{Styles and Style Aware Widgets}. +*/ diff --git a/src/gui/doc/src/qtgui.qdoc b/src/gui/doc/src/qtgui.qdoc new file mode 100644 index 0000000000..7e11aa5233 --- /dev/null +++ b/src/gui/doc/src/qtgui.qdoc @@ -0,0 +1,39 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms +** and conditions contained in a signed written agreement between you +** and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \module QtGui + \title QtGui Module + \ingroup modules + + \brief The QtGui module extends QtCore with GUI functionality. + + To include the definitions of both modules' classes, use the + following directive: + + \snippet code/doc_src_qtgui.pro 0 +*/ -- cgit v1.2.3