summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/code
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src/snippets/code')
-rw-r--r--doc/src/snippets/code/doc_src_containers.cpp275
-rw-r--r--doc/src/snippets/code/doc_src_coordsys.cpp87
-rw-r--r--doc/src/snippets/code/doc_src_examples_application.qdoc45
-rw-r--r--doc/src/snippets/code/doc_src_examples_arrowpad.cpp43
-rw-r--r--doc/src/snippets/code/doc_src_examples_arrowpad.qdoc54
-rw-r--r--doc/src/snippets/code/doc_src_examples_dropsite.qdoc43
-rw-r--r--doc/src/snippets/code/doc_src_examples_editabletreemodel.cpp48
-rw-r--r--doc/src/snippets/code/doc_src_examples_hellotr.qdoc71
-rw-r--r--doc/src/snippets/code/doc_src_examples_icons.cpp44
-rw-r--r--doc/src/snippets/code/doc_src_examples_icons.qdoc48
-rw-r--r--doc/src/snippets/code/doc_src_examples_imageviewer.cpp54
-rw-r--r--doc/src/snippets/code/doc_src_examples_imageviewer.qdoc48
-rw-r--r--doc/src/snippets/code/doc_src_examples_simpledommodel.cpp60
-rw-r--r--doc/src/snippets/code/doc_src_examples_simpletreemodel.qdoc52
-rw-r--r--doc/src/snippets/code/doc_src_examples_svgalib.qdoc43
-rw-r--r--doc/src/snippets/code/doc_src_examples_textfinder.pro46
-rw-r--r--doc/src/snippets/code/doc_src_examples_trollprint.cpp77
-rw-r--r--doc/src/snippets/code/doc_src_layout.cpp166
-rw-r--r--doc/src/snippets/code/doc_src_objecttrees.cpp60
-rw-r--r--doc/src/snippets/code/doc_src_properties.cpp132
-rw-r--r--doc/src/snippets/code/doc_src_qalgorithms.cpp354
-rw-r--r--doc/src/snippets/code/doc_src_qcache.cpp57
-rw-r--r--doc/src/snippets/code/doc_src_qiterator.cpp420
-rw-r--r--doc/src/snippets/code/doc_src_qnamespace.cpp59
-rw-r--r--doc/src/snippets/code/doc_src_qnamespace.qdoc43
-rw-r--r--doc/src/snippets/code/doc_src_qpair.cpp55
-rw-r--r--doc/src/snippets/code/doc_src_qplugin.cpp64
-rw-r--r--doc/src/snippets/code/doc_src_qplugin.pro44
-rw-r--r--doc/src/snippets/code/doc_src_qset.cpp166
-rw-r--r--doc/src/snippets/code/doc_src_qsignalspy.cpp81
-rw-r--r--doc/src/snippets/code/doc_src_qt4-mainwindow.cpp110
-rw-r--r--doc/src/snippets/code/doc_src_qt4-styles.cpp82
-rw-r--r--doc/src/snippets/code/doc_src_qtestevent.cpp51
-rw-r--r--doc/src/snippets/code/doc_src_qvarlengtharray.cpp78
-rw-r--r--doc/src/snippets/code/doc_src_resources.cpp54
-rw-r--r--doc/src/snippets/code/doc_src_resources.qdoc65
-rw-r--r--doc/src/snippets/code/doc_src_sql-driver.cpp82
-rw-r--r--doc/src/snippets/code/doc_src_sql-driver.qdoc235
-rw-r--r--doc/src/snippets/code/doc_src_styles.cpp134
-rw-r--r--doc/src/snippets/code/doc_src_stylesheet.cpp140
-rw-r--r--doc/src/snippets/code/doc_src_stylesheet.qdoc1866
-rw-r--r--doc/src/snippets/code/src.gui.text.qtextdocumentwriter.cpp45
-rw-r--r--doc/src/snippets/code/src.qdbus.qdbuspendingcall.cpp65
-rw-r--r--doc/src/snippets/code/src.qdbus.qdbuspendingreply.cpp63
-rw-r--r--doc/src/snippets/code/src_corelib_codecs_qtextcodec.cpp75
-rw-r--r--doc/src/snippets/code/src_corelib_codecs_qtextcodecplugin.cpp56
-rw-r--r--doc/src/snippets/code/src_corelib_concurrent_qfuture.cpp64
-rw-r--r--doc/src/snippets/code/src_corelib_concurrent_qfuturesynchronizer.cpp53
-rw-r--r--doc/src/snippets/code/src_corelib_concurrent_qfuturewatcher.cpp50
-rw-r--r--doc/src/snippets/code/src_corelib_concurrent_qtconcurrentexception.cpp75
-rw-r--r--doc/src/snippets/code/src_corelib_concurrent_qtconcurrentfilter.cpp171
-rw-r--r--doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp184
-rw-r--r--doc/src/snippets/code/src_corelib_concurrent_qtconcurrentrun.cpp98
-rw-r--r--doc/src/snippets/code/src_corelib_concurrent_qthreadpool.cpp53
-rw-r--r--doc/src/snippets/code/src_corelib_global_qglobal.cpp557
-rw-r--r--doc/src/snippets/code/src_corelib_io_qabstractfileengine.cpp120
-rw-r--r--doc/src/snippets/code/src_corelib_io_qdatastream.cpp121
-rw-r--r--doc/src/snippets/code/src_corelib_io_qdir.cpp175
-rw-r--r--doc/src/snippets/code/src_corelib_io_qdiriterator.cpp52
-rw-r--r--doc/src/snippets/code/src_corelib_io_qfile.cpp75
-rw-r--r--doc/src/snippets/code/src_corelib_io_qfileinfo.cpp146
-rw-r--r--doc/src/snippets/code/src_corelib_io_qiodevice.cpp99
-rw-r--r--doc/src/snippets/code/src_corelib_io_qprocess.cpp134
-rw-r--r--doc/src/snippets/code/src_corelib_io_qsettings.cpp316
-rw-r--r--doc/src/snippets/code/src_corelib_io_qtemporaryfile.cpp53
-rw-r--r--doc/src/snippets/code/src_corelib_io_qtextstream.cpp129
-rw-r--r--doc/src/snippets/code/src_corelib_io_qurl.cpp87
-rw-r--r--doc/src/snippets/code/src_corelib_kernel_qabstracteventdispatcher.cpp43
-rw-r--r--doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp123
-rw-r--r--doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp126
-rw-r--r--doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp136
-rw-r--r--doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp114
-rw-r--r--doc/src/snippets/code/src_corelib_kernel_qmimedata.cpp108
-rw-r--r--doc/src/snippets/code/src_corelib_kernel_qobject.cpp448
-rw-r--r--doc/src/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp61
-rw-r--r--doc/src/snippets/code/src_corelib_kernel_qtimer.cpp52
-rw-r--r--doc/src/snippets/code/src_corelib_kernel_qvariant.cpp136
-rw-r--r--doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp84
-rw-r--r--doc/src/snippets/code/src_corelib_plugin_quuid.cpp44
-rw-r--r--doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp55
-rw-r--r--doc/src/snippets/code/src_corelib_thread_qatomic.cpp98
-rw-r--r--doc/src/snippets/code/src_corelib_thread_qmutex.cpp193
-rw-r--r--doc/src/snippets/code/src_corelib_thread_qmutexpool.cpp61
-rw-r--r--doc/src/snippets/code/src_corelib_thread_qreadwritelock.cpp109
-rw-r--r--doc/src/snippets/code/src_corelib_thread_qsemaphore.cpp73
-rw-r--r--doc/src/snippets/code/src_corelib_thread_qthread.cpp56
-rw-r--r--doc/src/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp89
-rw-r--r--doc/src/snippets/code/src_corelib_tools_qbitarray.cpp176
-rw-r--r--doc/src/snippets/code/src_corelib_tools_qbytearray.cpp421
-rw-r--r--doc/src/snippets/code/src_corelib_tools_qdatetime.cpp146
-rw-r--r--doc/src/snippets/code/src_corelib_tools_qeasingcurve.cpp44
-rw-r--r--doc/src/snippets/code/src_corelib_tools_qhash.cpp299
-rw-r--r--doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp204
-rw-r--r--doc/src/snippets/code/src_corelib_tools_qlistdata.cpp267
-rw-r--r--doc/src/snippets/code/src_corelib_tools_qlocale.cpp95
-rw-r--r--doc/src/snippets/code/src_corelib_tools_qmap.cpp313
-rw-r--r--doc/src/snippets/code/src_corelib_tools_qpoint.cpp149
-rw-r--r--doc/src/snippets/code/src_corelib_tools_qqueue.cpp48
-rw-r--r--doc/src/snippets/code/src_corelib_tools_qrect.cpp50
-rw-r--r--doc/src/snippets/code/src_corelib_tools_qregexp.cpp224
-rw-r--r--doc/src/snippets/code/src_corelib_tools_qscopedpointer.cpp138
-rw-r--r--doc/src/snippets/code/src_corelib_tools_qsize.cpp136
-rw-r--r--doc/src/snippets/code/src_corelib_tools_qstring.cpp87
-rw-r--r--doc/src/snippets/code/src_corelib_tools_qtimeline.cpp55
-rw-r--r--doc/src/snippets/code/src_corelib_tools_qvector.cpp183
-rw-r--r--doc/src/snippets/code/src_corelib_xml_qxmlstream.cpp67
-rw-r--r--doc/src/snippets/code/src_gui_accessible_qaccessible.cpp52
-rw-r--r--doc/src/snippets/code/src_gui_dialogs_qabstractprintdialog.cpp46
-rw-r--r--doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp131
-rw-r--r--doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp85
-rw-r--r--doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp148
-rw-r--r--doc/src/snippets/code/src_gui_dialogs_qwizard.cpp80
-rw-r--r--doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp83
-rw-r--r--doc/src/snippets/code/src_gui_embedded_qcopchannel_qws.cpp66
-rw-r--r--doc/src/snippets/code/src_gui_embedded_qmouse_qws.cpp44
-rw-r--r--doc/src/snippets/code/src_gui_embedded_qmousetslib_qws.cpp49
-rw-r--r--doc/src/snippets/code/src_gui_embedded_qscreen_qws.cpp48
-rw-r--r--doc/src/snippets/code/src_gui_embedded_qtransportauth_qws.cpp87
-rw-r--r--doc/src/snippets/code/src_gui_embedded_qwindowsystem_qws.cpp85
-rw-r--r--doc/src/snippets/code/src_gui_graphicsview_qgraphicsgridlayout.cpp53
-rw-r--r--doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp278
-rw-r--r--doc/src/snippets/code/src_gui_graphicsview_qgraphicslinearlayout.cpp53
-rw-r--r--doc/src/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp87
-rw-r--r--doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp122
-rw-r--r--doc/src/snippets/code/src_gui_graphicsview_qgraphicssceneevent.cpp45
-rw-r--r--doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp132
-rw-r--r--doc/src/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp66
-rw-r--r--doc/src/snippets/code/src_gui_image_qbitmap.cpp44
-rw-r--r--doc/src/snippets/code/src_gui_image_qicon.cpp71
-rw-r--r--doc/src/snippets/code/src_gui_image_qimage.cpp82
-rw-r--r--doc/src/snippets/code/src_gui_image_qimagereader.cpp66
-rw-r--r--doc/src/snippets/code/src_gui_image_qimagewriter.cpp59
-rw-r--r--doc/src/snippets/code/src_gui_image_qmovie.cpp53
-rw-r--r--doc/src/snippets/code/src_gui_image_qpixmap.cpp58
-rw-r--r--doc/src/snippets/code/src_gui_image_qpixmapcache.cpp61
-rw-r--r--doc/src/snippets/code/src_gui_image_qpixmapfilter.cpp62
-rw-r--r--doc/src/snippets/code/src_gui_itemviews_qabstractitemview.cpp58
-rw-r--r--doc/src/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp63
-rw-r--r--doc/src/snippets/code/src_gui_itemviews_qitemeditorfactory.cpp63
-rw-r--r--doc/src/snippets/code/src_gui_itemviews_qitemselectionmodel.cpp50
-rw-r--r--doc/src/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp82
-rw-r--r--doc/src/snippets/code/src_gui_itemviews_qtablewidget.cpp45
-rw-r--r--doc/src/snippets/code/src_gui_itemviews_qtreewidget.cpp48
-rw-r--r--doc/src/snippets/code/src_gui_kernel_qaction.cpp49
-rw-r--r--doc/src/snippets/code/src_gui_kernel_qapplication.cpp183
-rw-r--r--doc/src/snippets/code/src_gui_kernel_qapplication_x11.cpp45
-rw-r--r--doc/src/snippets/code/src_gui_kernel_qclipboard.cpp53
-rw-r--r--doc/src/snippets/code/src_gui_kernel_qevent.cpp54
-rw-r--r--doc/src/snippets/code/src_gui_kernel_qformlayout.cpp76
-rw-r--r--doc/src/snippets/code/src_gui_kernel_qkeysequence.cpp59
-rw-r--r--doc/src/snippets/code/src_gui_kernel_qlayout.cpp67
-rw-r--r--doc/src/snippets/code/src_gui_kernel_qlayoutitem.cpp53
-rw-r--r--doc/src/snippets/code/src_gui_kernel_qshortcut.cpp55
-rw-r--r--doc/src/snippets/code/src_gui_kernel_qshortcutmap.cpp43
-rw-r--r--doc/src/snippets/code/src_gui_kernel_qsound.cpp49
-rw-r--r--doc/src/snippets/code/src_gui_kernel_qwidget.cpp137
-rw-r--r--doc/src/snippets/code/src_gui_painting_qbrush.cpp51
-rw-r--r--doc/src/snippets/code/src_gui_painting_qcolor.cpp49
-rw-r--r--doc/src/snippets/code/src_gui_painting_qdrawutil.cpp98
-rw-r--r--doc/src/snippets/code/src_gui_painting_qmatrix.cpp62
-rw-r--r--doc/src/snippets/code/src_gui_painting_qpainter.cpp259
-rw-r--r--doc/src/snippets/code/src_gui_painting_qpainterpath.cpp149
-rw-r--r--doc/src/snippets/code/src_gui_painting_qpen.cpp81
-rw-r--r--doc/src/snippets/code/src_gui_painting_qregion.cpp53
-rw-r--r--doc/src/snippets/code/src_gui_painting_qregion_unix.cpp54
-rw-r--r--doc/src/snippets/code/src_gui_painting_qtransform.cpp82
-rw-r--r--doc/src/snippets/code/src_gui_qproxystyle.cpp85
-rw-r--r--doc/src/snippets/code/src_gui_styles_qstyle.cpp48
-rw-r--r--doc/src/snippets/code/src_gui_styles_qstyleoption.cpp54
-rw-r--r--doc/src/snippets/code/src_gui_text_qfont.cpp67
-rw-r--r--doc/src/snippets/code/src_gui_text_qfontmetrics.cpp54
-rw-r--r--doc/src/snippets/code/src_gui_text_qsyntaxhighlighter.cpp126
-rw-r--r--doc/src/snippets/code/src_gui_text_qtextcursor.cpp80
-rw-r--r--doc/src/snippets/code/src_gui_text_qtextdocument.cpp50
-rw-r--r--doc/src/snippets/code/src_gui_text_qtextlayout.cpp62
-rw-r--r--doc/src/snippets/code/src_gui_util_qcompleter.cpp63
-rw-r--r--doc/src/snippets/code/src_gui_util_qdesktopservices.cpp60
-rw-r--r--doc/src/snippets/code/src_gui_util_qundostack.cpp109
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qabstractbutton.cpp60
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qabstractspinbox.cpp48
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qcalendarwidget.cpp79
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qcheckbox.cpp43
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qdatetimeedit.cpp79
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qdockwidget.cpp48
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qframe.cpp48
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qgroupbox.cpp43
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qlabel.cpp64
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qlineedit.cpp50
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp59
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qmenu.cpp77
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qmenubar.cpp48
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qplaintextedit.cpp55
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qpushbutton.cpp43
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qradiobutton.cpp43
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qrubberband.cpp62
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qscrollarea.cpp49
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qspinbox.cpp80
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qsplashscreen.cpp55
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qsplitter.cpp47
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qstatusbar.cpp43
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qtextbrowser.cpp44
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qtextedit.cpp60
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qvalidator.cpp135
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qworkspace.cpp48
-rw-r--r--doc/src/snippets/code/src_network_access_qftp.cpp99
-rw-r--r--doc/src/snippets/code/src_network_access_qhttp.cpp125
-rw-r--r--doc/src/snippets/code/src_network_access_qhttpmultipart.cpp67
-rw-r--r--doc/src/snippets/code/src_network_access_qhttppart.cpp65
-rw-r--r--doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp79
-rw-r--r--doc/src/snippets/code/src_network_access_qnetworkdiskcache.cpp64
-rw-r--r--doc/src/snippets/code/src_network_access_qnetworkreply.cpp50
-rw-r--r--doc/src/snippets/code/src_network_access_qnetworkrequest.cpp43
-rw-r--r--doc/src/snippets/code/src_network_bearer_qnetworkconfigmanager.cpp48
-rw-r--r--doc/src/snippets/code/src_network_kernel_qhostaddress.cpp48
-rw-r--r--doc/src/snippets/code/src_network_kernel_qhostinfo.cpp90
-rw-r--r--doc/src/snippets/code/src_network_kernel_qnetworkproxy.cpp54
-rw-r--r--doc/src/snippets/code/src_network_socket_qabstractsocket.cpp70
-rw-r--r--doc/src/snippets/code/src_network_socket_qlocalsocket_unix.cpp52
-rw-r--r--doc/src/snippets/code/src_network_socket_qnativesocketengine.cpp61
-rw-r--r--doc/src/snippets/code/src_network_socket_qtcpserver.cpp43
-rw-r--r--doc/src/snippets/code/src_network_socket_qudpsocket.cpp65
-rw-r--r--doc/src/snippets/code/src_network_ssl_qsslcertificate.cpp46
-rw-r--r--doc/src/snippets/code/src_network_ssl_qsslconfiguration.cpp45
-rw-r--r--doc/src/snippets/code/src_network_ssl_qsslsocket.cpp107
-rw-r--r--doc/src/snippets/code/src_opengl_qgl.cpp172
-rw-r--r--doc/src/snippets/code/src_opengl_qglcolormap.cpp61
-rw-r--r--doc/src/snippets/code/src_opengl_qglpixelbuffer.cpp59
-rw-r--r--doc/src/snippets/code/src_opengl_qglshaderprogram.cpp94
-rw-r--r--doc/src/snippets/code/src_qdbus_qdbusabstractinterface.cpp60
-rw-r--r--doc/src/snippets/code/src_qdbus_qdbusargument.cpp191
-rw-r--r--doc/src/snippets/code/src_qdbus_qdbuscontext.cpp72
-rw-r--r--doc/src/snippets/code/src_qdbus_qdbusinterface.cpp51
-rw-r--r--doc/src/snippets/code/src_qdbus_qdbusmetatype.cpp44
-rw-r--r--doc/src/snippets/code/src_qdbus_qdbusreply.cpp54
-rw-r--r--doc/src/snippets/code/src_qtestlib_qtestcase.cpp250
-rw-r--r--doc/src/snippets/code/src_sql_kernel_qsqldatabase.cpp135
-rw-r--r--doc/src/snippets/code/src_sql_kernel_qsqldriver.cpp64
-rw-r--r--doc/src/snippets/code/src_sql_kernel_qsqlerror.cpp46
-rw-r--r--doc/src/snippets/code/src_sql_kernel_qsqlindex.cpp48
-rw-r--r--doc/src/snippets/code/src_sql_kernel_qsqlquery.cpp80
-rw-r--r--doc/src/snippets/code/src_sql_kernel_qsqlresult.cpp85
-rw-r--r--doc/src/snippets/code/src_sql_models_qsqlquerymodel.cpp52
-rw-r--r--doc/src/snippets/code/src_xml_dom_qdom.cpp218
-rw-r--r--doc/src/snippets/code/src_xml_sax_qxml.cpp43
244 files changed, 24397 insertions, 0 deletions
diff --git a/doc/src/snippets/code/doc_src_containers.cpp b/doc/src/snippets/code/doc_src_containers.cpp
new file mode 100644
index 0000000000..fa300f916b
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_containers.cpp
@@ -0,0 +1,275 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 Employee
+{
+public:
+ Employee() {}
+ Employee(const Employee &other);
+
+ Employee &operator=(const Employee &other);
+
+private:
+ QString myName;
+ QDate myDateOfBirth;
+};
+//! [0]
+
+
+//! [1]
+QList<QString> list;
+list << "A" << "B" << "C" << "D";
+
+QListIterator<QString> i(list);
+while (i.hasNext())
+ qDebug() << i.next();
+//! [1]
+
+
+//! [2]
+QListIterator<QString> i(list);
+i.toBack();
+while (i.hasPrevious())
+ qDebug() << i.previous();
+//! [2]
+
+
+//! [3]
+QMutableListIterator<int> i(list);
+while (i.hasNext()) {
+ if (i.next() % 2 != 0)
+ i.remove();
+}
+//! [3]
+
+
+//! [4]
+QMutableListIterator<int> i(list);
+i.toBack();
+while (i.hasPrevious()) {
+ if (i.previous() % 2 != 0)
+ i.remove();
+}
+//! [4]
+
+
+//! [5]
+QMutableListIterator<int> i(list);
+while (i.hasNext()) {
+ if (i.next() > 128)
+ i.setValue(128);
+}
+//! [5]
+
+
+//! [6]
+QMutableListIterator<int> i(list);
+while (i.hasNext())
+ i.next() *= 2;
+//! [6]
+
+
+//! [7]
+QMap<QString, QString> map;
+map.insert("Paris", "France");
+map.insert("Guatemala City", "Guatemala");
+map.insert("Mexico City", "Mexico");
+map.insert("Moscow", "Russia");
+...
+
+QMutableMapIterator<QString, QString> i(map);
+while (i.hasNext()) {
+ if (i.next().key().endsWith("City"))
+ i.remove();
+}
+//! [7]
+
+
+//! [8]
+QMap<int, QWidget *> map;
+QHash<int, QWidget *> hash;
+
+QMapIterator<int, QWidget *> i(map);
+while (i.hasNext()) {
+ i.next();
+ hash.insert(i.key(), i.value());
+}
+//! [8]
+
+
+//! [9]
+QMutableMapIterator<int, QWidget *> i(map);
+while (i.findNext(widget))
+ i.remove();
+//! [9]
+
+
+//! [10]
+QList<QString> list;
+list << "A" << "B" << "C" << "D";
+
+QList<QString>::iterator i;
+for (i = list.begin(); i != list.end(); ++i)
+ *i = (*i).toLower();
+//! [10]
+
+
+//! [11]
+QList<QString> list;
+list << "A" << "B" << "C" << "D";
+
+QList<QString>::iterator i = list.end();
+while (i != list.begin()) {
+ --i;
+ *i = (*i).toLower();
+}
+//! [11]
+
+
+//! [12]
+QList<QString>::const_iterator i;
+for (i = list.constBegin(); i != list.constEnd(); ++i)
+ qDebug() << *i;
+//! [12]
+
+
+//! [13]
+QMap<int, int> map;
+...
+QMap<int, int>::const_iterator i;
+for (i = map.constBegin(); i != map.constEnd(); ++i)
+ qDebug() << i.key() << ":" << i.value();
+//! [13]
+
+
+//! [14]
+// RIGHT
+const QList<int> sizes = splitter->sizes();
+QList<int>::const_iterator i;
+for (i = sizes.begin(); i != sizes.end(); ++i)
+ ...
+
+// WRONG
+QList<int>::const_iterator i;
+for (i = splitter->sizes().begin();
+ i != splitter->sizes().end(); ++i)
+ ...
+//! [14]
+
+
+//! [15]
+QLinkedList<QString> list;
+...
+QString str;
+foreach (str, list)
+ qDebug() << str;
+//! [15]
+
+
+//! [16]
+QLinkedList<QString> list;
+...
+QLinkedListIterator<QString> i(list);
+while (i.hasNext())
+ qDebug() << i.next();
+//! [16]
+
+
+//! [17]
+QLinkedList<QString> list;
+...
+foreach (const QString &str, list)
+ qDebug() << str;
+//! [17]
+
+
+//! [18]
+QLinkedList<QString> list;
+...
+foreach (const QString &str, list) {
+ if (str.isEmpty())
+ break;
+ qDebug() << str;
+}
+//! [18]
+
+
+//! [19]
+QMap<QString, int> map;
+...
+foreach (const QString &str, map.keys())
+ qDebug() << str << ":" << map.value(str);
+//! [19]
+
+
+//! [20]
+QMultiMap<QString, int> map;
+...
+foreach (const QString &str, map.uniqueKeys()) {
+ foreach (int i, map.values(str))
+ qDebug() << str << ":" << i;
+}
+//! [20]
+
+
+//! [21]
+forever {
+ ...
+}
+//! [21]
+
+
+//! [22]
+CONFIG += no_keywords
+//! [22]
+
+
+//! [23]
+QString onlyLetters(const QString &in)
+{
+ QString out;
+ for (int j = 0; j < in.size(); ++j) {
+ if (in[j].isLetter())
+ out += in[j];
+ }
+ return out;
+}
+//! [23]
diff --git a/doc/src/snippets/code/doc_src_coordsys.cpp b/doc/src/snippets/code/doc_src_coordsys.cpp
new file mode 100644
index 0000000000..1ebb215941
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_coordsys.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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.setPen(Qt::darkGreen);
+painter.drawRect(1, 2, 6, 4);
+//! [0]
+
+
+//! [1]
+QPainter painter(this);
+
+painter.setPen(Qt::darkGreen);
+painter.drawLine(2, 7, 6, 1);
+//! [1]
+
+
+//! [2]
+QPainter painter(this);
+painter.setRenderHint(
+ QPainter::Antialiasing);
+painter.setPen(Qt::darkGreen);
+painter.drawRect(1, 2, 6, 4);
+//! [2]
+
+
+//! [3]
+QPainter painter(this);
+painter.setRenderHint(
+ QPainter::Antialiasing);
+painter.setPen(Qt::darkGreen);
+painter.drawLine(2, 7, 6, 1);
+//! [3]
+
+
+//! [4]
+QPainter painter(this);
+painter.setWindow(QRect(-50, -50, 100, 100));
+//! [4]
+
+
+//! [5]
+int side = qMin(width(), height())
+int x = (width() - side / 2);
+int y = (height() - side / 2);
+
+painter.setViewport(x, y, side, side);
+//! [5]
diff --git a/doc/src/snippets/code/doc_src_examples_application.qdoc b/doc/src/snippets/code/doc_src_examples_application.qdoc
new file mode 100644
index 0000000000..08e0747695
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_examples_application.qdoc
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+application -style=windows
+application -style=motif
+application -style=cde
+//! [0]
diff --git a/doc/src/snippets/code/doc_src_examples_arrowpad.cpp b/doc/src/snippets/code/doc_src_examples_arrowpad.cpp
new file mode 100644
index 0000000000..c834b9ff26
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_examples_arrowpad.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+qApp->translate("ArrowPad", x)
+//! [0]
diff --git a/doc/src/snippets/code/doc_src_examples_arrowpad.qdoc b/doc/src/snippets/code/doc_src_examples_arrowpad.qdoc
new file mode 100644
index 0000000000..ee3c36784f
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_examples_arrowpad.qdoc
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+lrelease arrowpad.pro
+//! [1]
+
+
+//! [2]
+export LANG=fr
+setenv LANG fr
+//! [2]
+
+
+//! [3]
+set LANG=fr
+//! [3]
diff --git a/doc/src/snippets/code/doc_src_examples_dropsite.qdoc b/doc/src/snippets/code/doc_src_examples_dropsite.qdoc
new file mode 100644
index 0000000000..d7bffc0227
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_examples_dropsite.qdoc
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+foreach(variable, container)
+//! [0]
diff --git a/doc/src/snippets/code/doc_src_examples_editabletreemodel.cpp b/doc/src/snippets/code/doc_src_examples_editabletreemodel.cpp
new file mode 100644
index 0000000000..a69a7bf772
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_examples_editabletreemodel.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QVariant a = model->index(0, 0, QModelIndex()).data();
+//! [0]
+
+
+//! [1]
+QVariant b = model->index(1, 0, QModelIndex()).data();
+//! [1]
diff --git a/doc/src/snippets/code/doc_src_examples_hellotr.qdoc b/doc/src/snippets/code/doc_src_examples_hellotr.qdoc
new file mode 100644
index 0000000000..9dbcb0af45
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_examples_hellotr.qdoc
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+lupdate -verbose hellotr.pro
+//! [0]
+
+
+//! [1]
+<!DOCTYPE TS><TS>
+<context>
+ <name>QPushButton</name>
+ <message>
+ <source>Hello world!</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
+//! [1]
+
+
+//! [2]
+linguist hellotr_la.ts
+//! [2]
+
+
+//! [3]
+<translation type='unfinished'></translation>
+//! [3]
+
+
+//! [4]
+<translation>Orbis, te saluto!</translation>
+//! [4]
diff --git a/doc/src/snippets/code/doc_src_examples_icons.cpp b/doc/src/snippets/code/doc_src_examples_icons.cpp
new file mode 100644
index 0000000000..411c49fb8d
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_examples_icons.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+if (!condition)
+ qFatal("ASSERT: "condition" in file ...");
+//! [0]
diff --git a/doc/src/snippets/code/doc_src_examples_icons.qdoc b/doc/src/snippets/code/doc_src_examples_icons.qdoc
new file mode 100644
index 0000000000..8ca57511f7
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_examples_icons.qdoc
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+qmake "CONFIG += debug" icons.pro
+//! [1]
+
+
+//! [2]
+qmake "CONFIG += release" icons.pro
+//! [2]
diff --git a/doc/src/snippets/code/doc_src_examples_imageviewer.cpp b/doc/src/snippets/code/doc_src_examples_imageviewer.cpp
new file mode 100644
index 0000000000..c86f8ace40
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_examples_imageviewer.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+imageLabel->resize(imageLabel->pixmap()->size());
+//! [0]
+
+
+//! [1]
+if (!imageLabel->pixmap())
+ qFatal("ASSERT: "imageLabel->pixmap()" in file ...");
+//! [1]
+
+
+//! [4]
+scrollBar->setValue(int(factor * scrollBar->value()));
+//! [4]
diff --git a/doc/src/snippets/code/doc_src_examples_imageviewer.qdoc b/doc/src/snippets/code/doc_src_examples_imageviewer.qdoc
new file mode 100644
index 0000000000..1870385de7
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_examples_imageviewer.qdoc
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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$
+**
+****************************************************************************/
+
+//! [2]
+qmake "CONFIG += debug" foo.pro
+//! [2]
+
+
+//! [3]
+qmake "CONFIG += release" foo.pro
+//! [3]
diff --git a/doc/src/snippets/code/doc_src_examples_simpledommodel.cpp b/doc/src/snippets/code/doc_src_examples_simpledommodel.cpp
new file mode 100644
index 0000000000..1abcdc21cc
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_examples_simpledommodel.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+// file is an open QFile object.
+QDomDocument document;
+if (document.setContent(&file)) {
+
+ QDomElement documentElement = document.documentElement();
+ QString text;
+ QDomNode node = documentElement.firstChild();
+
+ while (!node.isNull()) {
+ if (node.isText())
+ text += node.nodeValue();
+ else if (node.hasChildNodes()) {
+ // Examine the node's children and read any text found.
+ ...
+ }
+ node = node.nextSibling();
+ }
+}
+//! [0]
diff --git a/doc/src/snippets/code/doc_src_examples_simpletreemodel.qdoc b/doc/src/snippets/code/doc_src_examples_simpletreemodel.qdoc
new file mode 100644
index 0000000000..1084d238e7
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_examples_simpletreemodel.qdoc
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+Getting Started How to familiarize yourself with Qt Designer
+ Launching Designer Running the Qt Designer application
+ The User Interface How to interact with Qt Designer
+//! [0]
+
+
+//! [1]
+Connection Editing Mode Connecting widgets together with signals and slots
+ Connecting Objects Making connections in Qt Designer
+ Editing Connections Changing existing connections
+//! [1]
diff --git a/doc/src/snippets/code/doc_src_examples_svgalib.qdoc b/doc/src/snippets/code/doc_src_examples_svgalib.qdoc
new file mode 100644
index 0000000000..3c34818662
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_examples_svgalib.qdoc
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+myApplication -qws -display svgalib
+//! [0]
diff --git a/doc/src/snippets/code/doc_src_examples_textfinder.pro b/doc/src/snippets/code/doc_src_examples_textfinder.pro
new file mode 100644
index 0000000000..cdc2366b57
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_examples_textfinder.pro
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+CONFIG += uitools
+HEADERS = textfinder.h
+RESOURCES = textfinder.qrc
+SOURCES = textfinder.cpp main.cpp
+#! [0]
diff --git a/doc/src/snippets/code/doc_src_examples_trollprint.cpp b/doc/src/snippets/code/doc_src_examples_trollprint.cpp
new file mode 100644
index 0000000000..f7b8f48f3d
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_examples_trollprint.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+twoSidedEnabledRadio = new QRadioButton(tr("Enabled", "two-sided"));
+twoSidedDisabledRadio = new QRadioButton(tr("Disabled", "two-sided"));
+//! [0]
+
+
+//! [1]
+colorsEnabledRadio = new QRadioButton(tr("Enabled", "colors"), colors);
+colorsDisabledRadio = new QRadioButton(tr("Disabled", "colors"), colors);
+//! [1]
+
+
+//! [2]
+/*
+ TRANSLATOR MainWindow
+
+ In this application the whole application is a MainWindow.
+ Choose Help|About from the menu bar to see some text
+ belonging to MainWindow.
+
+ ...
+*/
+//! [2]
+
+
+//! [3]
+/*
+ TRANSLATOR ZClientErrorDialog
+
+ Choose Client|Edit to reach the Client Edit dialog, then choose
+ Client Specification from the drop down list at the top and pick
+ client Bartel Leendert van der Waerden. Now check the Profile
+ checkbox and then click the Start Processing button. You should
+ now see a pop up window with the text "Error: Name too long!".
+ This window is a ZClientErrorDialog.
+*/
+//! [3]
diff --git a/doc/src/snippets/code/doc_src_layout.cpp b/doc/src/snippets/code/doc_src_layout.cpp
new file mode 100644
index 0000000000..47db36bb3a
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_layout.cpp
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+#ifndef CARD_H
+#define CARD_H
+
+#include <QtGui>
+#include <QList>
+
+class CardLayout : public QLayout
+{
+public:
+ CardLayout(QWidget *parent, int dist): QLayout(parent, 0, dist) {}
+ CardLayout(QLayout *parent, int dist): QLayout(parent, dist) {}
+ CardLayout(int dist): QLayout(dist) {}
+ ~CardLayout();
+
+ void addItem(QLayoutItem *item);
+ QSize sizeHint() const;
+ QSize minimumSize() const;
+ QLayoutItem *count() const;
+ QLayoutItem *itemAt(int) const;
+ QLayoutItem *takeAt(int);
+ void setGeometry(const QRect &rect);
+
+private:
+ QList<QLayoutItem*> list;
+};
+#endif
+//! [0]
+
+
+//! [1]
+//#include "card.h"
+//! [1]
+
+//! [2]
+QLayoutItem *CardLayout::count() const
+{
+ // QList::size() returns the number of QLayoutItems in the list
+ return list.size();
+}
+//! [2]
+
+//! [3]
+QLayoutItem *CardLayout::itemAt(int idx) const
+{
+ // QList::value() performs index checking, and returns 0 if we are
+ // outside the valid range
+ return list.value(idx);
+}
+
+QLayoutItem *CardLayout::takeAt(int idx)
+{
+ // QList::take does not do index checking
+ return idx >= 0 && idx < list.size() ? list.takeAt(idx) : 0;
+}
+//! [3]
+
+
+//! [4]
+void CardLayout::addItem(QLayoutItem *item)
+{
+ list.append(item);
+}
+//! [4]
+
+
+//! [5]
+CardLayout::~CardLayout()
+{
+ QLayoutItem *item;
+ while ((item = takeAt(0)))
+ delete item;
+}
+//! [5]
+
+
+//! [6]
+void CardLayout::setGeometry(const QRect &r)
+{
+ QLayout::setGeometry(r);
+
+ if (list.size() == 0)
+ return;
+
+ int w = r.width() - (list.count() - 1) * spacing();
+ int h = r.height() - (list.count() - 1) * spacing();
+ int i = 0;
+ while (i < list.size()) {
+ QLayoutItem *o = list.at(i);
+ QRect geom(r.x() + i * spacing(), r.y() + i * spacing(), w, h);
+ o->setGeometry(geom);
+ ++i;
+ }
+}
+//! [6]
+
+
+//! [7]
+QSize CardLayout::sizeHint() const
+{
+ QSize s(0,0);
+ int n = list.count();
+ if (n > 0)
+ s = QSize(100,70); //start with a nice default size
+ int i = 0;
+ while (i < n) {
+ QLayoutItem *o = list.at(i);
+ s = s.expandedTo(o->sizeHint());
+ ++i;
+ }
+ return s + n*QSize(spacing(), spacing());
+}
+
+QSize CardLayout::minimumSize() const
+{
+ QSize s(0,0);
+ int n = list.count();
+ int i = 0;
+ while (i < n) {
+ QLayoutItem *o = list.at(i);
+ s = s.expandedTo(o->minimumSize());
+ ++i;
+ }
+ return s + n*QSize(spacing(), spacing());
+}
+//! [7]
diff --git a/doc/src/snippets/code/doc_src_objecttrees.cpp b/doc/src/snippets/code/doc_src_objecttrees.cpp
new file mode 100644
index 0000000000..cd92a49eea
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_objecttrees.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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()
+{
+ QWidget window;
+ QPushButton quit("Quit", &window);
+ ...
+}
+//![0]
+
+
+//![1]
+int main()
+{
+ QPushButton quit("Quit");
+ QWidget window;
+
+ quit.setParent(&window);
+ ...
+}
+//![1]
diff --git a/doc/src/snippets/code/doc_src_properties.cpp b/doc/src/snippets/code/doc_src_properties.cpp
new file mode 100644
index 0000000000..b5a103db0b
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_properties.cpp
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+Q_PROPERTY(type name
+ READ getFunction
+ [WRITE setFunction]
+ [RESET resetFunction]
+ [NOTIFY notifySignal]
+ [REVISION int]
+ [DESIGNABLE bool]
+ [SCRIPTABLE bool]
+ [STORED bool]
+ [USER bool]
+ [CONSTANT]
+ [FINAL])
+//! [0]
+
+
+//! [1]
+Q_PROPERTY(bool focus READ hasFocus)
+Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
+Q_PROPERTY(QCursor cursor READ cursor WRITE setCursor RESET unsetCursor)
+//! [1]
+
+
+//! [2]
+Q_PROPERTY(QDate date READ getDate WRITE setDate)
+//! [2]
+
+
+//! [3]
+QPushButton *button = new QPushButton;
+QObject *object = button;
+
+button->setDown(true);
+object->setProperty("down", true);
+//! [3]
+
+
+//! [4]
+QObject *object = ...
+const QMetaObject *metaobject = object->metaObject();
+int count = metaobject->propertyCount();
+for (int i=0; i<count; ++i) {
+ QMetaProperty metaproperty = metaobject->property(i);
+ const char *name = metaproperty.name();
+ QVariant value = object->property(name);
+ ...
+}
+//! [4]
+
+
+//! [5]
+class MyClass : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged)
+ Q_ENUMS(Priority)
+
+public:
+ MyClass(QObject *parent = 0);
+ ~MyClass();
+
+ enum Priority { High, Low, VeryHigh, VeryLow };
+
+ void setPriority(Priority priority)
+ {
+ m_priority = priority;
+ emit priorityChanged(priority);
+ }
+ Priority priority() const
+ { return m_priority; }
+
+signals:
+ void priorityChanged(Priority);
+
+private:
+ Priority m_priority;
+};
+//! [5]
+
+
+//! [6]
+MyClass *myinstance = new MyClass;
+QObject *object = myinstance;
+
+myinstance->setPriority(MyClass::VeryHigh);
+object->setProperty("priority", "VeryHigh");
+//! [6]
+
+
+//! [7]
+Q_CLASSINFO("Version", "3.0.0")
+//! [7]
diff --git a/doc/src/snippets/code/doc_src_qalgorithms.cpp b/doc/src/snippets/code/doc_src_qalgorithms.cpp
new file mode 100644
index 0000000000..0438105865
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_qalgorithms.cpp
@@ -0,0 +1,354 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QStringList list;
+list << "one" << "two" << "three";
+
+qFill(list.begin(), list.end(), "eleven");
+// list: [ "eleven", "eleven", "eleven" ]
+//! [0]
+
+
+//! [1]
+qFill(list.begin() + 1, list.end(), "six");
+// list: [ "eleven", "six", "six" ]
+//! [1]
+
+
+//! [2]
+QChar resolveEntity(const QString &entity)
+{
+ static const QLatin1String name_table[] = {
+ "AElig", "Aacute", ..., "zwnj"
+ };
+ static const ushort value_table[] = {
+ 0x0061, 0x00c1, ..., 0x200c
+ };
+ int N = sizeof(name_table) / sizeof(name_table[0]);
+
+ const QLatin1String *name = qBinaryFind(name_table, name_table + N,
+ entity);
+ int index = name - name_table;
+ if (index == N)
+ return QChar();
+
+ return QChar(value_table[index]);
+}
+//! [2]
+
+
+//! [3]
+QChar resolveEntity(const QString &entity)
+{
+ static QMap<QString, int> entityMap;
+
+ if (!entityMap) {
+ entityMap.insert("AElig", 0x0061);
+ entityMap.insert("Aacute", 0x00c1);
+ ...
+ entityMap.insert("zwnj", 0x200c);
+ }
+ return QChar(entityMap.value(entity));
+}
+//! [3]
+
+
+//! [4]
+QStringList list;
+list << "one" << "two" << "three";
+
+QVector<QString> vect1(3);
+qCopy(list.begin(), list.end(), vect1.begin());
+// vect: [ "one", "two", "three" ]
+
+QVector<QString> vect2(8);
+qCopy(list.begin(), list.end(), vect2.begin() + 2);
+// vect: [ "", "", "one", "two", "three", "", "", "" ]
+//! [4]
+
+
+//! [5]
+QStringList list;
+list << "one" << "two" << "three";
+
+QVector<QString> vect(5);
+qCopyBackward(list.begin(), list.end(), vect.end());
+// vect: [ "", "", "one", "two", "three" ]
+//! [5]
+
+
+//! [6]
+QStringList list;
+list << "one" << "two" << "three";
+
+QVector<QString> vect(3);
+vect[0] = "one";
+vect[1] = "two";
+vect[2] = "three";
+
+bool ret1 = qEqual(list.begin(), list.end(), vect.begin());
+// ret1 == true
+
+vect[2] = "seven";
+bool ret2 = qEqual(list.begin(), list.end(), vect.begin());
+// ret2 == false
+//! [6]
+
+
+//! [7]
+QStringList list;
+list << "one" << "two" << "three";
+
+qFill(list.begin(), list.end(), "eleven");
+// list: [ "eleven", "eleven", "eleven" ]
+
+qFill(list.begin() + 1, list.end(), "six");
+// list: [ "eleven", "six", "six" ]
+//! [7]
+
+
+//! [8]
+QStringList list;
+list << "one" << "two" << "three";
+
+QStringList::iterator i1 = qFind(list.begin(), list.end(), "two");
+// i1 == list.begin() + 1
+
+QStringList::iterator i2 = qFind(list.begin(), list.end(), "seventy");
+// i2 == list.end()
+//! [8]
+
+
+//! [9]
+QList<int> list;
+list << 3 << 3 << 6 << 6 << 6 << 8;
+
+int countOf6 = 0;
+qCount(list.begin(), list.end(), 6, countOf6);
+// countOf6 == 3
+
+int countOf7 = 0;
+qCount(list.begin(), list.end(), 7, countOf7);
+// countOf7 == 0
+//! [9]
+
+
+//! [10]
+double pi = 3.14;
+double e = 2.71;
+
+qSwap(pi, e);
+// pi == 2.71, e == 3.14
+//! [10]
+
+
+//! [11]
+QList<int> list;
+list << 33 << 12 << 68 << 6 << 12;
+qSort(list.begin(), list.end());
+// list: [ 6, 12, 12, 33, 68 ]
+//! [11]
+
+
+//! [12]
+bool caseInsensitiveLessThan(const QString &s1, const QString &s2)
+{
+ return s1.toLower() < s2.toLower();
+}
+
+int doSomething()
+{
+ QStringList list;
+ list << "AlPha" << "beTA" << "gamma" << "DELTA";
+ qSort(list.begin(), list.end(), caseInsensitiveLessThan);
+ // list: [ "AlPha", "beTA", "DELTA", "gamma" ]
+}
+//! [12]
+
+
+//! [13]
+QList<int> list;
+list << 33 << 12 << 68 << 6 << 12;
+qSort(list.begin(), list.end(), qGreater<int>());
+// list: [ 68, 33, 12, 12, 6 ]
+//! [13]
+
+
+//! [14]
+QStringList list;
+list << "AlPha" << "beTA" << "gamma" << "DELTA";
+
+QMap<QString, QString> map;
+foreach (const QString &str, list)
+ map.insert(str.toLower(), str);
+
+list = map.values();
+//! [14]
+
+
+//! [15]
+QList<int> list;
+list << 33 << 12 << 68 << 6 << 12;
+qStableSort(list.begin(), list.end());
+// list: [ 6, 12, 12, 33, 68 ]
+//! [15]
+
+
+//! [16]
+bool caseInsensitiveLessThan(const QString &s1, const QString &s2)
+{
+ return s1.toLower() < s2.toLower();
+}
+
+int doSomething()
+{
+ QStringList list;
+ list << "AlPha" << "beTA" << "gamma" << "DELTA";
+ qStableSort(list.begin(), list.end(), caseInsensitiveLessThan);
+ // list: [ "AlPha", "beTA", "DELTA", "gamma" ]
+}
+//! [16]
+
+
+//! [17]
+QList<int> list;
+list << 33 << 12 << 68 << 6 << 12;
+qStableSort(list.begin(), list.end(), qGreater<int>());
+// list: [ 68, 33, 12, 12, 6 ]
+//! [17]
+
+
+//! [18]
+QList<int> list;
+list << 3 << 3 << 6 << 6 << 6 << 8;
+
+QList<int>::iterator i = qLowerBound(list.begin(), list.end(), 5);
+list.insert(i, 5);
+// list: [ 3, 3, 5, 6, 6, 6, 8 ]
+
+i = qLowerBound(list.begin(), list.end(), 12);
+list.insert(i, 12);
+// list: [ 3, 3, 5, 6, 6, 6, 8, 12 ]
+//! [18]
+
+
+//! [19]
+QVector<int> vect;
+vect << 3 << 3 << 6 << 6 << 6 << 8;
+QVector<int>::iterator begin6 =
+ qLowerBound(vect.begin(), vect.end(), 6);
+QVector<int>::iterator end6 =
+ qUpperBound(begin6, vect.end(), 6);
+
+QVector<int>::iterator i = begin6;
+while (i != end6) {
+ *i = 7;
+ ++i;
+}
+// vect: [ 3, 3, 7, 7, 7, 8 ]
+//! [19]
+
+
+//! [20]
+QList<int> list;
+list << 3 << 3 << 6 << 6 << 6 << 8;
+
+QList<int>::iterator i = qUpperBound(list.begin(), list.end(), 5);
+list.insert(i, 5);
+// list: [ 3, 3, 5, 6, 6, 6, 8 ]
+
+i = qUpperBound(list.begin(), list.end(), 12);
+list.insert(i, 12);
+// list: [ 3, 3, 5, 6, 6, 6, 8, 12 ]
+//! [20]
+
+
+//! [21]
+QVector<int> vect;
+vect << 3 << 3 << 6 << 6 << 6 << 8;
+QVector<int>::iterator begin6 =
+ qLowerBound(vect.begin(), vect.end(), 6);
+QVector<int>::iterator end6 =
+ qUpperBound(vect.begin(), vect.end(), 6);
+
+QVector<int>::iterator i = begin6;
+while (i != end6) {
+ *i = 7;
+ ++i;
+}
+// vect: [ 3, 3, 7, 7, 7, 8 ]
+//! [21]
+
+
+//! [22]
+QVector<int> vect;
+vect << 3 << 3 << 6 << 6 << 6 << 8;
+
+QVector<int>::iterator i =
+ qBinaryFind(vect.begin(), vect.end(), 6);
+// i == vect.begin() + 2 (or 3 or 4)
+//! [22]
+
+
+//! [23]
+QList<Employee *> list;
+list.append(new Employee("Blackpool", "Stephen"));
+list.append(new Employee("Twist", "Oliver"));
+
+qDeleteAll(list.begin(), list.end());
+list.clear();
+//! [23]
+
+
+//! [24]
+QList<int> list;
+list << 33 << 12 << 68 << 6 << 12;
+qSort(list.begin(), list.end(), qLess<int>());
+// list: [ 6, 12, 12, 33, 68 ]
+//! [24]
+
+
+//! [25]
+QList<int> list;
+list << 33 << 12 << 68 << 6 << 12;
+qSort(list.begin(), list.end(), qGreater<int>());
+// list: [ 68, 33, 12, 12, 6 ]
+//! [25]
diff --git a/doc/src/snippets/code/doc_src_qcache.cpp b/doc/src/snippets/code/doc_src_qcache.cpp
new file mode 100644
index 0000000000..81fa3cf279
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_qcache.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QCache<int, Employee> cache;
+//! [0]
+
+
+//! [1]
+Employee *employee = new Employee;
+employee->setId(37);
+employee->setName("Richard Schmit");
+...
+cache.insert(employee->id(), employee);
+//! [1]
+
+
+//! [2]
+QCache<int, MyDataStructure> cache(5000);
+//! [2]
diff --git a/doc/src/snippets/code/doc_src_qiterator.cpp b/doc/src/snippets/code/doc_src_qiterator.cpp
new file mode 100644
index 0000000000..82b1bd3429
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_qiterator.cpp
@@ -0,0 +1,420 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QList<float> list;
+...
+QListIterator<float> i(list);
+while (i.hasNext())
+ qDebug() << i.next();
+//! [0]
+
+
+//! [1]
+QListIterator<float> i(list);
+i.toBack();
+while (i.hasPrevious())
+ qDebug() << i.previous();
+//! [1]
+
+
+//! [2]
+QLinkedList<float> list;
+...
+QLinkedListIterator<float> i(list);
+while (i.hasNext())
+ qDebug() << i.next();
+//! [2]
+
+
+//! [3]
+QLinkedListIterator<float> i(list);
+i.toBack();
+while (i.hasPrevious())
+ qDebug() << i.previous();
+//! [3]
+
+
+//! [4]
+QVector<float> vector;
+...
+QVectorIterator<float> i(vector);
+while (i.hasNext())
+ qDebug() << i.next();
+//! [4]
+
+
+//! [5]
+QVectorIterator<float> i(vector);
+i.toBack();
+while (i.hasPrevious())
+ qDebug() << i.previous();
+//! [5]
+
+
+//! [6]
+QSet<QString> set;
+...
+QSetIterator<QString> i(set);
+while (i.hasNext())
+ qDebug() << i.next();
+//! [6]
+
+
+//! [7]
+QSetIterator<QString> i(set);
+i.toBack();
+while (i.hasPrevious())
+ qDebug() << i.previous();
+//! [7]
+
+
+//! [8]
+QList<float> list;
+...
+QMutableListIterator<float> i(list);
+while (i.hasNext())
+ qDebug() << i.next();
+//! [8]
+
+
+//! [9]
+QMutableListIterator<float> i(list);
+i.toBack();
+while (i.hasPrevious())
+ qDebug() << i.previous();
+//! [9]
+
+
+//! [10]
+QMutableListIterator<int> i(list);
+while (i.hasNext()) {
+ int val = i.next();
+ if (val < 0) {
+ i.setValue(-val);
+ } else if (val == 0) {
+ i.remove();
+ }
+}
+//! [10]
+
+
+//! [11]
+QLinkedList<float> list;
+...
+QMutableLinkedListIterator<float> i(list);
+while (i.hasNext())
+ qDebug() << i.next();
+//! [11]
+
+
+//! [12]
+QMutableLinkedListIterator<float> i(list);
+i.toBack();
+while (i.hasPrevious())
+ qDebug() << i.previous();
+//! [12]
+
+
+//! [13]
+QMutableLinkedListIterator<int> i(list);
+while (i.hasNext()) {
+ int val = i.next();
+ if (val < 0) {
+ i.setValue(-val);
+ } else if (val == 0) {
+ i.remove();
+ }
+}
+//! [13]
+
+
+//! [14]
+QVector<float> vector;
+...
+QMutableVectorIterator<float> i(vector);
+while (i.hasNext())
+ qDebug() << i.next();
+//! [14]
+
+
+//! [15]
+QMutableVectorIterator<float> i(vector);
+i.toBack();
+while (i.hasPrevious())
+ qDebug() << i.previous();
+//! [15]
+
+
+//! [16]
+QMutableVectorIterator<int> i(vector);
+while (i.hasNext()) {
+ int val = i.next();
+ if (val < 0) {
+ i.setValue(-val);
+ } else if (val == 0) {
+ i.remove();
+ }
+}
+//! [16]
+
+
+//! [17]
+QSet<float> set;
+...
+QMutableSetIterator<float> i(set);
+while (i.hasNext())
+ qDebug() << i.next();
+//! [17]
+
+
+//! [18]
+QMutableSetIterator<float> i(set);
+i.toBack();
+while (i.hasPrevious())
+ qDebug() << i.previous();
+//! [18]
+
+
+//! [19]
+QMutableListIterator<int> i(list);
+while (i.hasNext()) {
+ int val = i.next();
+ if (val < -32768 || val > 32767)
+ i.remove();
+}
+//! [19]
+
+
+//! [20]
+QMutableLinkedListIterator<int> i(list);
+while (i.hasNext()) {
+ int val = i.next();
+ if (val < -32768 || val > 32767)
+ i.remove();
+}
+//! [20]
+
+
+//! [21]
+QMutableVectorIterator<int> i(vector);
+while (i.hasNext()) {
+ int val = i.next();
+ if (val < -32768 || val > 32767)
+ i.remove();
+}
+//! [21]
+
+
+//! [22]
+QMutableSetIterator<int> i(set);
+while (i.hasNext()) {
+ int val = i.next();
+ if (val < -32768 || val > 32767)
+ i.remove();
+}
+//! [22]
+
+
+//! [23]
+QMutableListIterator<double> i(list);
+while (i.hasNext()) {
+ double val = i.next();
+ i.setValue(sqrt(val));
+}
+//! [23]
+
+
+//! [24]
+QMutableLinkedListIterator<double> i(list);
+while (i.hasNext()) {
+ double val = i.next();
+ i.setValue(sqrt(val));
+}
+//! [24]
+
+
+//! [25]
+QMutableVectorIterator<double> i(list);
+while (i.hasNext()) {
+ double val = i.next();
+ i.setValue(sqrt(val));
+}
+//! [25]
+
+
+//! [26]
+QMap<int, QWidget *> map;
+...
+QMapIterator<int, QWidget *> i(map);
+while (i.hasNext()) {
+ i.next();
+ qDebug() << i.key() << ": " << i.value();
+}
+//! [26]
+
+
+//! [27]
+QMapIterator<int, QWidget *> i(map);
+i.toBack();
+while (i.hasPrevious()) {
+ i.previous();
+ qDebug() << i.key() << ": " << i.value();
+}
+//! [27]
+
+
+//! [28]
+QMapIterator<int, QWidget *> i(map);
+while (i.findNext(widget)) {
+ qDebug() << "Found widget " << widget << " under key "
+ << i.key();
+}
+//! [28]
+
+
+//! [29]
+QHash<int, QWidget *> hash;
+...
+QHashIterator<int, QWidget *> i(hash);
+while (i.hasNext()) {
+ i.next();
+ qDebug() << i.key() << ": " << i.value();
+}
+//! [29]
+
+
+//! [30]
+QHashIterator<int, QWidget *> i(hash);
+i.toBack();
+while (i.hasPrevious()) {
+ i.previous();
+ qDebug() << i.key() << ": " << i.value();
+}
+//! [30]
+
+
+//! [31]
+QHashIterator<int, QWidget *> i(hash);
+while (i.findNext(widget)) {
+ qDebug() << "Found widget " << widget << " under key "
+ << i.key();
+}
+//! [31]
+
+
+//! [32]
+QMap<int, QWidget *> map;
+...
+QMutableMapIterator<int, QWidget *> i(map);
+while (i.hasNext()) {
+ i.next();
+ qDebug() << i.key() << ": " << i.value();
+}
+//! [32]
+
+
+//! [33]
+QMutableMapIterator<int, QWidget *> i(map);
+i.toBack();
+while (i.hasPrevious()) {
+ i.previous();
+ qDebug() << i.key() << ": " << i.value();
+}
+//! [33]
+
+
+//! [34]
+QMutableMapIterator<int, QWidget *> i(map);
+while (i.findNext(widget)) {
+ qDebug() << "Found widget " << widget << " under key "
+ << i.key();
+}
+//! [34]
+
+
+//! [35]
+QMutableMapIterator<QString, QString> i(map);
+while (i.hasNext()) {
+ i.next();
+ if (i.key() == i.value())
+ i.remove();
+}
+//! [35]
+
+
+//! [36]
+QHash<int, QWidget *> hash;
+...
+QMutableHashIterator<QString, QWidget *> i(hash);
+while (i.hasNext()) {
+ i.next();
+ qDebug() << i.key() << ": " << i.value();
+}
+//! [36]
+
+
+//! [37]
+QMutableHashIterator<int, QWidget *> i(hash);
+i.toBack();
+while (i.hasPrevious()) {
+ i.previous();
+ qDebug() << i.key() << ": " << i.value();
+}
+//! [37]
+
+
+//! [38]
+QMutableHashIterator<int, QWidget *> i(hash);
+while (i.findNext(widget)) {
+ qDebug() << "Found widget " << widget << " under key "
+ << i.key();
+}
+//! [38]
+
+
+//! [39]
+QMutableHashIterator<QString, QString> i(hash);
+while (i.hasNext()) {
+ i.next();
+ if (i.key() == i.value())
+ i.remove();
+}
+//! [39]
diff --git a/doc/src/snippets/code/doc_src_qnamespace.cpp b/doc/src/snippets/code/doc_src_qnamespace.cpp
new file mode 100644
index 0000000000..c512862325
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_qnamespace.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+enum CustomEventPriority
+{
+ // An important event
+ ImportantEventPriority = Qt::HighEventPriority,
+
+ // A more important event
+ MoreImportantEventPriority = ImportantEventPriority + 1,
+
+ // A critical event
+ CriticalEventPriority = 100 * MoreImportantEventPriority,
+
+ // Not that important
+ StatusEventPriority = Qt::LowEventPriority,
+
+ // These are less important than Status events
+ IdleProcessingDoneEventPriority = StatusEventPriority - 1
+};
+//! [1]
diff --git a/doc/src/snippets/code/doc_src_qnamespace.qdoc b/doc/src/snippets/code/doc_src_qnamespace.qdoc
new file mode 100644
index 0000000000..6b5ce6a41d
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_qnamespace.qdoc
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QObject::connect: Cannot queue arguments of type 'MyType'
+//! [0]
diff --git a/doc/src/snippets/code/doc_src_qpair.cpp b/doc/src/snippets/code/doc_src_qpair.cpp
new file mode 100644
index 0000000000..a9a061e2c7
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_qpair.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QPair<QString, double> pair;
+//! [0]
+
+
+//! [1]
+pair.first = "pi";
+pair.second = 3.14159265358979323846;
+//! [1]
+
+
+//! [2]
+QList<QPair<int, double> > list;
+list.append(qMakePair(66, 3.14159));
+//! [2]
diff --git a/doc/src/snippets/code/doc_src_qplugin.cpp b/doc/src/snippets/code/doc_src_qplugin.cpp
new file mode 100644
index 0000000000..fdacc08c3a
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_qplugin.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+namespace Foo
+{
+ struct MyInterface { ... };
+}
+
+Q_DECLARE_INTERFACE(Foo::MyInterface, "org.examples.MyInterface")
+//! [0]
+
+
+//! [1]
+Q_EXPORT_PLUGIN2(pnp_extrafilters, ExtraFiltersPlugin)
+//! [1]
+
+
+//! [2]
+Q_IMPORT_PLUGIN(qjpeg)
+//! [2]
+
+
+//! [3]
+TEMPLATE = app
+QTPLUGIN += qjpeg qgif qmng # image formats
+//! [3]
diff --git a/doc/src/snippets/code/doc_src_qplugin.pro b/doc/src/snippets/code/doc_src_qplugin.pro
new file mode 100644
index 0000000000..f3444e273a
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_qplugin.pro
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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$
+**
+****************************************************************************/
+
+#! [3]
+TEMPLATE = app
+QTPLUGIN += qjpeg qgif qmng # image formats
+#! [3]
diff --git a/doc/src/snippets/code/doc_src_qset.cpp b/doc/src/snippets/code/doc_src_qset.cpp
new file mode 100644
index 0000000000..4a4953d452
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_qset.cpp
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QSet<QString> set;
+//! [0]
+
+
+//! [1]
+set.insert("one");
+set.insert("three");
+set.insert("seven");
+//! [1]
+
+
+//! [2]
+set << "twelve" << "fifteen" << "nineteen";
+//! [2]
+
+
+//! [3]
+if (!set.contains("ninety-nine"))
+ ...
+//! [3]
+
+
+//! [4]
+QSetIterator<QWidget *> i(set);
+while (i.hasNext())
+ qDebug() << i.next();
+//! [4]
+
+
+//! [5]
+QSet<QWidget *>::const_iterator i = set.constBegin();
+while (i != set.constEnd()) {
+ qDebug() << *i;
+ ++i;
+}
+//! [5]
+
+
+//! [6]
+QSet<QString> set;
+...
+foreach (const QString &value, set)
+ qDebug() << value;
+//! [6]
+
+
+//! [7]
+QSet<QString> set;
+set.reserve(20000);
+for (int i = 0; i < 20000; ++i)
+ set.insert(values[i]);
+//! [7]
+
+
+//! [8]
+QSet<QString> set;
+set << "January" << "February" << ... << "December";
+
+QSet<QString>::iterator i;
+for (i = set.begin(); i != set.end(); ++i)
+ qDebug() << *i;
+//! [8]
+
+
+//! [9]
+QSet<QString> set;
+set << "January" << "February" << ... << "December";
+
+QSet<QString>::iterator i = set.begin();
+while (i != set.end()) {
+ if ((*i).startsWith('J')) {
+ i = set.erase(i);
+ } else {
+ ++i;
+ }
+}
+//! [9]
+
+
+//! [10]
+QSet<QString> set;
+...
+QSet<QString>::iterator it = qFind(set.begin(), set.end(), "Jeanette");
+if (it != set.end())
+ cout << "Found Jeanette" << endl;
+//! [10]
+
+
+//! [11]
+QSet<QString> set;
+set << "January" << "February" << ... << "December";
+
+QSet<QString>::const_iterator i;
+for (i = set.begin(); i != set.end(); ++i)
+ qDebug() << *i;
+//! [11]
+
+
+//! [12]
+QSet<QString> set;
+...
+QSet<QString>::iterator it = qFind(set.begin(), set.end(), "Jeanette");
+if (it != set.constEnd())
+ cout << "Found Jeanette" << endl;
+//! [12]
+
+
+//! [13]
+QSet<QString> set;
+set << "red" << "green" << "blue" << ... << "black";
+
+QList<QString> list = set.toList();
+qSort(list);
+//! [13]
+
+
+//! [14]
+QStringList list;
+list << "Julia" << "Mike" << "Mike" << "Julia" << "Julia";
+
+QSet<QString> set = QSet<QString>::fromList(list);
+set.contains("Julia"); // returns true
+set.contains("Mike"); // returns true
+set.size(); // returns 2
+//! [14]
diff --git a/doc/src/snippets/code/doc_src_qsignalspy.cpp b/doc/src/snippets/code/doc_src_qsignalspy.cpp
new file mode 100644
index 0000000000..12462e2d74
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_qsignalspy.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QCheckBox *box = ...;
+QSignalSpy spy(box, SIGNAL(clicked(bool)));
+
+// do something that triggers the signal
+box->animateClick();
+
+QCOMPARE(spy.count(), 1); // make sure the signal was emitted exactly one time
+QList<QVariant> arguments = spy.takeFirst(); // take the first signal
+
+QVERIFY(arguments.at(0).toBool() == true); // verify the first argument
+//! [0]
+
+
+//! [1]
+QSignalSpy spy(myCustomObject, SIGNAL(mySignal(int, QString, double)));
+
+myCustomObject->doSomething(); // trigger emission of the signal
+
+QList<QVariant> arguments = spy.takeFirst();
+QVERIFY(arguments.at(0).type() == QVariant::Int);
+QVERIFY(arguments.at(1).type() == QVariant::QString);
+QVERIFY(arguments.at(2).type() == QVariant::double);
+//! [1]
+
+
+//! [2]
+qRegisterMetaType<QModelIndex>("QModelIndex");
+QSignalSpy spy(&model, SIGNAL(whatever(QModelIndex)));
+//! [2]
+
+
+//! [3]
+// get the first argument from the first received signal:
+QModelIndex result = qvariant_cast<QModelIndex>(spy.at(0).at(0));
+//! [3]
+
+
+//! [4]
+QSignalSpy spy(myPushButton, SIGNAL(clicked(bool)));
+//! [4]
diff --git a/doc/src/snippets/code/doc_src_qt4-mainwindow.cpp b/doc/src/snippets/code/doc_src_qt4-mainwindow.cpp
new file mode 100644
index 0000000000..d0c758e644
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_qt4-mainwindow.cpp
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+{
+//! [0]
+
+
+//! [1]
+fileToolbar->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
+addToolBar(Qt::TopToolBarArea, fileToolbar);
+//! [1]
+
+
+//! [2]
+setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
+setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
+setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
+setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
+//! [2]
+
+
+//! [3]
+QWidget *centralWidget = new QWidget(this);
+setCentralWidget(centralWidget);
+//! [3]
+
+
+//! [4]
+QPopupMenu *fileMenu = new QPopupMenu(this);
+openAction->addTo(fileMenu);
+saveAction->addTo(fileMenu);
+...
+menuBar()->insertItem(tr("&File"), fileMenu);
+//! [4]
+
+
+//! [5]
+QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
+fileMenu->addAction(openAction);
+fileMenu->addAction(saveAction);
+...
+//! [5]
+
+
+//! [6]
+QToolBar *fileTools = new QToolBar(this, "file toolbar");
+openAction->addTo(fileTools);
+saveAction->addTo(fileTools);
+...
+//! [6]
+
+
+//! [7]
+QToolBar *fileTools = addToolBar(tr("File Tool Bar"));
+fileTools->addAction(openAction);
+fileTools->addAction(saveAction);
+...
+//! [7]
+
+
+//! [8]
+QDockWidget *dockWidget = new QDockWidget(this);
+mainWin->moveDockWidget(dockWidget, Qt::DockLeft);
+//! [8]
+
+
+//! [9]
+QDockWidget *dockWidget = new QDockWidget(mainWindow);
+mainWindow->addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
+//! [9]
diff --git a/doc/src/snippets/code/doc_src_qt4-styles.cpp b/doc/src/snippets/code/doc_src_qt4-styles.cpp
new file mode 100644
index 0000000000..effe3cd561
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_qt4-styles.cpp
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+const QStyleOptionFocusRect *focusRectOption =
+ qstyleoption_cast<const QStyleOptionFocusRect *>(option);
+if (focusRectOption) {
+ ...
+}
+//! [0]
+
+
+//! [1]
+void MyWidget::paintEvent(QPaintEvent *event)
+{
+ QPainter painter(this);
+ ...
+
+ QStyleOptionFocusRect option(1);
+ option.init(this);
+ option.backgroundColor = palette().color(QPalette::Window);
+
+ style().drawPrimitive(QStyle::PE_FrameFocusRect, &option, &painter,
+ this);
+}
+//! [1]
+
+
+//! [2]
+void drawControl(ControlElement element,
+ QPainter *painter,
+ const QWidget *widget,
+ const QRect &rect,
+ const QColorGroup &colorGroup,
+ SFlags how = Style_Default,
+ const QStyleOption &option = QStyleOption::Default) const;
+//! [2]
+
+
+//! [3]
+void drawControl(ControlElement element,
+ const QStyleOption *option,
+ QPainter *painter,
+ const QWidget *widget = 0) const;
+//! [3]
diff --git a/doc/src/snippets/code/doc_src_qtestevent.cpp b/doc/src/snippets/code/doc_src_qtestevent.cpp
new file mode 100644
index 0000000000..fd1c819ac0
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_qtestevent.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QTestEventList events;
+events.addKeyClick('a');
+events.addKeyClick(Qt::Key_Backspace);
+events.addDelay(200);
+
+QLineEdit *lineEdit = new QLineEdit(myParent);
+...
+events.simulate(lineEdit);
+events.simulate(lineEdit);
+//! [0]
diff --git a/doc/src/snippets/code/doc_src_qvarlengtharray.cpp b/doc/src/snippets/code/doc_src_qvarlengtharray.cpp
new file mode 100644
index 0000000000..a9383301f5
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_qvarlengtharray.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 myfunc(int n)
+{
+ int table[n + 1]; // WRONG
+ ...
+ return table[n];
+}
+//! [0]
+
+
+//! [1]
+int myfunc(int n)
+{
+ int *table = new int[n + 1];
+ ...
+ int ret = table[n];
+ delete[] table;
+ return ret;
+}
+//! [1]
+
+
+//! [2]
+int myfunc(int n)
+{
+ QVarLengthArray<int, 1024> array(n + 1);
+ ...
+ return array[n];
+}
+//! [2]
+
+
+//! [3]
+QVarLengthArray<int> array(10);
+int *data = array.data();
+for (int i = 0; i < 10; ++i)
+ data[i] = 2 * i;
+//! [3]
diff --git a/doc/src/snippets/code/doc_src_resources.cpp b/doc/src/snippets/code/doc_src_resources.cpp
new file mode 100644
index 0000000000..b965cbeb29
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_resources.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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$
+**
+****************************************************************************/
+
+//! [4]
+QResource::registerResource("/path/to/myresource.rcc");
+//! [4]
+
+
+//! [5]
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Q_INIT_RESOURCE(graphlib);
+ ...
+ return app.exec();
+}
+//! [5]
diff --git a/doc/src/snippets/code/doc_src_resources.qdoc b/doc/src/snippets/code/doc_src_resources.qdoc
new file mode 100644
index 0000000000..0b727da461
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_resources.qdoc
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+<file alias="cut-img.png">images/cut.png</file>
+//! [0]
+
+
+//! [1]
+<qresource prefix="/myresources">
+ <file alias="cut-img.png">images/cut.png</file>
+</qresource>
+//! [1]
+
+
+//! [2]
+<qresource>
+ <file>cut.jpg</file>
+</qresource>
+<qresource lang="fr">
+ <file alias="cut.jpg">cut_fr.jpg</file>
+</qresource>
+//! [2]
+
+
+//! [3]
+rcc -binary myresource.qrc -o myresource.rcc
+//! [3]
diff --git a/doc/src/snippets/code/doc_src_sql-driver.cpp b/doc/src/snippets/code/doc_src_sql-driver.cpp
new file mode 100644
index 0000000000..56e4f9bcdb
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_sql-driver.cpp
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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$
+**
+****************************************************************************/
+
+//! [2]
+QSqlQuery q;
+q.exec("call qtestproc (@outval1, @outval2)");
+q.exec("select @outval1, @outval2");
+q.next();
+qDebug() << q.value(0) << q.value(1); // outputs "42" and "43"
+//! [2]
+
+
+//! [10]
+// STORED_PROC uses the return statement or returns multiple result sets
+QSqlQuery query;
+query.setForwardOnly(true);
+query.exec("{call STORED_PROC}");
+//! [10]
+
+
+//! [24]
+db.setHostName("MyServer");
+db.setDatabaseName("C:\\test.gdb");
+//! [24]
+
+
+//! [25]
+// connect to database using the Latin-1 character set
+db.setConnectOptions("ISC_DPB_LC_CTYPE=Latin1");
+db.open();
+//! [25]
+
+
+//! [26]
+QSqlQuery q;
+q.exec("execute procedure my_procedure");
+q.next();
+qDebug() << q.value(0); // outputs the first RETURN/OUT value
+//! [26]
+
+
+//! [31]
+QSqlDatabase: QMYSQL driver not loaded
+QSqlDatabase: available drivers: QMYSQL
+//! [31]
diff --git a/doc/src/snippets/code/doc_src_sql-driver.qdoc b/doc/src/snippets/code/doc_src_sql-driver.qdoc
new file mode 100644
index 0000000000..46cd1b3f3e
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_sql-driver.qdoc
@@ -0,0 +1,235 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+-no-sql-<driver> ... Disable SQL <driver> entirely.
+-qt-sql-<driver> ... Enable a SQL <driver> in the Qt Library, by default
+ none are turned on.
+-plugin-sql-<driver> Enable SQL <driver> as a plugin to be linked to
+ at run time.
+
+ Possible values for <driver>:
+ [ db2 ibase mysql oci odbc psql sqlite sqlite2 tds ]
+//! [0]
+
+
+//! [1]
+create procedure qtestproc (OUT param1 INT, OUT param2 INT)
+BEGIN
+ set param1 = 42;
+ set param2 = 43;
+END
+//! [1]
+
+
+//! [3]
+cd $QTDIR/src/plugins/sqldrivers/mysql
+qmake "INCLUDEPATH+=/usr/local/include" "LIBS+=-L/usr/local/lib -lmysqlclient_r" mysql.pro
+make
+//! [3]
+
+
+//! [4]
+cd $QTDIR/src/plugins/sqldrivers/mysql
+make install
+//! [4]
+
+
+//! [5]
+cd %QTDIR%\src\plugins\sqldrivers\mysql
+qmake "INCLUDEPATH+=C:\MySQL\include" "LIBS+=C:\MYSQL\MySQL Server <version>\lib\opt\libmysql.lib" mysql.pro
+nmake
+//! [5]
+
+
+//! [6]
+cd $QTDIR/src/plugins/sqldrivers/oci
+qmake "INCLUDEPATH+=$ORACLE_HOME/rdbms/public $ORACLE_HOME/rdbms/demo" "LIBS+=-L$ORACLE_HOME/lib -lclntsh -lwtc9" oci.pro
+make
+//! [6]
+
+
+//! [7]
+cd $QTDIR/src/plugins/sqldrivers/oci
+qmake "INCLUDEPATH+=/usr/include/oracle/10.1.0.3/client/" "LIBS+=-L/usr/lib/oracle/10.1.0.3/client/lib -lclntsh" oci.pro
+make
+//! [7]
+
+
+//! [8]
+set INCLUDE=%INCLUDE%;c:\oracle\oci\include
+set LIB=%LIB%;c:\oracle\oci\lib\msvc
+cd %QTDIR%\src\plugins\sqldrivers\oci
+qmake oci.pro
+nmake
+//! [8]
+
+
+//! [9]
+set PATH=%PATH%;c:\oracle\bin
+//! [9]
+
+
+//! [11]
+cd $QTDIR/src/plugins/sqldrivers/odbc
+qmake "INCLUDEPATH+=/usr/local/unixODBC/include" "LIBS+=-L/usr/local/unixODBC/lib -lodbc"
+make
+//! [11]
+
+
+//! [12]
+cd %QTDIR%\src\plugins\sqldrivers\odbc
+qmake odbc.pro
+nmake
+//! [12]
+
+
+//! [13]
+cd $QTDIR/src/plugins/sqldrivers/psql
+qmake "INCLUDEPATH+=/usr/include/pgsql" "LIBS+=-L/usr/lib -lpq" psql.pro
+make
+//! [13]
+
+
+//! [14]
+cd $QTDIR/src/plugins/sqldrivers/psql
+make install
+//! [14]
+
+
+//! [15]
+cd %QTDIR%\src\plugins\sqldrivers\psql
+qmake "INCLUDEPATH+=C:\psql\include" "LIBS+=C:\psql\lib\ms\libpq.lib" psql.pro
+nmake
+//! [15]
+
+
+//! [16]
+cd $QTDIR/src/plugins/sqldrivers/tds
+qmake "INCLUDEPATH=$SYBASE/include" "LIBS=-L$SYBASE/lib -lsybdb"
+make
+//! [16]
+
+
+//! [17]
+cd %QTDIR%\src\plugins\sqldrivers\tds
+qmake "LIBS+=NTWDBLIB.LIB" tds.pro
+nmake
+//! [17]
+
+
+//! [18]
+cd $QTDIR/src/plugins/sqldrivers/db2
+qmake "INCLUDEPATH+=$DB2DIR/include" "LIBS+=-L$DB2DIR/lib -ldb2"
+make
+//! [18]
+
+
+//! [19]
+cd $QTDIR/src/plugins/sqldrivers/db2
+make install
+//! [19]
+
+
+//! [20]
+cd %QTDIR%\src\plugins\sqldrivers\db2
+qmake "INCLUDEPATH+=<DB2 home>/sqllib/include" "LIBS+=<DB2 home>/sqllib/lib/db2cli.lib"
+nmake
+//! [20]
+
+
+//! [21]
+cd $QTDIR/src/plugins/sqldrivers/sqlite
+qmake "INCLUDEPATH+=$SQLITE/include" "LIBS+=-L$SQLITE/lib -lsqlite"
+make
+//! [21]
+
+
+//! [22]
+cd $QTDIR/src/plugins/sqldrivers/sqlite
+make install
+//! [22]
+
+
+//! [23]
+cd %QTDIR%\src\plugins\sqldrivers\sqlite
+qmake "INCLUDEPATH+=C:\SQLITE\INCLUDE" "LIBS+=C:\SQLITE\LIB\SQLITE3.LIB" sqlite.pro
+nmake
+//! [23]
+
+
+//! [27]
+cd $QTDIR/src/plugins/sqldrivers/ibase
+qmake "INCLUDEPATH+=/opt/interbase/include" "LIBS+=-L/opt/interbase/lib" ibase.pro
+make
+//! [27]
+
+
+//! [28]
+cd $QTDIR/src/plugins/sqldrivers/ibase
+qmake "INCLUDEPATH+=/opt/interbase/include" "LIBS+=-L/opt/interbase/lib -lfbclient" ibase.pro
+make
+//! [28]
+
+
+//! [29]
+cd %QTDIR%\src\plugins\sqldrivers\ibase
+qmake "INCLUDEPATH+=C:\interbase\include" ibase.pro
+nmake
+//! [29]
+
+
+//! [30]
+cd %QTDIR%\src\plugins\sqldrivers\ibase
+qmake "INCLUDEPATH+=C:\interbase\include" "LIBS+=-lfbclient" ibase.pro
+nmake
+//! [30]
+
+
+//! [32]
+configure -I /usr/include/oracle/10.1.0.3/client -L /usr/lib/oracle/10.1.0.3/client/lib -R /usr/lib/oracle/10.1.0.3/client/lib -lclntsh -lnnz10
+make
+//! [32]
+
+//! [33]
+cd $QTDIR/src/plugins/sqldrivers/oci
+qmake "INCLUDEPATH+=/usr/include/oracle/10.1.0.3/client" "LIBS+=-L/usr/lib/oracle/10.1.0.3/client/lib -Wl,-rpath,/usr/lib/oracle/10.1.0.3/client/lib -lclntsh -lnnz10" oci.pro
+make
+//! [33]
diff --git a/doc/src/snippets/code/doc_src_styles.cpp b/doc/src/snippets/code/doc_src_styles.cpp
new file mode 100644
index 0000000000..a2a6fa9694
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_styles.cpp
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+ opt.initFrom(q);
+ if (down)
+ opt.state |= QStyle::State_Sunken;
+ if (tristate && noChange)
+ opt.state |= QStyle::State_NoChange;
+ else
+ opt.state |= checked ? QStyle::State_On :
+ QStyle::State_Off;
+ if (q->testAttribute(Qt::WA_Hover) && q->underMouse()) {
+ if (hovering)
+ opt.state |= QStyle::State_MouseOver;
+ else
+ opt.state &= ~QStyle::State_MouseOver;
+ }
+ opt.text = text;
+ opt.icon = icon;
+ opt.iconSize = q->iconSize();
+//! [0]
+
+
+//! [1]
+ state = QStyle::State_None;
+ if (widget->isEnabled())
+ state |= QStyle::State_Enabled;
+ if (widget->hasFocus())
+ state |= QStyle::State_HasFocus;
+ if (widget->window()->testAttribute(Qt::WA_KeyboardFocusChange))
+ state |= QStyle::State_KeyboardFocusChange;
+ if (widget->underMouse())
+ state |= QStyle::State_MouseOver;
+ if (widget->window()->isActiveWindow())
+ state |= QStyle::State_Active;
+#ifdef Q_WS_MAC
+ extern bool qt_mac_can_clickThrough(const QWidget *w); //qwidget_mac.cpp
+ if (!(state & QStyle::State_Active) && !qt_mac_can_clickThrough(widget))
+ state &= ~QStyle::State_Enabled;
+#endif
+#ifdef QT_KEYPAD_NAVIGATION
+ if (widget->hasEditFocus())
+ state |= QStyle::State_HasEditFocus;
+#endif
+
+ direction = widget->layoutDirection();
+ rect = widget->rect();
+ palette = widget->palette();
+ fontMetrics = widget->fontMetrics();
+//! [1]
+
+
+//! [2]
+ QStylePainter p(this);
+ QStyleOptionButton opt = d->getStyleOption();
+ p.drawControl(QStyle::CE_CheckBox, opt);
+//! [2]
+
+
+//! [3]
+ QStyleOptionButton subopt = *btn;
+ subopt.rect = subElementRect(SE_CheckBoxIndicator, btn, widget);
+ drawPrimitive(PE_IndicatorCheckBox, &subopt, p, widget);
+ subopt.rect = subElementRect(SE_CheckBoxContents, btn, widget);
+ drawControl(CE_CheckBoxLabel, &subopt, p, widget);
+
+ if (btn->state & State_HasFocus) {
+ QStyleOptionFocusRect fropt;
+ fropt.QStyleOption::operator=(*btn);
+ fropt.rect = subElementRect(SE_CheckBoxFocusRect, btn, widget);
+ drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
+ }
+//! [3]
+
+
+//! [4]
+ const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt);
+ uint alignment = visualAlignment(btn->direction, Qt::AlignLeft | Qt::AlignVCenter);
+
+ if (!styleHint(SH_UnderlineShortcut, btn, widget))
+ alignment |= Qt::TextHideMnemonic;
+ QPixmap pix;
+ QRect textRect = btn->rect;
+ if (!btn->icon.isNull()) {
+ pix = btn->icon.pixmap(btn->iconSize, btn->state & State_Enabled ? QIcon::Normal : QIcon::Disabled);
+ drawItemPixmap(p, btn->rect, alignment, pix);
+ if (btn->direction == Qt::RightToLeft)
+ textRect.setRight(textRect.right() - btn->iconSize.width() - 4);
+ else
+ textRect.setLeft(textRect.left() + btn->iconSize.width() + 4);
+ }
+ if (!btn->text.isEmpty()){
+ drawItemText(p, textRect, alignment | Qt::TextShowMnemonic,
+ btn->palette, btn->state & State_Enabled, btn->text, QPalette::WindowText);
+ }
+//! [4]
diff --git a/doc/src/snippets/code/doc_src_stylesheet.cpp b/doc/src/snippets/code/doc_src_stylesheet.cpp
new file mode 100644
index 0000000000..3faaf2d037
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_stylesheet.cpp
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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$
+**
+****************************************************************************/
+
+//! [21]
+qApp->setStyleSheet("QPushButton { color: white }");
+//! [21]
+
+
+//! [22]
+myPushButton->setStyleSheet("* { color: blue }");
+//! [22]
+
+
+//! [23]
+myPushButton->setStyleSheet("color: blue");
+//! [23]
+
+
+//! [24]
+qApp->setStyleSheet("QGroupBox { color: red; } ");
+//! [24]
+
+//! [25]
+qApp->setStyleSheet("QGroupBox, QGroupBox * { color: red; }");
+//! [25]
+
+
+//! [26]
+class MyPushButton : public QPushButton {
+ // ...
+}
+
+// ...
+qApp->setStyleSheet("MyPushButton { background: yellow; }");
+//! [26]
+
+
+//! [27]
+namespace ns {
+ class MyPushButton : public QPushButton {
+ // ...
+ }
+}
+
+// ...
+qApp->setStyleSheet("ns--MyPushButton { background: yellow; }");
+//! [27]
+
+
+//! [32]
+void CustomWidget::paintEvent(QPaintEvent *)
+{
+ QStyleOption opt;
+ opt.init(this);
+ QPainter p(this);
+ style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
+}
+//! [32]
+
+
+//! [88]
+qApp->setStyleSheet("QLineEdit { background-color: yellow }");
+//! [88]
+
+
+//! [89]
+myDialog->setStyleSheet("QLineEdit { background-color: yellow }");
+//! [89]
+
+
+//! [90]
+myDialog->setStyleSheet("QLineEdit#nameEdit { background-color: yellow }");
+//! [90]
+
+
+//! [91]
+nameEdit->setStyleSheet("background-color: yellow");
+//! [91]
+
+
+//! [92]
+nameEdit->setStyleSheet("color: blue; background-color: yellow");
+//! [92]
+
+
+//! [93]
+nameEdit->setStyleSheet("color: blue;"
+ "background-color: yellow;"
+ "selection-color: yellow;"
+ "selection-background-color: blue;");
+//! [93]
+
+
+//! [95]
+QLineEdit *nameEdit = new QLineEdit(this);
+nameEdit->setProperty("mandatoryField", true);
+
+QLineEdit *emailEdit = new QLineEdit(this);
+emailEdit->setProperty("mandatoryField", true);
+
+QSpinBox *ageSpinBox = new QSpinBox(this);
+ageSpinBox->setProperty("mandatoryField", true);
+//! [95]
diff --git a/doc/src/snippets/code/doc_src_stylesheet.qdoc b/doc/src/snippets/code/doc_src_stylesheet.qdoc
new file mode 100644
index 0000000000..99b31c9387
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_stylesheet.qdoc
@@ -0,0 +1,1866 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QLineEdit { background: yellow }
+QCheckBox { color: red }
+//! [0]
+
+
+//! [1]
+QPushButton { color: red }
+//! [1]
+
+
+//! [2]
+QPushButton, QLineEdit, QComboBox { color: red }
+//! [2]
+
+
+//! [3]
+QPushButton { color: red }
+QLineEdit { color: red }
+QComboBox { color: red }
+//! [3]
+
+
+//! [4]
+QPushButton { color: red; background-color: white }
+//! [4]
+
+
+//! [5]
+QComboBox::drop-down { image: url(dropdown.png) }
+//! [5]
+
+
+//! [6]
+QComboBox {
+ margin-right: 20px;
+}
+QComboBox::drop-down {
+ subcontrol-origin: margin;
+}
+//! [6]
+
+
+//! [7]
+QComboBox::down-arrow {
+ image: url(down_arrow.png);
+}
+QComboBox::down-arrow:pressed {
+ position: relative;
+ top: 1px; left: 1px;
+}
+//! [7]
+
+
+//! [8]
+QPushButton:hover { color: white }
+//! [8]
+
+
+//! [9]
+QRadioButton:!hover { color: red }
+//! [9]
+
+
+//! [10]
+QCheckBox:hover:checked { color: white }
+//! [10]
+
+
+//! [11]
+QPushButton:hover:!pressed { color: blue; }
+//! [11]
+
+
+//! [12]
+QCheckBox:hover, QCheckBox:checked { color: white }
+//! [12]
+
+
+//! [13]
+QComboBox::drop-down:hover { image: url(dropdown_bright.png) }
+//! [13]
+
+
+//! [14]
+QPushButton#okButton { color: gray }
+QPushButton { color: red }
+//! [14]
+
+
+//! [15]
+QPushButton:hover { color: white }
+QPushButton { color: red }
+//! [15]
+
+
+//! [16]
+QPushButton:hover { color: white }
+QPushButton:enabled { color: red }
+//! [16]
+
+
+//! [17]
+QPushButton:enabled { color: red }
+QPushButton:hover { color: white }
+//! [17]
+
+
+//! [18]
+QPushButton:hover:enabled { color: white }
+QPushButton:enabled { color: red }
+//! [18]
+
+
+//! [19]
+QPushButton { color: red }
+QAbstractButton { color: gray }
+//! [19]
+
+
+//! [20]
+* {} /* a=0 b=0 c=0 -> specificity = 0 */
+LI {} /* a=0 b=0 c=1 -> specificity = 1 */
+UL LI {} /* a=0 b=0 c=2 -> specificity = 2 */
+UL OL+LI {} /* a=0 b=0 c=3 -> specificity = 3 */
+H1 + *[REL=up]{} /* a=0 b=1 c=1 -> specificity = 11 */
+UL OL LI.red {} /* a=0 b=1 c=3 -> specificity = 13 */
+LI.red.level {} /* a=0 b=2 c=1 -> specificity = 21 */
+#x34y {} /* a=1 b=0 c=0 -> specificity = 100 */
+//! [20]
+
+
+//! [28]
+MyLabel { qproperty-pixmap: url(pixmap.png); }
+MyGroupBox { qproperty-titleColor: rgb(100, 200, 100); }
+QPushButton { qproperty-iconSize: 20px 20px; }
+//! [28]
+
+
+//! [30]
+QPushButton { background-color: red; border: none; }
+//! [30]
+
+
+//! [31]
+QToolButton { background-color: red; border: none; }
+//! [31]
+
+
+//! [33]
+QTreeView {
+ alternate-background-color: blue;
+ background: yellow;
+}
+//! [33]
+
+
+//! [34]
+QTextEdit { background: yellow }
+//! [34]
+
+
+//! [35]
+QLabel {
+ background-image: url(dense6pattern.png);
+ background-repeat: repeat-xy;
+}
+//! [35]
+
+
+//! [36]
+QLabel { background-color: yellow }
+QLineEdit { background-color: rgb(255, 0, 0) }
+//! [36]
+
+
+//! [37]
+QFrame { background-image: url(:/images/hydro.png) }
+//! [37]
+
+
+//! [38]
+QFrame {
+ background: white url(:/images/ring.png);
+ background-repeat: repeat-y;
+ background-position: left;
+}
+//! [38]
+
+
+//! [39]
+QFrame {
+ background: url(:/images/footer.png);
+ background-position: bottom left;
+}
+//! [39]
+
+
+//! [40]
+QTextEdit {
+ background-image: url("leaves.png");
+ background-attachment: fixed;
+}
+//! [40]
+
+
+//! [41]
+QFrame {
+ background-image: url(:/images/header.png);
+ background-position: top left;
+ background-origin: content;
+ background-clip: padding;
+}
+//! [41]
+
+
+//! [42]
+QFrame {
+ background-image: url(:/images/header.png);
+ background-position: top left;
+ background-origin: content;
+}
+//! [42]
+
+
+//! [43]
+QLineEdit { border: 1px solid white }
+//! [43]
+
+
+//! [44]
+QLineEdit {
+ border-width: 1px;
+ border-style: solid;
+ border-color: white;
+}
+//! [44]
+
+
+//! [45]
+QLineEdit {
+ border-width: 1px;
+ border-style: solid;
+ border-radius: 4px;
+}
+//! [45]
+
+
+//! [46]
+QLineEdit {
+ border-width: 1px;
+ border-style: solid;
+ border-color: blue;
+}
+//! [46]
+
+
+//! [47]
+QLineEdit {
+ border-width: 2px;
+ border-style: solid;
+ border-color: darkblue;
+}
+//! [47]
+
+
+//! [48]
+QSpinBox::down-button { bottom: 2px }
+//! [48]
+
+
+//! [49]
+* { button-layout: 2 }
+//! [49]
+
+
+//! [50]
+QPushButton { color: red }
+//! [50]
+
+
+//! [51]
+QDialogButtonBox { dialogbuttonbox-buttons-have-icons: 1; }
+//! [51]
+
+
+//! [52]
+* { etch-disabled-text: 1 }
+//! [52]
+
+
+//! [53]
+QCheckBox { font: bold italic large "Times New Roman" }
+//! [53]
+
+
+//! [54]
+QCheckBox { font-family: "New Century Schoolbook" }
+//! [54]
+
+
+//! [55]
+QTextEdit { font-size: 12px }
+//! [55]
+
+
+//! [56]
+QTextEdit { font-style: italic }
+//! [56]
+
+
+//! [57]
+* { gridline-color: gray }
+//! [57]
+
+
+//! [58]
+QSpinBox::down-button { height: 10px }
+//! [58]
+
+
+//! [59]
+/* implicitly sets the size of down-button to the size of spindown.png */
+QSpinBox::down-button { image: url(:/images/spindown.png) }
+//! [59]
+
+
+//! [60]
+QSpinBox::down-button { left: 2px }
+//! [60]
+
+
+//! [61]
+* { lineedit-password-character: 9679 }
+//! [61]
+
+
+//! [62]
+QLineEdit { margin: 2px }
+//! [62]
+
+
+//! [63]
+QSpinBox { max-height: 24px }
+//! [63]
+
+
+//! [64]
+QComboBox { max-width: 72px }
+//! [64]
+
+
+//! [65]
+QMessageBox { messagebox-text-interaction-flags: 5 }
+//! [65]
+
+
+//! [66]
+QComboBox { min-height: 24px }
+//! [66]
+
+
+//! [67]
+QComboBox { min-width: 72px }
+//! [67]
+
+
+//! [68]
+QToolTip { opacity: 223 }
+//! [68]
+
+
+//! [69]
+QLineEdit { padding: 3px }
+//! [69]
+
+
+//! [70]
+QSpinBox::down-button { right: 2px }
+//! [70]
+
+
+//! [71]
+QTextEdit { selection-background-color: darkblue }
+//! [71]
+
+
+//! [72]
+QTextEdit { selection-color: white }
+//! [72]
+
+
+//! [73]
+* { show-decoration-selected: 1 }
+//! [73]
+
+
+//! [74]
+QMenuBar { spacing: 10 }
+//! [74]
+
+
+//! [75]
+QSpinBox::up-button {
+ image: url(:/images/spinup.png);
+ subcontrol-origin: content;
+ subcontrol-position: right top;
+}
+//! [75]
+
+
+//! [76]
+QSpinBox::down-button {
+ image: url(:/images/spindown.png);
+ subcontrol-origin: padding;
+ subcontrol-position: right bottom;
+}
+//! [76]
+
+
+//! [77]
+QPushButton {
+ text-align: left;
+}
+//! [77]
+
+
+//! [78]
+QSpinBox::up-button { top: 2px }
+//! [78]
+
+
+//! [79]
+QSpinBox::up-button { width: 12px }
+//! [79]
+
+
+//! [80]
+QTextEdit { background-position: bottom center }
+//! [80]
+
+
+//! [81]
+QDialog { etch-disabled-text: 1 }
+//! [81]
+
+
+//! [82]
+QLabel { border-color: red } /* red red red red */
+QLabel { border-color: red blue } /* red blue red blue */
+QLabel { border-color: red blue green } /* red blue green blue */
+QLabel { border-color: red blue green yellow } /* red blue green yellow */
+//! [82]
+
+
+//! [83]
+QLabel { border-width: 1px } /* 1px 1px 1px 1px */
+QLabel { border-width: 1px 2px } /* 1px 2px 1px 2px */
+QLabel { border-width: 1px 2px 3px } /* 1px 2px 3px 2px */
+QLabel { border-width: 1px 2px 3px 4px } /* 1px 2px 3px 4px */
+//! [83]
+
+
+//! [84]
+QLabel { border-color: red } /* opaque red */
+QLabel { border-color: #FF0000 } /* opaque red */
+QLabel { border-color: rgba(255, 0, 0, 75%) } /* 75% opaque red */
+QLabel { border-color: rgb(255, 0, 0) } /* opaque red */
+QLabel { border-color: rgb(100%, 0%, 0%) } /* opaque red */
+QLabel { border-color: hsv(60, 255, 255) } /* opaque yellow */
+QLabel { border-color: hsva(240, 255, 255, 75%) } /* 75% blue */
+//! [84]
+
+
+//! [85]
+/* linear gradient from white to green */
+QTextEdit {
+ background: qlineargradient(x1:0, y1:0, x2:1, y2:1,
+ stop:0 white, stop: 0.4 gray, stop:1 green)
+}
+
+/* linear gradient from white to green */
+QTextEdit {
+ background: qlineargradient(x1:0, y1:0, x2:1, y2:1,
+ stop:0 white, stop: 0.4 rgba(10, 20, 30, 40), stop:1 rgb(0, 200, 230, 200))
+}
+
+
+/* conical gradient from white to green */
+QTextEdit {
+ background: qconicalgradient(cx:0.5, cy:0.5, angle:30,
+ stop:0 white, stop:1 #00FF00)
+}
+
+/* radial gradient from white to green */
+QTextEdit {
+ background: qradialgradient(cx:0, cy:0, radius: 1,
+ fx:0.5, fy:0.5, stop:0 white, stop:1 green)
+}
+//! [85]
+
+
+//! [86]
+* {
+ file-icon: url(file.png),
+ url(file_selected.png) selected;
+ }
+
+QMessageBox {
+ dialogbuttonbox-buttons-have-icons: true;
+ dialog-ok-icon: url(ok.svg);
+ dialog-cancel-icon: url(cancel.png), url(grayed_cancel.png) disabled;
+}
+//! [86]
+
+
+//! [87]
+QPushButton { color: palette(dark); }
+//! [87]
+
+
+//! [94]
+*[mandatoryField="true"] { background-color: yellow }
+//! [94]
+
+
+//! [96]
+QPushButton#evilButton { background-color: red }
+//! [96]
+
+
+//! [97]
+QPushButton#evilButton {
+ background-color: red;
+ border-style: outset;
+ border-width: 2px;
+ border-color: beige;
+}
+//! [97]
+
+
+//! [98]
+QPushButton#evilButton {
+ background-color: red;
+ border-style: outset;
+ border-width: 2px;
+ border-radius: 10px;
+ border-color: beige;
+ font: bold 14px;
+ min-width: 10em;
+ padding: 6px;
+}
+//! [98]
+
+
+//! [99]
+QPushButton#evilButton {
+ background-color: red;
+ border-style: outset;
+ border-width: 2px;
+ border-radius: 10px;
+ border-color: beige;
+ font: bold 14px;
+ min-width: 10em;
+ padding: 6px;
+}
+QPushButton#evilButton:pressed {
+ background-color: rgb(224, 0, 0);
+ border-style: inset;
+}
+//! [99]
+
+
+//! [100]
+QPushButton#evilButton::menu-indicator {
+ image: url(myindicator.png);
+}
+//! [100]
+
+
+//! [101]
+QPushButton::menu-indicator {
+ image: url(myindicator.png);
+ subcontrol-position: right center;
+ subcontrol-origin: padding;
+ left: -2px;
+}
+//! [101]
+
+
+//! [102]
+QLineEdit { color: red }
+//! [102]
+
+
+//! [103]
+QLineEdit { color: red }
+QLineEdit[readOnly="true"] { color: gray }
+//! [103]
+
+
+//! [104]
+QLineEdit { color: red }
+QLineEdit[readOnly="true"] { color: gray }
+#registrationDialog QLineEdit { color: brown }
+//! [104]
+
+
+//! [105]
+QLineEdit { color: red }
+QLineEdit[readOnly="true"] { color: gray }
+QDialog QLineEdit { color: brown }
+//! [105]
+
+
+//! [106]
+QTextEdit, QListView {
+ background-color: white;
+ background-image: url(draft.png);
+ background-attachment: scroll;
+}
+//! [106]
+
+
+//! [107]
+QTextEdit, QListView {
+ background-color: white;
+ background-image: url(draft.png);
+ background-attachment: fixed;
+}
+//! [107]
+
+
+//! [108]
+QCheckBox {
+ spacing: 5px;
+}
+
+QCheckBox::indicator {
+ width: 13px;
+ height: 13px;
+}
+
+QCheckBox::indicator:unchecked {
+ image: url(:/images/checkbox_unchecked.png);
+}
+
+QCheckBox::indicator:unchecked:hover {
+ image: url(:/images/checkbox_unchecked_hover.png);
+}
+
+QCheckBox::indicator:unchecked:pressed {
+ image: url(:/images/checkbox_unchecked_pressed.png);
+}
+
+QCheckBox::indicator:checked {
+ image: url(:/images/checkbox_checked.png);
+}
+
+QCheckBox::indicator:checked:hover {
+ image: url(:/images/checkbox_checked_hover.png);
+}
+
+QCheckBox::indicator:checked:pressed {
+ image: url(:/images/checkbox_checked_pressed.png);
+}
+
+QCheckBox::indicator:indeterminate:hover {
+ image: url(:/images/checkbox_indeterminate_hover.png);
+}
+
+QCheckBox::indicator:indeterminate:pressed {
+ image: url(:/images/checkbox_indeterminate_pressed.png);
+}
+//! [108]
+
+
+//! [109]
+QComboBox {
+ border: 1px solid gray;
+ border-radius: 3px;
+ padding: 1px 18px 1px 3px;
+ min-width: 6em;
+}
+
+QComboBox:editable {
+ background: white;
+}
+
+QComboBox:!editable, QComboBox::drop-down:editable {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #E1E1E1, stop: 0.4 #DDDDDD,
+ stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);
+}
+
+/* QComboBox gets the "on" state when the popup is open */
+QComboBox:!editable:on, QComboBox::drop-down:editable:on {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #D3D3D3, stop: 0.4 #D8D8D8,
+ stop: 0.5 #DDDDDD, stop: 1.0 #E1E1E1);
+}
+
+QComboBox:on { /* shift the text when the popup opens */
+ padding-top: 3px;
+ padding-left: 4px;
+}
+
+QComboBox::drop-down {
+ subcontrol-origin: padding;
+ subcontrol-position: top right;
+ width: 15px;
+
+ border-left-width: 1px;
+ border-left-color: darkgray;
+ border-left-style: solid; /* just a single line */
+ border-top-right-radius: 3px; /* same radius as the QComboBox */
+ border-bottom-right-radius: 3px;
+}
+
+QComboBox::down-arrow {
+ image: url(/usr/share/icons/crystalsvg/16x16/actions/1downarrow.png);
+}
+
+QComboBox::down-arrow:on { /* shift the arrow when popup is open */
+ top: 1px;
+ left: 1px;
+}
+//! [109]
+
+
+//! [110]
+QComboBox QAbstractItemView {
+ border: 2px solid darkgray;
+ selection-background-color: lightgray;
+}
+//! [110]
+
+
+//! [111]
+QDockWidget {
+ border: 1px solid lightgray;
+ titlebar-close-icon: url(close.png);
+ titlebar-normal-icon: url(undock.png);
+}
+
+QDockWidget::title {
+ text-align: left; /* align the text to the left */
+ background: lightgray;
+ padding-left: 5px;
+}
+
+QDockWidget::close-button, QDockWidget::float-button {
+ border: 1px solid transparent;
+ background: darkgray;
+ padding: 0px;
+}
+
+QDockWidget::close-button:hover, QDockWidget::float-button:hover {
+ background: gray;
+}
+
+QDockWidget::close-button:pressed, QDockWidget::float-button:pressed {
+ padding: 1px -1px -1px 1px;
+}
+//! [111]
+
+
+//! [112]
+QDockWidget {
+ border: 1px solid lightgray;
+ titlebar-close-icon: url(close.png);
+ titlebar-normal-icon: url(float.png);
+}
+
+QDockWidget::title {
+ text-align: left;
+ background: lightgray;
+ padding-left: 35px;
+}
+
+QDockWidget::close-button, QDockWidget::float-button {
+ background: darkgray;
+ padding: 0px;
+ icon-size: 14px; /* maximum icon size */
+}
+
+QDockWidget::close-button:hover, QDockWidget::float-button:hover {
+ background: gray;
+}
+
+QDockWidget::close-button:pressed, QDockWidget::float-button:pressed {
+ padding: 1px -1px -1px 1px;
+}
+
+QDockWidget::close-button {
+ subcontrol-position: top left;
+ subcontrol-origin: margin;
+ position: absolute;
+ top: 0px; left: 0px; bottom: 0px;
+ width: 14px;
+}
+
+QDockWidget::float-button {
+ subcontrol-position: top left;
+ subcontrol-origin: margin;
+ position: absolute;
+ top: 0px; left: 16px; bottom: 0px;
+ width: 14px;
+}
+//! [112]
+
+
+//! [113]
+QFrame, QLabel, QToolTip {
+ border: 2px solid green;
+ border-radius: 4px;
+ padding: 2px;
+ background-image: url(images/welcome.png);
+}
+//! [113]
+
+
+//! [114]
+QGroupBox {
+ background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #E0E0E0, stop: 1 #FFFFFF);
+ border: 2px solid gray;
+ border-radius: 5px;
+ margin-top: 1ex; /* leave space at the top for the title */
+}
+
+QGroupBox::title {
+ subcontrol-origin: margin;
+ subcontrol-position: top center; /* position at the top center */
+ padding: 0 3px;
+ background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #FFOECE, stop: 1 #FFFFFF);
+}
+//! [114]
+
+
+//! [115]
+QGroupBox::indicator {
+ width: 13px;
+ height: 13px;
+}
+
+QGroupBox::indicator:unchecked {
+ image: url(:/images/checkbox_unchecked.png);
+}
+
+/* proceed with styling just like QCheckBox */
+//! [115]
+
+
+//! [116]
+QHeaderView::section {
+ background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,
+ stop:0 #616161, stop: 0.5 #505050,
+ stop: 0.6 #434343, stop:1 #656565);
+ color: white;
+ padding-left: 4px;
+ border: 1px solid #6c6c6c;
+}
+
+QHeaderView::section:checked
+{
+ background-color: red;
+}
+
+/* style the sort indicator */
+QHeaderView::down-arrow {
+ image: url(down_arrow.png);
+}
+
+QHeaderView::up-arrow {
+ image: url(up_arrow.png);
+}
+//! [116]
+
+
+//! [117]
+QLineEdit {
+ border: 2px solid gray;
+ border-radius: 10px;
+ padding: 0 8px;
+ background: yellow;
+ selection-background-color: darkgray;
+}
+//! [117]
+
+
+//! [118]
+QLineEdit[echoMode="2"] {
+ lineedit-password-character: 9679;
+}
+//! [118]
+
+
+//! [119]
+QLineEdit:read-only {
+ background: lightblue;
+//! [119]
+
+
+//! [120]
+QListView {
+ alternate-background-color: yellow;
+}
+//! [120]
+
+
+//! [121]
+QListView {
+ show-decoration-selected: 1; /* make the selection span the entire width of the view */
+}
+
+QListView::item:alternate {
+ background: #EEEEEE;
+}
+
+QListView::item:selected {
+ border: 1px solid #6a6ea9;
+}
+
+QListView::item:selected:!active {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #ABAFE5, stop: 1 #8588B2);
+}
+
+QListView::item:selected:active {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #6a6ea9, stop: 1 #888dd9);
+}
+
+QListView::item:hover {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #FAFBFE, stop: 1 #DCDEF1);
+}
+//! [121]
+
+
+//! [122]
+QMainWindow::separator {
+ background: yellow;
+ width: 10px; /* when vertical */
+ height: 10px; /* when horizontal */
+}
+
+QMainWindow::separator:hover {
+ background: red;
+}
+//! [122]
+
+
+//! [123]
+QMenu {
+ background-color: #ABABAB; /* sets background of the menu */
+ border: 1px solid black;
+}
+
+QMenu::item {
+ /* sets background of menu item. set this to something non-transparent
+ if you want menu color and menu item color to be different */
+ background-color: transparent;
+}
+
+QMenu::item:selected { /* when user selects item using mouse or keyboard */
+ background-color: #654321;
+}
+//! [123]
+
+
+//! [124]
+QMenu {
+ background-color: white;
+ margin: 2px; /* some spacing around the menu */
+}
+
+QMenu::item {
+ padding: 2px 25px 2px 20px;
+ border: 1px solid transparent; /* reserve space for selection border */
+}
+
+QMenu::item:selected {
+ border-color: darkblue;
+ background: rgba(100, 100, 100, 150);
+}
+
+QMenu::icon:checked { /* appearance of a 'checked' icon */
+ background: gray;
+ border: 1px inset gray;
+ position: absolute;
+ top: 1px;
+ right: 1px;
+ bottom: 1px;
+ left: 1px;
+}
+
+QMenu::separator {
+ height: 2px;
+ background: lightblue;
+ margin-left: 10px;
+ margin-right: 5px;
+}
+
+QMenu::indicator {
+ width: 13px;
+ height: 13px;
+}
+
+/* non-exclusive indicator = check box style indicator (see QActionGroup::setExclusive) */
+QMenu::indicator:non-exclusive:unchecked {
+ image: url(:/images/checkbox_unchecked.png);
+}
+
+QMenu::indicator:non-exclusive:unchecked:selected {
+ image: url(:/images/checkbox_unchecked_hover.png);
+}
+
+QMenu::indicator:non-exclusive:checked {
+ image: url(:/images/checkbox_checked.png);
+}
+
+QMenu::indicator:non-exclusive:checked:selected {
+ image: url(:/images/checkbox_checked_hover.png);
+}
+
+/* exclusive indicator = radio button style indicator (see QActionGroup::setExclusive) */
+QMenu::indicator:exclusive:unchecked {
+ image: url(:/images/radiobutton_unchecked.png);
+}
+
+QMenu::indicator:exclusive:unchecked:selected {
+ image: url(:/images/radiobutton_unchecked_hover.png);
+}
+
+QMenu::indicator:exclusive:checked {
+ image: url(:/images/radiobutton_checked.png);
+}
+
+QMenu::indicator:exclusive:checked:selected {
+ image: url(:/images/radiobutton_checked_hover.png);
+}
+
+//! [124]
+
+
+//! [125]
+QMenuBar {
+ background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,
+ stop:0 lightgray, stop:1 darkgray);
+}
+
+QMenuBar::item {
+ spacing: 3px; /* spacing between menu bar items */
+ padding: 1px 4px;
+ background: transparent;
+ border-radius: 4px;
+}
+
+QMenuBar::item:selected { /* when selected using mouse or keyboard */
+ background: #a8a8a8;
+}
+
+QMenuBar::item:pressed {
+ background: #888888;
+}
+//! [125]
+
+
+//! [126]
+QProgressBar {
+ border: 2px solid grey;
+ border-radius: 5px;
+}
+
+QProgressBar::chunk {
+ background-color: #05B8CC;
+ width: 20px;
+}
+//! [126]
+
+
+//! [127]
+QProgressBar {
+ border: 2px solid grey;
+ border-radius: 5px;
+ text-align: center;
+}
+//! [127]
+
+
+//! [128]
+QProgressBar::chunk {
+ background-color: #CD96CD;
+ width: 10px;
+ margin: 0.5px;
+}
+//! [128]
+
+
+//! [129]
+QPushButton {
+ border: 2px solid #8f8f91;
+ border-radius: 6px;
+ background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #f6f7fa, stop: 1 #dadbde);
+ min-width: 80px;
+}
+
+QPushButton:pressed {
+ background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #dadbde, stop: 1 #f6f7fa);
+}
+
+QPushButton:flat {
+ border: none; /* no border for a flat push button */
+}
+
+QPushButton:default {
+ border-color: navy; /* make the default button prominent */
+}
+//! [129]
+
+
+//! [130]
+QPushButton:open { /* when the button has its menu open */
+ background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #dadbde, stop: 1 #f6f7fa);
+}
+
+QPushButton::menu-indicator {
+ image: url(menu_indicator.png);
+ subcontrol-origin: padding;
+ subcontrol-position: bottom right;
+}
+
+QPushButton::menu-indicator:pressed, QPushButton::menu-indicator:open {
+ position: relative;
+ top: 2px; left: 2px; /* shift the arrow by 2 px */
+}
+//! [130]
+
+
+//! [131]
+QRadioButton::indicator {
+ width: 13px;
+ height: 13px;
+}
+
+QRadioButton::indicator::unchecked {
+ image: url(:/images/radiobutton_unchecked.png);
+}
+
+QRadioButton::indicator:unchecked:hover {
+ image: url(:/images/radiobutton_unchecked_hover.png);
+}
+
+QRadioButton::indicator:unchecked:pressed {
+ image: url(:/images/radiobutton_unchecked_pressed.png);
+}
+
+QRadioButton::indicator::checked {
+ image: url(:/images/radiobutton_checked.png);
+}
+
+QRadioButton::indicator:checked:hover {
+ image: url(:/images/radiobutton_checked_hover.png);
+}
+
+QRadioButton::indicator:checked:pressed {
+ image: url(:/images/radiobutton_checked_pressed.png);
+}
+//! [131]
+
+
+//! [132]
+QScrollBar:horizontal {
+ border: 2px solid grey;
+ background: #32CC99;
+ height: 15px;
+ margin: 0px 20px 0 20px;
+}
+//! [132]
+
+
+//! [133]
+QScrollBar::handle:horizontal {
+ background: white;
+ min-width: 20px;
+}
+//! [133]
+
+
+//! [134]
+QScrollBar::add-line:horizontal {
+ border: 2px solid grey;
+ background: #32CC99;
+ width: 20px;
+ subcontrol-position: right;
+ subcontrol-origin: margin;
+}
+
+QScrollBar::sub-line:horizontal {
+ border: 2px solid grey;
+ background: #32CC99;
+ width: 20px;
+ subcontrol-position: left;
+ subcontrol-origin: margin;
+}
+//! [134]
+
+
+//! [135]
+QScrollBar:left-arrow:horizontal, QScrollBar::right-arrow:horizontal {
+ border: 2px solid grey;
+ width: 3px;
+ height: 3px;
+ background: white;
+}
+
+QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {
+ background: none;
+}
+//! [135]
+
+
+//! [136]
+QScrollBar:horizontal {
+ border: 2px solid green;
+ background: cyan;
+ height: 15px;
+ margin: 0px 40px 0 0px;
+}
+
+QScrollBar::handle:horizontal {
+ background: gray;
+ min-width: 20px;
+}
+
+QScrollBar::add-line:horizontal {
+ background: blue;
+ width: 16px;
+ subcontrol-position: right;
+ subcontrol-origin: margin;
+ border: 2px solid black;
+}
+
+QScrollBar::sub-line:horizontal {
+ background: magenta;
+ width: 16px;
+ subcontrol-position: top right;
+ subcontrol-origin: margin;
+ border: 2px solid black;
+ position: absolute;
+ right: 20px;
+}
+
+QScrollBar:left-arrow:horizontal, QScrollBar::right-arrow:horizontal {
+ width: 3px;
+ height: 3px;
+ background: pink;
+}
+
+QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {
+ background: none;
+}
+
+//! [136]
+
+
+//! [137]
+ QScrollBar:vertical {
+ border: 2px solid grey;
+ background: #32CC99;
+ width: 15px;
+ margin: 22px 0 22px 0;
+ }
+ QScrollBar::handle:vertical {
+ background: white;
+ min-height: 20px;
+ }
+ QScrollBar::add-line:vertical {
+ border: 2px solid grey;
+ background: #32CC99;
+ height: 20px;
+ subcontrol-position: bottom;
+ subcontrol-origin: margin;
+ }
+
+ QScrollBar::sub-line:vertical {
+ border: 2px solid grey;
+ background: #32CC99;
+ height: 20px;
+ subcontrol-position: top;
+ subcontrol-origin: margin;
+ }
+ QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical {
+ border: 2px solid grey;
+ width: 3px;
+ height: 3px;
+ background: white;
+ }
+
+ QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
+ background: none;
+ }
+//! [137]
+
+
+//! [138]
+QSizeGrip {
+ image: url(:/images/sizegrip.png);
+ width: 16px;
+ height: 16px;
+}
+//! [138]
+
+
+//! [139]
+QSlider::groove:horizontal {
+ border: 1px solid #999999;
+ height: 8px; /* the groove expands to the size of the slider by default. by giving it a height, it has a fixed size */
+ background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #B1B1B1, stop:1 #c4c4c4);
+ margin: 2px 0;
+}
+
+QSlider::handle:horizontal {
+ background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f);
+ border: 1px solid #5c5c5c;
+ width: 18px;
+ margin: -2px 0; /* handle is placed by default on the contents rect of the groove. Expand outside the groove */
+ border-radius: 3px;
+}
+//! [139]
+
+
+//! [140]
+QSlider::groove:vertical {
+ background: red;
+ position: absolute; /* absolutely position 4px from the left and right of the widget. setting margins on the widget should work too... */
+ left: 4px; right: 4px;
+}
+
+QSlider::handle:vertical {
+ height: 10px;
+ background: green;
+ margin: 0 -4px; /* expand outside the groove */
+}
+
+QSlider::add-page:vertical {
+ background: white;
+}
+
+QSlider::sub-page:vertical {
+ background: pink;
+}
+//! [140]
+
+
+//! [141]
+QSpinBox {
+ padding-right: 15px; /* make room for the arrows */
+ border-image: url(:/images/frame.png) 4;
+ border-width: 3;
+}
+
+QSpinBox::up-button {
+ subcontrol-origin: border;
+ subcontrol-position: top right; /* position at the top right corner */
+
+ width: 16px; /* 16 + 2*1px border-width = 15px padding + 3px parent border */
+ border-image: url(:/images/spinup.png) 1;
+ border-width: 1px;
+}
+
+QSpinBox::up-button:hover {
+ border-image: url(:/images/spinup_hover.png) 1;
+}
+
+QSpinBox::up-button:pressed {
+ border-image: url(:/images/spinup_pressed.png) 1;
+}
+
+QSpinBox::up-arrow {
+ image: url(:/images/up_arrow.png);
+ width: 7px;
+ height: 7px;
+}
+
+QSpinBox::up-arrow:disabled, QSpinBox::up-arrow:off { /* off state when value is max */
+ image: url(:/images/up_arrow_disabled.png);
+}
+
+QSpinBox::down-button {
+ subcontrol-origin: border;
+ subcontrol-position: bottom right; /* position at bottom right corner */
+
+ width: 16px;
+ border-image: url(:/images/spindown.png) 1;
+ border-width: 1px;
+ border-top-width: 0;
+}
+
+QSpinBox::down-button:hover {
+ border-image: url(:/images/spindown_hover.png) 1;
+}
+
+QSpinBox::down-button:pressed {
+ border-image: url(:/images/spindown_pressed.png) 1;
+}
+
+QSpinBox::down-arrow {
+ image: url(:/images/down_arrow.png);
+ width: 7px;
+ height: 7px;
+}
+
+QSpinBox::down-arrow:disabled,
+QSpinBox::down-arrow:off { /* off state when value in min */
+ image: url(:/images/down_arrow_disabled.png);
+}
+
+//! [141]
+
+
+//! [142]
+QSplitter::handle {
+ image: url(images/splitter.png);
+}
+
+QSplitter::handle:horizontal {
+ width: 2px;
+}
+
+QSplitter::handle:vertical {
+ height: 2px;
+}
+
+QSplitter::handle:pressed {
+ url(images/splitter_pressed.png);
+}
+
+//! [142]
+
+
+//! [143]
+QStatusBar {
+ background: brown;
+}
+
+QStatusBar::item {
+ border: 1px solid red;
+ border-radius: 3px;
+}
+//! [143]
+
+
+//! [144]
+QStatusBar QLabel {
+ border: 3px solid white;
+}
+//! [144]
+
+
+//! [145]
+QTabWidget::pane { /* The tab widget frame */
+ border-top: 2px solid #C2C7CB;
+}
+
+QTabWidget::tab-bar {
+ left: 5px; /* move to the right by 5px */
+}
+
+/* Style the tab using the tab sub-control. Note that
+ it reads QTabBar _not_ QTabWidget */
+QTabBar::tab {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #E1E1E1, stop: 0.4 #DDDDDD,
+ stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);
+ border: 2px solid #C4C4C3;
+ border-bottom-color: #C2C7CB; /* same as the pane color */
+ border-top-left-radius: 4px;
+ border-top-right-radius: 4px;
+ min-width: 8ex;
+ padding: 2px;
+}
+
+QTabBar::tab:selected, QTabBar::tab:hover {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #fafafa, stop: 0.4 #f4f4f4,
+ stop: 0.5 #e7e7e7, stop: 1.0 #fafafa);
+}
+
+QTabBar::tab:selected {
+ border-color: #9B9B9B;
+ border-bottom-color: #C2C7CB; /* same as pane color */
+}
+
+QTabBar::tab:!selected {
+ margin-top: 2px; /* make non-selected tabs look smaller */
+}
+//! [145]
+
+
+//! [146]
+QTabWidget::pane { /* The tab widget frame */
+ border-top: 2px solid #C2C7CB;
+}
+
+QTabWidget::tab-bar {
+ left: 5px; /* move to the right by 5px */
+}
+
+/* Style the tab using the tab sub-control. Note that
+ it reads QTabBar _not_ QTabWidget */
+QTabBar::tab {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #E1E1E1, stop: 0.4 #DDDDDD,
+ stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);
+ border: 2px solid #C4C4C3;
+ border-bottom-color: #C2C7CB; /* same as the pane color */
+ border-top-left-radius: 4px;
+ border-top-right-radius: 4px;
+ min-width: 8ex;
+ padding: 2px;
+}
+
+QTabBar::tab:selected, QTabBar::tab:hover {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #fafafa, stop: 0.4 #f4f4f4,
+ stop: 0.5 #e7e7e7, stop: 1.0 #fafafa);
+}
+
+QTabBar::tab:selected {
+ border-color: #9B9B9B;
+ border-bottom-color: #C2C7CB; /* same as pane color */
+}
+
+QTabBar::tab:!selected {
+ margin-top: 2px; /* make non-selected tabs look smaller */
+}
+
+/* make use of negative margins for overlapping tabs */
+QTabBar::tab:selected {
+ /* expand/overlap to the left and right by 4px */
+ margin-left: -4px;
+ margin-right: -4px;
+}
+
+QTabBar::tab:first:selected {
+ margin-left: 0; /* the first selected tab has nothing to overlap with on the left */
+}
+
+QTabBar::tab:last:selected {
+ margin-right: 0; /* the last selected tab has nothing to overlap with on the right */
+}
+
+QTabBar::tab:only-one {
+ margin: 0; /* if there is only one tab, we don't want overlapping margins */
+}
+//! [146]
+
+
+//! [147]
+QTabWidget::pane { /* The tab widget frame */
+ border-top: 2px solid #C2C7CB;
+ position: absolute;
+ top: -0.5em;
+}
+
+QTabWidget::tab-bar {
+ alignment: center;
+}
+
+/* Style the tab using the tab sub-control. Note that
+ it reads QTabBar _not_ QTabWidget */
+QTabBar::tab {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #E1E1E1, stop: 0.4 #DDDDDD,
+ stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);
+ border: 2px solid #C4C4C3;
+ border-bottom-color: #C2C7CB; /* same as the pane color */
+ border-top-left-radius: 4px;
+ border-top-right-radius: 4px;
+ min-width: 8ex;
+ padding: 2px;
+}
+
+QTabBar::tab:selected, QTabBar::tab:hover {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #fafafa, stop: 0.4 #f4f4f4,
+ stop: 0.5 #e7e7e7, stop: 1.0 #fafafa);
+}
+
+QTabBar::tab:selected {
+ border-color: #9B9B9B;
+ border-bottom-color: #C2C7CB; /* same as pane color */
+}
+//! [147]
+
+
+//! [148]
+QTabBar::tear {
+ image: url(tear_indicator.png);
+}
+
+QTabBar::scroller { /* the width of the scroll buttons */
+ width: 20px;
+}
+
+QTabBar QToolButton { /* the scroll buttons are tool buttons */
+ border-image: url(scrollbutton.png) 2;
+ border-width: 2px;
+}
+
+QTabBar QToolButton::right-arrow { /* the arrow mark in the tool buttons */
+ image: url(rightarrow.png);
+}
+
+QTabBar QToolButton::left-arrow {
+ image: url(leftarrow.png);
+}
+//! [148]
+
+
+//! [149]
+QTableView {
+ selection-background-color: qlineargradient(x1: 0, y1: 0, x2: 0.5, y2: 0.5,
+ stop: 0 #FF92BB, stop: 1 white);
+}
+//! [149]
+
+
+//! [150]
+QTableView QTableCornerButton::section {
+ background: red;
+ border: 2px outset red;
+}
+//! [150]
+
+
+//! [151]
+QToolBar {
+ background: red;
+ spacing: 3px; /* spacing between items in the tool bar */
+}
+
+QToolBar::handle {
+ image: url(handle.png);
+}
+//! [151]
+
+
+//! [152]
+QToolBox::tab {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #E1E1E1, stop: 0.4 #DDDDDD,
+ stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);
+ border-radius: 5px;
+ color: darkgray;
+}
+
+QToolBox::tab:selected { /* italicize selected tabs */
+ font: italic;
+ color: white;
+}
+//! [152]
+
+
+//! [153]
+QToolButton { /* all types of tool button */
+ border: 2px solid #8f8f91;
+ border-radius: 6px;
+ background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #f6f7fa, stop: 1 #dadbde);
+}
+
+QToolButton[popupMode="1"] { /* only for MenuButtonPopup */
+ padding-right: 20px; /* make way for the popup button */
+}
+
+QToolButton:pressed {
+ background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #dadbde, stop: 1 #f6f7fa);
+}
+
+/* the subcontrols below are used only in the MenuButtonPopup mode */
+QToolButton::menu-button {
+ border: 2px solid gray;
+ border-top-right-radius: 6px;
+ border-bottom-right-radius: 6px;
+ /* 16px width + 4px for border = 20px allocated above */
+ width: 16px;
+}
+
+QToolButton::menu-arrow {
+ image: url(downarrow.png);
+}
+
+QToolButton::menu-arrow:open {
+ top: 1px; left: 1px; /* shift it a bit */
+}
+//! [153]
+
+
+//! [154]
+QToolTip {
+ border: 2px solid darkkhaki;
+ padding: 5px;
+ border-radius: 3px;
+ opacity: 200;
+}
+//! [154]
+
+
+//! [155]
+QTreeView {
+ alternate-background-color: yellow;
+}
+//! [155]
+
+
+//! [156]
+QTreeView {
+ show-decoration-selected: 1;
+}
+
+QTreeView::item {
+ border: 1px solid #d9d9d9;
+ border-top-color: transparent;
+ border-bottom-color: transparent;
+}
+
+QTreeView::item:hover {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e7effd, stop: 1 #cbdaf1);
+ border: 1px solid #bfcde4;
+}
+
+QTreeView::item:selected {
+ border: 1px solid #567dbc;
+}
+
+QTreeView::item:selected:active{
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6ea1f1, stop: 1 #567dbc);
+}
+
+QTreeView::item:selected:!active {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6b9be8, stop: 1 #577fbf);
+}
+//! [156]
+
+
+//! [157]
+QTreeView::branch {
+ background: palette(base);
+}
+
+QTreeView::branch:has-siblings:!adjoins-item {
+ background: cyan;
+}
+
+QTreeView::branch:has-siblings:adjoins-item {
+ background: red;
+}
+
+QTreeView::branch:!has-children:!has-siblings:adjoins-item {
+ background: blue;
+}
+
+QTreeView::branch:closed:has-children:has-siblings {
+ background: pink;
+}
+
+QTreeView::branch:has-children:!has-siblings:closed {
+ background: gray;
+}
+
+QTreeView::branch:open:has-children:has-siblings {
+ background: magenta;
+}
+
+QTreeView::branch:open:has-children:!has-siblings {
+ background: green;
+}
+
+//! [157]
+
+
+//! [158]
+QTreeView::branch:has-siblings:!adjoins-item {
+ border-image: url(vline.png) 0;
+}
+
+QTreeView::branch:has-siblings:adjoins-item {
+ border-image: url(branch-more.png) 0;
+}
+
+QTreeView::branch:!has-children:!has-siblings:adjoins-item {
+ border-image: url(branch-end.png) 0;
+}
+
+QTreeView::branch:has-children:!has-siblings:closed,
+QTreeView::branch:closed:has-children:has-siblings {
+ border-image: none;
+ image: url(branch-closed.png);
+}
+
+QTreeView::branch:open:has-children:!has-siblings,
+QTreeView::branch:open:has-children:has-siblings {
+ border-image: none;
+ image: url(branch-open.png);
+}
+//! [158]
+
+//! [159]
+QTabBar::close-button {
+ image: url(close.png)
+ subcontrol-position: left;
+}
+QTabBar::close-button:hover {
+ image: url(close-hover.png)
+}
+
+//! [159]
diff --git a/doc/src/snippets/code/src.gui.text.qtextdocumentwriter.cpp b/doc/src/snippets/code/src.gui.text.qtextdocumentwriter.cpp
new file mode 100644
index 0000000000..d7b982758b
--- /dev/null
+++ b/doc/src/snippets/code/src.gui.text.qtextdocumentwriter.cpp
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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/doc/src/snippets/code/src.qdbus.qdbuspendingcall.cpp b/doc/src/snippets/code/src.qdbus.qdbuspendingcall.cpp
new file mode 100644
index 0000000000..623c526f7b
--- /dev/null
+++ b/doc/src/snippets/code/src.qdbus.qdbuspendingcall.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+ QDBusPendingCall async = iface->asyncCall("RemoteMethod", value1, value2);
+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this);
+
+ QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
+ this, SLOT(callFinishedSlot(QDBusPendingCallWatcher*)));
+//! [0]
+
+}
+
+//! [1]
+void MyClass::callFinishedSlot(QDBusPendingCallWatcher *call)
+{
+ QDBusPendingReply<QString, QByteArray> reply = *call;
+ if (reply.isError()) {
+ showError();
+ } else {
+ QString text = reply.argumentAt<0>();
+ QByteArray data = reply.argumentAt<1>();
+ showReply(text, data);
+ }
+ call->deleteLater();
+}
+//! [1]
diff --git a/doc/src/snippets/code/src.qdbus.qdbuspendingreply.cpp b/doc/src/snippets/code/src.qdbus.qdbuspendingreply.cpp
new file mode 100644
index 0000000000..31e240ad35
--- /dev/null
+++ b/doc/src/snippets/code/src.qdbus.qdbuspendingreply.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+ QDBusPendingReply<QString> reply = interface->asyncCall("RemoteMethod");
+ reply.waitForFinished();
+ if (reply.isError())
+ // call failed. Show an error condition.
+ showError(reply.error());
+ else
+ // use the returned value
+ useValue(reply.value());
+//! [0]
+
+//! [2]
+ QDBusPendingReply<bool, QString> reply = interface->asyncCall("RemoteMethod");
+ reply.waitForFinished();
+ if (!reply.isError()) {
+ if (reply.argumentAt<0>())
+ showSuccess(reply.argumentAt<1>());
+ else
+ showFailure(reply.argumentAt<1>());
+ }
+//! [2]
+}
diff --git a/doc/src/snippets/code/src_corelib_codecs_qtextcodec.cpp b/doc/src/snippets/code/src_corelib_codecs_qtextcodec.cpp
new file mode 100644
index 0000000000..698c0b652e
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_codecs_qtextcodec.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QByteArray encodedString = "...";
+QTextCodec *codec = QTextCodec::codecForName("KOI8-R");
+QString string = codec->toUnicode(encodedString);
+//! [0]
+
+
+//! [1]
+QString string = "...";
+QTextCodec *codec = QTextCodec::codecForName("KOI8-R");
+QByteArray encodedString = codec->fromUnicode(string);
+//! [1]
+
+
+//! [2]
+QTextCodec *codec = QTextCodec::codecForName("Shift-JIS");
+QTextDecoder *decoder = codec->makeDecoder();
+
+QString string;
+while (new_data_available()) {
+ QByteArray chunk = get_new_data();
+ string += decoder->toUnicode(chunk);
+}
+delete decoder;
+//! [2]
+
+
+//! [3]
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QTextCodec::setCodecForTr(QTextCodec::codecForName("eucKR"));
+ ...
+}
+//! [3]
diff --git a/doc/src/snippets/code/src_corelib_codecs_qtextcodecplugin.cpp b/doc/src/snippets/code/src_corelib_codecs_qtextcodecplugin.cpp
new file mode 100644
index 0000000000..684884f400
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_codecs_qtextcodecplugin.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QList<QByteArray> MyCodecPlugin::names() const
+{
+ return QList<QByteArray> << "IBM01140" << "hp15-tw";
+}
+
+QTextCodec *MyCodecPlugin::createForName(const QByteArray &name)
+{
+ if (name == "IBM01140") {
+ return new Ibm01140Codec;
+ } else if (name == "hp15-tw") {
+ return new Hp15TwCodec;
+ }
+ return 0;
+}
+//! [0]
diff --git a/doc/src/snippets/code/src_corelib_concurrent_qfuture.cpp b/doc/src/snippets/code/src_corelib_concurrent_qfuture.cpp
new file mode 100644
index 0000000000..7e106bfb9c
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_concurrent_qfuture.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QFuture<QString> future = ...;
+
+QFuture<QString>::const_iterator i;
+for (i = future.constBegin(); i != future.constEnd(); ++i)
+ cout << *i << endl;
+//! [0]
+
+
+//! [1]
+QFuture<QString> future;
+...
+QFutureIterator<QString> i(future);
+while (i.hasNext())
+ qDebug() << i.next();
+//! [1]
+
+
+//! [2]
+QFutureIterator<QString> i(future);
+i.toBack();
+while (i.hasPrevious())
+ qDebug() << i.previous();
+//! [2]
diff --git a/doc/src/snippets/code/src_corelib_concurrent_qfuturesynchronizer.cpp b/doc/src/snippets/code/src_corelib_concurrent_qfuturesynchronizer.cpp
new file mode 100644
index 0000000000..291e2f4f4e
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_concurrent_qfuturesynchronizer.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 someFunction()
+{
+ QFutureSynchronizer<void> synchronizer;
+
+ ...
+
+ synchronizer.addFuture(QtConcurrent::run(anotherFunction));
+ synchronizer.addFuture(QtConcurrent::map(list, mapFunction));
+
+ return; // QFutureSynchronizer waits for all futures to finish
+}
+//! [0]
diff --git a/doc/src/snippets/code/src_corelib_concurrent_qfuturewatcher.cpp b/doc/src/snippets/code/src_corelib_concurrent_qfuturewatcher.cpp
new file mode 100644
index 0000000000..9f12e936fc
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_concurrent_qfuturewatcher.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+// Instantiate the objects and connect to the finished signal.
+MyClass myObject;
+QFutureWatcher<int> watcher;
+connect(&watcher, SIGNAL(finished()), &myObject, SLOT(handleFinished()));
+
+// Start the computation.
+QFuture<int> future = QtConcurrent::run(...);
+watcher.setFuture(future);
+//! [0]
diff --git a/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentexception.cpp b/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentexception.cpp
new file mode 100644
index 0000000000..85f3551b62
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentexception.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 MyException : public QtConcurrent::Exception
+{
+public:
+ void raise() const { throw *this; }
+ Exception *clone() const { return new MyException(*this); }
+};
+
+//! [0]
+
+
+//! [1]
+
+try {
+ QtConcurrent::blockingMap(list, throwFunction); // throwFunction throws MyException
+} catch (MyException &e) {
+ // handle exception
+}
+
+//! [1]
+
+
+//! [2]
+
+void MyException::raise() const { throw *this; }
+
+//! [2]
+
+
+//! [3]
+
+MyException *MyException::clone() const { return new MyException(*this); }
+
+//! [3]
diff --git a/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentfilter.cpp b/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentfilter.cpp
new file mode 100644
index 0000000000..d18f1e5165
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentfilter.cpp
@@ -0,0 +1,171 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+bool function(const T &t);
+//! [0]
+
+
+//! [1]
+bool allLowerCase(const QString &string)
+{
+ return string.lowered() == string;
+}
+
+QStringList strings = ...;
+QFuture<QString> lowerCaseStrings = QtConcurrent::filtered(strings, allLowerCase);
+//! [1]
+
+
+//! [2]
+QStringList strings = ...;
+QFuture<void> future = QtConcurrent::filter(strings, allLowerCase);
+//! [2]
+
+
+//! [3]
+V function(T &result, const U &intermediate)
+//! [3]
+
+
+//! [4]
+void addToDictionary(QSet<QString> &dictionary, const QString &string)
+{
+ dictionary.insert(string);
+}
+
+QStringList strings = ...;
+QFuture<QSet<QString> > dictionary = QtConcurrent::filteredReduced(strings, allLowerCase, addToDictionary);
+//! [4]
+
+
+//! [5]
+QStringList strings = ...;
+QFuture<QString> lowerCaseStrings = QtConcurrent::filtered(strings.constBegin(), strings.constEnd(), allLowerCase);
+
+// filter in-place only works on non-const iterators
+QFuture<void> future = QtConcurrent::filter(strings.begin(), strings.end(), allLowerCase);
+
+QFuture<QSet<QString> > dictionary = QtConcurrent::filteredReduced(strings.constBegin(), strings.constEnd(), allLowerCase, addToDictionary);
+//! [5]
+
+
+//! [6]
+QStringList strings = ...;
+
+// each call blocks until the entire operation is finished
+QStringList lowerCaseStrings = QtConcurrent::blockingFiltered(strings, allLowerCase);
+
+
+QtConcurrent::blockingFilter(strings, allLowerCase);
+
+QSet<QString> dictionary = QtConcurrent::blockingFilteredReduced(strings, allLowerCase, addToDictionary);
+//! [6]
+
+
+//! [7]
+// keep only images with an alpha channel
+QList<QImage> images = ...;
+QFuture<void> alphaImages = QtConcurrent::filter(strings, &QImage::hasAlphaChannel);
+
+// keep only gray scale images
+QList<QImage> images = ...;
+QFuture<QImage> grayscaleImages = QtConcurrent::filtered(images, &QImage::isGrayscale);
+
+// create a set of all printable characters
+QList<QChar> characters = ...;
+QFuture<QSet<QChar> > set = QtConcurrent::filteredReduced(characters, &QChar::isPrint, &QSet<QChar>::insert);
+//! [7]
+
+
+//! [8]
+// can mix normal functions and member functions with QtConcurrent::filteredReduced()
+
+// create a dictionary of all lower cased strings
+extern bool allLowerCase(const QString &string);
+QStringList strings = ...;
+QFuture<QSet<int> > averageWordLength = QtConcurrent::filteredReduced(strings, allLowerCase, QSet<QString>::insert);
+
+// create a collage of all gray scale images
+extern void addToCollage(QImage &collage, const QImage &grayscaleImage);
+QList<QImage> images = ...;
+QFuture<QImage> collage = QtConcurrent::filteredReduced(images, &QImage::isGrayscale, addToCollage);
+//! [8]
+
+
+//! [9]
+bool QString::contains(const QRegExp &regexp) const;
+//! [9]
+
+
+//! [10]
+boost::bind(&QString::contains, QRegExp("^\\S+$")); // matches strings without whitespace
+//! [10]
+
+
+//! [11]
+bool contains(const QString &string)
+//! [11]
+
+
+//! [12]
+QStringList strings = ...;
+boost::bind(static_cast<bool(QString::*)(const QRegExp&)>( &QString::contains ), QRegExp("..." ));
+//! [12]
+
+//! [13]
+struct StartsWith
+{
+ StartsWith(const QString &string)
+ : m_string(string) { }
+
+ typedef bool result_type;
+
+ bool operator()(const QString &testString)
+ {
+ return testString.startsWith(m_string);
+ }
+
+ QString m_string;
+};
+
+QList<QString> strings = ...;
+QFuture<QString> fooString = QtConcurrent::filtered(images, StartsWith(QLatin1String("Foo")));
+//! [13]
diff --git a/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp b/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp
new file mode 100644
index 0000000000..c48ce1e6ae
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp
@@ -0,0 +1,184 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+U function(const T &t);
+//! [0]
+
+
+//! [1]
+QImage scaled(const QImage &image)
+{
+ return image.scaled(100, 100);
+}
+
+QList<QImage> images = ...;
+QFuture<QImage> thumbnails = QtConcurrent::mapped(images, scaled);
+//! [1]
+
+
+//! [2]
+U function(T &t);
+//! [2]
+
+
+//! [3]
+void scale(QImage &image)
+{
+ image = image.scaled(100, 100);
+}
+
+QList<QImage> images = ...;
+QFuture<void> future = QtConcurrent::map(images, scale);
+//! [3]
+
+
+//! [4]
+V function(T &result, const U &intermediate)
+//! [4]
+
+
+//! [5]
+void addToCollage(QImage &collage, const QImage &thumbnail)
+{
+ QPainter p(&collage);
+ static QPoint offset = QPoint(0, 0);
+ p.drawImage(offset, thumbnail);
+ offset += ...;
+}
+
+QList<QImage> images = ...;
+QFuture<QImage> collage = QtConcurrent::mappedReduced(images, scaled, addToCollage);
+//! [5]
+
+
+//! [6]
+QList<QImage> images = ...;
+
+QFuture<QImage> thumbnails = QtConcurrent::mapped(images.constBegin(), images.constEnd(), scaled);
+
+// map in-place only works on non-const iterators
+QFuture<void> future = QtConcurrent::map(images.begin(), images.end(), scale);
+
+QFuture<QImage> collage = QtConcurrent::mappedReduced(images.constBegin(), images.constEnd(), scaled, addToCollage);
+//! [6]
+
+
+//! [7]
+QList<QImage> images = ...;
+
+// each call blocks until the entire operation is finished
+QList<QImage> future = QtConcurrent::blockingMapped(images, scaled);
+
+QtConcurrent::blockingMap(images, scale);
+
+QImage collage = QtConcurrent::blockingMappedReduced(images, scaled, addToCollage);
+//! [7]
+
+
+//! [8]
+// squeeze all strings in a QStringList
+QStringList strings = ...;
+QFuture<void> squeezedStrings = QtConcurrent::map(strings, &QString::squeeze);
+
+// swap the rgb values of all pixels on a list of images
+QList<QImage> images = ...;
+QFuture<QImage> bgrImages = QtConcurrent::mapped(images, &QImage::rgbSwapped);
+
+// create a set of the lengths of all strings in a list
+QStringList strings = ...;
+QFuture<QSet<int> > wordLengths = QtConcurrent::mappedReduced(string, &QString::length, &QSet<int>::insert);
+//! [8]
+
+
+//! [9]
+// can mix normal functions and member functions with QtConcurrent::mappedReduced()
+
+// compute the average length of a list of strings
+extern void computeAverage(int &average, int length);
+QStringList strings = ...;
+QFuture<int> averageWordLength = QtConcurrent::mappedReduced(strings, &QString::length, computeAverage);
+
+// create a set of the color distribution of all images in a list
+extern int colorDistribution(const QImage &string);
+QList<QImage> images = ...;
+QFuture<QSet<int> > totalColorDistribution = QtConcurrent::mappedReduced(images, colorDistribution, QSet<int>::insert);
+//! [9]
+
+
+//! [10]
+QImage QImage::scaledToWidth(int width, Qt::TransformationMode) const;
+//! [10]
+
+
+//! [11]
+boost::bind(&QImage::scaledToWidth, 100, Qt::SmoothTransformation)
+//! [11]
+
+
+//! [12]
+QImage scaledToWith(const QImage &image)
+//! [12]
+
+
+//! [13]
+QList<QImage> images = ...;
+QFuture<QImage> thumbnails = QtConcurrent::mapped(images, boost::bind(&QImage::scaledToWidth, 100 Qt::SmoothTransformation));
+//! [13]
+
+//! [14]
+struct Scaled
+{
+ Scaled(int size)
+ : m_size(size) { }
+
+ typedef QImage result_type;
+
+ QImage operator()(const QImage &image)
+ {
+ return image.scaled(m_size, m_size);
+ }
+
+ int m_size;
+};
+
+QList<QImage> images = ...;
+QFuture<QImage> thumbnails = QtConcurrent::mapped(images, Scaled(100));
+//! [14]
diff --git a/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentrun.cpp b/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentrun.cpp
new file mode 100644
index 0000000000..11f5163f50
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentrun.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+extern void aFunction();
+QFuture<void> future = QtConcurrent::run(aFunction);
+//! [0]
+
+
+//! [1]
+extern void aFunctionWithArguments(int arg1, double arg2, const QString &string);
+
+int integer = ...;
+double floatingPoint = ...;
+QString string = ...;
+
+QFuture<void> future = QtConcurrent::run(aFunctionWithArguments, integer, floatingPoint, string);
+//! [1]
+
+
+//! [2]
+extern QString functionReturningAString();
+QFuture<QString> future = QtConcurrent::run(functionReturningAString);
+...
+QString result = future.result();
+//! [2]
+
+
+//! [3]
+extern QString someFunction(const QByteArray &input);
+
+QByteArray bytearray = ...;
+
+QFuture<QString> future = QtConcurrent::run(someFunction, bytearray);
+...
+QString result = future.result();
+//! [3]
+
+//! [4]
+// call 'QList<QByteArray> QByteArray::split(char sep) const' in a separate thread
+QByteArray bytearray = "hello world";
+QFuture<QList<QByteArray> > future = QtConcurrent::run(bytearray, &QByteArray::split), ',');
+...
+QList<QByteArray> result = future.result();
+//! [4]
+
+//! [5]
+// call 'void QImage::invertPixels(InvertMode mode)' in a separate thread
+QImage image = ...;
+QFuture<void> future = QtConcurrent::run(image, &QImage::invertPixels, QImage::InvertRgba);
+...
+future.waitForFinished();
+// At this point, the pixels in 'image' have been inverted
+//! [5]
+
+
+//! [6]
+void someFunction(int arg1, double arg2);
+QFuture<void> future = QtConcurrent::run(boost::bind(someFunction, 1, 2.0));
+...
+//! [6]
diff --git a/doc/src/snippets/code/src_corelib_concurrent_qthreadpool.cpp b/doc/src/snippets/code/src_corelib_concurrent_qthreadpool.cpp
new file mode 100644
index 0000000000..6262cb1a11
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_concurrent_qthreadpool.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 HelloWorldTask : public QRunnable
+{
+ void run()
+ {
+ qDebug() << "Hello world from thread" << QThread::currentThread();
+ }
+}
+
+HelloWorldTask *hello = new HelloWorldTask();
+// QThreadPool takes ownership and deletes 'hello' automatically
+QThreadPool::globalInstance()->start(hello);
+//! [0]
diff --git a/doc/src/snippets/code/src_corelib_global_qglobal.cpp b/doc/src/snippets/code/src_corelib_global_qglobal.cpp
new file mode 100644
index 0000000000..c79a714192
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_global_qglobal.cpp
@@ -0,0 +1,557 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+label->setAlignment(Qt::AlignLeft | Qt::AlignTop);
+//! [0]
+
+
+//! [1]
+class MyClass
+{
+public:
+ enum Option {
+ NoOptions = 0x0,
+ ShowTabs = 0x1,
+ ShowAll = 0x2,
+ SqueezeBlank = 0x4
+ };
+ Q_DECLARE_FLAGS(Options, Option)
+ ...
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(MyClass::Options)
+//! [1]
+
+//! [meta-object flags]
+Q_FLAGS(Options)
+//! [meta-object flags]
+
+//! [2]
+typedef QFlags<Enum> Flags;
+//! [2]
+
+
+//! [3]
+int myValue = 10;
+int minValue = 2;
+int maxValue = 6;
+
+int boundedValue = qBound(minValue, myValue, maxValue);
+// boundedValue == 6
+//! [3]
+
+
+//! [4]
+if (!driver()->isOpen() || driver()->isOpenError()) {
+ qWarning("QSqlQuery::exec: database not open");
+ return false;
+}
+//! [4]
+
+
+//! [5]
+qint64 value = Q_INT64_C(932838457459459);
+//! [5]
+
+
+//! [6]
+quint64 value = Q_UINT64_C(932838457459459);
+//! [6]
+
+
+//! [7]
+void myMsgHandler(QtMsgType, const char *);
+//! [7]
+
+
+//! [8]
+qint64 value = Q_INT64_C(932838457459459);
+//! [8]
+
+
+//! [9]
+quint64 value = Q_UINT64_C(932838457459459);
+//! [9]
+
+
+//! [10]
+int absoluteValue;
+int myValue = -4;
+
+absoluteValue = qAbs(myValue);
+// absoluteValue == 4
+//! [10]
+
+
+//! [11]
+qreal valueA = 2.3;
+qreal valueB = 2.7;
+
+int roundedValueA = qRound(valueA);
+// roundedValueA = 2
+int roundedValueB = qRound(valueB);
+// roundedValueB = 3
+//! [11]
+
+
+//! [12]
+qreal valueA = 42949672960.3;
+qreal valueB = 42949672960.7;
+
+int roundedValueA = qRound(valueA);
+// roundedValueA = 42949672960
+int roundedValueB = qRound(valueB);
+// roundedValueB = 42949672961
+//! [12]
+
+
+//! [13]
+int myValue = 6;
+int yourValue = 4;
+
+int minValue = qMin(myValue, yourValue);
+// minValue == yourValue
+//! [13]
+
+
+//! [14]
+int myValue = 6;
+int yourValue = 4;
+
+int maxValue = qMax(myValue, yourValue);
+// maxValue == myValue
+//! [14]
+
+
+//! [15]
+int myValue = 10;
+int minValue = 2;
+int maxValue = 6;
+
+int boundedValue = qBound(minValue, myValue, maxValue);
+// boundedValue == 6
+//! [15]
+
+
+//! [16]
+#if QT_VERSION >= 0x040100
+ QIcon icon = style()->standardIcon(QStyle::SP_TrashIcon);
+#else
+ QPixmap pixmap = style()->standardPixmap(QStyle::SP_TrashIcon);
+ QIcon icon(pixmap);
+#endif
+//! [16]
+
+
+//! [17]
+// File: div.cpp
+
+#include <QtGlobal>
+
+int divide(int a, int b)
+{
+ Q_ASSERT(b != 0);
+ return a / b;
+}
+//! [17]
+
+
+//! [18]
+ASSERT: "b == 0" in file div.cpp, line 7
+//! [18]
+
+
+//! [19]
+// File: div.cpp
+
+#include <QtGlobal>
+
+int divide(int a, int b)
+{
+ Q_ASSERT_X(b != 0, "divide", "division by zero");
+ return a / b;
+}
+//! [19]
+
+
+//! [20]
+ASSERT failure in divide: "division by zero", file div.cpp, line 7
+//! [20]
+
+
+//! [21]
+int *a;
+
+Q_CHECK_PTR(a = new int[80]); // WRONG!
+
+a = new (nothrow) int[80]; // Right
+Q_CHECK_PTR(a);
+//! [21]
+
+
+//! [22]
+template<typename TInputType>
+const TInputType &myMin(const TInputType &value1, const TInputType &value2)
+{
+ qDebug() << Q_FUNC_INFO << "was called with value1:" << value1 << "value2:" << value2;
+
+ if(value1 < value2)
+ return value1;
+ else
+ return value2;
+}
+//! [22]
+
+
+//! [23]
+#include <qapplication.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+void myMessageOutput(QtMsgType type, const char *msg)
+{
+ switch (type) {
+ case QtDebugMsg:
+ fprintf(stderr, "Debug: %s\n", msg);
+ break;
+ case QtWarningMsg:
+ fprintf(stderr, "Warning: %s\n", msg);
+ break;
+ case QtCriticalMsg:
+ fprintf(stderr, "Critical: %s\n", msg);
+ break;
+ case QtFatalMsg:
+ fprintf(stderr, "Fatal: %s\n", msg);
+ abort();
+ }
+}
+
+int main(int argc, char **argv)
+{
+ qInstallMsgHandler(myMessageOutput);
+ QApplication app(argc, argv);
+ ...
+ return app.exec();
+}
+//! [23]
+
+
+//! [24]
+qDebug("Items in list: %d", myList.size());
+//! [24]
+
+
+//! [25]
+qDebug() << "Brush:" << myQBrush << "Other value:" << i;
+//! [25]
+
+
+//! [26]
+void f(int c)
+{
+ if (c > 200)
+ qWarning("f: bad argument, c == %d", c);
+}
+//! [26]
+
+
+//! [27]
+qWarning() << "Brush:" << myQBrush << "Other value:"
+<< i;
+//! [27]
+
+
+//! [28]
+void load(const QString &fileName)
+{
+ QFile file(fileName);
+ if (!file.exists())
+ qCritical("File '%s' does not exist!", qPrintable(fileName));
+}
+//! [28]
+
+
+//! [29]
+qCritical() << "Brush:" << myQBrush << "Other
+value:" << i;
+//! [29]
+
+
+//! [30]
+int divide(int a, int b)
+{
+ if (b == 0) // program error
+ qFatal("divide: cannot divide by zero");
+ return a / b;
+}
+//! [30]
+
+
+//! [31]
+forever {
+ ...
+}
+//! [31]
+
+
+//! [32]
+CONFIG += no_keywords
+//! [32]
+
+
+//! [33]
+CONFIG += no_keywords
+//! [33]
+
+
+//! [34]
+QString FriendlyConversation::greeting(int type)
+{
+static const char *greeting_strings[] = {
+ QT_TR_NOOP("Hello"),
+ QT_TR_NOOP("Goodbye")
+};
+return tr(greeting_strings[type]);
+}
+//! [34]
+
+
+//! [35]
+static const char *greeting_strings[] = {
+ QT_TRANSLATE_NOOP("FriendlyConversation", "Hello"),
+ QT_TRANSLATE_NOOP("FriendlyConversation", "Goodbye")
+};
+
+QString FriendlyConversation::greeting(int type)
+{
+ return tr(greeting_strings[type]);
+}
+
+QString global_greeting(int type)
+{
+ return qApp->translate("FriendlyConversation",
+ greeting_strings[type]);
+}
+//! [35]
+
+
+//! [36]
+
+static { const char *source; const char *comment; } greeting_strings[] =
+{
+ QT_TRANSLATE_NOOP3("FriendlyConversation", "Hello",
+ "A really friendly hello"),
+ QT_TRANSLATE_NOOP3("FriendlyConversation", "Goodbye",
+ "A really friendly goodbye")
+};
+
+QString FriendlyConversation::greeting(int type)
+{
+ return tr(greeting_strings[type].source,
+ greeting_strings[type].comment);
+}
+
+QString global_greeting(int type)
+{
+ return qApp->translate("FriendlyConversation",
+ greeting_strings[type].source,
+ greeting_strings[type].comment);
+}
+//! [36]
+
+
+//! [qttrid]
+ //% "%n fooish bar(s) found.\n"
+ //% "Do you want to continue?"
+ QString text = qtTrId("qtn_foo_bar", n);
+//! [qttrid]
+
+
+//! [qttrid_noop]
+static const char * const ids[] = {
+ //% "This is the first text."
+ QT_TRID_NOOP("qtn_1st_text"),
+ //% "This is the second text."
+ QT_TRID_NOOP("qtn_2nd_text"),
+ 0
+};
+
+void TheClass::addLabels()
+{
+ for (int i = 0; ids[i]; ++i)
+ new QLabel(qtTrId(ids[i]), this);
+}
+//! [qttrid_noop]
+
+
+//! [37]
+qWarning("%s: %s", qPrintable(key), qPrintable(value));
+//! [37]
+
+
+//! [38]
+struct Point2D
+{
+ int x;
+ int y;
+};
+
+Q_DECLARE_TYPEINFO(Point2D, Q_PRIMITIVE_TYPE);
+//! [38]
+
+
+//! [39]
+class Point2D
+{
+public:
+ Point2D() { data = new int[2]; }
+ Point2D(const Point2D &other) { ... }
+ ~Point2D() { delete[] data; }
+
+ Point2D &operator=(const Point2D &other) { ... }
+
+ int x() const { return data[0]; }
+ int y() const { return data[1]; }
+
+private:
+ int *data;
+};
+
+Q_DECLARE_TYPEINFO(Point2D, Q_MOVABLE_TYPE);
+//! [39]
+
+
+//! [40]
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+...
+#endif
+
+or
+
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+...
+#endif
+
+//! [40]
+
+
+//! [41]
+
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+...
+#endif
+
+//! [41]
+
+
+//! [42]
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+...
+#endif
+
+//! [42]
+
+//! [begin namespace macro]
+namespace QT_NAMESPACE {
+//! [begin namespace macro]
+
+//! [end namespace macro]
+}
+//! [end namespace macro]
+
+//! [43]
+class MyClass : public QObject
+{
+
+ private:
+ Q_DISABLE_COPY(MyClass)
+};
+
+//! [43]
+
+//! [44]
+class MyClass : public QObject
+{
+
+ private:
+ MyClass(const MyClass &);
+ MyClass &operator=(const MyClass &);
+};
+//! [44]
+
+//! [45]
+ QWidget w = QWidget();
+//! [45]
+
+//! [46]
+ // Instead of comparing with 0.0
+ qFuzzyCompare(0.0,1.0e-200); // This will return false
+ // Compare adding 1 to both values will fix the problem
+ qFuzzyCompare(1 + 0.0, 1 + 1.0e-200); // This will return true
+//! [46]
+
+//! [47]
+CApaApplication *myApplicationFactory();
+//! [47]
+
+//! [qlikely]
+ // the condition inside the "if" will be successful most of the times
+ for (int i = 1; i <= 365; i++) {
+ if (Q_LIKELY(isWorkingDay(i))) {
+ ...
+ }
+ ...
+ }
+//! [qlikely]
+
+//! [qunlikely]
+bool readConfiguration(const QFile &file)
+{
+ // We expect to be asked to read an existing file
+ if (Q_UNLIKELY(!file.exists())) {
+ qWarning() << "File not found";
+ return false;
+ }
+
+ ...
+ return true;
+}
+//! [qunlikely]
diff --git a/doc/src/snippets/code/src_corelib_io_qabstractfileengine.cpp b/doc/src/snippets/code/src_corelib_io_qabstractfileengine.cpp
new file mode 100644
index 0000000000..74ef79fa87
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_io_qabstractfileengine.cpp
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 ZipEngineHandler : public QAbstractFileEngineHandler
+{
+public:
+ QAbstractFileEngine *create(const QString &fileName) const;
+};
+
+QAbstractFileEngine *ZipEngineHandler::create(const QString &fileName) const
+{
+ // ZipEngineHandler returns a ZipEngine for all .zip files
+ return fileName.toLower().endsWith(".zip") ? new ZipEngine(fileName) : 0;
+}
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ ZipEngineHandler engine;
+
+ MainWindow window;
+ window.show();
+
+ return app.exec();
+}
+//! [0]
+
+
+//! [1]
+QAbstractSocketEngine *ZipEngineHandler::create(const QString &fileName) const
+{
+ // ZipEngineHandler returns a ZipEngine for all .zip files
+ return fileName.toLower().endsWith(".zip") ? new ZipEngine(fileName) : 0;
+}
+//! [1]
+
+
+//! [2]
+QAbstractFileEngineIterator *
+CustomFileEngine::beginEntryList(QDir::Filters filters, const QStringList &filterNames)
+{
+ return new CustomFileEngineIterator(filters, filterNames);
+}
+//! [2]
+
+
+//! [3]
+class CustomIterator : public QAbstractFileEngineIterator
+{
+public:
+ CustomIterator(const QStringList &nameFilters, QDir::Filters filters)
+ : QAbstractFileEngineIterator(nameFilters, filters), index(0)
+ {
+ // In a real iterator, these entries are fetched from the
+ // file system based on the value of path().
+ entries << "entry1" << "entry2" << "entry3";
+ }
+
+ bool hasNext() const
+ {
+ return index < entries.size() - 1;
+ }
+
+ QString next()
+ {
+ if (!hasNext())
+ return QString();
+ ++index;
+ return currentFilePath();
+ }
+
+ QString currentFileName()
+ {
+ return entries.at(index);
+ }
+
+private:
+ QStringList entries;
+ int index;
+};
+//! [3]
diff --git a/doc/src/snippets/code/src_corelib_io_qdatastream.cpp b/doc/src/snippets/code/src_corelib_io_qdatastream.cpp
new file mode 100644
index 0000000000..cd9632c885
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_io_qdatastream.cpp
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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$
+**
+****************************************************************************/
+
+void wrapInFunction()
+{
+
+//! [0]
+QFile file("file.dat");
+file.open(QIODevice::WriteOnly);
+QDataStream out(&file); // we will serialize the data into the file
+out << QString("the answer is"); // serialize a string
+out << (qint32)42; // serialize an integer
+//! [0]
+
+
+//! [1]
+QFile file("file.dat");
+file.open(QIODevice::ReadOnly);
+QDataStream in(&file); // read the data serialized from the file
+QString str;
+qint32 a;
+in >> str >> a; // extract "the answer is" and 42
+//! [1]
+
+
+//! [2]
+stream.setVersion(QDataStream::Qt_4_0);
+//! [2]
+
+
+//! [3]
+QFile file("file.xxx");
+file.open(QIODevice::WriteOnly);
+QDataStream out(&file);
+
+// Write a header with a "magic number" and a version
+out << (quint32)0xA0B0C0D0;
+out << (qint32)123;
+
+out.setVersion(QDataStream::Qt_4_0);
+
+// Write the data
+out << lots_of_interesting_data;
+//! [3]
+
+
+//! [4]
+QFile file("file.xxx");
+file.open(QIODevice::ReadOnly);
+QDataStream in(&file);
+
+// Read and check the header
+quint32 magic;
+in >> magic;
+if (magic != 0xA0B0C0D0)
+ return XXX_BAD_FILE_FORMAT;
+
+// Read the version
+qint32 version;
+in >> version;
+if (version < 100)
+ return XXX_BAD_FILE_TOO_OLD;
+if (version > 123)
+ return XXX_BAD_FILE_TOO_NEW;
+
+if (version <= 110)
+ in.setVersion(QDataStream::Qt_3_2);
+else
+ in.setVersion(QDataStream::Qt_4_0);
+
+// Read the data
+in >> lots_of_interesting_data;
+if (version >= 120)
+ in >> data_new_in_XXX_version_1_2;
+in >> other_interesting_data;
+//! [4]
+
+
+//! [5]
+QDataStream out(file);
+out.setVersion(QDataStream::Qt_4_0);
+//! [5]
+
+}
diff --git a/doc/src/snippets/code/src_corelib_io_qdir.cpp b/doc/src/snippets/code/src_corelib_io_qdir.cpp
new file mode 100644
index 0000000000..51262f711c
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_io_qdir.cpp
@@ -0,0 +1,175 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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$
+**
+****************************************************************************/
+
+
+void wrapInFunction()
+{
+
+//! [0]
+QDir("/home/user/Documents")
+QDir("C:/Documents and Settings")
+//! [0]
+
+
+//! [1]
+QDir("images/landscape.png")
+//! [1]
+
+
+//! [2]
+QDir("Documents/Letters/Applications").dirName() // "Applications"
+QDir().dirName() // "."
+//! [2]
+
+
+//! [3]
+QDir directory("Documents/Letters");
+QString path = directory.filePath("contents.txt");
+QString absolutePath = directory.absoluteFilePath("contents.txt");
+//! [3]
+
+
+//! [4]
+QDir dir("example");
+if (!dir.exists())
+ qWarning("Cannot find the example directory");
+//! [4]
+
+
+//! [5]
+QDir dir = QDir::root(); // "/"
+if (!dir.cd("tmp")) { // "/tmp"
+ qWarning("Cannot find the \"/tmp\" directory");
+} else {
+ QFile file(dir.filePath("ex1.txt")); // "/tmp/ex1.txt"
+ if (!file.open(QIODevice::ReadWrite))
+ qWarning("Cannot create the file %s", file.name());
+}
+//! [5]
+
+
+//! [6]
+QString bin = "/local/bin"; // where /local/bin is a symlink to /usr/bin
+QDir binDir(bin);
+QString canonicalBin = binDir.canonicalPath();
+// canonicalBin now equals "/usr/bin"
+
+QString ls = "/local/bin/ls"; // where ls is the executable "ls"
+QDir lsDir(ls);
+QString canonicalLs = lsDir.canonicalPath();
+// canonicalLS now equals "/usr/bin/ls".
+//! [6]
+
+
+//! [7]
+QDir dir("/home/bob");
+QString s;
+
+s = dir.relativeFilePath("images/file.jpg"); // s is "images/file.jpg"
+s = dir.relativeFilePath("/home/mary/file.txt"); // s is "../mary/file.txt"
+//! [7]
+
+
+//! [8]
+QDir::setSearchPaths("icons", QStringList(QDir::homePath() + "/images"));
+QDir::setSearchPaths("docs", QStringList(":/embeddedDocuments"));
+...
+QPixmap pixmap("icons:undo.png"); // will look for undo.png in QDir::homePath() + "/images"
+QFile file("docs:design.odf"); // will look in the :/embeddedDocuments resource path
+//! [8]
+
+
+//! [9]
+QDir dir("/tmp/root_link");
+dir = dir.canonicalPath();
+if (dir.isRoot())
+ qWarning("It is a root link");
+//! [9]
+
+
+//! [10]
+// The current directory is "/usr/local"
+QDir d1("/usr/local/bin");
+QDir d2("bin");
+if (d1 == d2)
+ qDebug("They're the same");
+//! [10]
+
+
+//! [11]
+// The current directory is "/usr/local"
+QDir d1("/usr/local/bin");
+d1.setFilter(QDir::Executable);
+QDir d2("bin");
+if (d1 != d2)
+ qDebug("They differ");
+//! [11]
+
+
+//! [12]
+C:/Documents and Settings/Username
+//! [12]
+
+
+//! [13]
+Q_INIT_RESOURCE(myapp);
+//! [13]
+
+
+//! [14]
+inline void initMyResource() { Q_INIT_RESOURCE(myapp); }
+
+namespace MyNamespace
+{
+ ...
+
+ void myFunction()
+ {
+ initMyResource();
+ }
+}
+//! [14]
+
+
+//! [15]
+Q_CLEANUP_RESOURCE(myapp);
+//! [15]
+
+}
diff --git a/doc/src/snippets/code/src_corelib_io_qdiriterator.cpp b/doc/src/snippets/code/src_corelib_io_qdiriterator.cpp
new file mode 100644
index 0000000000..e7a93d4021
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_io_qdiriterator.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QDirIterator it("/etc", QDirIterator::Subdirectories);
+while (it.hasNext()) {
+ qDebug() << it.next();
+
+ // /etc/.
+ // /etc/..
+ // /etc/X11
+ // /etc/X11/fs
+ // ...
+}
+//! [0]
diff --git a/doc/src/snippets/code/src_corelib_io_qfile.cpp b/doc/src/snippets/code/src_corelib_io_qfile.cpp
new file mode 100644
index 0000000000..158971e9ca
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_io_qfile.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QFile file;
+QDir::setCurrent("/tmp");
+file.setFileName("readme.txt");
+QDir::setCurrent("/home");
+file.open(QIODevice::ReadOnly); // opens "/home/readme.txt" under Unix
+//! [0]
+
+
+//! [1]
+QByteArray myEncoderFunc(const QString &fileName);
+//! [1]
+
+
+//! [2]
+QString myDecoderFunc(const QByteArray &localFileName);
+//! [2]
+
+
+//! [3]
+#include <stdio.h>
+
+void printError(const char* msg)
+{
+ QFile file;
+ file.open(stderr, QIODevice::WriteOnly);
+ file.write(msg, qstrlen(msg)); // write to stderr
+ file.close();
+}
+//! [3]
+
+
+//! [4]
+CONFIG += console
+//! [4]
diff --git a/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp b/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp
new file mode 100644
index 0000000000..85e00052f7
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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$
+**
+****************************************************************************/
+
+
+//![newstuff]
+ QFileInfo fi("c:/temp/foo"); => fi.absoluteFilePath() => "C:/temp/foo"
+//![newstuff]
+
+//! [0]
+#ifdef Q_OS_UNIX
+
+QFileInfo info1("/home/bob/bin/untabify");
+info1.isSymLink(); // returns true
+info1.absoluteFilePath(); // returns "/home/bob/bin/untabify"
+info1.size(); // returns 56201
+info1.symLinkTarget(); // returns "/opt/pretty++/bin/untabify"
+
+QFileInfo info2(info1.symLinkTarget());
+info2.isSymLink(); // returns false
+info2.absoluteFilePath(); // returns "/opt/pretty++/bin/untabify"
+info2.size(); // returns 56201
+
+#endif
+//! [0]
+
+
+//! [1]
+#ifdef Q_OS_WIN
+
+QFileInfo info1("C:\\Documents and Settings\\Bob\\untabify.lnk");
+info1.isSymLink(); // returns true
+info1.absoluteFilePath(); // returns "C:/Documents and Settings/Bob/untabify.lnk"
+info1.size(); // returns 743
+info1.symLinkTarget(); // returns "C:/Pretty++/untabify"
+
+QFileInfo info2(info1.symLinkTarget());
+info2.isSymLink(); // returns false
+info2.absoluteFilePath(); // returns "C:/Pretty++/untabify"
+info2.size(); // returns 63942
+
+#endif
+//! [1]
+
+
+//! [2]
+QString absolute = "/local/bin";
+QString relative = "local/bin";
+QFileInfo absFile(absolute);
+QFileInfo relFile(relative);
+
+QDir::setCurrent(QDir::rootPath());
+// absFile and relFile now point to the same file
+
+QDir::setCurrent("/tmp");
+// absFile now points to "/local/bin",
+// while relFile points to "/tmp/local/bin"
+//! [2]
+
+
+//! [3]
+QFileInfo fi("/tmp/archive.tar.gz");
+QString name = fi.fileName(); // name = "archive.tar.gz"
+//! [3]
+
+
+//! [4]
+QFileInfo fi("/Applications/Safari.app");
+QString bundle = fi.bundleName(); // name = "Safari"
+//! [4]
+
+
+//! [5]
+QFileInfo fi("/tmp/archive.tar.gz");
+QString base = fi.baseName(); // base = "archive"
+//! [5]
+
+
+//! [6]
+QFileInfo fi("/tmp/archive.tar.gz");
+QString base = fi.completeBaseName(); // base = "archive.tar"
+//! [6]
+
+
+//! [7]
+QFileInfo fi("/tmp/archive.tar.gz");
+QString ext = fi.completeSuffix(); // ext = "tar.gz"
+//! [7]
+
+
+//! [8]
+QFileInfo fi("/tmp/archive.tar.gz");
+QString ext = fi.suffix(); // ext = "gz"
+//! [8]
+
+
+//! [9]
+QFileInfo info(fileName);
+if (info.isSymLink())
+ fileName = info.symLinkTarget();
+//! [9]
+
+
+//! [10]
+QFileInfo fi("/tmp/archive.tar.gz");
+if (fi.permission(QFile::WriteUser | QFile::ReadGroup))
+ qWarning("I can change the file; my group can read the file");
+if (fi.permission(QFile::WriteGroup | QFile::WriteOther))
+ qWarning("The group or others can change the file");
+//! [10]
diff --git a/doc/src/snippets/code/src_corelib_io_qiodevice.cpp b/doc/src/snippets/code/src_corelib_io_qiodevice.cpp
new file mode 100644
index 0000000000..1e2a976c77
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_io_qiodevice.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QProcess gzip;
+gzip.start("gzip", QStringList() << "-c");
+if (!gzip.waitForStarted())
+ return false;
+
+gzip.write("uncompressed data");
+
+QByteArray compressed;
+while (gzip.waitForReadyRead())
+ compressed += gzip.readAll();
+//! [0]
+
+
+//! [1]
+qint64 CustomDevice::bytesAvailable() const
+{
+ return buffer.size() + QIODevice::bytesAvailable();
+}
+//! [1]
+
+
+//! [2]
+QFile file("box.txt");
+if (file.open(QFile::ReadOnly)) {
+ char buf[1024];
+ qint64 lineLength = file.readLine(buf, sizeof(buf));
+ if (lineLength != -1) {
+ // the line is available in buf
+ }
+}
+//! [2]
+
+
+//! [3]
+bool CustomDevice::canReadLine() const
+{
+ return buffer.contains('\n') || QIODevice::canReadLine();
+}
+//! [3]
+
+
+//! [4]
+bool isExeFile(QFile *file)
+{
+ char buf[2];
+ if (file->peek(buf, sizeof(buf)) == sizeof(buf))
+ return (buf[0] == 'M' && buf[1] == 'Z');
+ return false;
+}
+//! [4]
+
+
+//! [5]
+bool isExeFile(QFile *file)
+{
+ return file->peek(2) == "MZ";
+}
+//! [5]
diff --git a/doc/src/snippets/code/src_corelib_io_qprocess.cpp b/doc/src/snippets/code/src_corelib_io_qprocess.cpp
new file mode 100644
index 0000000000..64fb17a7c7
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_io_qprocess.cpp
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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$
+**
+****************************************************************************/
+
+
+void wrapInFunction()
+{
+
+//! [0]
+QProcess builder;
+builder.setProcessChannelMode(QProcess::MergedChannels);
+builder.start("make", QStringList() << "-j2");
+
+if (!builder.waitForFinished())
+ qDebug() << "Make failed:" << builder.errorString();
+else
+ qDebug() << "Make output:" << builder.readAll();
+//! [0]
+
+
+//! [1]
+QProcess more;
+more.start("more");
+more.write("Text to display");
+more.closeWriteChannel();
+// QProcess will emit readyRead() once "more" starts printing
+//! [1]
+
+
+//! [2]
+command1 | command2
+//! [2]
+
+
+//! [3]
+QProcess process1;
+QProcess process2;
+
+process1.setStandardOutputProcess(&process2);
+
+process1.start("command1");
+process2.start("command2");
+//! [3]
+
+
+//! [4]
+class SandboxProcess : public QProcess
+{
+ ...
+ protected:
+ void setupChildProcess();
+ ...
+};
+
+void SandboxProcess::setupChildProcess()
+{
+ // Drop all privileges in the child process, and enter
+ // a chroot jail.
+#if defined Q_OS_UNIX
+ ::setgroups(0, 0);
+ ::chroot("/etc/safe");
+ ::chdir("/");
+ ::setgid(safeGid);
+ ::setuid(safeUid);
+ ::umask(0);
+#endif
+}
+
+//! [4]
+
+
+//! [5]
+QProcess process;
+process.start("del /s *.txt");
+// same as process.start("del", QStringList() << "/s" << "*.txt");
+...
+//! [5]
+
+
+//! [6]
+QProcess process;
+process.start("dir \"My Documents\"");
+//! [6]
+
+
+//! [7]
+QProcess process;
+process.start("dir \"\"\"My Documents\"\"\"");
+//! [7]
+
+
+//! [8]
+QStringList environment = QProcess::systemEnvironment();
+// environment = {"PATH=/usr/bin:/usr/local/bin",
+// "USER=greg", "HOME=/home/greg"}
+//! [8]
+
+}
diff --git a/doc/src/snippets/code/src_corelib_io_qsettings.cpp b/doc/src/snippets/code/src_corelib_io_qsettings.cpp
new file mode 100644
index 0000000000..5abb0e368c
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_io_qsettings.cpp
@@ -0,0 +1,316 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QSettings settings("MySoft", "Star Runner");
+QColor color = settings.value("DataPump/bgcolor").value<QColor>();
+//! [0]
+
+
+//! [1]
+QSettings settings("MySoft", "Star Runner");
+QColor color = palette().background().color();
+settings.setValue("DataPump/bgcolor", color);
+//! [1]
+
+
+//! [2]
+QSettings settings("/home/petra/misc/myapp.ini",
+ QSettings::IniFormat);
+//! [2]
+
+
+//! [3]
+QSettings settings("/Users/petra/misc/myapp.plist",
+ QSettings::NativeFormat);
+//! [3]
+
+
+//! [4]
+QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Office",
+ QSettings::NativeFormat);
+//! [4]
+
+
+//! [5]
+settings.setValue("11.0/Outlook/Security/DontTrustInstalledFiles", 0);
+//! [5]
+
+
+//! [6]
+settings.setValue("HKEY_CURRENT_USER\\MySoft\\Star Runner\\Galaxy", "Milkyway");
+settings.setValue("HKEY_CURRENT_USER\\MySoft\\Star Runner\\Galaxy\\Sun", "OurStar");
+settings.value("HKEY_CURRENT_USER\\MySoft\\Star Runner\\Galaxy\\Default"); // returns "Milkyway"
+//! [6]
+
+
+//! [7]
+#ifdef Q_WS_MAC
+ QSettings settings("grenoullelogique.fr", "Squash");
+#else
+ QSettings settings("Grenoulle Logique", "Squash");
+#endif
+//! [7]
+
+
+//! [8]
+pos = @Point(100 100)
+//! [8]
+
+
+//! [9]
+windir = C:\Windows
+//! [9]
+
+
+//! [10]
+QSettings settings("Moose Tech", "Facturo-Pro");
+//! [10]
+
+
+//! [11]
+QSettings settings("Moose Soft", "Facturo-Pro");
+//! [11]
+
+
+//! [12]
+QCoreApplication::setOrganizationName("Moose Soft");
+QCoreApplication::setApplicationName("Facturo-Pro");
+QSettings settings;
+//! [12]
+
+
+//! [13]
+settings.beginGroup("mainwindow");
+settings.setValue("size", win->size());
+settings.setValue("fullScreen", win->isFullScreen());
+settings.endGroup();
+
+settings.beginGroup("outputpanel");
+settings.setValue("visible", panel->isVisible());
+settings.endGroup();
+//! [13]
+
+
+//! [14]
+settings.beginGroup("alpha");
+// settings.group() == "alpha"
+
+settings.beginGroup("beta");
+// settings.group() == "alpha/beta"
+
+settings.endGroup();
+// settings.group() == "alpha"
+
+settings.endGroup();
+// settings.group() == ""
+//! [14]
+
+
+//! [15]
+struct Login {
+ QString userName;
+ QString password;
+};
+QList<Login> logins;
+...
+
+QSettings settings;
+int size = settings.beginReadArray("logins");
+for (int i = 0; i < size; ++i) {
+ settings.setArrayIndex(i);
+ Login login;
+ login.userName = settings.value("userName").toString();
+ login.password = settings.value("password").toString();
+ logins.append(login);
+}
+settings.endArray();
+//! [15]
+
+
+//! [16]
+struct Login {
+ QString userName;
+ QString password;
+};
+QList<Login> logins;
+...
+
+QSettings settings;
+settings.beginWriteArray("logins");
+for (int i = 0; i < logins.size(); ++i) {
+ settings.setArrayIndex(i);
+ settings.setValue("userName", list.at(i).userName);
+ settings.setValue("password", list.at(i).password);
+}
+settings.endArray();
+//! [16]
+
+
+//! [17]
+QSettings settings;
+settings.setValue("fridge/color", Qt::white);
+settings.setValue("fridge/size", QSize(32, 96));
+settings.setValue("sofa", true);
+settings.setValue("tv", false);
+
+QStringList keys = settings.allKeys();
+// keys: ["fridge/color", "fridge/size", "sofa", "tv"]
+//! [17]
+
+
+//! [18]
+settings.beginGroup("fridge");
+keys = settings.allKeys();
+// keys: ["color", "size"]
+//! [18]
+
+
+//! [19]
+QSettings settings;
+settings.setValue("fridge/color", Qt::white);
+settings.setValue("fridge/size", QSize(32, 96));
+settings.setValue("sofa", true);
+settings.setValue("tv", false);
+
+QStringList keys = settings.childKeys();
+// keys: ["sofa", "tv"]
+//! [19]
+
+
+//! [20]
+settings.beginGroup("fridge");
+keys = settings.childKeys();
+// keys: ["color", "size"]
+//! [20]
+
+
+//! [21]
+QSettings settings;
+settings.setValue("fridge/color", Qt::white);
+settings.setValue("fridge/size", QSize(32, 96));
+settings.setValue("sofa", true);
+settings.setValue("tv", false);
+
+QStringList groups = settings.childGroups();
+// group: ["fridge"]
+//! [21]
+
+
+//! [22]
+settings.beginGroup("fridge");
+groups = settings.childGroups();
+// groups: []
+//! [22]
+
+
+//! [23]
+QSettings settings;
+settings.setValue("interval", 30);
+settings.value("interval").toInt(); // returns 30
+
+settings.setValue("interval", 6.55);
+settings.value("interval").toDouble(); // returns 6.55
+//! [23]
+
+
+//! [24]
+QSettings settings;
+settings.setValue("ape");
+settings.setValue("monkey", 1);
+settings.setValue("monkey/sea", 2);
+settings.setValue("monkey/doe", 4);
+
+settings.remove("monkey");
+QStringList keys = settings.allKeys();
+// keys: ["ape"]
+//! [24]
+
+
+//! [25]
+QSettings settings;
+settings.setValue("ape");
+settings.setValue("monkey", 1);
+settings.setValue("monkey/sea", 2);
+settings.setValue("monkey/doe", 4);
+
+settings.beginGroup("monkey");
+settings.remove("");
+settings.endGroup();
+
+QStringList keys = settings.allKeys();
+// keys: ["ape"]
+//! [25]
+
+
+//! [26]
+QSettings settings;
+settings.setValue("animal/snake", 58);
+settings.value("animal/snake", 1024).toInt(); // returns 58
+settings.value("animal/zebra", 1024).toInt(); // returns 1024
+settings.value("animal/zebra").toInt(); // returns 0
+//! [26]
+
+
+//! [27]
+bool myReadFunc(QIODevice &device, QSettings::SettingsMap &map);
+//! [27]
+
+
+//! [28]
+bool myWriteFunc(QIODevice &device, const QSettings::SettingsMap &map);
+//! [28]
+
+
+//! [29]
+bool readXmlFile(QIODevice &device, QSettings::SettingsMap &map);
+bool writeXmlFile(QIODevice &device, const QSettings::SettingsMap &map);
+
+int main(int argc, char *argv[])
+{
+ const QSettings::Format XmlFormat =
+ QSettings::registerFormat("xml", readXmlFile, writeXmlFile);
+
+ QSettings settings(XmlFormat, QSettings::UserScope, "MySoft",
+ "Star Runner");
+
+ ...
+}
+//! [29]
diff --git a/doc/src/snippets/code/src_corelib_io_qtemporaryfile.cpp b/doc/src/snippets/code/src_corelib_io_qtemporaryfile.cpp
new file mode 100644
index 0000000000..1fb1ccd77d
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_io_qtemporaryfile.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+ // Within a function/method...
+
+ QTemporaryFile file;
+ if (file.open()) {
+ // file.fileName() returns the unique file name
+ }
+
+ // The QTemporaryFile destructor removes the temporary file
+ // as it goes out of scope.
+//! [0]
+}
diff --git a/doc/src/snippets/code/src_corelib_io_qtextstream.cpp b/doc/src/snippets/code/src_corelib_io_qtextstream.cpp
new file mode 100644
index 0000000000..b3483a9b10
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_io_qtextstream.cpp
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QFile data("output.txt");
+if (data.open(QFile::WriteOnly | QFile::Truncate)) {
+ QTextStream out(&data);
+ out << "Result: " << qSetFieldWidth(10) << left << 3.14 << 2.7;
+ // writes "Result: 3.14 2.7 "
+}
+//! [0]
+
+
+//! [1]
+QTextStream stream(stdin);
+QString line;
+do {
+ line = stream.readLine();
+} while (!line.isNull());
+//! [1]
+
+
+//! [2]
+QTextStream in("0x50 0x20");
+int firstNumber, secondNumber;
+
+in >> firstNumber; // firstNumber == 80
+in >> dec >> secondNumber; // secondNumber == 0
+
+char ch;
+in >> ch; // ch == 'x'
+//! [2]
+
+
+//! [3]
+int main(int argc, char *argv[])
+{
+ // read numeric arguments (123, 0x20, 4.5...)
+ for (int i = 1; i < argc; ++i) {
+ int number;
+ QTextStream in(argv[i]);
+ in >> number;
+ ...
+ }
+}
+//! [3]
+
+
+//! [4]
+QString str;
+QTextStream in(stdin);
+in >> str;
+//! [4]
+
+
+//! [5]
+QString s;
+QTextStream out(&s);
+out.setFieldWidth(10);
+out.setFieldAlignment(QTextStream::AlignCenter);
+out.setPadChar('-');
+out << "Qt" << "rocks!";
+//! [5]
+
+
+//! [6]
+----Qt------rocks!--
+//! [6]
+
+
+//! [7]
+QTextStream in(file);
+QChar ch1, ch2, ch3;
+in >> ch1 >> ch2 >> ch3;
+//! [7]
+
+
+//! [8]
+QTextStream out(stdout);
+out << "Qt rocks!" << endl;
+//! [8]
+
+
+//! [9]
+stream << '\n' << flush;
+//! [9]
+
+
+//! [10]
+QTextStream out(&file);
+out.setCodec("UTF-8");
+//! [10]
diff --git a/doc/src/snippets/code/src_corelib_io_qurl.cpp b/doc/src/snippets/code/src_corelib_io_qurl.cpp
new file mode 100644
index 0000000000..18f36da9f4
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_io_qurl.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QUrl url("http://www.example.com/List of holidays.xml");
+// url.toEncoded() == "http://www.example.com/List%20of%20holidays.xml"
+//! [0]
+
+
+//! [1]
+QUrl url = QUrl::fromEncoded("http://qt.nokia.com/List%20of%20holidays.xml");
+//! [1]
+
+
+//! [2]
+bool checkUrl(const QUrl &url) {
+ if (!url.isValid()) {
+ qDebug(QString("Invalid URL: %1").arg(url.toString()));
+ return false;
+ }
+
+ return true;
+}
+//! [2]
+
+
+//! [3]
+QFtp ftp;
+ftp.connectToHost(url.host(), url.port(21));
+//! [3]
+
+
+//! [4]
+http://www.example.com/cgi-bin/drawgraph.cgi?type-pie/color-green
+//! [4]
+
+
+//! [5]
+QUrl baseUrl("http://qt.nokia.com/support");
+QUrl relativeUrl("../products/solutions");
+qDebug(baseUrl.resolved(relativeUrl).toString());
+// prints "http://qt.nokia.com/products/solutions"
+//! [5]
+
+
+//! [6]
+QByteArray ba = QUrl::toPercentEncoding("{a fishy string?}", "{}", "s");
+qDebug(ba.constData());
+// prints "{a fi%73hy %73tring%3F}"
+//! [6]
diff --git a/doc/src/snippets/code/src_corelib_kernel_qabstracteventdispatcher.cpp b/doc/src/snippets/code/src_corelib_kernel_qabstracteventdispatcher.cpp
new file mode 100644
index 0000000000..8f0a5c7ec8
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_kernel_qabstracteventdispatcher.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+bool myEventFilter(void *message);
+//! [0]
diff --git a/doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp b/doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp
new file mode 100644
index 0000000000..cf40f9a05a
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+beginInsertRows(parent, 2, 4);
+//! [0]
+
+
+//! [1]
+beginInsertRows(parent, 4, 5);
+//! [1]
+
+
+//! [2]
+beginRemoveRows(parent, 2, 3);
+//! [2]
+
+
+//! [3]
+beginInsertColumns(parent, 4, 6);
+//! [3]
+
+
+//! [4]
+beginInsertColumns(parent, 6, 8);
+//! [4]
+
+
+//! [5]
+beginRemoveColumns(parent, 4, 6);
+//! [5]
+
+
+//! [6]
+beginMoveRows(sourceParent, 2, 4, destinationParent, 2);
+//! [6]
+
+
+//! [7]
+beginMoveRows(sourceParent, 2, 4, destinationParent, 6);
+//! [7]
+
+
+//! [8]
+beginMoveRows(parent, 2, 2, parent, 0);
+//! [8]
+
+
+//! [9]
+beginMoveRows(parent, 2, 2, parent, 4);
+//! [9]
+
+
+//! [10]
+class CustomDataProxy : public QSortFilterProxyModel
+{
+ Q_OBJECT
+public:
+ CustomDataProxy(QObject *parent)
+ : QSortFilterProxyModel(parent)
+ {
+ }
+
+ ...
+
+ QVariant data(const QModelIndex &index, int role)
+ {
+ if (role != Qt::BackgroundRole)
+ return QSortFilterProxyModel::data(index, role);
+
+ if (m_customData.contains(index.row()))
+ return m_customData.value(index.row());
+ return QSortFilterProxyModel::data(index, role);
+ }
+
+private slots:
+ void resetInternalData()
+ {
+ m_customData.clear();
+ }
+
+private:
+ QHash<int, QVariant> m_customData;
+};
+//! [10]
+
diff --git a/doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp b/doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp
new file mode 100644
index 0000000000..0e6c16f6de
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QMouseEvent event(QEvent::MouseButtonPress, pos, 0, 0, 0);
+QApplication::sendEvent(mainWindow, &event);
+//! [0]
+
+
+//! [1]
+QPushButton *quitButton = new QPushButton("Quit");
+connect(quitButton, SIGNAL(clicked()), &app, SLOT(quit()));
+//! [1]
+
+
+//! [2]
+foreach (const QString &path, app.libraryPaths())
+ do_something(path);
+//! [2]
+
+
+//! [3]
+bool myEventFilter(void *message, long *result);
+//! [3]
+
+
+//! [4]
+static int *global_ptr = 0;
+
+static void cleanup_ptr()
+{
+ delete [] global_ptr;
+ global_ptr = 0;
+}
+
+void init_ptr()
+{
+ global_ptr = new int[100]; // allocate data
+ qAddPostRoutine(cleanup_ptr); // delete later
+}
+//! [4]
+
+
+//! [5]
+class MyPrivateInitStuff : public QObject
+{
+public:
+ static MyPrivateInitStuff *initStuff(QObject *parent)
+ {
+ if (!p)
+ p = new MyPrivateInitStuff(parent);
+ return p;
+ }
+
+ ~MyPrivateInitStuff()
+ {
+ // cleanup goes here
+ }
+
+private:
+ MyPrivateInitStuff(QObject *parent)
+ : QObject(parent)
+ {
+ // initialization goes here
+ }
+
+ MyPrivateInitStuff *p;
+};
+//! [5]
+
+
+//! [6]
+static inline QString tr(const char *sourceText,
+ const char *comment = 0);
+static inline QString trUtf8(const char *sourceText,
+ const char *comment = 0);
+//! [6]
+
+
+//! [7]
+class MyMfcView : public CView
+{
+ Q_DECLARE_TR_FUNCTIONS(MyMfcView)
+
+public:
+ MyMfcView();
+ ...
+};
+//! [7]
diff --git a/doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp b/doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp
new file mode 100644
index 0000000000..86bad5e825
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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$
+**
+****************************************************************************/
+
+
+void wrapInFunction()
+{
+
+//! [0]
+class MyClass : public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO("author", "Sabrina Schweinsteiger")
+ Q_CLASSINFO("url", "http://doc.moosesoft.co.uk/1.0/")
+
+public:
+ ...
+};
+//! [0]
+
+
+//! [1]
+QByteArray normType = QMetaObject::normalizedType(" int const *");
+// normType is now "const int*"
+//! [1]
+
+
+//! [2]
+QMetaObject::invokeMethod(pushButton, "animateClick",
+ Qt::QueuedConnection);
+//! [2]
+
+
+//! [3]
+QMetaObject::invokeMethod: Unable to handle unregistered datatype 'MyType'
+//! [3]
+
+
+//! [4]
+QString retVal;
+QMetaObject::invokeMethod(obj, "compute", Qt::DirectConnection,
+ Q_RETURN_ARG(QString, retVal),
+ Q_ARG(QString, "sqrt"),
+ Q_ARG(int, 42),
+ Q_ARG(double, 9.7));
+//! [4]
+
+
+//! [5]
+class MyClass
+{
+ Q_OBJECT
+ Q_CLASSINFO("author", "Sabrina Schweinsteiger")
+ Q_CLASSINFO("url", "http://doc.moosesoft.co.uk/1.0/")
+
+public:
+ ...
+};
+//! [5]
+
+
+//! [propertyCount]
+const QMetaObject* metaObject = obj->metaObject();
+QStringList properties;
+for(int i = metaObject->propertyOffset(); i < metaObject->propertyCount(); ++i)
+ properties << QString::fromLatin1(metaObject->property(i).name());
+//! [propertyCount]
+
+
+//! [methodCount]
+const QMetaObject* metaObject = obj->metaObject();
+QStringList methods;
+for(int i = metaObject->methodOffset(); i < metaObject->methodCount(); ++i)
+ methods << QString::fromLatin1(metaObject->method(i).signature());
+//! [methodCount]
+
+//! [6]
+int methodIndex = pushButton->metaObject()->indexOfMethod("animateClick()");
+QMetaMethod method = metaObject->method(methodIndex);
+method.invoke(pushButton, Qt::QueuedConnection);
+//! [6]
+
+//! [7]
+QMetaMethod::invoke: Unable to handle unregistered datatype 'MyType'
+//! [7]
+
+//! [8]
+QString retVal;
+QByteArray normalizedSignature = QMetaObject::normalizedSignature("compute(QString, int, double)");
+int methodIndex = obj->metaObject()->indexOfMethod(normalizedSignature);
+QMetaMethod method = metaObject->method(methodIndex);
+method.invoke(obj,
+ Qt::DirectConnection,
+ Q_RETURN_ARG(QString, retVal),
+ Q_ARG(QString, "sqrt"),
+ Q_ARG(int, 42),
+ Q_ARG(double, 9.7));
+//! [8]
+
+}
diff --git a/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp b/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp
new file mode 100644
index 0000000000..35e6feb523
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+struct MyStruct
+{
+ int i;
+ ...
+};
+
+Q_DECLARE_METATYPE(MyStruct)
+//! [0]
+
+
+//! [1]
+namespace MyNamespace
+{
+ ...
+}
+
+Q_DECLARE_METATYPE(MyNamespace::MyStruct)
+//! [1]
+
+
+//! [2]
+MyStruct s;
+QVariant var;
+var.setValue(s); // copy s into the variant
+
+...
+
+// retrieve the value
+MyStruct s2 = var.value<MyStruct>();
+//! [2]
+
+
+//! [3]
+int id = QMetaType::type("MyClass");
+if (id == 0) {
+ void *myClassPtr = QMetaType::construct(id);
+ ...
+ QMetaType::destroy(id, myClassPtr);
+ myClassPtr = 0;
+}
+//! [3]
+
+
+//! [4]
+qRegisterMetaType<MyClass>("MyClass");
+//! [4]
+
+
+//! [5]
+qRegisterMetaTypeStreamOperators<MyClass>("MyClass");
+//! [5]
+
+
+//! [6]
+QDataStream &operator<<(QDataStream &out, const MyClass &myObj);
+QDataStream &operator>>(QDataStream &in, MyClass &myObj);
+//! [6]
+
+
+//! [7]
+int id = qRegisterMetaType<MyStruct>();
+//! [7]
+
+
+//! [8]
+int id = qMetaTypeId<QString>(); // id is now QMetaType::QString
+id = qMetaTypeId<MyStruct>(); // compile error if MyStruct not declared
+//! [8]
+
+//! [9]
+typedef QString CustomString;
+qRegisterMetaType<CustomString>("CustomString");
+//! [9]
diff --git a/doc/src/snippets/code/src_corelib_kernel_qmimedata.cpp b/doc/src/snippets/code/src_corelib_kernel_qmimedata.cpp
new file mode 100644
index 0000000000..fcfc662f45
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_kernel_qmimedata.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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::dragEnterEvent(QDragEnterEvent *event)
+{
+ if (event->mimeData()->hasUrls())
+ event->acceptProposedAction();
+}
+
+void MyWidget::dropEvent(QDropEvent *event)
+{
+ if (event->mimeData()->hasUrls()) {
+ foreach (QUrl url, event->mimeData()->urls()) {
+ ...
+ }
+ }
+}
+//! [0]
+
+
+//! [1]
+QByteArray csvData = ...;
+
+QMimeData *mimeData = new QMimeData;
+mimeData->setData("text/csv", csvData);
+//! [1]
+
+
+//! [2]
+void MyWidget::dropEvent(QDropEvent *event)
+{
+ const MyMimeData *myData =
+ qobject_cast<const MyMimeData *>(event->mimeData());
+ if (myData) {
+ // access myData's data directly (not through QMimeData's API)
+ }
+}
+//! [2]
+
+
+//! [3]
+application/x-qt-windows-mime;value="<custom type>"
+//! [3]
+
+
+//! [4]
+application/x-qt-windows-mime;value="FileGroupDescriptor"
+application/x-qt-windows-mime;value="FileContents"
+//! [4]
+
+
+//! [5]
+if (event->mimeData()->hasImage()) {
+ QImage image = qvariant_cast<QImage>(event->mimeData()->imageData());
+ ...
+}
+//! [5]
+
+
+//! [6]
+mimeData->setImageData(QImage("beautifulfjord.png"));
+//! [6]
+
+
+//! [7]
+if (event->mimeData()->hasColor()) {
+ QColor color = qvariant_cast<QColor>(event->mimeData()->colorData());
+ ...
+}
+//! [7]
diff --git a/doc/src/snippets/code/src_corelib_kernel_qobject.cpp b/doc/src/snippets/code/src_corelib_kernel_qobject.cpp
new file mode 100644
index 0000000000..afb9460983
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_kernel_qobject.cpp
@@ -0,0 +1,448 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QLineEdit *lineEdit = static_cast<QLineEdit *>(
+ qt_find_obj_child(myWidget, "QLineEdit", "my line edit"));
+if (lineEdit)
+ lineEdit->setText("Default");
+//! [0]
+
+
+//! [1]
+QObject *obj = new QPushButton;
+obj->metaObject()->className(); // returns "QPushButton"
+
+QPushButton::staticMetaObject.className(); // returns "QPushButton"
+//! [1]
+
+
+//! [2]
+QPushButton::staticMetaObject.className(); // returns "QPushButton"
+
+QObject *obj = new QPushButton;
+obj->metaObject()->className(); // returns "QPushButton"
+//! [2]
+
+
+//! [3]
+QObject *obj = new QTimer; // QTimer inherits QObject
+
+QTimer *timer = qobject_cast<QTimer *>(obj);
+// timer == (QObject *)obj
+
+QAbstractButton *button = qobject_cast<QAbstractButton *>(obj);
+// button == 0
+//! [3]
+
+
+//! [4]
+QTimer *timer = new QTimer; // QTimer inherits QObject
+timer->inherits("QTimer"); // returns true
+timer->inherits("QObject"); // returns true
+timer->inherits("QAbstractButton"); // returns false
+
+// QVBoxLayout inherits QObject and QLayoutItem
+QVBoxLayout *layout = new QVBoxLayout;
+layout->inherits("QObject"); // returns true
+layout->inherits("QLayoutItem"); // returns true (even though QLayoutItem is not a QObject)
+//! [4]
+
+
+//! [5]
+qDebug("MyClass::setPrecision(): (%s) invalid precision %f",
+ qPrintable(objectName()), newPrecision);
+//! [5]
+
+
+//! [6]
+class MainWindow : public QMainWindow
+{
+public:
+ MainWindow();
+
+protected:
+ bool eventFilter(QObject *obj, QEvent *ev);
+
+private:
+ QTextEdit *textEdit;
+};
+
+MainWindow::MainWindow()
+{
+ textEdit = new QTextEdit;
+ setCentralWidget(textEdit);
+
+ textEdit->installEventFilter(this);
+}
+
+bool MainWindow::eventFilter(QObject *obj, QEvent *event)
+{
+ if (obj == textEdit) {
+ if (event->type() == QEvent::KeyPress) {
+ QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
+ qDebug() << "Ate key press" << keyEvent->key();
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ // pass the event on to the parent class
+ return QMainWindow::eventFilter(obj, event);
+ }
+}
+//! [6]
+
+
+//! [7]
+myObject->moveToThread(QApplication::instance()->thread());
+//! [7]
+
+
+//! [8]
+class MyObject : public QObject
+{
+ Q_OBJECT
+
+public:
+ MyObject(QObject *parent = 0);
+
+protected:
+ void timerEvent(QTimerEvent *event);
+};
+
+MyObject::MyObject(QObject *parent)
+ : QObject(parent)
+{
+ startTimer(50); // 50-millisecond timer
+ startTimer(1000); // 1-second timer
+ startTimer(60000); // 1-minute timer
+}
+
+void MyObject::timerEvent(QTimerEvent *event)
+{
+ qDebug() << "Timer ID:" << event->timerId();
+}
+//! [8]
+
+
+//! [9]
+QList<QObject *> list = window()->queryList("QAbstractButton"));
+foreach (QObject *obj, list)
+ static_cast<QAbstractButton *>(obj)->setEnabled(false);
+//! [9]
+
+
+//! [10]
+QPushButton *button = parentWidget->findChild<QPushButton *>("button1");
+//! [10]
+
+
+//! [11]
+QListWidget *list = parentWidget->findChild<QListWidget *>();
+//! [11]
+
+
+//! [12]
+QList<QWidget *> widgets = parentWidget.findChildren<QWidget *>("widgetname");
+//! [12]
+
+
+//! [13]
+QList<QPushButton *> allPButtons = parentWidget.findChildren<QPushButton *>();
+//! [13]
+
+
+//! [14]
+monitoredObj->installEventFilter(filterObj);
+//! [14]
+
+
+//! [15]
+class KeyPressEater : public QObject
+{
+ Q_OBJECT
+ ...
+
+protected:
+ bool eventFilter(QObject *obj, QEvent *event);
+};
+
+bool KeyPressEater::eventFilter(QObject *obj, QEvent *event)
+{
+ if (event->type() == QEvent::KeyPress) {
+ QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
+ qDebug("Ate key press %d", keyEvent->key());
+ return true;
+ } else {
+ // standard event processing
+ return QObject::eventFilter(obj, event);
+ }
+}
+//! [15]
+
+
+//! [16]
+KeyPressEater *keyPressEater = new KeyPressEater(this);
+QPushButton *pushButton = new QPushButton(this);
+QListView *listView = new QListView(this);
+
+pushButton->installEventFilter(keyPressEater);
+listView->installEventFilter(keyPressEater);
+//! [16]
+
+
+//! [17]
+MyWindow::MyWindow()
+{
+ QLabel *senderLabel = new QLabel(tr("Name:"));
+ QLabel *recipientLabel = new QLabel(tr("Name:", "recipient"));
+//! [17]
+}
+
+
+//! [18]
+int n = messages.count();
+showMessage(tr("%n message(s) saved", "", n));
+//! [18]
+
+
+//! [19]
+n == 1 ? tr("%n message saved") : tr("%n messages saved")
+//! [19]
+
+
+//! [20]
+label->setText(tr("F\374r \310lise"));
+//! [20]
+
+
+//! [21]
+if (receivers(SIGNAL(valueChanged(QByteArray))) > 0) {
+ QByteArray data;
+ get_the_value(&data); // expensive operation
+ emit valueChanged(data);
+}
+//! [21]
+
+
+//! [22]
+QLabel *label = new QLabel;
+QScrollBar *scrollBar = new QScrollBar;
+QObject::connect(scrollBar, SIGNAL(valueChanged(int)),
+ label, SLOT(setNum(int)));
+//! [22]
+
+
+//! [23]
+// WRONG
+QObject::connect(scrollBar, SIGNAL(valueChanged(int value)),
+ label, SLOT(setNum(int value)));
+//! [23]
+
+
+//! [24]
+class MyWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ MyWidget();
+
+signals:
+ void buttonClicked();
+
+private:
+ QPushButton *myButton;
+};
+
+MyWidget::MyWidget()
+{
+ myButton = new QPushButton(this);
+ connect(myButton, SIGNAL(clicked()),
+ this, SIGNAL(buttonClicked()));
+}
+//! [24]
+
+
+//! [25]
+QObject::connect: Cannot queue arguments of type 'MyType'
+(Make sure 'MyType' is registered using qRegisterMetaType().)
+//! [25]
+
+
+//! [26]
+disconnect(myObject, 0, 0, 0);
+//! [26]
+
+
+//! [27]
+myObject->disconnect();
+//! [27]
+
+
+//! [28]
+disconnect(myObject, SIGNAL(mySignal()), 0, 0);
+//! [28]
+
+
+//! [29]
+myObject->disconnect(SIGNAL(mySignal()));
+//! [29]
+
+
+//! [30]
+disconnect(myObject, 0, myReceiver, 0);
+//! [30]
+
+
+//! [31]
+myObject->disconnect(myReceiver);
+//! [31]
+
+
+//! [32]
+if (QLatin1String(signal) == SIGNAL(valueChanged(int))) {
+ // signal is valueChanged(int)
+}
+//! [32]
+
+
+//! [33]
+void on_<object name>_<signal name>(<signal parameters>);
+//! [33]
+
+
+//! [34]
+void on_button1_clicked();
+//! [34]
+
+
+//! [35]
+class MyClass : public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO("Author", "Pierre Gendron")
+ Q_CLASSINFO("URL", "http://www.my-organization.qc.ca")
+
+public:
+ ...
+};
+//! [35]
+
+
+//! [36]
+Q_PROPERTY(type name
+ READ getFunction
+ [WRITE setFunction]
+ [RESET resetFunction]
+ [NOTIFY notifySignal]
+ [DESIGNABLE bool]
+ [SCRIPTABLE bool]
+ [STORED bool]
+ [USER bool]
+ [CONSTANT]
+ [FINAL])
+//! [36]
+
+
+//! [37]
+Q_PROPERTY(QString title READ title WRITE setTitle USER true)
+//! [37]
+
+
+//! [38]
+class MyClass : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(Priority)
+
+public:
+ MyClass(QObject *parent = 0);
+ ~MyClass();
+
+ enum Priority { High, Low, VeryHigh, VeryLow };
+ void setPriority(Priority priority);
+ Priority priority() const;
+};
+//! [38]
+
+
+//! [39a]
+class QLibrary : public QObject
+{
+ ...
+ Q_FLAGS(LoadHint LoadHints)
+ ...
+//! [39a]
+
+//! [39b]
+ ...
+public:
+ enum LoadHint {
+ ResolveAllSymbolsHint = 0x01,
+ ExportExternalSymbolsHint = 0x02,
+ LoadArchiveMemberHint = 0x04
+ };
+ Q_DECLARE_FLAGS(LoadHints, LoadHint)
+ ...
+//! [39b]
+
+
+//! [40]
+//: This name refers to a host name.
+hostNameLabel->setText(tr("Name:"));
+
+/*: This text refers to a C++ code example. */
+QString example = tr("Example");
+//! [40]
+
+//! [meta data]
+//: This is a comment for the translator.
+//= qtn_foo_bar
+//~ loc-layout_id foo_dialog
+//~ loc-blank False
+//~ magic-stuff This might mean something magic.
+QString text = MyMagicClass::tr("Sim sala bim.");
+//! [meta data]
+
+//! [explicit tr context]
+QString text = QScrollBar::tr("Page up");
+//! [explicit tr context]
diff --git a/doc/src/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp b/doc/src/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp
new file mode 100644
index 0000000000..1f5c5acda4
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QSystemSemaphore sem("market", 3, QSystemSemaphore::Create);
+ // resources available == 3
+sem.acquire(); // resources available == 2
+sem.acquire(); // resources available == 1
+sem.acquire(); // resources available == 0
+sem.release(); // resources available == 1
+sem.release(2); // resources available == 3
+//! [0]
+
+
+//! [1]
+QSystemSemaphore sem("market", 5, QSystemSemaphore::Create);
+sem.acquire(5); // acquire all 5 resources
+sem.release(5); // release the 5 resources
+//! [1]
+
+
+//! [2]
+sem.release(10); // "create" 10 new resources
+//! [2]
diff --git a/doc/src/snippets/code/src_corelib_kernel_qtimer.cpp b/doc/src/snippets/code/src_corelib_kernel_qtimer.cpp
new file mode 100644
index 0000000000..ef06fd84b2
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_kernel_qtimer.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+#include <QApplication>
+#include <QTimer>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QTimer::singleShot(600000, &app, SLOT(quit()));
+ ...
+ return app.exec();
+}
+//! [0]
diff --git a/doc/src/snippets/code/src_corelib_kernel_qvariant.cpp b/doc/src/snippets/code/src_corelib_kernel_qvariant.cpp
new file mode 100644
index 0000000000..8b1bcbf41d
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_kernel_qvariant.cpp
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QDataStream out(...);
+QVariant v(123); // The variant now contains an int
+int x = v.toInt(); // x = 123
+out << v; // Writes a type tag and an int to out
+v = QVariant("hello"); // The variant now contains a QByteArray
+v = QVariant(tr("hello")); // The variant now contains a QString
+int y = v.toInt(); // y = 0 since v cannot be converted to an int
+QString s = v.toString(); // s = tr("hello") (see QObject::tr())
+out << v; // Writes a type tag and a QString to out
+...
+QDataStream in(...); // (opening the previously written stream)
+in >> v; // Reads an Int variant
+int z = v.toInt(); // z = 123
+qDebug("Type is %s", // prints "Type is int"
+ v.typeName());
+v = v.toInt() + 100; // The variant now hold the value 223
+v = QVariant(QStringList());
+//! [0]
+
+
+//! [1]
+QVariant x, y(QString()), z(QString(""));
+x.convert(QVariant::Int);
+// x.isNull() == true
+// y.isNull() == true, z.isNull() == false
+//! [1]
+
+
+//! [2]
+QVariant variant;
+...
+QColor color = variant.value<QColor>();
+//! [2]
+
+
+//! [3]
+QColor color = palette().background().color();
+QVariant variant = color;
+//! [3]
+
+
+//! [4]
+QVariant v;
+
+v.setValue(5);
+int i = v.toInt(); // i is now 5
+QString s = v.toString() // s is now "5"
+
+MyCustomStruct c;
+v.setValue(c);
+
+...
+
+MyCustomStruct c2 = v.value<MyCustomStruct>();
+//! [4]
+
+
+//! [5]
+QVariant v;
+
+MyCustomStruct c;
+if (v.canConvert<MyCustomStruct>())
+ c = v.value<MyCustomStruct>();
+
+v = 7;
+int i = v.value<int>(); // same as v.toInt()
+QString s = v.value<QString>(); // same as v.toString(), s is now "7"
+MyCustomStruct c2 = v.value<MyCustomStruct>(); // conversion failed, c2 is empty
+//! [5]
+
+
+//! [6]
+QVariant v = 42;
+
+v.canConvert<int>(); // returns true
+v.canConvert<QString>(); // returns true
+
+MyCustomStruct s;
+v.setValue(s);
+
+v.canConvert<int>(); // returns false
+v.canConvert<MyCustomStruct>(); // returns true
+//! [6]
+
+
+//! [7]
+MyCustomStruct s;
+return QVariant::fromValue(s);
+//! [7]
+
+
+//! [8]
+QObject *object = getObjectFromSomewhere();
+QVariant data = QVariant::fromValue(object);
+//! [8]
diff --git a/doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp b/doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp
new file mode 100644
index 0000000000..8943e92475
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QLibrary myLib("mylib");
+typedef void (*MyPrototype)();
+MyPrototype myFunction = (MyPrototype) myLib.resolve("mysymbol");
+if (myFunction)
+ myFunction();
+//! [0]
+
+
+//! [1]
+typedef void (*MyPrototype)();
+MyPrototype myFunction =
+ (MyPrototype) QLibrary::resolve("mylib", "mysymbol");
+if (myFunction)
+ myFunction();
+//! [1]
+
+
+//! [2]
+typedef int (*AvgFunction)(int, int);
+
+AvgFunction avg = (AvgFunction) library->resolve("avg");
+if (avg)
+ return avg(5, 8);
+else
+ return -1;
+//! [2]
+
+
+//! [3]
+extern "C" MY_EXPORT int avg(int a, int b)
+{
+ return (a + b) / 2;
+}
+//! [3]
+
+
+//! [4]
+#ifdef Q_WS_WIN
+#define MY_EXPORT __declspec(dllexport)
+#else
+#define MY_EXPORT
+#endif
+//! [4]
diff --git a/doc/src/snippets/code/src_corelib_plugin_quuid.cpp b/doc/src/snippets/code/src_corelib_plugin_quuid.cpp
new file mode 100644
index 0000000000..88cdb54515
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_plugin_quuid.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+// {67C8770B-44F1-410A-AB9A-F9B5446F13EE}
+QUuid IID_MyInterface(0x67c8770b, 0x44f1, 0x410a, 0xab, 0x9a, 0xf9, 0xb5, 0x44, 0x6f, 0x13, 0xee)
+//! [0]
diff --git a/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp b/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp
new file mode 100644
index 0000000000..9909b1b6e2
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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$
+**
+****************************************************************************/
+
+//! [simple state machine]
+QPushButton button;
+
+QStateMachine machine;
+QState *s1 = new QState();
+s1->assignProperty(&button, "text", "Click me");
+
+QFinalState *s2 = new QFinalState();
+s1->addTransition(&button, SIGNAL(clicked()), s2);
+
+machine.addState(s1);
+machine.addState(s2);
+machine.setInitialState(s1);
+machine.start();
+//! [simple state machine]
diff --git a/doc/src/snippets/code/src_corelib_thread_qatomic.cpp b/doc/src/snippets/code/src_corelib_thread_qatomic.cpp
new file mode 100644
index 0000000000..a70c187b7d
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_thread_qatomic.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+MySharedType &MySharedType::operator=(const MySharedType &other)
+{
+ (void) other.data->atomicInt.ref();
+ if (!data->atomicInt.deref()) {
+ // The last reference has been released
+ delete d;
+ }
+ d = other.d;
+ return *this;
+}
+//! [0]
+
+
+//! [1]
+if (currentValue == expectedValue) {
+ currentValue = newValue;
+ return true;
+}
+return false;
+//! [1]
+
+
+//! [2]
+int originalValue = currentValue;
+currentValue = newValue;
+return originalValue;
+//! [2]
+
+
+//! [3]
+int originalValue = currentValue;
+currentValue += valueToAdd;
+return originalValue;
+//! [3]
+
+
+//! [4]
+if (currentValue == expectedValue) {
+ currentValue = newValue;
+ return true;
+}
+return false;
+//! [4]
+
+
+//! [5]
+T *originalValue = currentValue;
+currentValue = newValue;
+return originalValue;
+//! [5]
+
+
+//! [6]
+T *originalValue = currentValue;
+currentValue += valueToAdd;
+return originalValue;
+//! [6]
diff --git a/doc/src/snippets/code/src_corelib_thread_qmutex.cpp b/doc/src/snippets/code/src_corelib_thread_qmutex.cpp
new file mode 100644
index 0000000000..7800a4da2d
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_thread_qmutex.cpp
@@ -0,0 +1,193 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 number = 6;
+
+void method1()
+{
+ number *= 5;
+ number /= 4;
+}
+
+void method2()
+{
+ number *= 3;
+ number /= 2;
+}
+//! [0]
+
+
+//! [1]
+// method1()
+number *= 5; // number is now 30
+number /= 4; // number is now 7
+
+// method2()
+number *= 3; // number is now 21
+number /= 2; // number is now 10
+//! [1]
+
+
+//! [2]
+// Thread 1 calls method1()
+number *= 5; // number is now 30
+
+// Thread 2 calls method2().
+//
+// Most likely Thread 1 has been put to sleep by the operating
+// system to allow Thread 2 to run.
+number *= 3; // number is now 90
+number /= 2; // number is now 45
+
+// Thread 1 finishes executing.
+number /= 4; // number is now 11, instead of 10
+//! [2]
+
+
+//! [3]
+QMutex mutex;
+int number = 6;
+
+void method1()
+{
+ mutex.lock();
+ number *= 5;
+ number /= 4;
+ mutex.unlock();
+}
+
+void method2()
+{
+ mutex.lock();
+ number *= 3;
+ number /= 2;
+ mutex.unlock();
+}
+//! [3]
+
+
+//! [4]
+int complexFunction(int flag)
+{
+ mutex.lock();
+
+ int retVal = 0;
+
+ switch (flag) {
+ case 0:
+ case 1:
+ mutex.unlock();
+ return moreComplexFunction(flag);
+ case 2:
+ {
+ int status = anotherFunction();
+ if (status < 0) {
+ mutex.unlock();
+ return -2;
+ }
+ retVal = status + flag;
+ }
+ break;
+ default:
+ if (flag > 10) {
+ mutex.unlock();
+ return -1;
+ }
+ break;
+ }
+
+ mutex.unlock();
+ return retVal;
+}
+//! [4]
+
+
+//! [5]
+int complexFunction(int flag)
+{
+ QMutexLocker locker(&mutex);
+
+ int retVal = 0;
+
+ switch (flag) {
+ case 0:
+ case 1:
+ return moreComplexFunction(flag);
+ case 2:
+ {
+ int status = anotherFunction();
+ if (status < 0)
+ return -2;
+ retVal = status + flag;
+ }
+ break;
+ default:
+ if (flag > 10)
+ return -1;
+ break;
+ }
+
+ return retVal;
+}
+//! [5]
+
+
+//! [6]
+class SignalWaiter
+{
+private:
+ QMutexLocker locker;
+
+public:
+ SignalWaiter(QMutex *mutex)
+ : locker(mutex)
+ {
+ }
+
+ void waitForSignal()
+ {
+ ...
+ while (!signalled)
+ waitCondition.wait(locker.mutex());
+ ...
+ }
+};
+//! [6]
diff --git a/doc/src/snippets/code/src_corelib_thread_qmutexpool.cpp b/doc/src/snippets/code/src_corelib_thread_qmutexpool.cpp
new file mode 100644
index 0000000000..5163fe54f8
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_thread_qmutexpool.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 Number {
+public:
+ Number(double n) : num (n) { }
+
+ void setNumber(double n) { num = n; }
+ double number() const { return num; }
+
+private:
+ double num;
+};
+//! [0]
+
+
+//! [1]
+void calcSquare(Number *num)
+{
+ QMutexLocker locker(mutexpool.get(num));
+ num.setNumber(num.number() * num.number());
+}
+//! [1]
diff --git a/doc/src/snippets/code/src_corelib_thread_qreadwritelock.cpp b/doc/src/snippets/code/src_corelib_thread_qreadwritelock.cpp
new file mode 100644
index 0000000000..9b325a785d
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_thread_qreadwritelock.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QReadWriteLock lock;
+
+void ReaderThread::run()
+{
+ ...
+ lock.lockForRead();
+ read_file();
+ lock.unlock();
+ ...
+}
+
+void WriterThread::run()
+{
+ ...
+ lock.lockForWrite();
+ write_file();
+ lock.unlock();
+ ...
+}
+//! [0]
+
+
+//! [1]
+QReadWriteLock lock;
+
+QByteArray readData()
+{
+ QReadLocker locker(&lock);
+ ...
+ return data;
+}
+//! [1]
+
+
+//! [2]
+QReadWriteLock lock;
+
+QByteArray readData()
+{
+ lock.lockForRead();
+ ...
+ lock.unlock();
+ return data;
+}
+//! [2]
+
+
+//! [3]
+QReadWriteLock lock;
+
+void writeData(const QByteArray &data)
+{
+ QWriteLocker locker(&lock);
+ ...
+}
+//! [3]
+
+
+//! [4]
+QReadWriteLock lock;
+
+void writeData(const QByteArray &data)
+{
+ lock.lockForWrite();
+ ...
+ lock.unlock();
+}
+//! [4]
diff --git a/doc/src/snippets/code/src_corelib_thread_qsemaphore.cpp b/doc/src/snippets/code/src_corelib_thread_qsemaphore.cpp
new file mode 100644
index 0000000000..72a15dee2c
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_thread_qsemaphore.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QSemaphore sem(5); // sem.available() == 5
+
+sem.acquire(3); // sem.available() == 2
+sem.acquire(2); // sem.available() == 0
+sem.release(5); // sem.available() == 5
+sem.release(5); // sem.available() == 10
+
+sem.tryAcquire(1); // sem.available() == 9, returns true
+sem.tryAcquire(250); // sem.available() == 9, returns false
+//! [0]
+
+
+//! [1]
+QSemaphore sem(5); // a semaphore that guards 5 resources
+sem.acquire(5); // acquire all 5 resources
+sem.release(5); // release the 5 resources
+sem.release(10); // "create" 10 new resources
+//! [1]
+
+
+//! [2]
+QSemaphore sem(5); // sem.available() == 5
+sem.tryAcquire(250); // sem.available() == 5, returns false
+sem.tryAcquire(3); // sem.available() == 2, returns true
+//! [2]
+
+
+//! [3]
+QSemaphore sem(5); // sem.available() == 5
+sem.tryAcquire(250, 1000); // sem.available() == 5, waits 1000 milliseconds and returns false
+sem.tryAcquire(3, 30000); // sem.available() == 2, returns true without waiting
+//! [3]
diff --git a/doc/src/snippets/code/src_corelib_thread_qthread.cpp b/doc/src/snippets/code/src_corelib_thread_qthread.cpp
new file mode 100644
index 0000000000..2b2422f7de
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_thread_qthread.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 MyThread : public QThread
+{
+public:
+ void run();
+};
+
+void MyThread::run()
+{
+ QTcpSocket socket;
+ // connect QTcpSocket's signals somewhere meaningful
+ ...
+ socket.connectToHost(hostName, portNumber);
+ exec();
+}
+//! [0]
diff --git a/doc/src/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp b/doc/src/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp
new file mode 100644
index 0000000000..49574cb36d
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+forever {
+ mutex.lock();
+ keyPressed.wait(&mutex);
+ do_something();
+ mutex.unlock();
+}
+//! [0]
+
+
+//! [1]
+forever {
+ getchar();
+ keyPressed.wakeAll();
+}
+//! [1]
+
+
+//! [2]
+forever {
+ mutex.lock();
+ keyPressed.wait(&mutex);
+ ++count;
+ mutex.unlock();
+
+ do_something();
+
+ mutex.lock();
+ --count;
+ mutex.unlock();
+}
+//! [2]
+
+
+//! [3]
+forever {
+ getchar();
+
+ mutex.lock();
+ // Sleep until there are no busy worker threads
+ while (count > 0) {
+ mutex.unlock();
+ sleep(1);
+ mutex.lock();
+ }
+ keyPressed.wakeAll();
+ mutex.unlock();
+}
+//! [3]
diff --git a/doc/src/snippets/code/src_corelib_tools_qbitarray.cpp b/doc/src/snippets/code/src_corelib_tools_qbitarray.cpp
new file mode 100644
index 0000000000..11621dcf92
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_tools_qbitarray.cpp
@@ -0,0 +1,176 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QBitArray ba(200);
+//! [0]
+
+
+//! [1]
+QBitArray ba;
+ba.resize(3);
+ba[0] = true;
+ba[1] = false;
+ba[2] = true;
+//! [1]
+
+
+//! [2]
+QBitArray ba(3);
+ba.setBit(0, true);
+ba.setBit(1, false);
+ba.setBit(2, true);
+//! [2]
+
+
+//! [3]
+QBitArray x(5);
+x.setBit(3, true);
+// x: [ 0, 0, 0, 1, 0 ]
+
+QBitArray y(5);
+y.setBit(4, true);
+// y: [ 0, 0, 0, 0, 1 ]
+
+x |= y;
+// x: [ 0, 0, 0, 1, 1 ]
+//! [3]
+
+
+//! [4]
+QBitArray().isNull(); // returns true
+QBitArray().isEmpty(); // returns true
+
+QBitArray(0).isNull(); // returns false
+QBitArray(0).isEmpty(); // returns true
+
+QBitArray(3).isNull(); // returns false
+QBitArray(3).isEmpty(); // returns false
+//! [4]
+
+
+//! [5]
+QBitArray().isNull(); // returns true
+QBitArray(0).isNull(); // returns false
+QBitArray(3).isNull(); // returns false
+//! [5]
+
+
+//! [6]
+QBitArray ba(8);
+ba.fill(true);
+// ba: [ 1, 1, 1, 1, 1, 1, 1, 1 ]
+
+ba.fill(false, 2);
+// ba: [ 0, 0 ]
+//! [6]
+
+
+//! [7]
+QBitArray a(3);
+a[0] = false;
+a[1] = true;
+a[2] = a[0] ^ a[1];
+//! [7]
+
+
+//! [8]
+QBitArray a(3);
+QBitArray b(2);
+a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ]
+b[0] = 1; b[1] = 0; // b: [ 1, 1 ]
+a &= b; // a: [ 1, 0, 0 ]
+//! [8]
+
+
+//! [9]
+QBitArray a(3);
+QBitArray b(2);
+a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ]
+b[0] = 1; b[1] = 0; // b: [ 1, 1 ]
+a |= b; // a: [ 1, 1, 1 ]
+//! [9]
+
+
+//! [10]
+QBitArray a(3);
+QBitArray b(2);
+a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ]
+b[0] = 1; b[1] = 0; // b: [ 1, 1 ]
+a ^= b; // a: [ 0, 1, 1 ]
+//! [10]
+
+
+//! [11]
+QBitArray a(3);
+QBitArray b;
+a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ]
+b = ~a; // b: [ 0, 1, 0 ]
+//! [11]
+
+
+//! [12]
+QBitArray a(3);
+QBitArray b(2);
+QBitArray c;
+a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ]
+b[0] = 1; b[1] = 0; // b: [ 1, 1 ]
+c = a & b; // c: [ 1, 0, 0 ]
+//! [12]
+
+
+//! [13]
+QBitArray a(3);
+QBitArray b(2);
+QBitArray c;
+a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ]
+b[0] = 1; b[1] = 0; // b: [ 1, 1 ]
+c = a | b; // c: [ 1, 1, 1 ]
+//! [13]
+
+
+//! [14]
+QBitArray a(3);
+QBitArray b(2);
+QBitArray c;
+a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ]
+b[0] = 1; b[1] = 0; // b: [ 1, 1 ]
+c = a ^ b; // c: [ 0, 1, 1 ]
+//! [14]
diff --git a/doc/src/snippets/code/src_corelib_tools_qbytearray.cpp b/doc/src/snippets/code/src_corelib_tools_qbytearray.cpp
new file mode 100644
index 0000000000..4f3d8dda91
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_tools_qbytearray.cpp
@@ -0,0 +1,421 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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$
+**
+****************************************************************************/
+
+
+void wrapInFunction()
+{
+
+//! [0]
+QByteArray ba("Hello");
+//! [0]
+
+
+//! [1]
+QByteArray ba;
+ba.resize(5);
+ba[0] = 0x3c;
+ba[1] = 0xb8;
+ba[2] = 0x64;
+ba[3] = 0x18;
+ba[4] = 0xca;
+//! [1]
+
+
+//! [2]
+for (int i = 0; i < ba.size(); ++i) {
+ if (ba.at(i) >= 'a' && ba.at(i) <= 'f')
+ cout << "Found character in range [a-f]" << endl;
+}
+//! [2]
+
+
+//! [3]
+QByteArray x("and");
+x.prepend("rock "); // x == "rock and"
+x.append(" roll"); // x == "rock and roll"
+x.replace(5, 3, "&"); // x == "rock & roll"
+//! [3]
+
+
+//! [4]
+QByteArray ba("We must be <b>bold</b>, very <b>bold</b>");
+int j = 0;
+while ((j = ba.indexOf("<b>", j)) != -1) {
+ cout << "Found <b> tag at index position " << j << endl;
+ ++j;
+}
+//! [4]
+
+
+//! [5]
+QByteArray().isNull(); // returns true
+QByteArray().isEmpty(); // returns true
+
+QByteArray("").isNull(); // returns false
+QByteArray("").isEmpty(); // returns true
+
+QByteArray("abc").isNull(); // returns false
+QByteArray("abc").isEmpty(); // returns false
+//! [5]
+
+
+//! [6]
+QByteArray ba("Hello");
+int n = ba.size(); // n == 5
+ba.data()[0]; // returns 'H'
+ba.data()[4]; // returns 'o'
+ba.data()[5]; // returns '\0'
+//! [6]
+
+
+//! [7]
+QByteArray().isEmpty(); // returns true
+QByteArray("").isEmpty(); // returns true
+QByteArray("abc").isEmpty(); // returns false
+//! [7]
+
+
+//! [8]
+QByteArray ba("Hello world");
+char *data = ba.data();
+while (*data) {
+ cout << "[" << *data << "]" << endl;
+ ++data;
+}
+//! [8]
+
+
+//! [9]
+QByteArray ba;
+for (int i = 0; i < 10; ++i)
+ ba[i] = 'A' + i;
+// ba == "ABCDEFGHIJ"
+//! [9]
+
+
+//! [10]
+QByteArray ba("Stockholm");
+ba.truncate(5); // ba == "Stock"
+//! [10]
+
+
+//! [11]
+QByteArray ba("STARTTLS\r\n");
+ba.chop(2); // ba == "STARTTLS"
+//! [11]
+
+
+//! [12]
+QByteArray x("free");
+QByteArray y("dom");
+x += y;
+// x == "freedom"
+//! [12]
+
+
+//! [13]
+QByteArray().isNull(); // returns true
+QByteArray("").isNull(); // returns false
+QByteArray("abc").isNull(); // returns false
+//! [13]
+
+
+//! [14]
+QByteArray ba("Istambul");
+ba.fill('o');
+// ba == "oooooooo"
+
+ba.fill('X', 2);
+// ba == "XX"
+//! [14]
+
+
+//! [15]
+QByteArray x("ship");
+QByteArray y("air");
+x.prepend(y);
+// x == "airship"
+//! [15]
+
+
+//! [16]
+QByteArray x("free");
+QByteArray y("dom");
+x.append(y);
+// x == "freedom"
+//! [16]
+
+
+//! [17]
+QByteArray ba("Meal");
+ba.insert(1, QByteArray("ontr"));
+// ba == "Montreal"
+//! [17]
+
+
+//! [18]
+QByteArray ba("Montreal");
+ba.remove(1, 4);
+// ba == "Meal"
+//! [18]
+
+
+//! [19]
+QByteArray x("Say yes!");
+QByteArray y("no");
+x.replace(4, 3, y);
+// x == "Say no!"
+//! [19]
+
+
+//! [20]
+QByteArray ba("colour behaviour flavour neighbour");
+ba.replace(QByteArray("ou"), QByteArray("o"));
+// ba == "color behavior flavor neighbor"
+//! [20]
+
+
+//! [21]
+QByteArray x("sticky question");
+QByteArray y("sti");
+x.indexOf(y); // returns 0
+x.indexOf(y, 1); // returns 10
+x.indexOf(y, 10); // returns 10
+x.indexOf(y, 11); // returns -1
+//! [21]
+
+
+//! [22]
+QByteArray ba("ABCBA");
+ba.indexOf("B"); // returns 1
+ba.indexOf("B", 1); // returns 1
+ba.indexOf("B", 2); // returns 3
+ba.indexOf("X"); // returns -1
+//! [22]
+
+
+//! [23]
+QByteArray x("crazy azimuths");
+QByteArray y("az");
+x.lastIndexOf(y); // returns 6
+x.lastIndexOf(y, 6); // returns 6
+x.lastIndexOf(y, 5); // returns 2
+x.lastIndexOf(y, 1); // returns -1
+//! [23]
+
+
+//! [24]
+QByteArray ba("ABCBA");
+ba.lastIndexOf("B"); // returns 3
+ba.lastIndexOf("B", 3); // returns 3
+ba.lastIndexOf("B", 2); // returns 1
+ba.lastIndexOf("X"); // returns -1
+//! [24]
+
+
+//! [25]
+QByteArray url("ftp://ftp.qt.nokia.com/");
+if (url.startsWith("ftp:"))
+ ...
+//! [25]
+
+
+//! [26]
+QByteArray url("http://qt.nokia.com/index.html");
+if (url.endsWith(".html"))
+ ...
+//! [26]
+
+
+//! [27]
+QByteArray x("Pineapple");
+QByteArray y = x.left(4);
+// y == "Pine"
+//! [27]
+
+
+//! [28]
+QByteArray x("Pineapple");
+QByteArray y = x.right(5);
+// y == "apple"
+//! [28]
+
+
+//! [29]
+QByteArray x("Five pineapples");
+QByteArray y = x.mid(5, 4); // y == "pine"
+QByteArray z = x.mid(5); // z == "pineapples"
+//! [29]
+
+
+//! [30]
+QByteArray x("Qt by NOKIA");
+QByteArray y = x.toLower();
+// y == "qt by nokia"
+//! [30]
+
+
+//! [31]
+QByteArray x("Qt by NOKIA");
+QByteArray y = x.toUpper();
+// y == "QT BY NOKIA"
+//! [31]
+
+
+//! [32]
+QByteArray ba(" lots\t of\nwhitespace\r\n ");
+ba = ba.simplified();
+// ba == "lots of whitespace";
+//! [32]
+
+
+//! [33]
+QByteArray ba(" lots\t of\nwhitespace\r\n ");
+ba = ba.trimmed();
+// ba == "lots\t of\nwhitespace";
+//! [33]
+
+
+//! [34]
+QByteArray x("apple");
+QByteArray y = x.leftJustified(8, '.'); // y == "apple..."
+//! [34]
+
+
+//! [35]
+QByteArray x("apple");
+QByteArray y = x.rightJustified(8, '.'); // y == "...apple"
+//! [35]
+
+
+//! [36]
+QByteArray str("FF");
+bool ok;
+int hex = str.toInt(&ok, 16); // hex == 255, ok == true
+int dec = str.toInt(&ok, 10); // dec == 0, ok == false
+//! [36]
+
+
+//! [37]
+QByteArray str("FF");
+bool ok;
+long hex = str.toLong(&ok, 16); // hex == 255, ok == true
+long dec = str.toLong(&ok, 10); // dec == 0, ok == false
+//! [37]
+
+
+//! [38]
+QByteArray string("1234.56");
+double a = string.toDouble(); // a == 1234.56
+//! [38]
+
+
+//! [39]
+QByteArray text("Qt is great!");
+text.toBase64(); // returns "UXQgaXMgZ3JlYXQh"
+//! [39]
+
+
+//! [40]
+QByteArray ba;
+int n = 63;
+ba.setNum(n); // ba == "63"
+ba.setNum(n, 16); // ba == "3f"
+//! [40]
+
+
+//! [41]
+int n = 63;
+QByteArray::number(n); // returns "63"
+QByteArray::number(n, 16); // returns "3f"
+QByteArray::number(n, 16).toUpper(); // returns "3F"
+//! [41]
+
+
+//! [42]
+QByteArray ba = QByteArray::number(12.3456, 'E', 3);
+// ba == 1.235E+01
+//! [42]
+
+
+//! [43]
+ static const char mydata[] = {
+ 0x00, 0x00, 0x03, 0x84, 0x78, 0x9c, 0x3b, 0x76,
+ 0xec, 0x18, 0xc3, 0x31, 0x0a, 0xf1, 0xcc, 0x99,
+ ...
+ 0x6d, 0x5b
+};
+
+QByteArray data = QByteArray::fromRawData(mydata, sizeof(mydata));
+QDataStream in(&data, QIODevice::ReadOnly);
+...
+//! [43]
+
+
+//! [44]
+QByteArray text = QByteArray::fromBase64("UXQgaXMgZ3JlYXQh");
+text.data(); // returns "Qt is great!"
+//! [44]
+
+
+//! [45]
+QByteArray text = QByteArray::fromHex("517420697320677265617421");
+text.data(); // returns "Qt is great!"
+//! [45]
+
+//! [46]
+QString tmp = "test";
+QByteArray text = tmp.toLocal8Bit();
+char *data = new char[text.size()]
+strcpy(data, text.data());
+delete [] data;
+//! [46]
+
+//! [47]
+QString tmp = "test";
+QByteArray text = tmp.toLocal8Bit();
+char *data = new char[text.size() + 1]
+strcpy(data, text.data());
+delete [] data;
+//! [47]
+
+}
+
+
diff --git a/doc/src/snippets/code/src_corelib_tools_qdatetime.cpp b/doc/src/snippets/code/src_corelib_tools_qdatetime.cpp
new file mode 100644
index 0000000000..3c53394a3b
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_tools_qdatetime.cpp
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QDate d1(1995, 5, 17); // May 17, 1995
+QDate d2(1995, 5, 20); // May 20, 1995
+d1.daysTo(d2); // returns 3
+d2.daysTo(d1); // returns -3
+//! [0]
+
+
+//! [1]
+QDate date = QDate::fromString("1MM12car2003", "d'MM'MMcaryyyy");
+// date is 1 December 2003
+//! [1]
+
+
+//! [2]
+QDate date = QDate::fromString("130", "Md"); // invalid
+//! [2]
+
+
+//! [3]
+QDate::fromString("1.30", "M.d"); // January 30 1900
+QDate::fromString("20000110", "yyyyMMdd"); // January 10, 2000
+QDate::fromString("20000110", "yyyyMd"); // January 10, 2000
+//! [3]
+
+
+//! [4]
+QDate::isValid(2002, 5, 17); // true
+QDate::isValid(2002, 2, 30); // false (Feb 30 does not exist)
+QDate::isValid(2004, 2, 29); // true (2004 is a leap year)
+QDate::isValid(2000, 2, 29); // true (2000 is a leap year)
+QDate::isValid(2006, 2, 29); // false (2006 is not a leap year)
+QDate::isValid(2100, 2, 29); // false (2100 is not a leap year)
+QDate::isValid(1202, 6, 6); // true (even though 1202 is pre-Gregorian)
+//! [4]
+
+
+//! [5]
+QTime n(14, 0, 0); // n == 14:00:00
+QTime t;
+t = n.addSecs(70); // t == 14:01:10
+t = n.addSecs(-70); // t == 13:58:50
+t = n.addSecs(10 * 60 * 60 + 5); // t == 00:00:05
+t = n.addSecs(-15 * 60 * 60); // t == 23:00:00
+//! [5]
+
+
+//! [6]
+QTime time = QTime::fromString("1mm12car00", "m'mm'hcarss");
+// time is 12:01.00
+//! [6]
+
+
+//! [7]
+QTime time = QTime::fromString("00:710", "hh:ms"); // invalid
+//! [7]
+
+
+//! [8]
+QTime time = QTime::fromString("1.30", "m.s");
+// time is 00:01:30.000
+//! [8]
+
+
+//! [9]
+QTime::isValid(21, 10, 30); // returns true
+QTime::isValid(22, 5, 62); // returns false
+//! [9]
+
+
+//! [10]
+QTime t;
+t.start();
+some_lengthy_task();
+qDebug("Time elapsed: %d ms", t.elapsed());
+//! [10]
+
+
+//! [11]
+QDateTime now = QDateTime::currentDateTime();
+QDateTime xmas(QDate(now.date().year(), 12, 25), QTime(0, 0));
+qDebug("There are %d seconds to Christmas", now.secsTo(xmas));
+//! [11]
+
+
+//! [12]
+QTime time1 = QTime::fromString("131", "HHh");
+// time1 is 13:00:00
+QTime time1 = QTime::fromString("1apA", "1amAM");
+// time1 is 01:00:00
+
+QDateTime dateTime2 = QDateTime::fromString("M1d1y9800:01:02",
+ "'M'M'd'd'y'yyhh:mm:ss");
+// dateTime is 1 January 1998 00:01:02
+//! [12]
+
+
+//! [13]
+QDateTime dateTime = QDateTime::fromString("130", "Mm"); // invalid
+//! [13]
+
+
+//! [14]
+QDateTime dateTime = QDateTime::fromString("1.30.1", "M.d.s");
+// dateTime is January 30 in 1900 at 00:00:01.
+//! [14]
diff --git a/doc/src/snippets/code/src_corelib_tools_qeasingcurve.cpp b/doc/src/snippets/code/src_corelib_tools_qeasingcurve.cpp
new file mode 100644
index 0000000000..59ae1b551c
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_tools_qeasingcurve.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+qreal myEasingFunction(qreal progress);
+//! [0]
+
diff --git a/doc/src/snippets/code/src_corelib_tools_qhash.cpp b/doc/src/snippets/code/src_corelib_tools_qhash.cpp
new file mode 100644
index 0000000000..a6bedb957e
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_tools_qhash.cpp
@@ -0,0 +1,299 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QHash<QString, int> hash;
+//! [0]
+
+
+//! [1]
+hash["one"] = 1;
+hash["three"] = 3;
+hash["seven"] = 7;
+//! [1]
+
+
+//! [2]
+hash.insert("twelve", 12);
+//! [2]
+
+
+//! [3]
+int num1 = hash["thirteen"];
+int num2 = hash.value("thirteen");
+//! [3]
+
+
+//! [4]
+int timeout = 30;
+if (hash.contains("TIMEOUT"))
+ timeout = hash.value("TIMEOUT");
+//! [4]
+
+
+//! [5]
+int timeout = hash.value("TIMEOUT", 30);
+//! [5]
+
+
+//! [6]
+// WRONG
+QHash<int, QWidget *> hash;
+...
+for (int i = 0; i < 1000; ++i) {
+ if (hash[i] == okButton)
+ cout << "Found button at index " << i << endl;
+}
+//! [6]
+
+
+//! [7]
+QHashIterator<QString, int> i(hash);
+while (i.hasNext()) {
+ i.next();
+ cout << i.key() << ": " << i.value() << endl;
+}
+//! [7]
+
+
+//! [8]
+QHash<QString, int>::const_iterator i = hash.constBegin();
+while (i != hash.constEnd()) {
+ cout << i.key() << ": " << i.value() << endl;
+ ++i;
+}
+//! [8]
+
+
+//! [9]
+hash.insert("plenty", 100);
+hash.insert("plenty", 2000);
+// hash.value("plenty") == 2000
+//! [9]
+
+
+//! [10]
+QList<int> values = hash.values("plenty");
+for (int i = 0; i < values.size(); ++i)
+ cout << values.at(i) << endl;
+//! [10]
+
+
+//! [11]
+QHash<QString, int>::iterator i = hash.find("plenty");
+while (i != hash.end() && i.key() == "plenty") {
+ cout << i.value() << endl;
+ ++i;
+}
+//! [11]
+
+
+//! [12]
+QHash<QString, int> hash;
+...
+foreach (int value, hash)
+ cout << value << endl;
+//! [12]
+
+
+//! [13]
+#ifndef EMPLOYEE_H
+#define EMPLOYEE_H
+
+class Employee
+{
+public:
+ Employee() {}
+ Employee(const QString &name, const QDate &dateOfBirth);
+ ...
+
+private:
+ QString myName;
+ QDate myDateOfBirth;
+};
+
+inline bool operator==(const Employee &e1, const Employee &e2)
+{
+ return e1.name() == e2.name()
+ && e1.dateOfBirth() == e2.dateOfBirth();
+}
+
+inline uint qHash(const Employee &key)
+{
+ return qHash(key.name()) ^ key.dateOfBirth().day();
+}
+
+#endif // EMPLOYEE_H
+//! [13]
+
+
+//! [14]
+QHash<QString, int> hash;
+hash.reserve(20000);
+for (int i = 0; i < 20000; ++i)
+ hash.insert(keys[i], values[i]);
+//! [14]
+
+
+//! [15]
+QHash<QObject *, int> objectHash;
+...
+QHash<QObject *, int>::iterator i = objectHash.find(obj);
+while (i != objectHash.end() && i.key() == obj) {
+ if (i.value() == 0) {
+ i = objectHash.erase(i);
+ } else {
+ ++i;
+ }
+}
+//! [15]
+
+
+//! [16]
+QHash<QString, int> hash;
+...
+QHash<QString, int>::const_iterator i = hash.find("HDR");
+while (i != hash.end() && i.key() == "HDR") {
+ cout << i.value() << endl;
+ ++i;
+}
+//! [16]
+
+
+//! [17]
+QHash<QString, int> hash;
+hash.insert("January", 1);
+hash.insert("February", 2);
+...
+hash.insert("December", 12);
+
+QHash<QString, int>::iterator i;
+for (i = hash.begin(); i != hash.end(); ++i)
+ cout << i.key() << ": " << i.value() << endl;
+//! [17]
+
+
+//! [18]
+QHash<QString, int>::iterator i;
+for (i = hash.begin(); i != hash.end(); ++i)
+ i.value() += 2;
+//! [18]
+
+
+//! [19]
+QHash<QString, int>::iterator i = hash.begin();
+while (i != hash.end()) {
+ if (i.key().startsWith("_"))
+ i = hash.erase(i);
+ else
+ ++i;
+}
+//! [19]
+
+
+//! [20]
+QHash<QString, int>::iterator i = hash.begin();
+while (i != hash.end()) {
+ QHash<QString, int>::iterator prev = i;
+ ++i;
+ if (prev.key().startsWith("_"))
+ hash.erase(prev);
+}
+//! [20]
+
+
+//! [21]
+// WRONG
+while (i != hash.end()) {
+ if (i.key().startsWith("_"))
+ hash.erase(i);
+ ++i;
+}
+//! [21]
+
+
+//! [22]
+if (i.key() == "Hello")
+ i.value() = "Bonjour";
+//! [22]
+
+
+//! [23]
+QHash<QString, int> hash;
+hash.insert("January", 1);
+hash.insert("February", 2);
+...
+hash.insert("December", 12);
+
+QHash<QString, int>::const_iterator i;
+for (i = hash.constBegin(); i != hash.constEnd(); ++i)
+ cout << i.key() << ": " << i.value() << endl;
+//! [23]
+
+
+//! [24]
+QMultiHash<QString, int> hash1, hash2, hash3;
+
+hash1.insert("plenty", 100);
+hash1.insert("plenty", 2000);
+// hash1.size() == 2
+
+hash2.insert("plenty", 5000);
+// hash2.size() == 1
+
+hash3 = hash1 + hash2;
+// hash3.size() == 3
+//! [24]
+
+
+//! [25]
+QList<int> values = hash.values("plenty");
+for (int i = 0; i < values.size(); ++i)
+ cout << values.at(i) << endl;
+//! [25]
+
+
+//! [26]
+QMultiHash<QString, int>::iterator i = hash.find("plenty");
+while (i != hash.end() && i.key() == "plenty") {
+ cout << i.value() << endl;
+ ++i;
+}
+//! [26]
diff --git a/doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp b/doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp
new file mode 100644
index 0000000000..2bfafc81b4
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp
@@ -0,0 +1,204 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QLinkedList<int> integerList;
+QLinkedList<QTime> timeList;
+//! [0]
+
+
+//! [1]
+QLinkedList<QString> list;
+list << "one" << "two" << "three";
+// list: ["one", "two", "three"]
+//! [1]
+
+
+//! [2]
+QLinkedList<QWidget *> list;
+...
+while (!list.isEmpty())
+ delete list.takeFirst();
+//! [2]
+
+
+//! [3]
+QLinkedList<QString> list;
+list.append("one");
+list.append("two");
+list.append("three");
+// list: ["one", "two", "three"]
+//! [3]
+
+
+//! [4]
+QLinkedList<QString> list;
+list.prepend("one");
+list.prepend("two");
+list.prepend("three");
+// list: ["three", "two", "one"]
+//! [4]
+
+
+//! [5]
+QList<QString> list;
+list << "sun" << "cloud" << "sun" << "rain";
+list.removeAll("sun");
+// list: ["cloud", "rain"]
+//! [5]
+
+
+//! [6]
+QList<QString> list;
+list << "sun" << "cloud" << "sun" << "rain";
+list.removeOne("sun");
+// list: ["cloud", "sun", "rain"]
+//! [6]
+
+
+//! [7]
+QLinkedList<QString> list;
+list.append("January");
+list.append("February");
+...
+list.append("December");
+
+QLinkedList<QString>::iterator i;
+for (i = list.begin(); i != list.end(); ++i)
+ cout << *i << endl;
+//! [7]
+
+
+//! [8]
+QLinkedList<QString> list;
+...
+QLinkedList<QString>::iterator it = qFind(list.begin(),
+ list.end(), "Joel");
+if (it != list.end())
+ cout << "Found Joel" << endl;
+//! [8]
+
+
+//! [9]
+QLinkedList<int>::iterator i;
+for (i = list.begin(); i != list.end(); ++i)
+ *i += 2;
+//! [9]
+
+
+//! [10]
+QLinkedList<QString> list;
+...
+QLinkedList<QString>::iterator i = list.begin();
+while (i != list.end()) {
+ if ((*i).startsWith("_"))
+ i = list.erase(i);
+ else
+ ++i;
+}
+//! [10]
+
+
+//! [11]
+QLinkedList<QString>::iterator i = list.begin();
+while (i != list.end()) {
+ QLinkedList<QString>::iterator previous = i;
+ ++i;
+ if ((*previous).startsWith("_"))
+ list.erase(previous);
+}
+//! [11]
+
+
+//! [12]
+// WRONG
+while (i != list.end()) {
+ if ((*i).startsWith("_"))
+ list.erase(i);
+ ++i;
+}
+//! [12]
+
+
+//! [13]
+if (*it == "Hello")
+ *it = "Bonjour";
+//! [13]
+
+
+//! [14]
+QLinkedList<QString> list;
+list.append("January");
+list.append("February");
+...
+list.append("December");
+
+QLinkedList<QString>::const_iterator i;
+for (i = list.constBegin(); i != list.constEnd(); ++i)
+ cout << *i << endl;
+//! [14]
+
+
+//! [15]
+QLinkedList<QString> list;
+...
+QLinkedList<QString>::iterator it = qFind(list.constBegin(),
+ list.constEnd(), "Joel");
+if (it != list.constEnd())
+ cout << "Found Joel" << endl;
+//! [15]
+
+
+//! [16]
+std::list<double> stdlist;
+list.push_back(1.2);
+list.push_back(0.5);
+list.push_back(3.14);
+
+QLinkedList<double> list = QLinkedList<double>::fromStdList(stdlist);
+//! [16]
+
+
+//! [17]
+QLinkedList<double> list;
+list << 1.2 << 0.5 << 3.14;
+
+std::list<double> stdlist = list.toStdList();
+//! [17]
diff --git a/doc/src/snippets/code/src_corelib_tools_qlistdata.cpp b/doc/src/snippets/code/src_corelib_tools_qlistdata.cpp
new file mode 100644
index 0000000000..f580ba1940
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_tools_qlistdata.cpp
@@ -0,0 +1,267 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QList<int> integerList;
+QList<QDate> dateList;
+//! [0]
+
+
+//! [1]
+QList<QString> list;
+list << "one" << "two" << "three";
+// list: ["one", "two", "three"]
+//! [1]
+
+
+//! [2]
+if (list[0] == "Bob")
+ list[0] = "Robert";
+//! [2]
+
+
+//! [3]
+for (int i = 0; i < list.size(); ++i) {
+ if (list.at(i) == "Jane")
+ cout << "Found Jane at position " << i << endl;
+}
+//! [3]
+
+
+//! [4]
+QList<QWidget *> list;
+...
+while (!list.isEmpty())
+ delete list.takeFirst();
+//! [4]
+
+
+//! [5]
+int i = list.indexOf("Jane");
+if (i != -1)
+ cout << "First occurrence of Jane is at position " << i << endl;
+//! [5]
+
+
+//! [6]
+QList<QString> list;
+list.append("one");
+list.append("two");
+list.append("three");
+// list: ["one", "two", "three"]
+//! [6]
+
+
+//! [7]
+QList<QString> list;
+list.prepend("one");
+list.prepend("two");
+list.prepend("three");
+// list: ["three", "two", "one"]
+//! [7]
+
+
+//! [8]
+QList<QString> list;
+list << "alpha" << "beta" << "delta";
+list.insert(2, "gamma");
+// list: ["alpha", "beta", "gamma", "delta"]
+//! [8]
+
+
+//! [9]
+QList<QString> list;
+list << "sun" << "cloud" << "sun" << "rain";
+list.removeAll("sun");
+// list: ["cloud", "rain"]
+//! [9]
+
+
+//! [10]
+QList<QString> list;
+list << "sun" << "cloud" << "sun" << "rain";
+list.removeOne("sun");
+// list: ["cloud", ,"sun", "rain"]
+//! [10]
+
+
+//! [11]
+QList<QString> list;
+list << "A" << "B" << "C" << "D" << "E" << "F";
+list.move(1, 4);
+// list: ["A", "C", "D", "E", "B", "F"]
+//! [11]
+
+
+//! [12]
+QList<QString> list;
+list << "A" << "B" << "C" << "D" << "E" << "F";
+list.swap(1, 4);
+// list: ["A", "E", "C", "D", "B", "F"]
+//! [12]
+
+
+//! [13]
+QList<QString> list;
+list << "A" << "B" << "C" << "B" << "A";
+list.indexOf("B"); // returns 1
+list.indexOf("B", 1); // returns 1
+list.indexOf("B", 2); // returns 3
+list.indexOf("X"); // returns -1
+//! [13]
+
+
+//! [14]
+QList<QString> list;
+list << "A" << "B" << "C" << "B" << "A";
+list.lastIndexOf("B"); // returns 3
+list.lastIndexOf("B", 3); // returns 3
+list.lastIndexOf("B", 2); // returns 1
+list.lastIndexOf("X"); // returns -1
+//! [14]
+
+
+//! [15]
+QList<QString> list;
+list.append("January");
+list.append("February");
+...
+list.append("December");
+
+QList<QString>::iterator i;
+for (i = list.begin(); i != list.end(); ++i)
+ cout << *i << endl;
+//! [15]
+
+
+//! [16]
+QList<int>::iterator i;
+for (i = list.begin(); i != list.end(); ++i)
+ *i += 2;
+//! [16]
+
+
+//! [17]
+QList<QWidget *> list;
+...
+qDeleteAll(list.begin(), list.end());
+//! [17]
+
+
+//! [18]
+if (*it == "Hello")
+ *it = "Bonjour";
+//! [18]
+
+
+//! [19]
+QList<QString> list;
+list.append("January");
+list.append("February");
+...
+list.append("December");
+
+QList<QString>::const_iterator i;
+for (i = list.constBegin(); i != list.constEnd(); ++i)
+ cout << *i << endl;
+//! [19]
+
+
+//! [20]
+QList<QWidget *> list;
+...
+qDeleteAll(list.constBegin(), list.constEnd());
+//! [20]
+
+
+//! [21]
+QVector<double> vect;
+vect << 20.0 << 30.0 << 40.0 << 50.0;
+
+QList<double> list = QVector<T>::fromVector(vect);
+// list: [20.0, 30.0, 40.0, 50.0]
+//! [21]
+
+
+//! [22]
+QStringList list;
+list << "Sven" << "Kim" << "Ola";
+
+QVector<QString> vect = list.toVector();
+// vect: ["Sven", "Kim", "Ola"]
+//! [22]
+
+
+//! [23]
+QSet<int> set;
+set << 20 << 30 << 40 << ... << 70;
+
+QList<int> list = QList<int>::fromSet(set);
+qSort(list);
+//! [23]
+
+
+//! [24]
+QStringList list;
+list << "Julia" << "Mike" << "Mike" << "Julia" << "Julia";
+
+QSet<QString> set = list.toSet();
+set.contains("Julia"); // returns true
+set.contains("Mike"); // returns true
+set.size(); // returns 2
+//! [24]
+
+
+//! [25]
+std::list<double> stdlist;
+list.push_back(1.2);
+list.push_back(0.5);
+list.push_back(3.14);
+
+QList<double> list = QList<double>::fromStdList(stdlist);
+//! [25]
+
+
+//! [26]
+QList<double> list;
+list << 1.2 << 0.5 << 3.14;
+
+std::list<double> stdlist = list.toStdList();
+//! [26]
diff --git a/doc/src/snippets/code/src_corelib_tools_qlocale.cpp b/doc/src/snippets/code/src_corelib_tools_qlocale.cpp
new file mode 100644
index 0000000000..674b6f6313
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_tools_qlocale.cpp
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QLocale egyptian(QLocale::Arabic, QLocale::Egypt);
+QString s1 = egyptian.toString(1.571429E+07, 'e');
+QString s2 = egyptian.toString(10);
+
+double d = egyptian.toDouble(s1);
+int i = egyptian.toInt(s2);
+//! [0]
+
+
+//! [1]
+QLocale::setDefault(QLocale(QLocale::Hebrew, QLocale::Israel));
+QLocale hebrew; // Constructs a default QLocale
+QString s1 = hebrew.toString(15714.3, 'e');
+
+bool ok;
+double d;
+
+QLocale::setDefault(QLocale::C);
+d = QString("1234,56").toDouble(&ok); // ok == false
+d = QString("1234.56").toDouble(&ok); // ok == true, d == 1234.56
+
+QLocale::setDefault(QLocale::German);
+d = QString("1234,56").toDouble(&ok); // ok == true, d == 1234.56
+d = QString("1234.56").toDouble(&ok); // ok == true, d == 1234.56
+
+QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates));
+str = QString("%1 %L2 %L3")
+ .arg(12345).arg(12345).arg(12345, 0, 16);
+// str == "12345 12,345 3039"
+//! [1]
+
+
+//! [2]
+QLocale korean("ko");
+QLocale swiss("de_CH");
+//! [2]
+
+
+//! [3]
+bool ok;
+double d;
+
+QLocale c(QLocale::C);
+d = c.toDouble( "1234.56", &ok ); // ok == true, d == 1234.56
+d = c.toDouble( "1,234.56", &ok ); // ok == true, d == 1234.56
+d = c.toDouble( "1234,56", &ok ); // ok == false
+
+QLocale german(QLocale::German);
+d = german.toDouble( "1234,56", &ok ); // ok == true, d == 1234.56
+d = german.toDouble( "1.234,56", &ok ); // ok == true, d == 1234.56
+d = german.toDouble( "1234.56", &ok ); // ok == false
+
+d = german.toDouble( "1.234", &ok ); // ok == true, d == 1234.0
+//! [3]
diff --git a/doc/src/snippets/code/src_corelib_tools_qmap.cpp b/doc/src/snippets/code/src_corelib_tools_qmap.cpp
new file mode 100644
index 0000000000..13715435f1
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_tools_qmap.cpp
@@ -0,0 +1,313 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QMap<QString, int> map;
+//! [0]
+
+
+//! [1]
+map["one"] = 1;
+map["three"] = 3;
+map["seven"] = 7;
+//! [1]
+
+
+//! [2]
+map.insert("twelve", 12);
+//! [2]
+
+
+//! [3]
+int num1 = map["thirteen"];
+int num2 = map.value("thirteen");
+//! [3]
+
+
+//! [4]
+int timeout = 30;
+if (map.contains("TIMEOUT"))
+ timeout = map.value("TIMEOUT");
+//! [4]
+
+
+//! [5]
+int timeout = map.value("TIMEOUT", 30);
+//! [5]
+
+
+//! [6]
+// WRONG
+QMap<int, QWidget *> map;
+...
+for (int i = 0; i < 1000; ++i) {
+ if (map[i] == okButton)
+ cout << "Found button at index " << i << endl;
+}
+//! [6]
+
+
+//! [7]
+QMapIterator<QString, int> i(map);
+while (i.hasNext()) {
+ i.next();
+ cout << i.key() << ": " << i.value() << endl;
+}
+//! [7]
+
+
+//! [8]
+QMap<QString, int>::const_iterator i = map.constBegin();
+while (i != map.constEnd()) {
+ cout << i.key() << ": " << i.value() << endl;
+ ++i;
+}
+//! [8]
+
+
+//! [9]
+map.insert("plenty", 100);
+map.insert("plenty", 2000);
+// map.value("plenty") == 2000
+//! [9]
+
+
+//! [10]
+QList<int> values = map.values("plenty");
+for (int i = 0; i < values.size(); ++i)
+ cout << values.at(i) << endl;
+//! [10]
+
+
+//! [11]
+QMap<QString, int>::iterator i = map.find("plenty");
+while (i != map.end() && i.key() == "plenty") {
+ cout << i.value() << endl;
+ ++i;
+}
+//! [11]
+
+
+//! [12]
+QMap<QString, int> map;
+...
+foreach (int value, map)
+ cout << value << endl;
+//! [12]
+
+
+//! [13]
+#ifndef EMPLOYEE_H
+#define EMPLOYEE_H
+
+class Employee
+{
+public:
+ Employee() {}
+ Employee(const QString &name, const QDate &dateOfBirth);
+ ...
+
+private:
+ QString myName;
+ QDate myDateOfBirth;
+};
+
+inline bool operator<(const Employee &e1, const Employee &e2)
+{
+ if (e1.name() != e2.name())
+ return e1.name() < e2.name();
+ return e1.dateOfBirth() < e2.dateOfBirth();
+}
+
+#endif // EMPLOYEE_H
+//! [13]
+
+
+//! [14]
+QMap<QString, int> map;
+...
+QMap<QString, int>::const_iterator i = map.find("HDR");
+while (i != map.end() && i.key() == "HDR") {
+ cout << i.value() << endl;
+ ++i;
+}
+//! [14]
+
+
+//! [15]
+QMap<int, QString> map;
+map.insert(1, "one");
+map.insert(5, "five");
+map.insert(10, "ten");
+
+map.lowerBound(0); // returns iterator to (1, "one")
+map.lowerBound(1); // returns iterator to (1, "one")
+map.lowerBound(2); // returns iterator to (5, "five")
+map.lowerBound(10); // returns iterator to (10, "ten")
+map.lowerBound(999); // returns end()
+//! [15]
+
+
+//! [16]
+QMap<QString, int> map;
+...
+QMap<QString, int>::const_iterator i = map.lowerBound("HDR");
+QMap<QString, int>::const_iterator upperBound = map.upperBound("HDR");
+while (i != upperBound) {
+ cout << i.value() << endl;
+ ++i;
+}
+//! [16]
+
+
+//! [17]
+QMap<int, QString> map;
+map.insert(1, "one");
+map.insert(5, "five");
+map.insert(10, "ten");
+
+map.upperBound(0); // returns iterator to (1, "one")
+map.upperBound(1); // returns iterator to (5, "five")
+map.upperBound(2); // returns iterator to (5, "five")
+map.upperBound(10); // returns end()
+map.upperBound(999); // returns end()
+//! [17]
+
+
+//! [18]
+QMap<QString, int> map;
+map.insert("January", 1);
+map.insert("February", 2);
+...
+map.insert("December", 12);
+
+QMap<QString, int>::iterator i;
+for (i = map.begin(); i != map.end(); ++i)
+ cout << i.key() << ": " << i.value() << endl;
+//! [18]
+
+
+//! [19]
+QMap<QString, int>::iterator i;
+for (i = map.begin(); i != map.end(); ++i)
+ i.value() += 2;
+//! [19]
+
+
+//! [20]
+QMap<QString, int>::iterator i = map.begin();
+while (i != map.end()) {
+ if (i.key().startsWith("_"))
+ i = map.erase(i);
+ else
+ ++i;
+}
+//! [20]
+
+
+//! [21]
+QMap<QString, int>::iterator i = map.begin();
+while (i != map.end()) {
+ QMap<QString, int>::iterator prev = i;
+ ++i;
+ if (prev.key().startsWith("_"))
+ map.erase(prev);
+}
+//! [21]
+
+
+//! [22]
+// WRONG
+while (i != map.end()) {
+ if (i.key().startsWith("_"))
+ map.erase(i);
+ ++i;
+}
+//! [22]
+
+
+//! [23]
+if (i.key() == "Hello")
+ i.value() = "Bonjour";
+//! [23]
+
+
+//! [24]
+QMap<QString, int> map;
+map.insert("January", 1);
+map.insert("February", 2);
+...
+map.insert("December", 12);
+
+QMap<QString, int>::const_iterator i;
+for (i = map.constBegin(); i != map.constEnd(); ++i)
+ cout << i.key() << ": " << i.value() << endl;
+//! [24]
+
+
+//! [25]
+QMultiMap<QString, int> map1, map2, map3;
+
+map1.insert("plenty", 100);
+map1.insert("plenty", 2000);
+// map1.size() == 2
+
+map2.insert("plenty", 5000);
+// map2.size() == 1
+
+map3 = map1 + map2;
+// map3.size() == 3
+//! [25]
+
+
+//! [26]
+QList<int> values = map.values("plenty");
+for (int i = 0; i < values.size(); ++i)
+ cout << values.at(i) << endl;
+//! [26]
+
+
+//! [27]
+QMultiMap<QString, int>::iterator i = map.find("plenty");
+while (i != map.end() && i.key() == "plenty") {
+ cout << i.value() << endl;
+ ++i;
+}
+//! [27]
diff --git a/doc/src/snippets/code/src_corelib_tools_qpoint.cpp b/doc/src/snippets/code/src_corelib_tools_qpoint.cpp
new file mode 100644
index 0000000000..f5c6ec996c
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_tools_qpoint.cpp
@@ -0,0 +1,149 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QPoint p;
+
+p.setX(p.x() + 1);
+p += QPoint(1, 0);
+p.rx()++;
+//! [0]
+
+
+//! [1]
+QPoint p(1, 2);
+p.rx()--; // p becomes (0, 2)
+//! [1]
+
+
+//! [2]
+QPoint p(1, 2);
+p.ry()++; // p becomes (1, 3)
+//! [2]
+
+
+//! [3]
+QPoint p( 3, 7);
+QPoint q(-1, 4);
+p += q; // p becomes (2, 11)
+//! [3]
+
+
+//! [4]
+QPoint p( 3, 7);
+QPoint q(-1, 4);
+p -= q; // p becomes (4, 3)
+//! [4]
+
+
+//! [5]
+QPoint p(-1, 4);
+p *= 2.5; // p becomes (-3, 10)
+//! [5]
+
+
+//! [6]
+QPoint p(-3, 10);
+p /= 2.5; // p becomes (-1, 4)
+//! [6]
+
+
+//! [7]
+QPoint oldPosition;
+
+MyWidget::mouseMoveEvent(QMouseEvent *event)
+{
+ QPoint point = event->pos() - oldPosition;
+ if (point.manhattanLength() > 3)
+ // the mouse has moved more than 3 pixels since the oldPosition
+}
+//! [7]
+
+
+//! [8]
+double trueLength = sqrt(pow(x(), 2) + pow(y(), 2));
+//! [8]
+
+
+//! [9]
+QPointF p;
+
+p.setX(p.x() + 1.0);
+p += QPointF(1.0, 0.0);
+p.rx()++;
+//! [9]
+
+
+//! [10]
+ QPointF p(1.1, 2.5);
+ p.rx()--; // p becomes (0.1, 2.5)
+//! [10]
+
+
+//! [11]
+QPointF p(1.1, 2.5);
+p.ry()++; // p becomes (1.1, 3.5)
+//! [11]
+
+
+//! [12]
+QPointF p( 3.1, 7.1);
+QPointF q(-1.0, 4.1);
+p += q; // p becomes (2.1, 11.2)
+//! [12]
+
+
+//! [13]
+QPointF p( 3.1, 7.1);
+QPointF q(-1.0, 4.1);
+p -= q; // p becomes (4.1, 3.0)
+//! [13]
+
+
+//! [14]
+QPointF p(-1.1, 4.1);
+p *= 2.5; // p becomes (-2.75, 10.25)
+//! [14]
+
+
+//! [15]
+QPointF p(-2.75, 10.25);
+p /= 2.5; // p becomes (-1.1, 4.1)
+//! [15]
diff --git a/doc/src/snippets/code/src_corelib_tools_qqueue.cpp b/doc/src/snippets/code/src_corelib_tools_qqueue.cpp
new file mode 100644
index 0000000000..6b5509aa1a
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_tools_qqueue.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QQueue<int> queue;
+queue.enqueue(1);
+queue.enqueue(2);
+queue.enqueue(3);
+while (!queue.isEmpty())
+ cout << queue.dequeue() << endl;
+//! [0]
diff --git a/doc/src/snippets/code/src_corelib_tools_qrect.cpp b/doc/src/snippets/code/src_corelib_tools_qrect.cpp
new file mode 100644
index 0000000000..3a3d0deec0
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_tools_qrect.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QRect r1(100, 200, 11, 16);
+QRect r2(QPoint(100, 200), QSize(11, 16));
+//! [0]
+
+
+//! [1]
+QRectF r1(100, 200, 11, 16);
+QRectF r2(QPoint(100, 200), QSize(11, 16));
+//! [1]
diff --git a/doc/src/snippets/code/src_corelib_tools_qregexp.cpp b/doc/src/snippets/code/src_corelib_tools_qregexp.cpp
new file mode 100644
index 0000000000..ccb6382723
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_tools_qregexp.cpp
@@ -0,0 +1,224 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QRegExp rx("(\\d+)");
+QString str = "Offsets: 12 14 99 231 7";
+QStringList list;
+int pos = 0;
+
+while ((pos = rx.indexIn(str, pos)) != -1) {
+ list << rx.cap(1);
+ pos += rx.matchedLength();
+}
+// list: ["12", "14", "99", "231", "7"]
+//! [0]
+
+
+//! [1]
+QRegExp rx("*.txt");
+rx.setPatternSyntax(QRegExp::Wildcard);
+rx.exactMatch("README.txt"); // returns true
+rx.exactMatch("welcome.txt.bak"); // returns false
+//! [1]
+
+
+//! [2]
+QRegExp rx("ro+m");
+rx.setMinimal(true);
+//! [2]
+
+
+//! [3]
+QRegExp mark("\\b" // word boundary
+ "[Mm]ark" // the word we want to match
+ );
+//! [3]
+
+
+//! [4]
+QRegExp rx("^\\d\\d?$"); // match integers 0 to 99
+rx.indexIn("123"); // returns -1 (no match)
+rx.indexIn("-6"); // returns -1 (no match)
+rx.indexIn("6"); // returns 0 (matched as position 0)
+//! [4]
+
+
+//! [5]
+QRegExp rx("^\\S+$"); // match strings without whitespace
+rx.indexIn("Hello world"); // returns -1 (no match)
+rx.indexIn("This_is-OK"); // returns 0 (matched at position 0)
+//! [5]
+
+
+//! [6]
+QRegExp rx("\\b(mail|letter|correspondence)\\b");
+rx.indexIn("I sent you an email"); // returns -1 (no match)
+rx.indexIn("Please write the letter"); // returns 17
+//! [6]
+
+
+//! [7]
+QString captured = rx.cap(1); // captured == "letter"
+//! [7]
+
+
+//! [8]
+QRegExp rx("&(?!amp;)"); // match ampersands but not &amp;
+QString line1 = "This & that";
+line1.replace(rx, "&amp;");
+// line1 == "This &amp; that"
+QString line2 = "His &amp; hers & theirs";
+line2.replace(rx, "&amp;");
+// line2 == "His &amp; hers &amp; theirs"
+//! [8]
+
+
+//! [9]
+QString str = "One Eric another Eirik, and an Ericsson. "
+ "How many Eiriks, Eric?";
+QRegExp rx("\\b(Eric|Eirik)\\b"); // match Eric or Eirik
+int pos = 0; // where we are in the string
+int count = 0; // how many Eric and Eirik's we've counted
+while (pos >= 0) {
+ pos = rx.indexIn(str, pos);
+ if (pos >= 0) {
+ ++pos; // move along in str
+ ++count; // count our Eric or Eirik
+ }
+}
+//! [9]
+
+
+//! [10]
+str = "Nokia Corporation\tqt.nokia.com\tNorway";
+QString company, web, country;
+rx.setPattern("^([^\t]+)\t([^\t]+)\t([^\t]+)$");
+if (rx.indexIn(str) != -1) {
+ company = rx.cap(1);
+ web = rx.cap(2);
+ country = rx.cap(3);
+}
+//! [10]
+
+
+//! [11]
+QStringList field = str.split("\t");
+//! [11]
+
+
+//! [12]
+QRegExp rx("*.html");
+rx.setPatternSyntax(QRegExp::Wildcard);
+rx.exactMatch("index.html"); // returns true
+rx.exactMatch("default.htm"); // returns false
+rx.exactMatch("readme.txt"); // returns false
+//! [12]
+
+
+//! [13]
+QString str = "offsets: 1.23 .50 71.00 6.00";
+QRegExp rx("\\d*\\.\\d+"); // primitive floating point matching
+int count = 0;
+int pos = 0;
+while ((pos = rx.indexIn(str, pos)) != -1) {
+ ++count;
+ pos += rx.matchedLength();
+}
+// pos will be 9, 14, 18 and finally 24; count will end up as 4
+//! [13]
+
+
+//! [14]
+QRegExp rx("(\\d+)(\\s*)(cm|inch(es)?)");
+int pos = rx.indexIn("Length: 36 inches");
+QStringList list = rx.capturedTexts();
+// list is now ("36 inches", "36", " ", "inches", "es")
+//! [14]
+
+
+//! [15]
+QRegExp rx("(\\d+)(?:\\s*)(cm|inch(?:es)?)");
+int pos = rx.indexIn("Length: 36 inches");
+QStringList list = rx.capturedTexts();
+// list is now ("36 inches", "36", "inches")
+//! [15]
+
+
+//! [16]
+QStringList list = rx.capturedTexts();
+QStringList::iterator it = list.begin();
+while (it != list.end()) {
+ myProcessing(*it);
+ ++it;
+}
+//! [16]
+
+
+//! [17]
+QRegExp rxlen("(\\d+)(?:\\s*)(cm|inch)");
+int pos = rxlen.indexIn("Length: 189cm");
+if (pos > -1) {
+ QString value = rxlen.cap(1); // "189"
+ QString unit = rxlen.cap(2); // "cm"
+ // ...
+}
+//! [17]
+
+
+//! [18]
+QRegExp rx("/([a-z]+)/([a-z]+)");
+rx.indexIn("Output /dev/null"); // returns 7 (position of /dev/null)
+rx.pos(0); // returns 7 (position of /dev/null)
+rx.pos(1); // returns 8 (position of dev)
+rx.pos(2); // returns 12 (position of null)
+//! [18]
+
+
+//! [19]
+s1 = QRegExp::escape("bingo"); // s1 == "bingo"
+s2 = QRegExp::escape("f(x)"); // s2 == "f\\(x\\)"
+//! [19]
+
+
+//! [20]
+QRegExp rx("(" + QRegExp::escape(name) +
+ "|" + QRegExp::escape(alias) + ")");
+//! [20]
diff --git a/doc/src/snippets/code/src_corelib_tools_qscopedpointer.cpp b/doc/src/snippets/code/src_corelib_tools_qscopedpointer.cpp
new file mode 100644
index 0000000000..be28d56eb2
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_tools_qscopedpointer.cpp
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 myFunction(bool useSubClass)
+{
+ MyClass *p = useSubClass ? new MyClass() : new MySubClass;
+ QIODevice *device = handsOverOwnership();
+
+ if (m_value > 3) {
+ delete p;
+ delete device;
+ return;
+ }
+
+ try {
+ process(device);
+ }
+ catch (...) {
+ delete p;
+ delete device;
+ throw;
+ }
+
+ delete p;
+ delete device;
+}
+//! [0]
+
+//! [1]
+void myFunction(bool useSubClass)
+{
+ // assuming that MyClass has a virtual destructor
+ QScopedPointer<MyClass> p(useSubClass ? new MyClass() : new MySubClass);
+ QScopedPointer<QIODevice> device(handsOverOwnership());
+
+ if (m_value > 3)
+ return;
+
+ process(device);
+}
+//! [1]
+
+//! [2]
+ const QWidget *const p = new QWidget();
+ // is equivalent to:
+ const QScopedPointer<const QWidget> p(new QWidget());
+
+ QWidget *const p = new QWidget();
+ // is equivalent to:
+ const QScopedPointer<QWidget> p(new QWidget());
+
+ const QWidget *p = new QWidget();
+ // is equivalent to:
+ QScopedPointer<const QWidget> p(new QWidget());
+//! [2]
+
+//! [3]
+if (scopedPointer) {
+ ...
+}
+//! [3]
+
+//! [4]
+class MyPrivateClass; // forward declare MyPrivateClass
+
+class MyClass
+{
+private:
+ QScopedPointer<MyPrivateClass> privatePtr; // QScopedPointer to forward declared class
+
+public:
+ MyClass(); // OK
+ inline ~MyClass() {} // VIOLATION - Destructor must not be inline
+
+private:
+ Q_DISABLE_COPY(MyClass) // OK - copy constructor and assignment operators
+ // are now disabled, so the compiler won't implicitely
+ // generate them.
+};
+//! [4]
+
+//! [5]
+// this QScopedPointer deletes its data using the delete[] operator:
+QScopedPointer<int, QScopedPointerArrayDeleter<int> > arrayPointer(new int[42]);
+
+// this QScopedPointer frees its data using free():
+QScopedPointer<int, QScopedPointerPodDeleter> podPointer(reinterpret_cast<int *>(malloc(42)));
+
+// this struct calls "myCustomDeallocator" to delete the pointer
+struct ScopedPointerCustomDeleter
+{
+ static inline void cleanup(MyCustomClass *pointer)
+ {
+ myCustomDeallocator(pointer);
+ }
+};
+
+// QScopedPointer using a custom deleter:
+QScopedPointer<MyCustomClass, ScopedPointerCustomDeleter> customPointer(new MyCustomClass);
+//! [5]
diff --git a/doc/src/snippets/code/src_corelib_tools_qsize.cpp b/doc/src/snippets/code/src_corelib_tools_qsize.cpp
new file mode 100644
index 0000000000..701627eb20
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_tools_qsize.cpp
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QSize t1(10, 12);
+t1.scale(60, 60, Qt::IgnoreAspectRatio);
+// t1 is (60, 60)
+
+QSize t2(10, 12);
+t2.scale(60, 60, Qt::KeepAspectRatio);
+// t2 is (50, 60)
+
+QSize t3(10, 12);
+t3.scale(60, 60, Qt::KeepAspectRatioByExpanding);
+// t3 is (60, 72)
+//! [0]
+
+
+//! [1]
+QSize size(100, 10);
+size.rwidth() += 20;
+
+// size becomes (120,10)
+//! [1]
+
+
+//! [2]
+QSize size(100, 10);
+size.rheight() += 5;
+
+// size becomes (100,15)
+//! [2]
+
+
+//! [3]
+QSize s( 3, 7);
+QSize r(-1, 4);
+s += r;
+
+// s becomes (2,11)
+//! [3]
+
+
+//! [4]
+QSize s( 3, 7);
+QSize r(-1, 4);
+s -= r;
+
+// s becomes (4,3)
+//! [4]
+
+
+//! [5]
+QSizeF t1(10, 12);
+t1.scale(60, 60, Qt::IgnoreAspectRatio);
+// t1 is (60, 60)
+
+QSizeF t2(10, 12);
+t2.scale(60, 60, Qt::KeepAspectRatio);
+// t2 is (50, 60)
+
+QSizeF t3(10, 12);
+t3.scale(60, 60, Qt::KeepAspectRatioByExpanding);
+// t3 is (60, 72)
+//! [5]
+
+
+//! [6]
+QSizeF size(100.3, 10);
+size.rwidth() += 20.5;
+
+ // size becomes (120.8,10)
+//! [6]
+
+
+//! [7]
+QSizeF size(100, 10.2);
+size.rheight() += 5.5;
+
+// size becomes (100,15.7)
+//! [7]
+
+
+//! [8]
+QSizeF s( 3, 7);
+QSizeF r(-1, 4);
+s += r;
+
+// s becomes (2,11)
+//! [8]
+
+
+//! [9]
+QSizeF s( 3, 7);
+QSizeF r(-1, 4);
+s -= r;
+
+// s becomes (4,3)
+//! [9]
diff --git a/doc/src/snippets/code/src_corelib_tools_qstring.cpp b/doc/src/snippets/code/src_corelib_tools_qstring.cpp
new file mode 100644
index 0000000000..0cd1801beb
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_tools_qstring.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+DEFINES += QT_NO_CAST_FROM_ASCII \
+ QT_NO_CAST_TO_ASCII
+//! [0]
+
+
+//! [1]
+QString url = QLatin1String("http://www.unicode.org/");
+//! [1]
+
+
+//! [2]
+double d = 12.34;
+QString str = QString("delta: %1").arg(d, 0, 'E', 3);
+// str == "delta: 1.234E+01"
+//! [2]
+
+
+//! [3]
+if (str == "auto" || str == "extern"
+ || str == "static" || str == "register") {
+ ...
+}
+//! [3]
+
+
+//! [4]
+if (str == QString("auto") || str == QString("extern")
+ || str == QString("static") || str == QString("register")) {
+ ...
+}
+//! [4]
+
+
+//! [5]
+if (str == QLatin1String("auto")
+ || str == QLatin1String("extern")
+ || str == QLatin1String("static")
+ || str == QLatin1String("register") {
+ ...
+}
+//! [5]
+
+
+//! [6]
+QLabel *label = new QLabel(QLatin1String("MOD"), this);
+//! [6]
diff --git a/doc/src/snippets/code/src_corelib_tools_qtimeline.cpp b/doc/src/snippets/code/src_corelib_tools_qtimeline.cpp
new file mode 100644
index 0000000000..3374995bb2
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_tools_qtimeline.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+...
+progressBar = new QProgressBar(this);
+progressBar->setRange(0, 100);
+
+// Construct a 1-second timeline with a frame range of 0 - 100
+QTimeLine *timeLine = new QTimeLine(1000, this);
+timeLine->setFrameRange(0, 100);
+connect(timeLine, SIGNAL(frameChanged(int)), progressBar, SLOT(setValue(int)));
+
+// Clicking the push button will start the progress bar animation
+pushButton = new QPushButton(tr("Start animation"), this);
+connect(pushButton, SIGNAL(clicked()), timeLine, SLOT(start()));
+...
+//! [0]
diff --git a/doc/src/snippets/code/src_corelib_tools_qvector.cpp b/doc/src/snippets/code/src_corelib_tools_qvector.cpp
new file mode 100644
index 0000000000..fc46d913d3
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_tools_qvector.cpp
@@ -0,0 +1,183 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QVector<int> integerVector;
+QVector<QString> stringVector;
+//! [0]
+
+
+//! [1]
+QVector<QString> vector(200);
+//! [1]
+
+
+//! [2]
+QVector<QString> vector(200, "Pass");
+//! [2]
+
+
+//! [3]
+if (vector[0] == "Liz")
+ vector[0] = "Elizabeth";
+//! [3]
+
+
+//! [4]
+for (int i = 0; i < vector.size(); ++i) {
+ if (vector.at(i) == "Alfonso")
+ cout << "Found Alfonso at position " << i << endl;
+}
+//! [4]
+
+
+//! [5]
+int i = vector.indexOf("Harumi");
+if (i != -1)
+ cout << "First occurrence of Harumi is at position " << i << endl;
+//! [5]
+
+
+//! [6]
+QVector<int> vector(10);
+int *data = vector.data();
+for (int i = 0; i < 10; ++i)
+ data[i] = 2 * i;
+//! [6]
+
+
+//! [7]
+QVector<QString> vector(0);
+vector.append("one");
+vector.append("two");
+vector.append("three");
+// vector: ["one", "two", "three"]
+//! [7]
+
+
+//! [8]
+QVector<QString> vector;
+vector.prepend("one");
+vector.prepend("two");
+vector.prepend("three");
+// vector: ["three", "two", "one"]
+//! [8]
+
+
+//! [9]
+QVector<QString> vector;
+vector << "alpha" << "beta" << "delta";
+vector.insert(2, "gamma");
+// vector: ["alpha", "beta", "gamma", "delta"]
+//! [9]
+
+
+//! [10]
+QVector<double> vector;
+vector << 2.718 << 1.442 << 0.4342;
+vector.insert(1, 3, 9.9);
+// vector: [2.718, 9.9, 9.9, 9.9, 1.442, 0.4342]
+//! [10]
+
+
+//! [11]
+QVector<QString> vector(3);
+vector.fill("Yes");
+// vector: ["Yes", "Yes", "Yes"]
+
+vector.fill("oh", 5);
+// vector: ["oh", "oh", "oh", "oh", "oh"]
+//! [11]
+
+
+//! [12]
+QVector<QString> vector;
+vector << "A" << "B" << "C" << "B" << "A";
+vector.indexOf("B"); // returns 1
+vector.indexOf("B", 1); // returns 1
+vector.indexOf("B", 2); // returns 3
+vector.indexOf("X"); // returns -1
+//! [12]
+
+
+//! [13]
+QList<QString> vector;
+vector << "A" << "B" << "C" << "B" << "A";
+vector.lastIndexOf("B"); // returns 3
+vector.lastIndexOf("B", 3); // returns 3
+vector.lastIndexOf("B", 2); // returns 1
+vector.lastIndexOf("X"); // returns -1
+//! [13]
+
+
+//! [14]
+QVector<double> vect;
+vect << "red" << "green" << "blue" << "black";
+
+QList<double> list = vect.toList();
+// list: ["red", "green", "blue", "black"]
+//! [14]
+
+
+//! [15]
+QStringList list;
+list << "Sven" << "Kim" << "Ola";
+
+QVector<QString> vect = QVector<QString>::fromList(list);
+// vect: ["Sven", "Kim", "Ola"]
+//! [15]
+
+
+//! [16]
+std::vector<double> stdvector;
+vector.push_back(1.2);
+vector.push_back(0.5);
+vector.push_back(3.14);
+
+QVector<double> vector = QVector<double>::fromStdVector(stdvector);
+//! [16]
+
+
+//! [17]
+QVector<double> vector;
+vector << 1.2 << 0.5 << 3.14;
+
+std::vector<double> stdvector = vector.toStdVector();
+//! [17]
diff --git a/doc/src/snippets/code/src_corelib_xml_qxmlstream.cpp b/doc/src/snippets/code/src_corelib_xml_qxmlstream.cpp
new file mode 100644
index 0000000000..fe08cea4c9
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_xml_qxmlstream.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+ QXmlStreamReader xml;
+ ...
+ while (!xml.atEnd()) {
+ xml.readNext();
+ ... // do processing
+ }
+ if (xml.hasError()) {
+ ... // do error handling
+ }
+//! [0]
+
+
+//! [1]
+ writeStartElement(qualifiedName);
+ writeCharacters(text);
+ writeEndElement();
+//! [1]
+
+
+//! [2]
+ writeStartElement(namespaceUri, name);
+ writeCharacters(text);
+ writeEndElement();
+//! [2]
+
+
diff --git a/doc/src/snippets/code/src_gui_accessible_qaccessible.cpp b/doc/src/snippets/code/src_gui_accessible_qaccessible.cpp
new file mode 100644
index 0000000000..84eb1cd1ac
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_accessible_qaccessible.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QAccessibleInterface *child = 0;
+int targetChild = object->navigate(Accessible::Child, 1, &child);
+if (child) {
+ // ...
+ delete child;
+}
+//! [0]
+
+//! [1]
+typedef QAccessibleInterface* myFactoryFunction(const QString &key, QObject *);
+//! [1]
diff --git a/doc/src/snippets/code/src_gui_dialogs_qabstractprintdialog.cpp b/doc/src/snippets/code/src_gui_dialogs_qabstractprintdialog.cpp
new file mode 100644
index 0000000000..bc5d296e07
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_dialogs_qabstractprintdialog.cpp
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QPrintDialog printDialog(printer, parent);
+if (printDialog.exec() == QDialog::Accepted) {
+ // print ...
+}
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp b/doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp
new file mode 100644
index 0000000000..ef14632437
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+fileName = QFileDialog::getOpenFileName(this,
+ tr("Open Image"), "/home/jana", tr("Image Files (*.png *.jpg *.bmp)"));
+//! [0]
+
+
+//! [1]
+"Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"
+//! [1]
+
+
+//! [2]
+QFileDialog dialog(this);
+dialog.setFileMode(QFileDialog::AnyFile);
+//! [2]
+
+
+//! [3]
+dialog.setNameFilter(tr("Images (*.png *.xpm *.jpg)"));
+//! [3]
+
+
+//! [4]
+dialog.setViewMode(QFileDialog::Detail);
+//! [4]
+
+
+//! [5]
+QStringList fileNames;
+if (dialog.exec())
+ fileNames = dialog.selectedFiles();
+//! [5]
+
+
+//! [6]
+dialog.setNameFilter("All C++ files (*.cpp *.cc *.C *.cxx *.c++)");
+dialog.setNameFilter("*.cpp *.cc *.C *.cxx *.c++");
+//! [6]
+
+
+//! [7]
+QStringList filters;
+filters << "Image files (*.png *.xpm *.jpg)"
+ << "Text files (*.txt)"
+ << "Any files (*)";
+
+QFileDialog dialog(this);
+dialog.setNameFilters(filters);
+dialog.exec();
+//! [7]
+
+
+//! [8]
+QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),
+ "/home",
+ tr("Images (*.png *.xpm *.jpg)"));
+//! [8]
+
+
+//! [9]
+QStringList files = QFileDialog::getOpenFileNames(
+ this,
+ "Select one or more files to open",
+ "/home",
+ "Images (*.png *.xpm *.jpg)");
+//! [9]
+
+
+//! [10]
+QStringList list = files;
+QStringList::Iterator it = list.begin();
+while(it != list.end()) {
+ myProcessing(*it);
+ ++it;
+}
+//! [10]
+
+
+//! [11]
+QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),
+ "/home/jana/untitled.png",
+ tr("Images (*.png *.xpm *.jpg)"));
+//! [11]
+
+
+//! [12]
+QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
+ "/home",
+ QFileDialog::ShowDirsOnly
+ | QFileDialog::DontResolveSymlinks);
+//! [12]
diff --git a/doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp b/doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp
new file mode 100644
index 0000000000..ef906d7e7e
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+bool ok;
+QFont font = QFontDialog::getFont(
+ &ok, QFont("Helvetica [Cronyx]", 10), this);
+if (ok) {
+ // the user clicked OK and font is set to the font the user selected
+} else {
+ // the user canceled the dialog; font is set to the initial
+ // value, in this case Helvetica [Cronyx], 10
+}
+//! [0]
+
+
+//! [1]
+myWidget.setFont(QFontDialog::getFont(0, myWidget.font()));
+//! [1]
+
+
+//! [2]
+bool ok;
+QFont font = QFontDialog::getFont(&ok, QFont("Times", 12), this);
+if (ok) {
+ // font is set to the font the user selected
+} else {
+ // the user canceled the dialog; font is set to the initial
+ // value, in this case Times, 12.
+}
+//! [2]
+
+
+//! [3]
+myWidget.setFont(QFontDialog::getFont(0, myWidget.font()));
+//! [3]
+
+
+//! [4]
+bool ok;
+QFont font = QFontDialog::getFont(&ok, this);
+if (ok) {
+ // font is set to the font the user selected
+} else {
+ // the user canceled the dialog; font is set to the default
+ // application font, QApplication::font()
+}
+//! [4]
diff --git a/doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp b/doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp
new file mode 100644
index 0000000000..7db6e264ae
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 ret = QMessageBox::warning(this, tr("My Application"),
+ tr("The document has been modified.\n"
+ "Do you want to save your changes?"),
+ QMessageBox::Save | QMessageBox::Discard
+ | QMessageBox::Cancel,
+ QMessageBox::Save);
+//! [0]
+
+
+//! [1]
+QMessageBox msgBox;
+msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
+switch (msgBox.exec()) {
+case QMessageBox::Yes:
+ // yes was clicked
+ break;
+case QMessageBox::No:
+ // no was clicked
+ break;
+default:
+ // should never be reached
+ break;
+}
+//! [1]
+
+
+//! [2]
+QMessageBox msgBox;
+QPushButton *connectButton = msgBox.addButton(tr("Connect"), QMessageBox::ActionRole);
+QPushButton *abortButton = msgBox.addButton(QMessageBox::Abort);
+
+msgBox.exec();
+
+if (msgBox.clickedButton() == connectButton) {
+ // connect
+} else if (msgBox.clickedButton() == abortButton) {
+ // abort
+}
+//! [2]
+
+
+//! [3]
+QMessageBox messageBox(this);
+QAbstractButton *disconnectButton =
+ messageBox.addButton(tr("Disconnect"), QMessageBox::ActionRole);
+...
+messageBox.exec();
+if (messageBox.clickedButton() == disconnectButton) {
+ ...
+}
+//! [3]
+
+
+//! [4]
+#include <QApplication>
+#include <QMessageBox>
+
+int main(int argc, char *argv[])
+{
+ QT_REQUIRE_VERSION(argc, argv, "4.0.2")
+
+ QApplication app(argc, argv);
+ ...
+ return app.exec();
+}
+//! [4]
+
+//! [5]
+QMessageBox msgBox;
+msgBox.setText("The document has been modified.");
+msgBox.exec();
+//! [5]
+
+//! [6]
+QMessageBox msgBox;
+msgBox.setText("The document has been modified.");
+msgBox.setInformativeText("Do you want to save your changes?");
+msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
+msgBox.setDefaultButton(QMessageBox::Save);
+int ret = msgBox.exec();
+//! [6]
+
+//! [7]
+switch (ret) {
+ case QMessageBox::Save:
+ // Save was clicked
+ break;
+ case QMessageBox::Discard:
+ // Don't Save was clicked
+ break;
+ case QMessageBox::Cancel:
+ // Cancel was clicked
+ break;
+ default:
+ // should never be reached
+ break;
+}
+//! [7]
+
+//! [9]
+QMessageBox msgBox(this);
+msgBox.setText(tr("The document has been modified.\n"
+ "Do you want to save your changes?"));
+msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard
+ | QMessageBox::Cancel);
+msgBox.setDefaultButton(QMessageBox::Save);
+//! [9]
diff --git a/doc/src/snippets/code/src_gui_dialogs_qwizard.cpp b/doc/src/snippets/code/src_gui_dialogs_qwizard.cpp
new file mode 100644
index 0000000000..0a8c033a26
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_dialogs_qwizard.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 LicenseWizard::nextId() const
+{
+ switch (currentId()) {
+ case Page_Intro:
+ if (field("intro.evaluate").toBool()) {
+ return Page_Evaluate;
+ } else {
+ return Page_Register;
+ }
+ case Page_Evaluate:
+ return Page_Conclusion;
+ case Page_Register:
+ if (field("register.upgradeKey").toString().isEmpty()) {
+ return Page_Details;
+ } else {
+ return Page_Conclusion;
+ }
+ case Page_Details:
+ return Page_Conclusion;
+ case Page_Conclusion:
+ default:
+ return -1;
+ }
+}
+//! [0]
+
+
+//! [1]
+MyWizard::MyWizard(QWidget *parent)
+ : QWizard(parent)
+{
+ ...
+ QList<QWizard::WizardButton> layout;
+ layout << QWizard::Stretch << QWizard::BackButton << QWizard::CancelButton
+ << QWizard::NextButton << QWizard::FinishButton;
+ setButtonLayout(layout);
+ ...
+}
+//! [1]
diff --git a/doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp b/doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp
new file mode 100644
index 0000000000..1fa1717fd6
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+MyGraphicsOpacityEffect::draw(QPainter *painter)
+{
+ // Fully opaque; draw directly without going through a pixmap.
+ if (qFuzzyCompare(m_opacity, 1)) {
+ drawSource(painter);
+ return;
+ }
+ ...
+}
+//! [0]
+
+//! [1]
+MyGraphicsEffect::draw(QPainter *painter)
+{
+ ...
+ QPoint offset;
+ if (sourceIsPixmap()) {
+ // No point in drawing in device coordinates (pixmap will be scaled anyways).
+ const QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset);
+ ...
+ painter->drawPixmap(offset, pixmap);
+ } else {
+ // Draw pixmap in device coordinates to avoid pixmap scaling;
+ const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset);
+ painter->setWorldTransform(QTransform());
+ ...
+ painter->drawPixmap(offset, pixmap);
+ }
+ ...
+}
+//! [1]
+
+//! [2]
+...
+QLinearGradient alphaGradient(rect.topLeft(), rect.bottomLeft());
+alphaGradient.setColorAt(0.0, Qt::transparent);
+alphaGradient.setColorAt(0.5, Qt::black);
+alphaGradient.setColorAt(1.0, Qt::transparent);
+QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect;
+effect->setOpacityMask(alphaGradient);
+...
+//! [2]
diff --git a/doc/src/snippets/code/src_gui_embedded_qcopchannel_qws.cpp b/doc/src/snippets/code/src_gui_embedded_qcopchannel_qws.cpp
new file mode 100644
index 0000000000..38d17e8033
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_embedded_qcopchannel_qws.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 MyClass::receive(const QString &message, const QByteArray &data)
+{
+ QDataStream in(data);
+ if (message == "execute(QString,QString)") {
+ QString cmd;
+ QString arg;
+ in >> cmd >> arg;
+ ...
+ } else if (message == "delete(QString)") {
+ QString fileName;
+ in >> fileName;
+ ...
+ } else {
+ ...
+ }
+}
+//! [0]
+
+
+//! [1]
+QByteArray data;
+QDataStream out(&data, QIODevice::WriteOnly);
+out << QString("cat") << QString("file.txt");
+QCopChannel::send("System/Shell", "execute(QString,QString)", data);
+//! [1]
diff --git a/doc/src/snippets/code/src_gui_embedded_qmouse_qws.cpp b/doc/src/snippets/code/src_gui_embedded_qmouse_qws.cpp
new file mode 100644
index 0000000000..31db87037a
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_embedded_qmouse_qws.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+s*Xs = a*Xd + b*Yd + c
+s*Ys = d*Xd + e*Yd + f
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_embedded_qmousetslib_qws.cpp b/doc/src/snippets/code/src_gui_embedded_qmousetslib_qws.cpp
new file mode 100644
index 0000000000..dc5a77300f
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_embedded_qmousetslib_qws.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+configure -L <path to tslib library> -I <path to tslib headers>
+//! [0]
+
+
+//! [1]
+module_raw input
+module linear
+//! [1]
diff --git a/doc/src/snippets/code/src_gui_embedded_qscreen_qws.cpp b/doc/src/snippets/code/src_gui_embedded_qscreen_qws.cpp
new file mode 100644
index 0000000000..cb902e5ed4
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_embedded_qscreen_qws.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+[screen driver][:driver specific options][:display number]
+//! [0]
+
+
+//! [1]
+Mach64:/dev/fb1:2
+//! [1]
diff --git a/doc/src/snippets/code/src_gui_embedded_qtransportauth_qws.cpp b/doc/src/snippets/code/src_gui_embedded_qtransportauth_qws.cpp
new file mode 100644
index 0000000000..0d5294be08
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_embedded_qtransportauth_qws.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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$
+**
+****************************************************************************/
+
+
+void wrapInFunction()
+{
+
+//! [0]
+QTransportAuth::Data *conData;
+QTransportAuth *a = QTransportAuth::getInstance();
+
+conData = a->connectTransport(
+ QTransportAuth::Trusted | QTransportAuth::UnixStreamSock,
+ socketDescriptor );
+//! [0]
+
+
+//! [1]
+// mySocket can be any QIODevice subclass
+AuthDevice *ad = a->recvBuf( d, mySocket );
+
+// proxy in the auth device where the socket would have gone
+connect( ad, SIGNAL(readyRead()), this, SLOT(mySocketReadyRead()));
+//! [1]
+
+
+//! [2]
+AuthDevice *ad = a->authBuf( d, mySocket );
+
+ad->write( someData );
+//! [2]
+
+
+//! [3]
+policyCheck( QTransportAuth::Data &, const QString & )
+//! [3]
+
+
+//! [4]
+QTransportAuth::Result r = d.status & QTransportAuth::ErrMask;
+qWarning( "error: %s", QTransportAuth::errorStrings[r] );
+//! [4]
+
+
+//! [5]
+MD5(K XOR opad, MD5(K XOR ipad, text))
+//! [5]
+
+}
+
diff --git a/doc/src/snippets/code/src_gui_embedded_qwindowsystem_qws.cpp b/doc/src/snippets/code/src_gui_embedded_qwindowsystem_qws.cpp
new file mode 100644
index 0000000000..defa56a9e2
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_embedded_qwindowsystem_qws.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+bool MyScreenSaver::save( int level )
+{
+ switch ( level ) {
+ case 0:
+ if ( dim_enabled ) {
+ // dim the screen
+ }
+ return true;
+ case 1:
+ if ( screenoff_enabled ) {
+ // turn off the screen
+ }
+ return true;
+ case 2:
+ if ( suspend_enabled ) {
+ // suspend
+ }
+ return true;
+ default:
+ return false;
+ }
+}
+
+...
+
+int timings[4];
+timings[0] = 5000; // dim after 5 seconds
+timings[1] = 10000; // light off after 15 seconds
+timings[2] = 45000; // suspend after 60 seconds
+timings[3] = 0;
+QWSServer::setScreenSaverIntervals( timings );
+
+// ignore the key/mouse event that turns on the screen
+int blocklevel = 1;
+if ( !screenoff_enabled ) {
+ // screenoff is disabled, ignore the key/mouse event that wakes from suspend
+ blocklevel = 2;
+ if ( !suspend_enabled ) {
+ // suspend is disabled, never ignore events
+ blocklevel = -1;
+ }
+}
+QWSServer::setScreenSaverBlockLevel( blocklevel );
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_graphicsview_qgraphicsgridlayout.cpp b/doc/src/snippets/code/src_gui_graphicsview_qgraphicsgridlayout.cpp
new file mode 100644
index 0000000000..fb4178bda0
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_graphicsview_qgraphicsgridlayout.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QGraphicsScene scene;
+QGraphicsWidget *textEdit = scene.addWidget(new QTextEdit);
+QGraphicsWidget *pushButton = scene.addWidget(new QPushButton);
+
+QGraphicsGridLayout *layout = new QGraphicsGridLayout;
+layout->addItem(textEdit, 0, 0);
+layout->addItem(pushButton, 0, 1);
+
+QGraphicsWidget *form = new QGraphicsWidget;
+form->setLayout(layout);
+scene.addItem(form);
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp b/doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp
new file mode 100644
index 0000000000..c4cf674995
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp
@@ -0,0 +1,278 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 SimpleItem : public QGraphicsItem
+{
+public:
+ QRectF boundingRect() const
+ {
+ qreal penWidth = 1;
+ return QRectF(-10 - penWidth / 2, -10 - penWidth / 2,
+ 20 + penWidth, 20 + penWidth);
+ }
+
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+ QWidget *widget)
+ {
+ painter->drawRoundedRect(-10, -10, 20, 20, 5, 5);
+ }
+};
+//! [0]
+
+
+//! [1]
+class CustomItem : public QGraphicsItem
+{
+ ...
+ enum { Type = UserType + 1 };
+
+ int type() const
+ {
+ // Enable the use of qgraphicsitem_cast with this item.
+ return Type;
+ }
+ ...
+};
+//! [1]
+
+
+//! [2]
+item->setCursor(Qt::IBeamCursor);
+//! [2]
+
+
+//! [3]
+item->setCursor(Qt::IBeamCursor);
+//! [3]
+
+
+//! [4]
+QGraphicsRectItem rect;
+rect.setPos(100, 100);
+
+rect.sceneTransform().map(QPointF(0, 0));
+// returns QPointF(100, 100);
+
+rect.sceneTransform().inverted().map(QPointF(100, 100));
+// returns QPointF(0, 0);
+//! [4]
+
+
+//! [5]
+QGraphicsRectItem rect;
+rect.setPos(100, 100);
+
+rect.deviceTransform(view->viewportTransform()).map(QPointF(0, 0));
+// returns the item's (0, 0) point in view's viewport coordinates
+
+rect.deviceTransform(view->viewportTransform()).inverted().map(QPointF(100, 100));
+// returns view's viewport's (100, 100) coordinate in item coordinates
+//! [5]
+
+
+//! [6]
+// Rotate an item 45 degrees around (0, 0).
+item->rotate(45);
+
+// Rotate an item 45 degrees around (x, y).
+item->setTransform(QTransform().translate(x, y).rotate(45).translate(-x, -y));
+//! [6]
+
+
+//! [7]
+// Scale an item by 3x2 from its origin
+item->scale(3, 2);
+
+// Scale an item by 3x2 from (x, y)
+item->setTransform(QTransform().translate(x, y).scale(3, 2).translate(-x, -y));
+//! [7]
+
+
+//! [8]
+QRectF CircleItem::boundingRect() const
+{
+ qreal penWidth = 1;
+ return QRectF(-radius - penWidth / 2, -radius - penWidth / 2,
+ diameter + penWidth, diameter + penWidth);
+}
+//! [8]
+
+
+//! [9]
+QPainterPath RoundItem::shape() const
+{
+ QPainterPath path;
+ path.addEllipse(boundingRect());
+ return path;
+}
+//! [9]
+
+
+//! [10]
+void RoundRectItem::paint(QPainter *painter,
+ const QStyleOptionGraphicsItem *option,
+ QWidget *widget)
+{
+ painter->drawRoundedRect(-10, -10, 20, 20, 5, 5);
+}
+//! [10]
+
+
+//! [11]
+static const int ObjectName = 0;
+
+QGraphicsItem *item = scene.itemAt(100, 50);
+if (item->data(ObjectName).toString().isEmpty()) {
+ if (qgraphicsitem_cast<ButtonItem *>(item))
+ item->setData(ObjectName, "Button");
+}
+//! [11]
+
+
+//! [12]
+QGraphicsScene scene;
+QGraphicsEllipseItem *ellipse = scene.addEllipse(QRectF(-10, -10, 20, 20));
+QGraphicsLineItem *line = scene.addLine(QLineF(-10, -10, 20, 20));
+
+line->installSceneEventFilter(ellipse);
+// line's events are filtered by ellipse's sceneEventFilter() function.
+
+ellipse->installSceneEventFilter(line);
+// ellipse's events are filtered by line's sceneEventFilter() function.
+//! [12]
+
+
+//! [13]
+void CustomItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
+{
+ QMenu menu;
+ QAction *removeAction = menu.addAction("Remove");
+ QAction *markAction = menu.addAction("Mark");
+ QAction *selectedAction = menu.exec(event->screenPos());
+ // ...
+}
+//! [13]
+
+
+//! [14]
+CustomItem::CustomItem()
+{
+ setAcceptDrops(true);
+ ...
+}
+
+void CustomItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
+{
+ event->setAccepted(event->mimeData()->hasFormat("text/plain"));
+}
+//! [14]
+
+
+//! [15]
+QVariant Component::itemChange(GraphicsItemChange change, const QVariant &value)
+{
+ if (change == ItemPositionChange && scene()) {
+ // value is the new position.
+ QPointF newPos = value.toPointF();
+ QRectF rect = scene()->sceneRect();
+ if (!rect.contains(newPos)) {
+ // Keep the item inside the scene rect.
+ newPos.setX(qMin(rect.right(), qMax(newPos.x(), rect.left())));
+ newPos.setY(qMin(rect.bottom(), qMax(newPos.y(), rect.top())));
+ return newPos;
+ }
+ }
+ return QGraphicsItem::itemChange(change, value);
+}
+//! [15]
+
+
+//! [16]
+void CircleItem::setRadius(qreal newRadius)
+{
+ if (radius != newRadius) {
+ prepareGeometryChange();
+ radius = newRadius;
+ }
+}
+//! [16]
+
+
+//! [17]
+// Group all selected items together
+QGraphicsItemGroup *group = scene->createItemGroup(scene->selecteditems());
+
+// Destroy the group, and delete the group item
+scene->destroyItemGroup(group);
+//! [17]
+
+
+//! [QGraphicsItem type]
+class CustomItem : public QGraphicsItem
+{
+ ...
+ enum { Type = UserType + 1 };
+
+ int type() const
+ {
+ // Enable the use of qgraphicsitem_cast with this item.
+ return Type;
+ }
+ ...
+};
+//! [QGraphicsItem type]
+
+//! [18]
+class QGraphicsPathItem : public QAbstractGraphicsShapeItem
+{
+ public:
+ enum { Type = 2 };
+ int type() const { return Type; }
+ ...
+};
+//! [18]
+
+//! [19]
+QTransform xform = item->deviceTransform(view->viewportTransform());
+QRect deviceRect = xform.mapRect(rect).toAlignedRect();
+view->viewport()->scroll(dx, dy, deviceRect);
+//! [19]
+
diff --git a/doc/src/snippets/code/src_gui_graphicsview_qgraphicslinearlayout.cpp b/doc/src/snippets/code/src_gui_graphicsview_qgraphicslinearlayout.cpp
new file mode 100644
index 0000000000..492827a9d1
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_graphicsview_qgraphicslinearlayout.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QGraphicsScene scene;
+QGraphicsWidget *textEdit = scene.addWidget(new QTextEdit);
+QGraphicsWidget *pushButton = scene.addWidget(new QPushButton);
+
+QGraphicsLinearLayout *layout = new QGraphicsLinearLayout;
+layout->addItem(textEdit);
+layout->addItem(pushButton);
+
+QGraphicsWidget *form = new QGraphicsWidget;
+form->setLayout(layout);
+scene.addItem(form);
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp b/doc/src/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp
new file mode 100644
index 0000000000..470b1505da
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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)
+{
+ QApplication app(argc, argv);
+
+ QTabWidget *tabWidget = new QTabWidget;
+
+ QGraphicsScene scene;
+ QGraphicsProxyWidget *proxy = scene.addWidget(tabWidget);
+
+ QGraphicsView view(&scene);
+ view.show();
+
+ return app.exec();
+}
+//! [0]
+
+//! [1]
+QGroupBox *groupBox = new QGroupBox("Contact Details");
+QLabel *numberLabel = new QLabel("Telephone number");
+QLineEdit *numberEdit = new QLineEdit;
+
+QFormLayout *layout = new QFormLayout;
+layout->addRow(numberLabel, numberEdit);
+groupBox->setLayout(layout);
+
+QGraphicsScene scene;
+QGraphicsProxyWidget *proxy = scene.addWidget(groupBox);
+
+QGraphicsView view(&scene);
+view.show();
+//! [1]
+
+//! [2]
+QGraphicsScene scene;
+
+QLineEdit *edit = new QLineEdit;
+QGraphicsProxyWidget *proxy = scene.addWidget(edit);
+
+edit->isVisible(); // returns true
+proxy->isVisible(); // also returns true
+
+edit->hide();
+
+edit->isVisible(); // returns false
+proxy->isVisible(); // also returns false
+//! [2]
diff --git a/doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp b/doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp
new file mode 100644
index 0000000000..383a8efbb7
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QGraphicsScene scene;
+scene.addText("Hello, world!");
+
+QGraphicsView view(&scene);
+view.show();
+//! [0]
+
+
+//! [1]
+QGraphicsScene scene;
+scene.addItem(...
+...
+QPrinter printer(QPrinter::HighResolution);
+printer.setPaperSize(QPrinter::A4);
+
+QPainter painter(&printer);
+scene.render(&painter);
+//! [1]
+
+
+//! [2]
+QSizeF segmentSize = sceneRect().size() / pow(2, depth - 1);
+//! [2]
+
+
+//! [3]
+QGraphicsScene scene;
+QGraphicsView view(&scene);
+view.show();
+
+// a blue background
+scene.setBackgroundBrush(Qt::blue);
+
+// a gradient background
+QRadialGradient gradient(0, 0, 10);
+gradient.setSpread(QGradient::RepeatSpread);
+scene.setBackgroundBrush(gradient);
+//! [3]
+
+
+//! [4]
+QGraphicsScene scene;
+QGraphicsView view(&scene);
+view.show();
+
+// a white semi-transparent foreground
+scene.setForegroundBrush(QColor(255, 255, 255, 127));
+
+// a grid foreground
+scene.setForegroundBrush(QBrush(Qt::lightGray, Qt::CrossPattern));
+//! [4]
+
+
+//! [5]
+QRectF TileScene::rectForTile(int x, int y) const
+{
+ // Return the rectangle for the tile at position (x, y).
+ return QRectF(x * tileWidth, y * tileHeight, tileWidth, tileHeight);
+}
+
+void TileScene::setTile(int x, int y, const QPixmap &pixmap)
+{
+ // Sets or replaces the tile at position (x, y) with pixmap.
+ if (x >= 0 && x < numTilesH && y >= 0 && y < numTilesV) {
+ tiles[y][x] = pixmap;
+ invalidate(rectForTile(x, y), BackgroundLayer);
+ }
+}
+
+void TileScene::drawBackground(QPainter *painter, const QRectF &exposed)
+{
+ // Draws all tiles that intersect the exposed area.
+ for (int y = 0; y < numTilesV; ++y) {
+ for (int x = 0; x < numTilesH; ++x) {
+ QRectF rect = rectForTile(x, y);
+ if (exposed.intersects(rect))
+ painter->drawPixmap(rect.topLeft(), tiles[y][x]);
+ }
+ }
+}
+//! [5]
diff --git a/doc/src/snippets/code/src_gui_graphicsview_qgraphicssceneevent.cpp b/doc/src/snippets/code/src_gui_graphicsview_qgraphicssceneevent.cpp
new file mode 100644
index 0000000000..9ad042bc82
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_graphicsview_qgraphicssceneevent.cpp
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+
+setDropAction(proposedAction());
+
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp b/doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp
new file mode 100644
index 0000000000..0fffc4be40
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QGraphicsScene scene;
+scene.addText("Hello, world!");
+
+QGraphicsView view(&scene);
+view.show();
+//! [0]
+
+
+//! [1]
+QGraphicsScene scene;
+scene.addRect(QRectF(-10, -10, 20, 20));
+
+QGraphicsView view(&scene);
+view.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
+view.show();
+//! [1]
+
+
+//! [2]
+QGraphicsView view;
+view.setBackgroundBrush(QImage(":/images/backgroundtile.png"));
+view.setCacheMode(QGraphicsView::CacheBackground);
+//! [2]
+
+
+//! [3]
+QGraphicsScene scene;
+scene.addText("GraphicsView rotated clockwise");
+
+QGraphicsView view(&scene);
+view.rotate(90); // the text is rendered with a 90 degree clockwise rotation
+view.show();
+//! [3]
+
+
+//! [4]
+QGraphicsScene scene;
+scene.addItem(...
+...
+
+QGraphicsView view(&scene);
+view.show();
+...
+
+QPrinter printer(QPrinter::HighResolution);
+printer.setPageSize(QPrinter::A4);
+QPainter painter(&printer);
+
+// print, fitting the viewport contents into a full page
+view.render(&painter);
+
+// print the upper half of the viewport into the lower.
+// half of the page.
+QRect viewport = view.viewport()->rect();
+view.render(&painter,
+ QRectF(0, printer.height() / 2,
+ printer.width(), printer.height() / 2),
+ viewport.adjusted(0, 0, 0, -viewport.height() / 2));
+
+//! [4]
+
+
+//! [5]
+void CustomView::mousePressEvent(QMouseEvent *event)
+{
+ qDebug() << "There are" << items(event->pos()).size()
+ << "items at position" << mapToScene(event->pos());
+}
+//! [5]
+
+
+//! [6]
+void CustomView::mousePressEvent(QMouseEvent *event)
+{
+ if (QGraphicsItem *item = itemAt(event->pos())) {
+ qDebug() << "You clicked on item" << item;
+ } else {
+ qDebug() << "You didn't click on an item.";
+ }
+}
+//! [6]
+
+
+//! [7]
+QGraphicsScene scene;
+scene.addText("GraphicsView rotated clockwise");
+
+QGraphicsView view(&scene);
+view.rotate(90); // the text is rendered with a 90 degree clockwise rotation
+view.show();
+//! [7]
diff --git a/doc/src/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp b/doc/src/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp
new file mode 100644
index 0000000000..aed1787984
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 MyGroupBoxWidget::initStyleOption(QStyleOption *option) const
+{
+ QGraphicsWidget::initStyleOption(option);
+ if (QStyleOptionGroupBox *box = qstyleoption_cast<QStyleOptionGroupBox *>(option)) {
+ // Add group box specific state.
+ box->flat = isFlat();
+ ...
+ }
+}
+//! [0]
+
+
+//! [1]
+setTabOrder(a, b); // a to b
+setTabOrder(b, c); // a to b to c
+setTabOrder(c, d); // a to b to c to d
+//! [1]
+
+
+//! [2]
+// WRONG
+setTabOrder(c, d); // c to d
+setTabOrder(a, b); // a to b AND c to d
+setTabOrder(b, c); // a to b to c, but not c to d
+//! [2]
diff --git a/doc/src/snippets/code/src_gui_image_qbitmap.cpp b/doc/src/snippets/code/src_gui_image_qbitmap.cpp
new file mode 100644
index 0000000000..7b388433b5
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_image_qbitmap.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+uchar arrow_bits[] = { 0x3f, 0x1f, 0x0f, 0x1f, 0x3b, 0x71, 0xe0, 0xc0 };
+QBitmap bm(8, 8, arrow_bits, true);
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_image_qicon.cpp b/doc/src/snippets/code/src_gui_image_qicon.cpp
new file mode 100644
index 0000000000..cf6469eaae
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_image_qicon.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QToolButton *button = new QToolButton;
+button->setIcon(QIcon("open.xpm"));
+//! [0]
+
+
+//! [1]
+button->setIcon(QIcon());
+//! [1]
+
+
+//! [2]
+void MyWidget::drawIcon(QPainter *painter, QPoint pos)
+{
+ QPixmap pixmap = icon.pixmap(QSize(22, 22),
+ isEnabled() ? QIcon::Normal
+ : QIcon::Disabled,
+ isChecked() ? QIcon::On
+ : QIcon::Off);
+ painter->drawPixmap(pos, pixmap);
+}
+//! [2]
+
+//! [3]
+ QIcon undoicon = QIcon::fromTheme("edit-undo");
+//! [3]
+
+//! [4]
+ QIcon undoicon = QIcon::fromTheme("edit-undo", QIcon(":/undo.png"));
+//! [4]
+
diff --git a/doc/src/snippets/code/src_gui_image_qimage.cpp b/doc/src/snippets/code/src_gui_image_qimage.cpp
new file mode 100644
index 0000000000..cbfdf14cc1
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_image_qimage.cpp
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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/doc/src/snippets/code/src_gui_image_qimagereader.cpp b/doc/src/snippets/code/src_gui_image_qimagereader.cpp
new file mode 100644
index 0000000000..f4c64c165f
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_image_qimagereader.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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/doc/src/snippets/code/src_gui_image_qimagewriter.cpp b/doc/src/snippets/code/src_gui_image_qimagewriter.cpp
new file mode 100644
index 0000000000..e44442ba7e
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_image_qimagewriter.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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/doc/src/snippets/code/src_gui_image_qmovie.cpp b/doc/src/snippets/code/src_gui_image_qmovie.cpp
new file mode 100644
index 0000000000..4efbac52b9
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_image_qmovie.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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/doc/src/snippets/code/src_gui_image_qpixmap.cpp b/doc/src/snippets/code/src_gui_image_qpixmap.cpp
new file mode 100644
index 0000000000..11e021201d
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_image_qpixmap.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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/doc/src/snippets/code/src_gui_image_qpixmapcache.cpp b/doc/src/snippets/code/src_gui_image_qpixmapcache.cpp
new file mode 100644
index 0000000000..08973b851d
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_image_qpixmapcache.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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/doc/src/snippets/code/src_gui_image_qpixmapfilter.cpp b/doc/src/snippets/code/src_gui_image_qpixmapfilter.cpp
new file mode 100644
index 0000000000..2d9c78f579
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_image_qpixmapfilter.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QPixmapColorizeFilter *myFilter = new QPixmapColorFilter;
+myFilter->setColor(QColor(128, 0, 0));
+myFilter->draw(painter, QPoint(0, 0), originalPixmap);
+//! [0]
+
+//! [1]
+QPixmapConvolutionFilter *myFilter = new QPixmapConvolutionFilter;
+qreal kernel[] = {
+ 0.0,-1.0, 0.0,
+ -1.0, 5.0,-1.0,
+ 0.0,-1.0, 0.0
+ };
+myFilter->setConvolutionKernel(kernel, 3, 3);
+myFilter->draw(painter, QPoint(0, 0), originalPixmap);
+//! [1]
+
+//! [2]
+QPixmapDropShadowFilter *myFilter = new QPixmapDropShadowFilter;
+myFilter->draw(painter, QPoint(0, 0), originalPixmap);
+//! [2]
+
diff --git a/doc/src/snippets/code/src_gui_itemviews_qabstractitemview.cpp b/doc/src/snippets/code/src_gui_itemviews_qabstractitemview.cpp
new file mode 100644
index 0000000000..75ada3acd2
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_itemviews_qabstractitemview.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 MyView::resizeEvent(QResizeEvent *event) {
+ horizontalScrollBar()->setRange(0, realWidth - width());
+ ...
+}
+//! [0]
+
+//! [1]
+setIndexWidget(index, new QLineEdit);
+...
+setIndexWidget(index, new QTextEdit);
+//! [1]
+
+//! [2]
+QItemSelectionModel *m = view->selectionModel();
+view->setModel(new model);
+delete m;
+//! [2]
diff --git a/doc/src/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp b/doc/src/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp
new file mode 100644
index 0000000000..a3b90e2c1e
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QDataWidgetMapper *mapper = new QDataWidgetMapper;
+mapper->setModel(model);
+mapper->addMapping(mySpinBox, 0);
+mapper->addMapping(myLineEdit, 1);
+mapper->addMapping(myCountryChooser, 2);
+mapper->toFirst();
+//! [0]
+
+
+//! [1]
+QDataWidgetMapper *mapper = new QDataWidgetMapper();
+mapper->setModel(myModel);
+mapper->addMapping(nameLineEdit, 0);
+mapper->addMapping(ageSpinBox, 1);
+//! [1]
+
+
+//! [2]
+QDataWidgetMapper *mapper = new QDataWidgetMapper();
+connect(myTableView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
+ mapper, SLOT(setCurrentModelIndex(QModelIndex)));
+//! [2]
diff --git a/doc/src/snippets/code/src_gui_itemviews_qitemeditorfactory.cpp b/doc/src/snippets/code/src_gui_itemviews_qitemeditorfactory.cpp
new file mode 100644
index 0000000000..bef6711da0
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_itemviews_qitemeditorfactory.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+Q_PROPERTY(QColor color READ color WRITE setColor USER true)
+//! [0]
+
+
+//! [1]
+QItemEditorCreator<MyEditor> *itemCreator =
+ new QItemEditorCreator<MyEditor>("myProperty");
+
+QItemEditorFactory *factory = new QItemEditorFactory;
+//! [1]
+
+
+//! [2]
+QItemEditorFactory *editorFactory = new QItemEditorFactory;
+QItemEditorCreatorBase *creator = new QStandardItemEditorCreator<MyFancyDateTimeEdit>();
+editorFactory->registerEditor(QVariant::DateType, creator);
+//! [2]
+
+
+//! [3]
+Q_PROPERTY(QColor color READ color WRITE setColor USER true)
+//! [3]
diff --git a/doc/src/snippets/code/src_gui_itemviews_qitemselectionmodel.cpp b/doc/src/snippets/code/src_gui_itemviews_qitemselectionmodel.cpp
new file mode 100644
index 0000000000..1277506cd0
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_itemviews_qitemselectionmodel.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QItemSelection *selection = new QItemSelection(topLeft, bottomRight);
+//! [0]
+
+
+//! [1]
+QItemSelection *selection = new QItemSelection();
+...
+selection->select(topLeft, bottomRight);
+//! [1]
diff --git a/doc/src/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp b/doc/src/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp
new file mode 100644
index 0000000000..6005179843
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QStandardItemModel model(4, 4);
+for (int row = 0; row < 4; ++row) {
+ for (int column = 0; column < 4; ++column) {
+ QStandardItem *item = new QStandardItem(QString("row %0, column %1").arg(row).arg(column));
+ model.setItem(row, column, item);
+ }
+}
+//! [0]
+
+
+//! [1]
+QStandardItemModel model;
+QStandardItem *parentItem = model.invisibleRootItem();
+for (int i = 0; i < 4; ++i) {
+ QStandardItem *item = new QStandardItem(QString("item %0").arg(i));
+ parentItem->appendRow(item);
+ parentItem = item;
+}
+//! [1]
+
+
+//! [2]
+QTreeView *treeView = new QTreeView(this);
+treeView->setModel(myStandardItemModel);
+connect(treeView, SIGNAL(clicked(QModelIndex)),
+ this, SLOT(clicked(QModelIndex)));
+//! [2]
+
+
+//! [3]
+void MyWidget::clicked(const QModelIndex &index)
+{
+ QStandardItem *item = myStandardItemModel->itemFromIndex(index);
+ // Do stuff with the item ...
+}
+//! [3]
+
+
+//! [4]
+treeView->scrollTo(item->index());
+//! [4]
diff --git a/doc/src/snippets/code/src_gui_itemviews_qtablewidget.cpp b/doc/src/snippets/code/src_gui_itemviews_qtablewidget.cpp
new file mode 100644
index 0000000000..4035ca8e13
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_itemviews_qtablewidget.cpp
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+setCellWidget(index, new QLineEdit);
+...
+setCellWidget(index, new QTextEdit);
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_itemviews_qtreewidget.cpp b/doc/src/snippets/code/src_gui_itemviews_qtreewidget.cpp
new file mode 100644
index 0000000000..4f5bc37d36
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_itemviews_qtreewidget.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QTreeWidget *treeWidget = new QTreeWidget();
+treeWidget->setColumnCount(1);
+QList<QTreeWidgetItem *> items;
+for (int i = 0; i < 10; ++i)
+ items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("item: %1").arg(i))));
+treeWidget->insertTopLevelItems(0, items);
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_kernel_qaction.cpp b/doc/src/snippets/code/src_gui_kernel_qaction.cpp
new file mode 100644
index 0000000000..bfc613b36e
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_kernel_qaction.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 app(argc, argv);
+app.setAttribute(Qt::AA_DontShowIconsInMenus); // Icons are *no longer shown* in menus
+// ...
+QAction *myAction = new QAction();
+// ...
+myAction->setIcon(SomeIcon);
+myAction->setIconVisibleInMenu(true); // Icon *will* be shown in menus for *this* action.
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_kernel_qapplication.cpp b/doc/src/snippets/code/src_gui_kernel_qapplication.cpp
new file mode 100644
index 0000000000..bb0cdde200
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_kernel_qapplication.cpp
@@ -0,0 +1,183 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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/doc/src/snippets/code/src_gui_kernel_qapplication_x11.cpp b/doc/src/snippets/code/src_gui_kernel_qapplication_x11.cpp
new file mode 100644
index 0000000000..a73f65de62
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_kernel_qapplication_x11.cpp
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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/doc/src/snippets/code/src_gui_kernel_qclipboard.cpp b/doc/src/snippets/code/src_gui_kernel_qclipboard.cpp
new file mode 100644
index 0000000000..dd052d790b
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_kernel_qclipboard.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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/doc/src/snippets/code/src_gui_kernel_qevent.cpp b/doc/src/snippets/code/src_gui_kernel_qevent.cpp
new file mode 100644
index 0000000000..d0627b2b44
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_kernel_qevent.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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)
+{
+ int numDegrees = event->delta() / 8;
+ int numSteps = numDegrees / 15;
+
+ if (event->orientation() == Qt::Horizontal) {
+ scrollHorizontally(numSteps);
+ } else {
+ scrollVertically(numSteps);
+ }
+ event->accept();
+}
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_kernel_qformlayout.cpp b/doc/src/snippets/code/src_gui_kernel_qformlayout.cpp
new file mode 100644
index 0000000000..94e6b1bd90
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_kernel_qformlayout.cpp
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QFormLayout *formLayout = new QFormLayout;
+formLayout->addRow(tr("&Name:"), nameLineEdit);
+formLayout->addRow(tr("&Email:"), emailLineEdit);
+formLayout->addRow(tr("&Age:"), ageSpinBox);
+setLayout(formLayout);
+//! [0]
+
+
+//! [1]
+nameLabel = new QLabel(tr("&Name:"));
+nameLabel->setBuddy(nameLineEdit);
+
+emailLabel = new QLabel(tr("&Name:"));
+emailLabel->setBuddy(emailLineEdit);
+
+ageLabel = new QLabel(tr("&Name:"));
+ageLabel->setBuddy(ageSpinBox);
+
+QGridLayout *gridLayout = new QGridLayout;
+gridLayout->addWidget(nameLabel, 0, 0);
+gridLayout->addWidget(nameLineEdit, 0, 1);
+gridLayout->addWidget(emailLabel, 1, 0);
+gridLayout->addWidget(emailLineEdit, 1, 1);
+gridLayout->addWidget(ageLabel, 2, 0);
+gridLayout->addWidget(ageSpinBox, 2, 1);
+setLayout(gridLayout);
+//! [1]
+
+
+//! [2]
+formLayout->setRowWrapPolicy(QFormLayout::DontWrapRows);
+formLayout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
+formLayout->setFormAlignment(Qt::AlignHCenter | Qt::AlignTop);
+formLayout->setLabelAlignment(Qt::AlignLeft);
+//! [2]
diff --git a/doc/src/snippets/code/src_gui_kernel_qkeysequence.cpp b/doc/src/snippets/code/src_gui_kernel_qkeysequence.cpp
new file mode 100644
index 0000000000..1672dc7e85
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_kernel_qkeysequence.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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/doc/src/snippets/code/src_gui_kernel_qlayout.cpp b/doc/src/snippets/code/src_gui_kernel_qlayout.cpp
new file mode 100644
index 0000000000..35da7cd89e
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_kernel_qlayout.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 void paintLayout(QPainter *painter, QLayoutItem *item)
+{
+ QLayout *layout = item->layout();
+ if (layout) {
+ for (int i = 0; i < layout->count(); ++i)
+ paintLayout(painter, layout->itemAt(i));
+ }
+ painter->drawRect(item->geometry());
+}
+
+void MyWidget::paintEvent(QPaintEvent *)
+{
+ QPainter painter(this);
+ if (layout())
+ paintLayout(&painter, layout());
+}
+//! [0]
+
+
+//! [1]
+QLayoutItem *child;
+while ((child = layout->takeAt(0)) != 0) {
+ ...
+ delete child;
+}
+//! [1]
diff --git a/doc/src/snippets/code/src_gui_kernel_qlayoutitem.cpp b/doc/src/snippets/code/src_gui_kernel_qlayoutitem.cpp
new file mode 100644
index 0000000000..306b822bdf
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_kernel_qlayoutitem.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 MyLayout::heightForWidth(int w) const
+{
+ if (cache_dirty || cached_width != w) {
+ // not all C++ compilers support "mutable"
+ MyLayout *that = (MyLayout*)this;
+ int h = calculateHeightForWidth(w);
+ that->cached_hfw = h;
+ return h;
+ }
+ return cached_hfw;
+}
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_kernel_qshortcut.cpp b/doc/src/snippets/code/src_gui_kernel_qshortcut.cpp
new file mode 100644
index 0000000000..16bdda8799
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_kernel_qshortcut.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+shortcut = new QShortcut(QKeySequence(tr("Ctrl+O", "File|Open")),
+ parent);
+//! [0]
+
+
+//! [1]
+setKey(0); // no signal emitted
+setKey(QKeySequence()); // no signal emitted
+setKey(0x3b1); // Greek letter alpha
+setKey(Qt::Key_D); // 'd', e.g. to delete
+setKey('q'); // 'q', e.g. to quit
+setKey(Qt::CTRL + Qt::Key_P); // Ctrl+P, e.g. to print document
+setKey("Ctrl+P"); // Ctrl+P, e.g. to print document
+//! [1]
diff --git a/doc/src/snippets/code/src_gui_kernel_qshortcutmap.cpp b/doc/src/snippets/code/src_gui_kernel_qshortcutmap.cpp
new file mode 100644
index 0000000000..db8edb46f3
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_kernel_qshortcutmap.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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/doc/src/snippets/code/src_gui_kernel_qsound.cpp b/doc/src/snippets/code/src_gui_kernel_qsound.cpp
new file mode 100644
index 0000000000..ebaeead9cb
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_kernel_qsound.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QSound::play("mysounds/bells.wav");
+//! [0]
+
+
+//! [1]
+QSound bells("mysounds/bells.wav");
+bells.play();
+//! [1]
diff --git a/doc/src/snippets/code/src_gui_kernel_qwidget.cpp b/doc/src/snippets/code/src_gui_kernel_qwidget.cpp
new file mode 100644
index 0000000000..d142d56a1a
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_kernel_qwidget.cpp
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+w->setWindowState(w->windowState() ^ Qt::WindowFullScreen);
+//! [0]
+
+
+//! [1]
+w->setWindowState(w->windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
+//! [1]
+
+
+//! [2]
+width = baseSize().width() + i * sizeIncrement().width();
+height = baseSize().height() + j * sizeIncrement().height();
+//! [2]
+
+
+//! [3]
+aWidget->window()->setWindowTitle("New Window Title");
+//! [3]
+
+
+//! [4]
+QFont font("Helvetica", 12, QFont::Bold);
+setFont(font);
+//! [4]
+
+
+//! [5]
+QFont font;
+font.setBold(false);
+setFont(font);
+//! [5]
+
+
+//! [6]
+setCursor(Qt::IBeamCursor);
+//! [6]
+
+
+//! [7]
+QPixmap pixmap(widget->size());
+widget->render(&pixmap);
+//! [7]
+
+
+//! [8]
+QPainter painter(this);
+...
+painter.end();
+myWidget->render(this);
+//! [8]
+
+
+//! [9]
+setTabOrder(a, b); // a to b
+setTabOrder(b, c); // a to b to c
+setTabOrder(c, d); // a to b to c to d
+//! [9]
+
+
+//! [10]
+// WRONG
+setTabOrder(c, d); // c to d
+setTabOrder(a, b); // a to b AND c to d
+setTabOrder(b, c); // a to b to c, but not c to d
+//! [10]
+
+
+//! [11]
+void MyWidget::closeEvent(QCloseEvent *event)
+{
+ QSettings settings("MyCompany", "MyApp");
+ settings.setValue("geometry", saveGeometry());
+ QWidget::closeEvent(event);
+}
+//! [11]
+
+
+//! [12]
+QSettings settings("MyCompany", "MyApp");
+myWidget->restoreGeometry(settings.value("myWidget/geometry").toByteArray());
+//! [12]
+
+
+//! [13]
+setUpdatesEnabled(false);
+bigVisualChanges();
+setUpdatesEnabled(true);
+//! [13]
+
+
+//! [14]
+...
+extern void qt_x11_set_global_double_buffer(bool);
+qt_x11_set_global_double_buffer(false);
+...
+//! [14]
diff --git a/doc/src/snippets/code/src_gui_painting_qbrush.cpp b/doc/src/snippets/code/src_gui_painting_qbrush.cpp
new file mode 100644
index 0000000000..c2ce61ea35
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_painting_qbrush.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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/doc/src/snippets/code/src_gui_painting_qcolor.cpp b/doc/src/snippets/code/src_gui_painting_qcolor.cpp
new file mode 100644
index 0000000000..31434f2d96
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_painting_qcolor.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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/doc/src/snippets/code/src_gui_painting_qdrawutil.cpp b/doc/src/snippets/code/src_gui_painting_qdrawutil.cpp
new file mode 100644
index 0000000000..6822d818ae
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_painting_qdrawutil.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QFrame frame:
+frame.setFrameStyle(QFrame::HLine | QFrame::Sunken);
+//! [0]
+
+
+//! [1]
+QFrame frame:
+frame.setFrameStyle(QFrame::Box | QFrame::Raised);
+//! [1]
+
+
+//! [2]
+QFrame frame:
+frame.setFrameStyle( QFrame::Panel | QFrame::Sunken);
+//! [2]
+
+
+//! [3]
+QFrame frame:
+frame.setFrameStyle(QFrame::WinPanel | QFrame::Raised);
+//! [3]
+
+
+//! [4]
+QFrame frame:
+frame.setFrameStyle(QFrame::Box | QFrame::Plain);
+//! [4]
+
+
+//! [5]
+QFrame frame:
+frame.setFrameStyle(QFrame::HLine | QFrame::Sunken);
+//! [5]
+
+
+//! [6]
+QFrame frame:
+frame.setFrameStyle(QFrame::Box | QFrame::Raised);
+//! [6]
+
+
+//! [7]
+QFrame frame:
+frame.setFrameStyle( QFrame::Panel | QFrame::Sunken);
+//! [7]
+
+
+//! [8]
+QFrame frame:
+frame.setFrameStyle(QFrame::WinPanel | QFrame::Raised);
+//! [8]
+
+
+//! [9]
+QFrame frame:
+frame.setFrameStyle(QFrame::Box | QFrame::Plain);
+//! [9]
diff --git a/doc/src/snippets/code/src_gui_painting_qmatrix.cpp b/doc/src/snippets/code/src_gui_painting_qmatrix.cpp
new file mode 100644
index 0000000000..63dfd6d493
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_painting_qmatrix.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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/doc/src/snippets/code/src_gui_painting_qpainter.cpp b/doc/src/snippets/code/src_gui_painting_qpainter.cpp
new file mode 100644
index 0000000000..da566ed43a
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_painting_qpainter.cpp
@@ -0,0 +1,259 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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/doc/src/snippets/code/src_gui_painting_qpainterpath.cpp b/doc/src/snippets/code/src_gui_painting_qpainterpath.cpp
new file mode 100644
index 0000000000..b2a9dcf5c7
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_painting_qpainterpath.cpp
@@ -0,0 +1,149 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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/doc/src/snippets/code/src_gui_painting_qpen.cpp b/doc/src/snippets/code/src_gui_painting_qpen.cpp
new file mode 100644
index 0000000000..8674516fbc
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_painting_qpen.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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<qreal> dashes;
+qreal space = 4;
+
+dashes << 1 << space << 3 << space << 9 << space
+ << 27 << space << 9 << space;
+
+pen.setDashPattern(dashes);
+//! [2]
+
+
+//! [3]
+QPen pen;
+QVector<qreal> dashes;
+qreal space = 4;
+dashes << 1 << space << 3 << space << 9 << space
+ << 27 << space << 9 << space;
+pen.setDashPattern(dashes);
+//! [3]
diff --git a/doc/src/snippets/code/src_gui_painting_qregion.cpp b/doc/src/snippets/code/src_gui_painting_qregion.cpp
new file mode 100644
index 0000000000..660138d461
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_painting_qregion.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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/doc/src/snippets/code/src_gui_painting_qregion_unix.cpp b/doc/src/snippets/code/src_gui_painting_qregion_unix.cpp
new file mode 100644
index 0000000000..2eddeea506
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_painting_qregion_unix.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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/doc/src/snippets/code/src_gui_painting_qtransform.cpp b/doc/src/snippets/code/src_gui_painting_qtransform.cpp
new file mode 100644
index 0000000000..24b1a359e1
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_painting_qtransform.cpp
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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/doc/src/snippets/code/src_gui_qproxystyle.cpp b/doc/src/snippets/code/src_gui_qproxystyle.cpp
new file mode 100644
index 0000000000..b4cd0b65d0
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_qproxystyle.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 MyProxyStyle : public QProxyStyle
+{
+public:
+
+ int styleHint(StyleHint hint, const QStyleOption *option = 0,
+ const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const
+ {
+ if (hint == QStyle::SH_UnderlineShortcut)
+ return 1;
+ return QProxyStyle::styleHint(hint, option, widget, returnData);
+ }
+};
+
+//! [0]
+
+//! [1]
+#include "textedit.h"
+#include <QApplication>
+#include <QProxyStyle>
+
+class MyProxyStyle : public QProxyStyle
+{
+ public:
+ int styleHint(StyleHint hint, const QStyleOption *option = 0,
+ const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const
+ {
+ if (hint == QStyle::SH_UnderlineShortcut)
+ return 0;
+ return QProxyStyle::styleHint(hint, option, widget, returnData);
+ }
+};
+
+int main(int argc, char **argv)
+{
+ Q_INIT_RESOURCE(textedit);
+
+ QApplication a(argc, argv);
+ a.setStyle(new MyProxyStyle);
+ TextEdit mw;
+ mw.resize(700, 800);
+ mw.show();
+ //...
+}
+//! [1]
diff --git a/doc/src/snippets/code/src_gui_styles_qstyle.cpp b/doc/src/snippets/code/src_gui_styles_qstyle.cpp
new file mode 100644
index 0000000000..40fb230c02
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_styles_qstyle.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+./myapplication -style motif
+//! [0]
+
+
+//! [1]
+./myapplication -style custom
+//! [1]
diff --git a/doc/src/snippets/code/src_gui_styles_qstyleoption.cpp b/doc/src/snippets/code/src_gui_styles_qstyleoption.cpp
new file mode 100644
index 0000000000..ba65d3f5ea
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_styles_qstyleoption.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 MyStyle::styleHint(StyleHint stylehint, const QStyleOption *opt,
+ const QWidget *widget, QStyleHintReturn* returnData) const;
+{
+ if (stylehint == SH_RubberBand_Mask) {
+ const QStyleHintReturnMask *maskReturn =
+ qstyleoption_cast<const QStyleHintReturnMask *>(hint);
+ if (maskReturn) {
+ ...
+ }
+ }
+ ...
+}
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_text_qfont.cpp b/doc/src/snippets/code/src_gui_text_qfont.cpp
new file mode 100644
index 0000000000..5694d6aab0
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_text_qfont.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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/doc/src/snippets/code/src_gui_text_qfontmetrics.cpp b/doc/src/snippets/code/src_gui_text_qfontmetrics.cpp
new file mode 100644
index 0000000000..3be333d22a
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_text_qfontmetrics.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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/doc/src/snippets/code/src_gui_text_qsyntaxhighlighter.cpp b/doc/src/snippets/code/src_gui_text_qsyntaxhighlighter.cpp
new file mode 100644
index 0000000000..a273f333a5
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_text_qsyntaxhighlighter.cpp
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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<ParenthesisInfo> parentheses;
+};
+//! [4]
diff --git a/doc/src/snippets/code/src_gui_text_qtextcursor.cpp b/doc/src/snippets/code/src_gui_text_qtextcursor.cpp
new file mode 100644
index 0000000000..9e99c4b676
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_text_qtextcursor.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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/doc/src/snippets/code/src_gui_text_qtextdocument.cpp b/doc/src/snippets/code/src_gui_text_qtextdocument.cpp
new file mode 100644
index 0000000000..775cc0fcd1
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_text_qtextdocument.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QString plain = "#include <QtCore>"
+QString html = Qt::escape(plain);
+// html == "#include &lt;QtCore&gt;"
+//! [0]
+
+
+//! [1]
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>...
+//! [1]
diff --git a/doc/src/snippets/code/src_gui_text_qtextlayout.cpp b/doc/src/snippets/code/src_gui_text_qtextlayout.cpp
new file mode 100644
index 0000000000..feb5219c1a
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_text_qtextlayout.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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/doc/src/snippets/code/src_gui_util_qcompleter.cpp b/doc/src/snippets/code/src_gui_util_qcompleter.cpp
new file mode 100644
index 0000000000..bfc1b54cbd
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_util_qcompleter.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QStringList wordList;
+wordList << "alpha" << "omega" << "omicron" << "zeta";
+
+QLineEdit *lineEdit = new QLineEdit(this);
+
+QCompleter *completer = new QCompleter(wordList, this);
+completer->setCaseSensitivity(Qt::CaseInsensitive);
+lineEdit->setCompleter(completer);
+//! [0]
+
+
+//! [1]
+QCompleter *completer = new QCompleter(this);
+completer->setModel(new QDirModel(completer));
+lineEdit->setCompleter(completer);
+//! [1]
+
+
+//! [2]
+for (int i = 0; completer->setCurrentRow(i); i++)
+ qDebug() << completer->currentCompletion() << " is match number " << i;
+//! [2]
diff --git a/doc/src/snippets/code/src_gui_util_qdesktopservices.cpp b/doc/src/snippets/code/src_gui_util_qdesktopservices.cpp
new file mode 100644
index 0000000000..c878b71b6c
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_util_qdesktopservices.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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/doc/src/snippets/code/src_gui_util_qundostack.cpp b/doc/src/snippets/code/src_gui_util_qundostack.cpp
new file mode 100644
index 0000000000..2eccd71015
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_util_qundostack.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 AppendText : public QUndoCommand
+{
+public:
+ AppendText(QString *doc, const QString &text)
+ : m_document(doc), m_text(text) { setText("append text"); }
+ virtual void undo()
+ { m_document->chop(m_text.length()); }
+ virtual void redo()
+ { m_document->append(m_text); }
+private:
+ QString *m_document;
+ QString m_text;
+};
+//! [0]
+
+
+//! [1]
+MyCommand *command1 = new MyCommand();
+stack->push(command1);
+MyCommand *command2 = new MyCommand();
+stack->push(command2);
+
+stack->undo();
+
+MyCommand *command3 = new MyCommand();
+stack->push(command3); // command2 gets deleted
+//! [1]
+
+
+//! [2]
+QUndoCommand *insertRed = new QUndoCommand(); // an empty command
+insertRed->setText("insert red text");
+
+new InsertText(document, idx, text, insertRed); // becomes child of insertRed
+new SetColor(document, idx, text.length(), Qt::red, insertRed);
+
+stack.push(insertRed);
+//! [2]
+
+
+//! [3]
+bool AppendText::mergeWith(const QUndoCommand *other)
+{
+ if (other->id() != id()) // make sure other is also an AppendText command
+ return false;
+ m_text += static_cast<const AppendText*>(other)->m_text;
+ return true;
+}
+//! [3]
+
+
+//! [4]
+stack.beginMacro("insert red text");
+stack.push(new InsertText(document, idx, text));
+stack.push(new SetColor(document, idx, text.length(), Qt::red));
+stack.endMacro(); // indexChanged() is emitted
+//! [4]
+
+
+//! [5]
+QUndoCommand *insertRed = new QUndoCommand(); // an empty command
+insertRed->setText("insert red text");
+
+new InsertText(document, idx, text, insertRed); // becomes child of insertRed
+new SetColor(document, idx, text.length(), Qt::red, insertRed);
+
+stack.push(insertRed);
+//! [5]
diff --git a/doc/src/snippets/code/src_gui_widgets_qabstractbutton.cpp b/doc/src/snippets/code/src_gui_widgets_qabstractbutton.cpp
new file mode 100644
index 0000000000..3bfe1d2aaa
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qabstractbutton.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QPushButton *button = new QPushButton(tr("Ro&ck && Roll"), this);
+//! [0]
+
+
+//! [1]
+button->setIcon(QIcon(":/images/print.png"));
+button->setShortcut(tr("Alt+F7"));
+//! [1]
+
+
+//! [2]
+void MyWidget::reactToToggle(bool checked)
+{
+ if (checked) {
+ // Examine the new button states.
+ ...
+ }
+}
+//! [2]
diff --git a/doc/src/snippets/code/src_gui_widgets_qabstractspinbox.cpp b/doc/src/snippets/code/src_gui_widgets_qabstractspinbox.cpp
new file mode 100644
index 0000000000..3a73308e63
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qabstractspinbox.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QSpinBox *spinBox = new QSpinBox(this);
+spinBox->setRange(0, 100);
+spinBox->setWrapping(true);
+spinBox->setValue(100);
+spinBox->stepBy(1);
+// value is 0
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_widgets_qcalendarwidget.cpp b/doc/src/snippets/code/src_gui_widgets_qcalendarwidget.cpp
new file mode 100644
index 0000000000..336a4064b5
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qcalendarwidget.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QCalendarWidget *calendar;
+calendar->setGridVisible(true);
+//! [0]
+
+
+//! [1]
+QCalendarWidget *calendar;
+calendar->setGridVisible(true);
+calendar->setMinimumDate(QDate(2006, 6, 19));
+//! [1]
+
+
+//! [2]
+QCalendarWidget *calendar;
+calendar->setGridVisible(true);
+calendar->setMaximumDate(QDate(2006, 7, 3));
+//! [2]
+
+
+//! [3]
+QCalendarWidget *calendar;
+
+calendar->setDateRange(min, max);
+//! [3]
+
+
+//! [4]
+QCalendarWidget *calendar;
+
+calendar->setMinimumDate(min);
+calendar->setMaximumDate(max);
+//! [4]
+
+
+//! [5]
+QCalendarWidget *calendar;
+calendar->setGridVisible(true);
+//! [5]
diff --git a/doc/src/snippets/code/src_gui_widgets_qcheckbox.cpp b/doc/src/snippets/code/src_gui_widgets_qcheckbox.cpp
new file mode 100644
index 0000000000..785d0cfd93
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qcheckbox.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QCheckBox *checkbox = new QCheckBox("C&ase sensitive", this);
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_widgets_qdatetimeedit.cpp b/doc/src/snippets/code/src_gui_widgets_qdatetimeedit.cpp
new file mode 100644
index 0000000000..73253f79f1
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qdatetimeedit.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QDateTimeEdit *dateEdit = new QDateTimeEdit(QDate::currentDate());
+dateEdit->setMinimumDate(QDate::currentDate().addDays(-365));
+dateEdit->setMaximumDate(QDate::currentDate().addDays(365));
+dateEdit->setDisplayFormat("yyyy.MM.dd");
+//! [0]
+
+
+//! [1]
+setDateTimeRange(min, max);
+//! [1]
+
+
+//! [2]
+setMinimumDateTime(min);
+setMaximumDateTime(max);
+//! [2]
+
+
+//! [3]
+setDateRange(min, max);
+//! [3]
+
+
+//! [4]
+setMinimumDate(min);
+setMaximumDate(max);
+//! [4]
+
+
+//! [5]
+setTimeRange(min, max);
+//! [5]
+
+
+//! [6]
+setMinimumTime(min);
+setMaximumTime(max);
+//! [6]
diff --git a/doc/src/snippets/code/src_gui_widgets_qdockwidget.cpp b/doc/src/snippets/code/src_gui_widgets_qdockwidget.cpp
new file mode 100644
index 0000000000..fd1d81769b
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qdockwidget.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QDockWidget *dockWidget = qobject_cast<QDockWidget*>(parentWidget());
+if (dockWidget->features() & QDockWidget::DockWidgetVerticalTitleBar) {
+ // I need to be vertical
+} else {
+ // I need to be horizontal
+}
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_widgets_qframe.cpp b/doc/src/snippets/code/src_gui_widgets_qframe.cpp
new file mode 100644
index 0000000000..5fb45c1f77
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qframe.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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(...);
+label.setFrameStyle(QFrame::Panel | QFrame::Raised);
+label.setLineWidth(2);
+
+QProgressBar pbar(...);
+label.setFrameStyle(QFrame::NoFrame);
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_widgets_qgroupbox.cpp b/doc/src/snippets/code/src_gui_widgets_qgroupbox.cpp
new file mode 100644
index 0000000000..0f4a5b8afa
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qgroupbox.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+g->setTitle("&User information");
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_widgets_qlabel.cpp b/doc/src/snippets/code/src_gui_widgets_qlabel.cpp
new file mode 100644
index 0000000000..cda00fa349
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qlabel.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 = new QLabel(this);
+label->setFrameStyle(QFrame::Panel | QFrame::Sunken);
+label->setText("first line\nsecond line");
+label->setAlignment(Qt::AlignBottom | Qt::AlignRight);
+//! [0]
+
+
+//! [1]
+QLineEdit* phoneEdit = new QLineEdit(this);
+QLabel* phoneLabel = new QLabel("&Phone:", this);
+phoneLabel->setBuddy(phoneEdit);
+//! [1]
+
+
+//! [2]
+QLineEdit *nameEd = new QLineEdit(this);
+QLabel *nameLb = new QLabel("&Name:", this);
+nameLb->setBuddy(nameEd);
+QLineEdit *phoneEd = new QLineEdit(this);
+QLabel *phoneLb = new QLabel("&Phone:", this);
+phoneLb->setBuddy(phoneEd);
+// (layout setup not shown)
+//! [2]
diff --git a/doc/src/snippets/code/src_gui_widgets_qlineedit.cpp b/doc/src/snippets/code/src_gui_widgets_qlineedit.cpp
new file mode 100644
index 0000000000..7b9e183703
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qlineedit.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 LineEdit::contextMenuEvent(QContextMenuEvent *event)
+{
+ QMenu *menu = createStandardContextMenu();
+ menu->addAction(tr("My Menu Item"));
+ //...
+ menu->exec(event->globalPos());
+ delete menu;
+}
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp b/doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp
new file mode 100644
index 0000000000..d465c7013d
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 MyMainWindow::closeEvent(QCloseEvent *event)
+{
+ QSettings settings("MyCompany", "MyApp");
+ settings.setValue("geometry", saveGeometry());
+ settings.setValue("windowState", saveState());
+ QMainWindow::closeEvent(event);
+}
+//! [0]
+
+
+//! [1]
+void MainWindow::readSettings()
+{
+ QSettings settings("MyCompany", "MyApp");
+ restoreGeometry(settings.value("myWidget/geometry").toByteArray());
+ restoreState(settings.value("myWidget/windowState").toByteArray());
+}
+//! [1]
diff --git a/doc/src/snippets/code/src_gui_widgets_qmenu.cpp b/doc/src/snippets/code/src_gui_widgets_qmenu.cpp
new file mode 100644
index 0000000000..f2dd1ccf52
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qmenu.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+exec(QCursor::pos());
+//! [0]
+
+
+//! [1]
+exec(somewidget.mapToGlobal(QPoint(0,0)));
+//! [1]
+
+
+//! [2]
+exec(e->globalPos());
+//! [2]
+
+
+//! [3]
+exec(QCursor::pos());
+//! [3]
+
+
+//! [4]
+exec(somewidget.mapToGlobal(QPoint(0, 0)));
+//! [4]
+
+
+//! [5]
+exec(e->globalPos());
+//! [5]
+
+
+//! [6]
+QMenu menu;
+QAction *at = actions[0]; // Assumes actions is not empty
+foreach (QAction *a, actions)
+ menu.addAction(a);
+menu.exec(pos, at);
+//! [6]
diff --git a/doc/src/snippets/code/src_gui_widgets_qmenubar.cpp b/doc/src/snippets/code/src_gui_widgets_qmenubar.cpp
new file mode 100644
index 0000000000..98eafb4239
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qmenubar.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+menubar->addMenu(fileMenu);
+//! [0]
+
+
+//! [1]
+QMenuBar *menuBar = new QMenuBar(0);
+//! [1]
diff --git a/doc/src/snippets/code/src_gui_widgets_qplaintextedit.cpp b/doc/src/snippets/code/src_gui_widgets_qplaintextedit.cpp
new file mode 100644
index 0000000000..4b0219d68c
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qplaintextedit.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 MyQPlainTextEdit::contextMenuEvent(QContextMenuEvent *event)
+{
+ QMenu *menu = createStandardContextMenu();
+ menu->addAction(tr("My Menu Item"));
+ //...
+ menu->exec(event->globalPos());
+ delete menu;
+}
+//! [0]
+
+
+//! [1]
+edit->textCursor().insertText(text);
+//! [1]
diff --git a/doc/src/snippets/code/src_gui_widgets_qpushbutton.cpp b/doc/src/snippets/code/src_gui_widgets_qpushbutton.cpp
new file mode 100644
index 0000000000..099d087dcb
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qpushbutton.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QPushButton *button = new QPushButton("&Download", this);
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_widgets_qradiobutton.cpp b/doc/src/snippets/code/src_gui_widgets_qradiobutton.cpp
new file mode 100644
index 0000000000..3dc031c383
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qradiobutton.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QRadioButton *button = new QRadioButton("Search from the &cursor", this);
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_widgets_qrubberband.cpp b/doc/src/snippets/code/src_gui_widgets_qrubberband.cpp
new file mode 100644
index 0000000000..3289344c43
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qrubberband.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 Widget::mousePressEvent(QMouseEvent *event)
+{
+ origin = event->pos();
+ if (!rubberBand)
+ rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
+ rubberBand->setGeometry(QRect(origin, QSize()));
+ rubberBand->show();
+}
+
+void Widget::mouseMoveEvent(QMouseEvent *event)
+{
+ rubberBand->setGeometry(QRect(origin, event->pos()).normalized());
+}
+
+void Widget::mouseReleaseEvent(QMouseEvent *event)
+{
+ rubberBand->hide();
+ // determine selection, for example using QRect::intersects()
+ // and QRect::contains().
+}
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_widgets_qscrollarea.cpp b/doc/src/snippets/code/src_gui_widgets_qscrollarea.cpp
new file mode 100644
index 0000000000..64f8d293df
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qscrollarea.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 *imageLabel = new QLabel;
+QImage image("happyguy.png");
+imageLabel->setPixmap(QPixmap::fromImage(image));
+
+scrollArea = new QScrollArea;
+scrollArea->setBackgroundRole(QPalette::Dark);
+scrollArea->setWidget(imageLabel);
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_widgets_qspinbox.cpp b/doc/src/snippets/code/src_gui_widgets_qspinbox.cpp
new file mode 100644
index 0000000000..d4022d790e
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qspinbox.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+sb->setPrefix("$");
+//! [0]
+
+
+//! [1]
+sb->setSuffix(" km");
+//! [1]
+
+
+//! [2]
+setRange(minimum, maximum);
+//! [2]
+
+
+//! [3]
+setMinimum(minimum);
+setMaximum(maximum);
+//! [3]
+
+
+//! [4]
+spinbox->setPrefix("$");
+//! [4]
+
+
+//! [5]
+spinbox->setSuffix(" km");
+//! [5]
+
+
+//! [6]
+setRange(minimum, maximum);
+//! [6]
+
+
+//! [7]
+setMinimum(minimum);
+setMaximum(maximum);
+//! [7]
diff --git a/doc/src/snippets/code/src_gui_widgets_qsplashscreen.cpp b/doc/src/snippets/code/src_gui_widgets_qsplashscreen.cpp
new file mode 100644
index 0000000000..c8ee298c78
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qsplashscreen.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 pixmap(":/splash.png");
+QSplashScreen *splash = new QSplashScreen(pixmap);
+splash->show();
+
+... // Loading some items
+splash->showMessage("Loaded modules");
+
+qApp->processEvents();
+
+... // Establishing connections
+splash->showMessage("Established connections");
+
+qApp->processEvents();
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_widgets_qsplitter.cpp b/doc/src/snippets/code/src_gui_widgets_qsplitter.cpp
new file mode 100644
index 0000000000..05f907a7e6
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qsplitter.cpp
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QWidget *widget = splitter->widget(index);
+QSizePolicy policy = widget->sizePolicy();
+policy.setHorizontalStretch(stretch);
+policy.setVerticalStretch(stretch);
+widget->setSizePolicy(policy);
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_widgets_qstatusbar.cpp b/doc/src/snippets/code/src_gui_widgets_qstatusbar.cpp
new file mode 100644
index 0000000000..12e962c970
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qstatusbar.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+statusBar()->addWidget(new MyReadWriteIndication);
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_widgets_qtextbrowser.cpp b/doc/src/snippets/code/src_gui_widgets_qtextbrowser.cpp
new file mode 100644
index 0000000000..8ad9deb4ea
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qtextbrowser.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+backaction.setToolTip(browser.historyTitle(-1));
+forwardaction.setToolTip(browser.historyTitle(+1));
+//! [0]
diff --git a/doc/src/snippets/code/src_gui_widgets_qtextedit.cpp b/doc/src/snippets/code/src_gui_widgets_qtextedit.cpp
new file mode 100644
index 0000000000..5ee24a04d3
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qtextedit.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 MyTextEdit::contextMenuEvent(QContextMenuEvent *event)
+{
+ QMenu *menu = createStandardContextMenu();
+ menu->addAction(tr("My Menu Item"));
+ //...
+ menu->exec(event->globalPos());
+ delete menu;
+}
+//! [0]
+
+
+//! [1]
+edit->textCursor().insertText(text);
+//! [1]
+
+
+//! [2]
+edit->textCursor().insertHtml(fragment);
+//! [2]
diff --git a/doc/src/snippets/code/src_gui_widgets_qvalidator.cpp b/doc/src/snippets/code/src_gui_widgets_qvalidator.cpp
new file mode 100644
index 0000000000..4a104ddc33
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qvalidator.cpp
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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/doc/src/snippets/code/src_gui_widgets_qworkspace.cpp b/doc/src/snippets/code/src_gui_widgets_qworkspace.cpp
new file mode 100644
index 0000000000..fd1a43bf13
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qworkspace.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+MainWindow::MainWindow()
+{
+ workspace = new QWorkspace;
+ setCentralWidget(workspace);
+ ...
+}
+//! [0]
diff --git a/doc/src/snippets/code/src_network_access_qftp.cpp b/doc/src/snippets/code/src_network_access_qftp.cpp
new file mode 100644
index 0000000000..621d10de0b
--- /dev/null
+++ b/doc/src/snippets/code/src_network_access_qftp.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QFtp *ftp = new QFtp(parent);
+ftp->connectToHost("ftp.qt.nokia.com");
+ftp->login();
+//! [0]
+
+
+//! [1]
+ftp->connectToHost("ftp.qt.nokia.com"); // id == 1
+ftp->login(); // id == 2
+ftp->cd("qt"); // id == 3
+ftp->get("INSTALL"); // id == 4
+ftp->close(); // id == 5
+//! [1]
+
+
+//! [2]
+start(1)
+stateChanged(HostLookup)
+stateChanged(Connecting)
+stateChanged(Connected)
+finished(1, false)
+
+start(2)
+stateChanged(LoggedIn)
+finished(2, false)
+
+start(3)
+finished(3, false)
+
+start(4)
+dataTransferProgress(0, 3798)
+dataTransferProgress(2896, 3798)
+readyRead()
+dataTransferProgress(3798, 3798)
+readyRead()
+finished(4, false)
+
+start(5)
+stateChanged(Closing)
+stateChanged(Unconnected)
+finished(5, false)
+
+done(false)
+//! [2]
+
+
+//! [3]
+start(1)
+stateChanged(HostLookup)
+stateChanged(Connecting)
+stateChanged(Connected)
+finished(1, false)
+
+start(2)
+finished(2, true)
+
+done(true)
+//! [3]
diff --git a/doc/src/snippets/code/src_network_access_qhttp.cpp b/doc/src/snippets/code/src_network_access_qhttp.cpp
new file mode 100644
index 0000000000..374f1f2121
--- /dev/null
+++ b/doc/src/snippets/code/src_network_access_qhttp.cpp
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+content-type: text/html
+//! [0]
+
+
+//! [1]
+header.setValue("content-type", "text/html");
+QString contentType = header.value("content-type");
+//! [1]
+
+
+//! [2]
+QHttpRequestHeader header("GET", QUrl::toPercentEncoding("/index.html"));
+header.setValue("Host", "qt.nokia.com");
+http->setHost("qt.nokia.com");
+http->request(header);
+//! [2]
+
+
+//! [3]
+http->setHost("qt.nokia.com"); // id == 1
+http->get(QUrl::toPercentEncoding("/index.html")); // id == 2
+//! [3]
+
+
+//! [4]
+requestStarted(1)
+requestFinished(1, false)
+
+requestStarted(2)
+stateChanged(Connecting)
+stateChanged(Sending)
+dataSendProgress(77, 77)
+stateChanged(Reading)
+responseHeaderReceived(responseheader)
+dataReadProgress(5388, 0)
+readyRead(responseheader)
+dataReadProgress(18300, 0)
+readyRead(responseheader)
+stateChanged(Connected)
+requestFinished(2, false)
+
+done(false)
+
+stateChanged(Closing)
+stateChanged(Unconnected)
+//! [4]
+
+
+//! [5]
+http->setHost("www.foo.bar"); // id == 1
+http->get("/index.html"); // id == 2
+http->post("register.html", data); // id == 3
+//! [5]
+
+
+//! [6]
+requestStarted(1)
+requestFinished(1, false)
+
+requestStarted(2)
+stateChanged(HostLookup)
+requestFinished(2, true)
+
+done(true)
+
+stateChanged(Unconnected)
+//! [6]
+
+
+//! [7]
+void Ticker::getTicks()
+{
+ http = new QHttp(this);
+ connect(http, SIGNAL(done(bool)), this, SLOT(showPage()));
+ http->setProxy("proxy.example.com", 3128);
+ http->setHost("ticker.example.com");
+ http->get("/ticks.asp");
+}
+
+void Ticker::showPage()
+{
+ display(http->readAll());
+}
+//! [7]
diff --git a/doc/src/snippets/code/src_network_access_qhttpmultipart.cpp b/doc/src/snippets/code/src_network_access_qhttpmultipart.cpp
new file mode 100644
index 0000000000..9ad2222434
--- /dev/null
+++ b/doc/src/snippets/code/src_network_access_qhttpmultipart.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
+
+QHttpPart textPart;
+textPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"text\""));
+textPart.setBody("my text");
+
+QHttpPart imagePart;
+imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg"));
+imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"image\""));
+QFile *file = new QFile("image.jpg");
+file->open(QIODevice::ReadOnly);
+imagePart.setBodyDevice(file);
+file->setParent(multiPart); // we cannot delete the file now, so delete it with the multiPart
+
+multiPart->append(textPart);
+multiPart->append(imagePart);
+
+QUrl url("http://my.server.tld");
+QNetworkRequest request(url);
+
+QNetworkAccessManager manager;
+QNetworkReply *reply = manager.post(request, multiPart);
+multiPart->setParent(reply); // delete the multiPart with the reply
+// here connect signals etc.
+//! [0]
diff --git a/doc/src/snippets/code/src_network_access_qhttppart.cpp b/doc/src/snippets/code/src_network_access_qhttppart.cpp
new file mode 100644
index 0000000000..0e2dbea43b
--- /dev/null
+++ b/doc/src/snippets/code/src_network_access_qhttppart.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+Content-Type: text/plain
+Content-Disposition: form-data; name="text"
+
+here goes the body
+//! [0]
+
+//! [1]
+QHttpPart textPart;
+textPart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("text/plain"));
+textPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"text\""));
+textPart.setBody("here goes the body");
+//! [1]
+
+//! [2]
+QHttpPart imagePart;
+imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg"));
+imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"image\""));
+imagePart.setRawHeader("Content-ID", "my@content.id"); // add any headers you like via setRawHeader()
+QFile *file = new QFile("image.jpg");
+file->open(QIODevice::ReadOnly);
+imagePart.setBodyDevice(file);
+//! [2]
+
diff --git a/doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp b/doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp
new file mode 100644
index 0000000000..327d58f226
--- /dev/null
+++ b/doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QNetworkAccessManager *manager = new QNetworkAccessManager(this);
+connect(manager, SIGNAL(finished(QNetworkReply*)),
+ this, SLOT(replyFinished(QNetworkReply*)));
+
+manager->get(QNetworkRequest(QUrl("http://qt.nokia.com")));
+//! [0]
+
+
+//! [1]
+QNetworkRequest request;
+request.setUrl(QUrl("http://qt.nokia.com"));
+request.setRawHeader("User-Agent", "MyOwnBrowser 1.0");
+
+QNetworkReply *reply = manager->get(request);
+connect(reply, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
+connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
+ this, SLOT(slotError(QNetworkReply::NetworkError)));
+connect(reply, SIGNAL(sslErrors(QList<QSslError>)),
+ this, SLOT(slotSslErrors(QList<QSslError>)));
+//! [1]
+
+//! [2]
+QNetworkConfigurationManager manager;
+networkAccessManager->setConfiguration(manager.defaultConfiguration());
+//! [2]
+
+//! [3]
+networkAccessManager->setConfiguration(QNetworkConfiguration());
+//! [3]
+
+//! [4]
+networkAccessManager->setNetworkAccessible(QNetworkAccessManager::NotAccessible);
+//! [4]
+
+//! [5]
+networkAccessManager->setNetworkAccessible(QNetworkAccessManager::Accessible);
+//! [5]
+
diff --git a/doc/src/snippets/code/src_network_access_qnetworkdiskcache.cpp b/doc/src/snippets/code/src_network_access_qnetworkdiskcache.cpp
new file mode 100644
index 0000000000..8d775bb20e
--- /dev/null
+++ b/doc/src/snippets/code/src_network_access_qnetworkdiskcache.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QNetworkAccessManager *manager = new QNetworkAccessManager(this);
+QNetworkDiskCache *diskCache = new QNetworkDiskCache(this);
+diskCache->setCacheDirectory("cacheDir");
+manager->setCache(diskCache);
+//! [0]
+
+//! [1]
+// do a normal request (preferred from network, as this is the default)
+QNetworkRequest request(QUrl(QString("http://qt.nokia.com")));
+manager->get(request);
+
+// do a request preferred from cache
+QNetworkRequest request2(QUrl(QString("http://qt.nokia.com")));
+request2.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
+manager->get(request2);
+//! [1]
+
+//! [2]
+void replyFinished(QNetworkReply *reply) {
+ QVariant fromCache = reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute);
+ qDebug() << "page from cache?" << fromCache.toBool();
+}
+//! [2]
diff --git a/doc/src/snippets/code/src_network_access_qnetworkreply.cpp b/doc/src/snippets/code/src_network_access_qnetworkreply.cpp
new file mode 100644
index 0000000000..01f66bc63c
--- /dev/null
+++ b/doc/src/snippets/code/src_network_access_qnetworkreply.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QList<QSslCertificate> cert = QSslCertificate::fromPath(QLatin1String("server-certificate.pem"));
+QSslError error(QSslError::SelfSignedCertificate, cert.at(0));
+QList<QSslError> expectedSslErrors;
+expectedSslErrors.append(error);
+
+QNetworkReply *reply = manager.get(QNetworkRequest(QUrl("https://server.tld/index.html")));
+reply->ignoreSslErrors(expectedSslErrors);
+// here connect signals etc.
+//! [0]
diff --git a/doc/src/snippets/code/src_network_access_qnetworkrequest.cpp b/doc/src/snippets/code/src_network_access_qnetworkrequest.cpp
new file mode 100644
index 0000000000..685eb0c3bc
--- /dev/null
+++ b/doc/src/snippets/code/src_network_access_qnetworkrequest.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+request.setRawHeader("Last-Modified", "Sun, 06 Nov 1994 08:49:37 GMT");
+//! [0]
diff --git a/doc/src/snippets/code/src_network_bearer_qnetworkconfigmanager.cpp b/doc/src/snippets/code/src_network_bearer_qnetworkconfigmanager.cpp
new file mode 100644
index 0000000000..af1a3e84df
--- /dev/null
+++ b/doc/src/snippets/code/src_network_bearer_qnetworkconfigmanager.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QNetworkConfigurationManager mgr;
+QList<QNetworkConfiguration> activeConfigs = mgr.allConfigurations(QNetworkConfiguration::Active)
+if (activeConfigs.count() > 0)
+ Q_ASSERT(mgr.isOnline())
+else
+ Q_ASSERT(!mgr.isOnline())
+//! [0]
diff --git a/doc/src/snippets/code/src_network_kernel_qhostaddress.cpp b/doc/src/snippets/code/src_network_kernel_qhostaddress.cpp
new file mode 100644
index 0000000000..bd203862c9
--- /dev/null
+++ b/doc/src/snippets/code/src_network_kernel_qhostaddress.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+Q_IPV6ADDR addr = hostAddr.toIPv6Address();
+// addr contains 16 unsigned characters
+
+for (int i = 0; i < 16; ++i) {
+ // process addr[i]
+}
+//! [0]
diff --git a/doc/src/snippets/code/src_network_kernel_qhostinfo.cpp b/doc/src/snippets/code/src_network_kernel_qhostinfo.cpp
new file mode 100644
index 0000000000..97d58ef32c
--- /dev/null
+++ b/doc/src/snippets/code/src_network_kernel_qhostinfo.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+// To find the IP address of qt.nokia.com
+QHostInfo::lookupHost("qt.nokia.com",
+ this, SLOT(printResults(QHostInfo)));
+
+// To find the host name for 4.2.2.1
+QHostInfo::lookupHost("4.2.2.1",
+ this, SLOT(printResults(QHostInfo)));
+//! [0]
+
+
+//! [1]
+QHostInfo info = QHostInfo::fromName("qt.nokia.com");
+//! [1]
+
+
+//! [2]
+QHostInfo::lookupHost("www.kde.org",
+ this, SLOT(lookedUp(QHostInfo)));
+//! [2]
+
+
+//! [3]
+void MyWidget::lookedUp(const QHostInfo &host)
+{
+ if (host.error() != QHostInfo::NoError) {
+ qDebug() << "Lookup failed:" << host.errorString();
+ return;
+ }
+
+ foreach (const QHostAddress &address, host.addresses())
+ qDebug() << "Found address:" << address.toString();
+}
+//! [3]
+
+
+//! [4]
+QHostInfo::lookupHost("4.2.2.1",
+ this, SLOT(lookedUp(QHostInfo)));
+//! [4]
+
+
+//! [5]
+QHostInfo info;
+...
+if (!info.addresses().isEmpty()) {
+ QHostAddress address = info.addresses().first();
+ // use the first IP address
+}
+//! [5]
diff --git a/doc/src/snippets/code/src_network_kernel_qnetworkproxy.cpp b/doc/src/snippets/code/src_network_kernel_qnetworkproxy.cpp
new file mode 100644
index 0000000000..393674c6f1
--- /dev/null
+++ b/doc/src/snippets/code/src_network_kernel_qnetworkproxy.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QNetworkProxy proxy;
+proxy.setType(QNetworkProxy::Socks5Proxy);
+proxy.setHostName("proxy.example.com");
+proxy.setPort(1080);
+proxy.setUser("username");
+proxy.setPassword("password");
+QNetworkProxy::setApplicationProxy(proxy);
+//! [0]
+
+
+//! [1]
+serverSocket->setProxy(QNetworkProxy::NoProxy);
+//! [1]
diff --git a/doc/src/snippets/code/src_network_socket_qabstractsocket.cpp b/doc/src/snippets/code/src_network_socket_qabstractsocket.cpp
new file mode 100644
index 0000000000..8021b80733
--- /dev/null
+++ b/doc/src/snippets/code/src_network_socket_qabstractsocket.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+socket->connectToHost("imap", 143);
+if (socket->waitForConnected(1000))
+ qDebug("Connected!");
+//! [0]
+
+
+//! [1]
+socket->disconnectFromHost();
+ if (socket->state() == QAbstractSocket::UnconnectedState ||
+ socket->waitForDisconnected(1000))
+ qDebug("Disconnected!");
+//! [1]
+
+
+//! [2]
+ // This slot is connected to QAbstractSocket::readyRead()
+ void SocketClass::readyReadSlot()
+ {
+ while (!socket.atEnd()) {
+ QByteArray data = socket.read(100);
+ ....
+ }
+ }
+//! [2]
+
+
+//! [3]
+socket->setProxy(QNetworkProxy::NoProxy);
+//! [3]
diff --git a/doc/src/snippets/code/src_network_socket_qlocalsocket_unix.cpp b/doc/src/snippets/code/src_network_socket_qlocalsocket_unix.cpp
new file mode 100644
index 0000000000..9a6e5c2830
--- /dev/null
+++ b/doc/src/snippets/code/src_network_socket_qlocalsocket_unix.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+socket->connectToServer("market");
+if (socket->waitForConnected(1000))
+ qDebug("Connected!");
+//! [0]
+
+
+//! [1]
+socket->disconnectFromServer();
+if (socket->waitForDisconnected(1000))
+ qDebug("Disconnected!");
+//! [1]
diff --git a/doc/src/snippets/code/src_network_socket_qnativesocketengine.cpp b/doc/src/snippets/code/src_network_socket_qnativesocketengine.cpp
new file mode 100644
index 0000000000..85cf4d7a62
--- /dev/null
+++ b/doc/src/snippets/code/src_network_socket_qnativesocketengine.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QNativeSocketEngine socketLayer;
+socketLayer.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol);
+socketLayer.connectToHost(QHostAddress::LocalHost, 22);
+// returns false
+
+socketLayer.waitForWrite();
+socketLayer.connectToHost(QHostAddress::LocalHost, 22);
+// returns true
+//! [0]
+
+
+//! [1]
+QNativeSocketEngine socketLayer;
+socketLayer.bind(QHostAddress::Any, 4000);
+socketLayer.listen();
+if (socketLayer.waitForRead()) {
+ int clientSocket = socketLayer.accept();
+ // a client is connected
+}
+//! [1]
diff --git a/doc/src/snippets/code/src_network_socket_qtcpserver.cpp b/doc/src/snippets/code/src_network_socket_qtcpserver.cpp
new file mode 100644
index 0000000000..6dca8b6054
--- /dev/null
+++ b/doc/src/snippets/code/src_network_socket_qtcpserver.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+server->setProxy(QNetworkProxy::NoProxy);
+//! [0]
diff --git a/doc/src/snippets/code/src_network_socket_qudpsocket.cpp b/doc/src/snippets/code/src_network_socket_qudpsocket.cpp
new file mode 100644
index 0000000000..47f00b6b45
--- /dev/null
+++ b/doc/src/snippets/code/src_network_socket_qudpsocket.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 Server::initSocket()
+{
+ udpSocket = new QUdpSocket(this);
+ udpSocket->bind(QHostAddress::LocalHost, 7755);
+
+ connect(udpSocket, SIGNAL(readyRead()),
+ this, SLOT(readPendingDatagrams()));
+}
+
+void Server::readPendingDatagrams()
+{
+ while (udpSocket->hasPendingDatagrams()) {
+ QByteArray datagram;
+ datagram.resize(udpSocket->pendingDatagramSize());
+ QHostAddress sender;
+ quint16 senderPort;
+
+ udpSocket->readDatagram(datagram.data(), datagram.size(),
+ &sender, &senderPort);
+
+ processTheDatagram(datagram);
+ }
+}
+//! [0]
diff --git a/doc/src/snippets/code/src_network_ssl_qsslcertificate.cpp b/doc/src/snippets/code/src_network_ssl_qsslcertificate.cpp
new file mode 100644
index 0000000000..679f41e1b4
--- /dev/null
+++ b/doc/src/snippets/code/src_network_ssl_qsslcertificate.cpp
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+foreach (const QSslCertificate &cert, QSslCertificate::fromPath("C:/ssl/certificate.*.pem", QSsl::Pem,
+ QRegExp::Wildcard)) {
+ qDebug() << cert.issuerInfo(QSslCertificate::Organization);
+}
+//! [0]
diff --git a/doc/src/snippets/code/src_network_ssl_qsslconfiguration.cpp b/doc/src/snippets/code/src_network_ssl_qsslconfiguration.cpp
new file mode 100644
index 0000000000..7e078d3607
--- /dev/null
+++ b/doc/src/snippets/code/src_network_ssl_qsslconfiguration.cpp
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QSslConfiguration config = sslSocket.sslConfiguration();
+config.setProtocol(QSsl::TlsV1);
+sslSocket.setSslConfiguration(config);
+//! [0]
diff --git a/doc/src/snippets/code/src_network_ssl_qsslsocket.cpp b/doc/src/snippets/code/src_network_ssl_qsslsocket.cpp
new file mode 100644
index 0000000000..d415bae034
--- /dev/null
+++ b/doc/src/snippets/code/src_network_ssl_qsslsocket.cpp
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QSslSocket *socket = new QSslSocket(this);
+connect(socket, SIGNAL(encrypted()), this, SLOT(ready()));
+
+socket->connectToHostEncrypted("imap.example.com", 993);
+//! [0]
+
+
+//! [1]
+void SslServer::incomingConnection(int socketDescriptor)
+{
+ QSslSocket *serverSocket = new QSslSocket;
+ if (serverSocket->setSocketDescriptor(socketDescriptor)) {
+ connect(serverSocket, SIGNAL(encrypted()), this, SLOT(ready()));
+ serverSocket->startServerEncryption();
+ } else {
+ delete serverSocket;
+ }
+}
+//! [1]
+
+
+//! [2]
+QSslSocket socket;
+socket.connectToHostEncrypted("http.example.com", 443);
+if (!socket.waitForEncrypted()) {
+ qDebug() << socket.errorString();
+ return false;
+}
+
+socket.write("GET / HTTP/1.0\r\n\r\n");
+while (socket.waitForReadyRead())
+ qDebug() << socket.readAll().data();
+//! [2]
+
+
+//! [3]
+QSslSocket socket;
+connect(&socket, SIGNAL(encrypted()), receiver, SLOT(socketEncrypted()));
+
+socket.connectToHostEncrypted("imap", 993);
+socket->write("1 CAPABILITY\r\n");
+//! [3]
+
+
+//! [4]
+QSslSocket socket;
+socket.setCiphers("DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:AES256-SHA");
+//! [4]
+
+
+//! [5]
+socket->connectToHostEncrypted("imap", 993);
+if (socket->waitForEncrypted(1000))
+ qDebug("Encrypted!");
+//! [5]
+
+//! [6]
+QList<QSslCertificate> cert = QSslCertificate::fromPath(QLatin1String("server-certificate.pem"));
+QSslError error(QSslError::SelfSignedCertificate, cert.at(0));
+QList<QSslError> expectedSslErrors;
+expectedSslErrors.append(error);
+
+QSslSocket socket;
+socket.ignoreSslErrors(expectedSslErrors);
+socket.connectToHostEncrypted("server.tld", 443);
+//! [6]
diff --git a/doc/src/snippets/code/src_opengl_qgl.cpp b/doc/src/snippets/code/src_opengl_qgl.cpp
new file mode 100644
index 0000000000..6ef049ac90
--- /dev/null
+++ b/doc/src/snippets/code/src_opengl_qgl.cpp
@@ -0,0 +1,172 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QGLFormat fmt;
+fmt.setAlpha(true);
+fmt.setStereo(true);
+QGLFormat::setDefaultFormat(fmt);
+//! [0]
+
+
+//! [1]
+QGLFormat fmt;
+fmt.setDoubleBuffer(false); // single buffer
+fmt.setDirectRendering(false); // software rendering
+MyGLWidget* myWidget = new MyGLWidget(fmt, ...);
+//! [1]
+
+
+//! [2]
+QGLFormat fmt;
+fmt.setOverlay(true);
+fmt.setStereo(true);
+MyGLWidget* myWidget = new MyGLWidget(fmt, ...);
+if (!myWidget->format().stereo()) {
+ // ok, goggles off
+ if (!myWidget->format().hasOverlay()) {
+ qFatal("Cool hardware required");
+ }
+}
+//! [2]
+
+
+//! [3]
+// The rendering in MyGLWidget depends on using
+// stencil buffer and alpha channel
+MyGLWidget::MyGLWidget(QWidget* parent)
+ : QGLWidget(QGLFormat(QGL::StencilBuffer | QGL::AlphaChannel), parent)
+{
+ if (!format().stencil())
+ qWarning("Could not get stencil buffer; results will be suboptimal");
+ if (!format().alpha())
+ qWarning("Could not get alpha channel; results will be suboptimal");
+ ...
+}
+//! [3]
+
+
+//! [4]
+QApplication a(argc, argv);
+QGLFormat f;
+f.setDoubleBuffer(false);
+QGLFormat::setDefaultFormat(f);
+//! [4]
+
+
+//! [5]
+QGLFormat f = QGLFormat::defaultOverlayFormat();
+f.setDoubleBuffer(true);
+QGLFormat::setDefaultOverlayFormat(f);
+//! [5]
+
+
+//! [6]
+// ...continued from above
+MyGLWidget* myWidget = new MyGLWidget(QGLFormat(QGL::HasOverlay), ...);
+if (myWidget->format().hasOverlay()) {
+ // Yes, we got an overlay, let's check _its_ format:
+ QGLContext* olContext = myWidget->overlayContext();
+ if (olContext->format().doubleBuffer())
+ ; // yes, we got a double buffered overlay
+ else
+ ; // no, only single buffered overlays are available
+}
+//! [6]
+
+
+//! [7]
+QGLContext *cx;
+// ...
+QGLFormat f;
+f.setStereo(true);
+cx->setFormat(f);
+if (!cx->create())
+ exit(); // no OpenGL support, or cannot render on the specified paintdevice
+if (!cx->format().stereo())
+ exit(); // could not create stereo context
+//! [7]
+
+
+//! [8]
+class MyGLDrawer : public QGLWidget
+{
+ Q_OBJECT // must include this if you use Qt signals/slots
+
+public:
+ MyGLDrawer(QWidget *parent)
+ : QGLWidget(parent) {}
+
+protected:
+
+ void initializeGL()
+ {
+ // Set up the rendering context, define display lists etc.:
+ ...
+ glClearColor(0.0, 0.0, 0.0, 0.0);
+ glEnable(GL_DEPTH_TEST);
+ ...
+ }
+
+ void resizeGL(int w, int h)
+ {
+ // setup viewport, projection etc.:
+ glViewport(0, 0, (GLint)w, (GLint)h);
+ ...
+ glFrustum(...);
+ ...
+ }
+
+ void paintGL()
+ {
+ // draw the scene:
+ ...
+ glRotatef(...);
+ glMaterialfv(...);
+ glBegin(GL_QUADS);
+ glVertex3f(...);
+ glVertex3f(...);
+ ...
+ glEnd();
+ ...
+ }
+
+};
+//! [8]
diff --git a/doc/src/snippets/code/src_opengl_qglcolormap.cpp b/doc/src/snippets/code/src_opengl_qglcolormap.cpp
new file mode 100644
index 0000000000..3bd780ba45
--- /dev/null
+++ b/doc/src/snippets/code/src_opengl_qglcolormap.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+#include <QApplication>
+#include <QGLColormap>
+
+int main()
+{
+ QApplication app(argc, argv);
+
+ MySuperGLWidget widget; // a QGLWidget in color-index mode
+ QGLColormap colormap;
+
+ // This will fill the colormap with colors ranging from
+ // black to white.
+ for (int i = 0; i < colormap.size(); i++)
+ colormap.setEntry(i, qRgb(i, i, i));
+
+ widget.setColormap(colormap);
+ widget.show();
+ return app.exec();
+}
+//! [0]
diff --git a/doc/src/snippets/code/src_opengl_qglpixelbuffer.cpp b/doc/src/snippets/code/src_opengl_qglpixelbuffer.cpp
new file mode 100644
index 0000000000..6825ebfab8
--- /dev/null
+++ b/doc/src/snippets/code/src_opengl_qglpixelbuffer.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QGLPixelBuffer pbuffer(...);
+...
+pbuffer.makeCurrent();
+GLuint dynamicTexture = pbuffer.generateDynamicTexture();
+pbuffer.bindToDynamicTexture(dynamicTexture);
+...
+pbuffer.releaseFromDynamicTexture();
+//! [0]
+
+
+//! [1]
+QGLPixelBuffer pbuffer(...);
+...
+pbuffer.makeCurrent();
+GLuint dynamicTexture = pbuffer.generateDynamicTexture();
+...
+pbuffer.updateDynamicTexture(dynamicTexture);
+//! [1]
diff --git a/doc/src/snippets/code/src_opengl_qglshaderprogram.cpp b/doc/src/snippets/code/src_opengl_qglshaderprogram.cpp
new file mode 100644
index 0000000000..aa5225a5e8
--- /dev/null
+++ b/doc/src/snippets/code/src_opengl_qglshaderprogram.cpp
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QGLShader shader(QGLShader::Vertex);
+shader.compileSourceCode(code);
+
+QGLShaderProgram program(context);
+program.addShader(shader);
+program.link();
+
+program.bind();
+//! [0]
+
+//! [1]
+program.addShaderFromSourceCode(QGLShader::Vertex,
+ "attribute highp vec4 vertex;\n"
+ "attribute mediump mat4 matrix;\n"
+ "void main(void)\n"
+ "{\n"
+ " gl_Position = matrix * vertex;\n"
+ "}");
+program.addShaderFromSourceCode(QGLShader::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.attributeLocation("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/doc/src/snippets/code/src_qdbus_qdbusabstractinterface.cpp b/doc/src/snippets/code/src_qdbus_qdbusabstractinterface.cpp
new file mode 100644
index 0000000000..ba1b902a7a
--- /dev/null
+++ b/doc/src/snippets/code/src_qdbus_qdbusabstractinterface.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QString value = retrieveValue();
+QDBusMessage reply;
+
+QDBusReply<int> api = interface->call(QLatin1String("GetAPIVersion"));
+if (api >= 14)
+ reply = interface->call(QLatin1String("ProcessWorkUnicode"), value);
+else
+ reply = interface->call(QLatin1String("ProcessWork"), QLatin1String("UTF-8"), value.toUtf8());
+//! [0]
+
+//! [1]
+QString value = retrieveValue();
+QDBusPendingCall pcall = interface->asyncCall(QLatin1String("Process"), value);
+
+QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall, this);
+
+QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
+ this, SLOT(callFinishedSlot(QDBusPendingCallWatcher*)));
+//! [1]
diff --git a/doc/src/snippets/code/src_qdbus_qdbusargument.cpp b/doc/src/snippets/code/src_qdbus_qdbusargument.cpp
new file mode 100644
index 0000000000..125dc332a9
--- /dev/null
+++ b/doc/src/snippets/code/src_qdbus_qdbusargument.cpp
@@ -0,0 +1,191 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+struct MyStructure
+{
+ int count;
+ QString name;
+};
+Q_DECLARE_METATYPE(MyStructure)
+
+// Marshall the MyStructure data into a D-Bus argument
+QDBusArgument &operator<<(QDBusArgument &argument, const MyStructure &mystruct)
+{
+ argument.beginStructure();
+ argument << mystruct.count << mystruct.name;
+ argument.endStructure();
+ return argument;
+}
+
+// Retrieve the MyStructure data from the D-Bus argument
+const QDBusArgument &operator>>(const QDBusArgument &argument, MyStructure &mystruct)
+{
+ argument.beginStructure();
+ argument >> mystruct.count >> mystruct.name;
+ argument.endStructure();
+ return argument;
+}
+//! [0]
+
+
+//! [1]
+qDBusRegisterMetaType<MyStructure>();
+//! [1]
+
+
+//! [2]
+MyType item = qdbus_cast<Type>(argument);
+//! [2]
+
+
+//! [3]
+MyType item;
+argument >> item;
+//! [3]
+
+
+//! [4]
+QDBusArgument &operator<<(QDBusArgument &argument, const MyStructure &mystruct)
+{
+ argument.beginStructure();
+ argument << mystruct.member1 << mystruct.member2 << ... ;
+ argument.endStructure();
+ return argument;
+}
+//! [4]
+
+
+//! [5]
+QDBusArgument &operator<<(QDBusArgument &argument, const MyStructure &mystruct)
+{
+ argument.beginStructure();
+ argument << mystruct.member1 << mystruct.member2;
+
+ argument.beginStructure();
+ argument << mystruct.member3.subMember1 << mystruct.member3.subMember2;
+ argument.endStructure();
+
+ argument << mystruct.member4;
+ argument.endStructure();
+ return argument;
+}
+//! [5]
+
+
+//! [6]
+// append an array of MyElement types
+QDBusArgument &operator<<(QDBusArgument &argument, const MyArray &myarray)
+{
+ argument.beginArray( qMetaTypeId<MyElement>() );
+ for ( int i = 0; i < myarray.length; ++i )
+ argument << myarray.elements[i];
+ argument.endArray();
+ return argument;
+}
+//! [6]
+
+
+//! [7]
+// append a dictionary that associates ints to MyValue types
+QDBusArgument &operator<<(QDBusArgument &argument, const MyDictionary &mydict)
+{
+ argument.beginMap( QVariant::Int, qMetaTypeId<MyValue>() );
+ for ( int i = 0; i < mydict.length; ++i ) {
+ argument.beginMapEntry();
+ argument << mydict.data[i].key << mydict.data[i].value;
+ argument.endMapEntry();
+ }
+ argument.endMap();
+ return argument;
+}
+//! [7]
+
+
+//! [8]
+const QDBusArgument &operator>>(const QDBusArgument &argument, MyStructure &mystruct)
+{
+ argument.beginStructure()
+ argument >> mystruct.member1 >> mystruct.member2 >> mystruct.member3 >> ...;
+ argument.endStructure();
+ return argument;
+}
+//! [8]
+
+
+//! [9]
+// extract a MyArray array of MyElement elements
+const QDBusArgument &operator>>(const QDBusArgument &argument, MyArray &myarray)
+{
+ argument.beginArray();
+ myarray.clear();
+
+ while ( !argument.atEnd() ) {
+ MyElement element;
+ argument >> element;
+ myarray.append( element );
+ }
+
+ argument.endArray();
+ return argument;
+}
+//! [9]
+
+
+//! [10]
+// extract a MyDictionary map that associates ints to MyValue elements
+const QDBusArgument &operator>>(const QDBusArgument &argument, MyDictionary &mydict)
+{
+ argument.beginMap();
+ mydict.clear();
+
+ while ( !argMap.atEnd() ) {
+ int key;
+ MyValue value;
+ argument.beginMapEntry();
+ argument >> key >> value;
+ argument.endMapEntry();
+ mydict.append( key, value );
+ }
+
+ argument.endMap();
+ return argument;
+}
+//! [10]
diff --git a/doc/src/snippets/code/src_qdbus_qdbuscontext.cpp b/doc/src/snippets/code/src_qdbus_qdbuscontext.cpp
new file mode 100644
index 0000000000..312b8bb545
--- /dev/null
+++ b/doc/src/snippets/code/src_qdbus_qdbuscontext.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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 MyObject: public QObject,
+ protected QDBusContext
+{
+ Q_OBJECT
+ QDBusConnection conn;
+ QDBusMessage msg;
+
+...
+
+protected slots:
+ void process();
+public slots:
+ void methodWithError();
+ QString methodWithDelayedReply();
+};
+
+void MyObject::methodWithError()
+{
+ sendErrorReply(QDBusError::NotSupported,
+ "The method call 'methodWithError()' is not supported");
+}
+
+QString MyObject::methodWithDelayedReply()
+{
+ conn = connection();
+ msg = message();
+ setDelayedReply(true);
+ QMetaObject::invokeMethod(this, "process", Qt::QueuedConnection);
+ return QString();
+}
+//! [0]
diff --git a/doc/src/snippets/code/src_qdbus_qdbusinterface.cpp b/doc/src/snippets/code/src_qdbus_qdbusinterface.cpp
new file mode 100644
index 0000000000..425a736d28
--- /dev/null
+++ b/doc/src/snippets/code/src_qdbus_qdbusinterface.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QDBusInterface remoteApp( "com.example.Calculator", "/Calculator/Operations",
+ "org.mathematics.RPNCalculator" );
+remoteApp.call( "PushOperand", 2 );
+remoteApp.call( "PushOperand", 2 );
+remoteApp.call( "ExecuteOperation", "+" );
+QDBusReply<int> reply = remoteApp.call( "PopOperand" );
+
+if ( reply.isValid() )
+ printf( "%d", reply.value() ); // prints 4
+//! [0]
diff --git a/doc/src/snippets/code/src_qdbus_qdbusmetatype.cpp b/doc/src/snippets/code/src_qdbus_qdbusmetatype.cpp
new file mode 100644
index 0000000000..3774c10643
--- /dev/null
+++ b/doc/src/snippets/code/src_qdbus_qdbusmetatype.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+#include <QDBusMetaType>
+qDBusRegisterMetaType<MyClass>();
+//! [0]
diff --git a/doc/src/snippets/code/src_qdbus_qdbusreply.cpp b/doc/src/snippets/code/src_qdbus_qdbusreply.cpp
new file mode 100644
index 0000000000..2e6b33a6bd
--- /dev/null
+++ b/doc/src/snippets/code/src_qdbus_qdbusreply.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QDBusReply<QString> reply = interface->call("RemoteMethod");
+if (reply.isValid())
+ // use the returned value
+ useValue(reply.value());
+else
+ // call failed. Show an error condition.
+ showError(reply.error());
+//! [0]
+
+
+//! [1]
+QString reply = interface->call("RemoteMethod");
+//! [1]
diff --git a/doc/src/snippets/code/src_qtestlib_qtestcase.cpp b/doc/src/snippets/code/src_qtestlib_qtestcase.cpp
new file mode 100644
index 0000000000..986026f089
--- /dev/null
+++ b/doc/src/snippets/code/src_qtestlib_qtestcase.cpp
@@ -0,0 +1,250 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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$
+**
+****************************************************************************/
+
+
+void wrapInFunction()
+{
+
+//! [0]
+QVERIFY(1 + 1 == 2);
+//! [0]
+
+
+//! [1]
+QVERIFY2(1 + 1 == 2, "A breach in basic arithmetic occurred.");
+//! [1]
+
+
+//! [2]
+QCOMPARE(QString("hello").toUpper(), QString("HELLO"));
+//! [2]
+
+
+//! [3]
+void TestQString::toInt_data()
+{
+ QTest::addColumn<QString>("aString");
+ QTest::addColumn<int>("expected");
+
+ QTest::newRow("positive value") << "42" << 42;
+ QTest::newRow("negative value") << "-42" << -42;
+ QTest::newRow("zero") << "0" << 0;
+}
+//! [3]
+
+
+//! [4]
+void TestQString::toInt()
+{
+ QFETCH(QString, aString);
+ QFETCH(int, expected);
+
+ QCOMPARE(aString.toInt(), expected);
+}
+//! [4]
+
+
+//! [5]
+if (sizeof(int) != 4)
+ QFAIL("This test has not been ported to this platform yet.");
+//! [5]
+
+
+//! [6]
+QFETCH(QString, myString);
+QCOMPARE(QString("hello").toUpper(), myString);
+//! [6]
+
+
+//! [7]
+QTEST(QString("hello").toUpper(), "myString");
+//! [7]
+
+
+//! [8]
+if (!QSqlDatabase::drivers().contains("SQLITE"))
+ QSKIP("This test requires the SQLITE database driver", SkipAll);
+//! [8]
+
+
+//! [9]
+QEXPECT_FAIL("", "Will fix in the next release", Continue);
+QCOMPARE(i, 42);
+QCOMPARE(j, 43);
+//! [9]
+
+
+//! [10]
+QEXPECT_FAIL("data27", "Oh my, this is soooo broken", Abort);
+QCOMPARE(i, 42);
+//! [10]
+
+
+//! [11]
+class TestQString: public QObject { ... };
+QTEST_MAIN(TestQString)
+//! [11]
+
+
+//! [12]
+#ifdef Q_WS_X11
+ QTEST_MAIN(MyX11Test)
+#else
+ // do nothing on non-X11 platforms
+ QTEST_NOOP_MAIN
+#endif
+//! [12]
+
+
+//! [13]
+QTest::keyClick(myWidget, 'a');
+//! [13]
+
+
+//! [14]
+QTest::keyClick(myWidget, Qt::Key_Escape);
+
+QTest::keyClick(myWidget, Qt::Key_Escape, Qt::ShiftModifier, 200);
+//! [14]
+
+
+//! [15]
+QTest::keyClicks(myWidget, "hello world");
+//! [15]
+
+
+//! [16]
+namespace QTest {
+ template<>
+ char *toString(const MyPoint &point)
+ {
+ QByteArray ba = "MyPoint(";
+ ba += QByteArray::number(point.x()) + ", " + QByteArray::number(point.y());
+ ba += ")";
+ return qstrdup(ba.data());
+ }
+}
+//! [16]
+
+
+//! [17]
+int i = 0;
+while (myNetworkServerNotResponding() && i++ < 50)
+ QTest::qWait(250);
+//! [17]
+
+
+//! [18]
+MyFirstTestObject test1;
+QTest::qExec(&test1);
+
+MySecondTestObject test2;
+QTest::qExec(&test2);
+//! [18]
+
+
+//! [19]
+QDir dir;
+
+QTest::ignoreMessage(QtWarningMsg, "QDir::mkdir: Empty or null file name(s)");
+dir.mkdir("");
+//! [19]
+
+
+//! [20]
+void myTestFunction_data()
+{
+ QTest::addColumn<QString>("aString");
+ QTest::newRow("just hello") << QString("hello");
+ QTest::newRow("a null string") << QString();
+}
+//! [20]
+
+
+//! [21]
+void myTestFunction_data() {
+ QTest::addColumn<int>("intval");
+ QTest::addColumn<QString>("str");
+ QTest::addColumn<double>("dbl");
+
+ QTest::newRow("row1") << 1 << "hello" << 1.5;
+}
+//! [21]
+
+
+//! [22]
+void MyTestClass::cleanup()
+{
+ if (qstrcmp(currentTestFunction(), "myDatabaseTest") == 0) {
+ // clean up all database connections
+ closeAllDatabases();
+ }
+}
+//! [22]
+
+
+//! [23]
+QTest::qSleep(250);
+//! [23]
+
+//! [24]
+QWidget widget;
+widget.show();
+QTest::qWaitForWindowShown(&widget);
+//! [24]
+
+//! [25]
+QWidget widget;
+
+QTest::touchEvent(&widget)
+ .press(0, QPoint(10, 10));
+QTest::touchEvent(&widget)
+ .stationary(0)
+ .press(1, QPoint(40, 10));
+QTest::touchEvent(&widget)
+ .move(0, QPoint(12, 12))
+ .move(1, QPoint(45, 5));
+QTest::touchEvent(&widget)
+ .release(0)
+ .release(1);
+//! [25]
+
+}
+
diff --git a/doc/src/snippets/code/src_sql_kernel_qsqldatabase.cpp b/doc/src/snippets/code/src_sql_kernel_qsqldatabase.cpp
new file mode 100644
index 0000000000..50ea67c104
--- /dev/null
+++ b/doc/src/snippets/code/src_sql_kernel_qsqldatabase.cpp
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+// WRONG
+QSqlDatabase db = QSqlDatabase::database("sales");
+QSqlQuery query("SELECT NAME, DOB FROM EMPLOYEES", db);
+QSqlDatabase::removeDatabase("sales"); // will output a warning
+
+// "db" is now a dangling invalid database connection,
+// "query" contains an invalid result set
+//! [0]
+
+
+//! [1]
+{
+ QSqlDatabase db = QSqlDatabase::database("sales");
+ QSqlQuery query("SELECT NAME, DOB FROM EMPLOYEES", db);
+}
+// Both "db" and "query" are destroyed because they are out of scope
+QSqlDatabase::removeDatabase("sales"); // correct
+//! [1]
+
+
+//! [2]
+QSqlDatabase::registerSqlDriver("MYDRIVER",
+ new QSqlDriverCreator<MyDatabaseDriver>);
+QSqlDatabase db = QSqlDatabase::addDatabase("MYDRIVER");
+//! [2]
+
+
+//! [3]
+...
+db = QSqlDatabase::addDatabase("QODBC");
+db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=myaccessfile.mdb");
+if (db.open()) {
+ // success!
+}
+...
+//! [3]
+
+
+//! [4]
+...
+// MySQL connection
+db.setConnectOptions("CLIENT_SSL=1;CLIENT_IGNORE_SPACE=1"); // use an SSL connection to the server
+if (!db.open()) {
+ db.setConnectOptions(); // clears the connect option string
+ ...
+}
+...
+// PostgreSQL connection
+db.setConnectOptions("requiressl=1"); // enable PostgreSQL SSL connections
+if (!db.open()) {
+ db.setConnectOptions(); // clear options
+ ...
+}
+...
+// ODBC connection
+db.setConnectOptions("SQL_ATTR_ACCESS_MODE=SQL_MODE_READ_ONLY;SQL_ATTR_TRACE=SQL_OPT_TRACE_ON"); // set ODBC options
+if (!db.open()) {
+ db.setConnectOptions(); // don't try to set this option
+ ...
+}
+//! [4]
+
+
+//! [5]
+#include "qtdir/src/sql/drivers/psql/qsql_psql.cpp"
+//! [5]
+
+
+//! [6]
+PGconn *con = PQconnectdb("host=server user=bart password=simpson dbname=springfield");
+QPSQLDriver *drv = new QPSQLDriver(con);
+QSqlDatabase db = QSqlDatabase::addDatabase(drv); // becomes the new default connection
+QSqlQuery query;
+query.exec("SELECT NAME, ID FROM STAFF");
+...
+//! [6]
+
+
+//! [7]
+unix:LIBS += -lpq
+win32:LIBS += libpqdll.lib
+//! [7]
+
+
+//! [8]
+QSqlDatabase db;
+qDebug() << db.isValid(); // Returns false
+
+db = QSqlDatabase::database("sales");
+qDebug() << db.isValid(); // Returns true if "sales" connection exists
+
+QSqlDatabase::removeDatabase("sales");
+qDebug() << db.isValid(); // Returns false
+//! [8]
diff --git a/doc/src/snippets/code/src_sql_kernel_qsqldriver.cpp b/doc/src/snippets/code/src_sql_kernel_qsqldriver.cpp
new file mode 100644
index 0000000000..d49b6e0e19
--- /dev/null
+++ b/doc/src/snippets/code/src_sql_kernel_qsqldriver.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QSqlDatabase db = ...;
+QVariant v = db.driver()->handle();
+if (v.isValid() && qstrcmp(v.typeName(), "sqlite3*")==0) {
+ // v.data() returns a pointer to the handle
+ sqlite3 *handle = *static_cast<sqlite3 **>(v.data());
+ if (handle != 0) { // check that it is not NULL
+ ...
+ }
+}
+//! [0]
+
+
+//! [1]
+if (v.typeName() == "PGconn*") {
+ PGconn *handle = *static_cast<PGconn **>(v.data());
+ if (handle != 0) ...
+}
+
+if (v.typeName() == "MYSQL*") {
+ MYSQL *handle = *static_cast<MYSQL **>(v.data());
+ if (handle != 0) ...
+}
+//! [1]
diff --git a/doc/src/snippets/code/src_sql_kernel_qsqlerror.cpp b/doc/src/snippets/code/src_sql_kernel_qsqlerror.cpp
new file mode 100644
index 0000000000..cb45abf336
--- /dev/null
+++ b/doc/src/snippets/code/src_sql_kernel_qsqlerror.cpp
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QSqlQueryModel model;
+model.setQuery("select * from myTable");
+if (model.lastError().isValid())
+ qDebug() << model.lastError();
+//! [0]
diff --git a/doc/src/snippets/code/src_sql_kernel_qsqlindex.cpp b/doc/src/snippets/code/src_sql_kernel_qsqlindex.cpp
new file mode 100644
index 0000000000..bf04f2befb
--- /dev/null
+++ b/doc/src/snippets/code/src_sql_kernel_qsqlindex.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QStringList list = myIndex.toStringList();
+QStringList::Iterator it = list.begin();
+while(it != list.end()) {
+ myProcessing(*it);
+ ++it;
+}
+//! [0]
diff --git a/doc/src/snippets/code/src_sql_kernel_qsqlquery.cpp b/doc/src/snippets/code/src_sql_kernel_qsqlquery.cpp
new file mode 100644
index 0000000000..c739a9f499
--- /dev/null
+++ b/doc/src/snippets/code/src_sql_kernel_qsqlquery.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+SELECT forename, surname FROM people;
+//! [0]
+
+
+//! [1]
+QSqlQuery q("select * from employees");
+QSqlRecord rec = q.record();
+
+qDebug() << "Number of columns: " << rec.count();
+
+int nameCol = rec.indexOf("name"); // index of the field "name"
+while (q.next())
+ qDebug() << q.value(nameCol).toString(); // output all names
+//! [1]
+
+
+//! [2]
+QSqlQuery q;
+q.prepare("insert into myTable values (?, ?)");
+
+QVariantList ints;
+ints << 1 << 2 << 3 << 4;
+q.addBindValue(ints);
+
+QVariantList names;
+names << "Harald" << "Boris" << "Trond" << QVariant(QVariant::String);
+q.addBindValue(names);
+
+if (!q.execBatch())
+ qDebug() << q.lastError();
+//! [2]
+
+
+//! [3]
+1 Harald
+2 Boris
+3 Trond
+4 NULL
+//! [3]
diff --git a/doc/src/snippets/code/src_sql_kernel_qsqlresult.cpp b/doc/src/snippets/code/src_sql_kernel_qsqlresult.cpp
new file mode 100644
index 0000000000..96bb9fbbae
--- /dev/null
+++ b/doc/src/snippets/code/src_sql_kernel_qsqlresult.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QSqlQuery q;
+q.prepare("insert into test (i1, i2, s) values (?, ?, ?)");
+
+QVariantList col1;
+QVariantList col2;
+QVariantList col3;
+
+col1 << 1 << 3;
+col2 << 2 << 4;
+col3 << "hello" << "world";
+
+q.bindValue(0, col1);
+q.bindValue(1, col2);
+q.bindValue(2, col3);
+
+if (!q.execBatch())
+ qDebug() << q.lastError();
+//! [0]
+
+
+//! [1]
+QSqlQuery query = ...
+QVariant v = query.result()->handle();
+if (v.isValid() && qstrcmp(v.typeName(), "sqlite3_stmt*")) {
+ // v.data() returns a pointer to the handle
+ sqlite3_stmt *handle = *static_cast<sqlite3_stmt **>(v.data());
+ if (handle != 0) { // check that it is not NULL
+ ...
+ }
+}
+//! [1]
+
+
+//! [2]
+if (v.typeName() == "PGresult*") {
+ PGresult *handle = *static_cast<PGresult **>(v.data());
+ if (handle != 0) ...
+}
+
+if (v.typeName() == "MYSQL_STMT*") {
+ MYSQL_STMT *handle = *static_cast<MYSQL_STMT **>(v.data());
+ if (handle != 0) ...
+}
+//! [2]
diff --git a/doc/src/snippets/code/src_sql_models_qsqlquerymodel.cpp b/doc/src/snippets/code/src_sql_models_qsqlquerymodel.cpp
new file mode 100644
index 0000000000..0d85803dc0
--- /dev/null
+++ b/doc/src/snippets/code/src_sql_models_qsqlquerymodel.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+while (myModel->canFetchMore())
+ myModel->fetchMore();
+//! [0]
+
+
+//! [1]
+QSqlQueryModel model;
+model.setQuery("select * from MyTable");
+if (model.lastError().isValid())
+ qDebug() << model.lastError();
+//! [1]
diff --git a/doc/src/snippets/code/src_xml_dom_qdom.cpp b/doc/src/snippets/code/src_xml_dom_qdom.cpp
new file mode 100644
index 0000000000..e49bcf40ee
--- /dev/null
+++ b/doc/src/snippets/code/src_xml_dom_qdom.cpp
@@ -0,0 +1,218 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+QDomDocument doc;
+QDomImplementation impl;
+
+// This will create the element, but the resulting XML document will
+// be invalid, because '~' is not a valid character in a tag name.
+impl.setInvalidDataPolicy(QDomImplementation::AcceptInvalidData);
+QDomElement elt1 = doc.createElement("foo~bar");
+
+// This will create an element with the tag name "foobar".
+impl.setInvalidDataPolicy(QDomImplementation::DropInvalidData);
+QDomElement elt2 = doc.createElement("foo~bar");
+
+// This will create a null element.
+impl.setInvalidDataPolicy(QDomImplementation::ReturnNullNode);
+QDomElement elt3 = doc.createElement("foo~bar");
+//! [0]
+
+
+//! [1]
+QDomDocument d;
+d.setContent(someXML);
+QDomNode n = d.firstChild();
+while (!n.isNull()) {
+ if (n.isElement()) {
+ QDomElement e = n.toElement();
+ cout << "Element name: " << e.tagName() << endl;
+ break;
+ }
+ n = n.nextSibling();
+}
+//! [1]
+
+
+//! [2]
+QDomDocument document;
+QDomElement element1 = document.documentElement();
+QDomElement element2 = element1;
+//! [2]
+
+
+//! [3]
+QDomElement element3 = document.createElement("MyElement");
+QDomElement element4 = document.createElement("MyElement");
+//! [3]
+
+
+//! [4]
+<body>
+<h1>Heading</h1>
+<p>Hello <b>you</b></p>
+</body>
+//! [4]
+
+
+//! [5]
+<h1>Heading</h1>
+<p>The text...</p>
+<h2>Next heading</h2>
+//! [5]
+
+
+//! [6]
+<h1>Heading</h1>
+<p>The text...</p>
+<h2>Next heading</h2>
+//! [6]
+
+
+//! [7]
+<link href="http://qt.nokia.com" color="red" />
+//! [7]
+
+
+//! [8]
+QDomElement e = //...
+//...
+QDomAttr a = e.attributeNode("href");
+cout << a.value() << endl; // prints "http://qt.nokia.com"
+a.setValue("http://qt.nokia.com/doc"); // change the node's attribute
+QDomAttr a2 = e.attributeNode("href");
+cout << a2.value() << endl; // prints "http://qt.nokia.com/doc"
+//! [8]
+
+
+//! [9]
+QDomElement e = //...
+//...
+QString s = e.text()
+//! [9]
+
+
+//! [10]
+QString text;
+QDomElement element = doc.documentElement();
+for(QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling())
+{
+ QDomText t = n.toText();
+ if (!t.isNull())
+ text += t.data();
+}
+//! [10]
+
+
+//! [11]
+QDomDocument doc = // ...
+QDomElement root = doc.firstChildElement("database");
+QDomElement elt = root.firstChildElement("entry");
+for (; !elt.isNull(); elt = elt.nextSiblingElement("entry")) {
+ // ...
+}
+//! [11]
+
+
+//! [12]
+<img src="myimg.png">
+//! [12]
+
+
+//! [13]
+<h1>Hello <b>Qt</b> <![CDATA[<xml is cool>]]></h1>
+//! [13]
+
+
+//! [14]
+Hello Qt <xml is cool>
+//! [14]
+
+
+//! [15]
+<!-- this is a comment -->
+//! [15]
+
+
+//! [16]
+QDomDocument doc("mydocument");
+QFile file("mydocument.xml");
+if (!file.open(QIODevice::ReadOnly))
+ return;
+if (!doc.setContent(&file)) {
+ file.close();
+ return;
+}
+file.close();
+
+// print out the element names of all elements that are direct children
+// of the outermost element.
+QDomElement docElem = doc.documentElement();
+
+QDomNode n = docElem.firstChild();
+while(!n.isNull()) {
+ QDomElement e = n.toElement(); // try to convert the node to an element.
+ if(!e.isNull()) {
+ cout << qPrintable(e.tagName()) << endl; // the node really is an element.
+ }
+ n = n.nextSibling();
+}
+
+// Here we append a new element to the end of the document
+QDomElement elem = doc.createElement("img");
+elem.setAttribute("src", "myimage.png");
+docElem.appendChild(elem);
+//! [16]
+
+
+//! [17]
+QDomDocument doc("MyML");
+QDomElement root = doc.createElement("MyML");
+doc.appendChild(root);
+
+QDomElement tag = doc.createElement("Greeting");
+root.appendChild(tag);
+
+QDomText t = doc.createTextNode("Hello World");
+tag.appendChild(t);
+
+QString xml = doc.toString();
+//! [17]
diff --git a/doc/src/snippets/code/src_xml_sax_qxml.cpp b/doc/src/snippets/code/src_xml_sax_qxml.cpp
new file mode 100644
index 0000000000..7cd7a33b76
--- /dev/null
+++ b/doc/src/snippets/code/src_xml_sax_qxml.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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]
+xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
+//! [0]