summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src/snippets')
-rw-r--r--doc/src/snippets/alphachannel.cpp108
-rw-r--r--doc/src/snippets/brush/brush.cpp86
-rw-r--r--doc/src/snippets/brush/gradientcreationsnippet.cpp62
-rw-r--r--doc/src/snippets/buffer/buffer.cpp124
-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
-rw-r--r--doc/src/snippets/complexpingpong-example.txt4
-rw-r--r--doc/src/snippets/customstyle/customstyle.cpp92
-rw-r--r--doc/src/snippets/customstyle/customstyle.h60
-rw-r--r--doc/src/snippets/customviewstyle.cpp69
-rw-r--r--doc/src/snippets/dialogs/dialogs.cpp268
-rw-r--r--doc/src/snippets/dockwidgets/mainwindow.cpp122
-rw-r--r--doc/src/snippets/dragging/mainwindow.cpp110
-rw-r--r--doc/src/snippets/droparea.cpp140
-rw-r--r--doc/src/snippets/file/file.cpp123
-rw-r--r--doc/src/snippets/filedialogurls.cpp61
-rw-r--r--doc/src/snippets/fileinfo/main.cpp92
-rw-r--r--doc/src/snippets/graphicssceneadditemsnippet.cpp80
-rw-r--r--doc/src/snippets/image/image.cpp104
-rw-r--r--doc/src/snippets/image/supportedformat.cpp52
-rw-r--r--doc/src/snippets/javastyle.cpp2745
-rw-r--r--doc/src/snippets/layouts/layouts.cpp165
-rw-r--r--doc/src/snippets/mainwindowsnippet.cpp92
-rw-r--r--doc/src/snippets/matrix/matrix.cpp140
-rw-r--r--doc/src/snippets/mdiareasnippets.cpp97
-rw-r--r--doc/src/snippets/myscrollarea.cpp128
-rw-r--r--doc/src/snippets/network/tcpwait.cpp69
-rw-r--r--doc/src/snippets/ntfsp.cpp50
-rw-r--r--doc/src/snippets/picture/picture.cpp151
-rw-r--r--doc/src/snippets/pointer/pointer.cpp60
-rw-r--r--doc/src/snippets/polygon/polygon.cpp112
-rw-r--r--doc/src/snippets/printing-qprinter/errors.cpp65
-rw-r--r--doc/src/snippets/printing-qprinter/object.cpp71
-rw-r--r--doc/src/snippets/process/process.cpp76
-rw-r--r--doc/src/snippets/qdbusextratypes/qdbusextratypes.cpp66
-rw-r--r--doc/src/snippets/qdebug/qdebugsnippet.cpp73
-rw-r--r--doc/src/snippets/qdir-listfiles/main.cpp62
-rw-r--r--doc/src/snippets/qdir-namefilters/main.cpp65
-rw-r--r--doc/src/snippets/qelapsedtimer/main.cpp111
-rw-r--r--doc/src/snippets/qfontdatabase/main.cpp74
-rw-r--r--doc/src/snippets/qlistwidget-using/mainwindow.cpp158
-rw-r--r--doc/src/snippets/qmacnativewidget/main.mm134
-rw-r--r--doc/src/snippets/qprocess-environment/main.cpp73
-rw-r--r--doc/src/snippets/qprocess/qprocess-simpleexecution.cpp66
-rw-r--r--doc/src/snippets/qsignalmapper/buttonwidget.cpp66
-rw-r--r--doc/src/snippets/qsignalmapper/buttonwidget.h67
-rw-r--r--doc/src/snippets/qsortfilterproxymodel-details/main.cpp99
-rw-r--r--doc/src/snippets/qsplashscreen/main.cpp63
-rw-r--r--doc/src/snippets/qstack/main.cpp55
-rw-r--r--doc/src/snippets/qstackedlayout/main.cpp89
-rw-r--r--doc/src/snippets/qstackedwidget/main.cpp87
-rw-r--r--doc/src/snippets/qstatustipevent/main.cpp82
-rw-r--r--doc/src/snippets/qstring/main.cpp941
-rw-r--r--doc/src/snippets/qstring/stringbuilder.cpp67
-rw-r--r--doc/src/snippets/qstringlist/main.cpp155
-rw-r--r--doc/src/snippets/qstringlistmodel/main.cpp66
-rw-r--r--doc/src/snippets/qstyleoption/main.cpp139
-rw-r--r--doc/src/snippets/qstyleplugin/main.cpp97
-rw-r--r--doc/src/snippets/qtablewidget-resizing/mainwindow.cpp115
-rw-r--r--doc/src/snippets/qtablewidget-using/mainwindow.cpp150
-rw-r--r--doc/src/snippets/qtcast/qtcast.cpp79
-rw-r--r--doc/src/snippets/qtreewidget-using/mainwindow.cpp230
-rw-r--r--doc/src/snippets/qtreewidgetitemiterator-using/mainwindow.cpp197
-rw-r--r--doc/src/snippets/quiloader/main.cpp70
-rw-r--r--doc/src/snippets/quiloader/mywidget.cpp60
-rw-r--r--doc/src/snippets/quiloader/mywidget.qrc5
-rw-r--r--doc/src/snippets/qx11embedcontainer/main.cpp67
-rw-r--r--doc/src/snippets/qx11embedwidget/main.cpp61
-rw-r--r--doc/src/snippets/qxmlstreamwriter/main.cpp76
-rw-r--r--doc/src/snippets/separations/finalwidget.cpp126
-rw-r--r--doc/src/snippets/settings/settings.cpp184
-rw-r--r--doc/src/snippets/shareddirmodel/main.cpp81
-rw-r--r--doc/src/snippets/sharedemployee/employee.h94
-rw-r--r--doc/src/snippets/sharedemployee/main.cpp50
-rw-r--r--doc/src/snippets/signalmapper/filereader.cpp107
-rw-r--r--doc/src/snippets/signalsandslots/lcdnumber.h88
-rw-r--r--doc/src/snippets/signalsandslots/signalsandslots.cpp84
-rw-r--r--doc/src/snippets/signalsandslots/signalsandslots.h89
-rw-r--r--doc/src/snippets/splitter/splitter.cpp84
-rw-r--r--doc/src/snippets/splitterhandle/splitter.cpp78
-rw-r--r--doc/src/snippets/splitterhandle/splitter.h73
-rw-r--r--doc/src/snippets/sqldatabase/sqldatabase.cpp559
-rw-r--r--doc/src/snippets/styles/styles.cpp91
-rw-r--r--doc/src/snippets/stylesheet/common-mistakes.cpp52
-rw-r--r--doc/src/snippets/textblock-fragments/xmlwriter.cpp117
-rw-r--r--doc/src/snippets/textdocument-css/main.cpp59
-rw-r--r--doc/src/snippets/textdocument-imagedrop/textedit.cpp71
-rw-r--r--doc/src/snippets/textdocument-lists/mainwindow.cpp192
-rw-r--r--doc/src/snippets/textdocument-tables/mainwindow.cpp204
-rw-r--r--doc/src/snippets/textdocument-texttable/main.cpp84
-rw-r--r--doc/src/snippets/textdocumentendsnippet.cpp56
-rw-r--r--doc/src/snippets/threads/threads.cpp117
-rw-r--r--doc/src/snippets/timeline/main.cpp72
-rw-r--r--doc/src/snippets/timers/timers.cpp78
-rw-r--r--doc/src/snippets/transform/main.cpp140
-rw-r--r--doc/src/snippets/whatsthis/whatsthis.cpp64
-rw-r--r--doc/src/snippets/widget-mask/main.cpp54
-rw-r--r--doc/src/snippets/widgetdelegate.cpp66
-rw-r--r--doc/src/snippets/widgetprinting.cpp93
-rw-r--r--doc/src/snippets/widgets-tutorial/template.cpp56
-rw-r--r--doc/src/snippets/xml/rsslisting/handler.cpp182
-rw-r--r--doc/src/snippets/xml/rsslisting/rsslisting.cpp251
-rw-r--r--doc/src/snippets/xml/simpleparse/main.cpp87
345 files changed, 38123 insertions, 0 deletions
diff --git a/doc/src/snippets/alphachannel.cpp b/doc/src/snippets/alphachannel.cpp
new file mode 100644
index 0000000000..d5ec20e60c
--- /dev/null
+++ b/doc/src/snippets/alphachannel.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$
+**
+****************************************************************************/
+
+#include <qapplication.h>
+#include <qlabel.h>
+#include <qpixmap.h>
+#include <qprinter.h>
+#include <qpainter.h>
+#include <qfile.h>
+#include <qdir.h>
+#include <qfileinfo.h>
+#include <QtGui>
+#include <QtCore>
+
+class MyClass : public QWidget
+{
+public:
+ MyClass(QWidget *parent = 0) : QWidget(parent) { }
+
+protected:
+ void paintEvent(QPaintEvent *e)
+ {
+ /*QRadialGradient rg(50, 50, 50, 50, 50);
+ rg.setColorAt(0, QColor::fromRgbF(1, 0, 0, 1));
+ rg.setColorAt(1, QColor::fromRgbF(0, 0, 0, 0));
+ QPainter pmp(&pm);
+ pmp.fillRect(0, 0, 100, 100, rg);
+ pmp.end();*/
+
+ createImage();
+
+ QPainter p(this);
+ p.fillRect(rect(), Qt::white);
+
+ p.drawPixmap(0, 0, pixmap);
+
+ p.drawPixmap(100, 0, channelImage);
+ }
+
+ void createImage()
+ {
+//! [0]
+ pixmap = QPixmap(100, 100);
+ pixmap.fill(Qt::transparent);
+
+ QRadialGradient gradient(50, 50, 50, 50, 50);
+ gradient.setColorAt(0, QColor::fromRgbF(1, 0, 0, 1));
+ gradient.setColorAt(1, QColor::fromRgbF(0, 0, 0, 0));
+ QPainter painter(&pixmap);
+ painter.fillRect(0, 0, 100, 100, gradient);
+
+ channelImage = pixmap.alphaChannel();
+ update();
+//! [0]
+ }
+
+ QPixmap channelImage, pixmap;
+ QSize sizeHint() const { return QSize(500, 500); }
+};
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ MyClass cl;
+ cl.show();
+ QObject::connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
+
+ int ret = app.exec();
+ return ret;
+}
diff --git a/doc/src/snippets/brush/brush.cpp b/doc/src/snippets/brush/brush.cpp
new file mode 100644
index 0000000000..57a219242c
--- /dev/null
+++ b/doc/src/snippets/brush/brush.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+int main()
+{
+ QWidget anyPaintDevice;
+ {
+ // PEN SNIPPET
+ QPainter painter;
+ QPen pen(Qt::red, 2); // red solid line, 2 pixels wide
+ painter.begin(&anyPaintDevice); // paint something
+ painter.setPen(pen); // set the red, wide pen
+ painter.drawRect(40,30, 200,100); // draw a rectangle
+ painter.setPen(Qt::blue); // set blue pen, 0 pixel width
+ painter.drawLine(40,30, 240,130); // draw a diagonal in rectangle
+ painter.end(); // painting done
+ }
+
+ {
+ // BRUSH SNIPPET
+ QPainter painter;
+ QBrush brush(Qt::yellow); // yellow solid pattern
+ painter.begin(&anyPaintDevice); // paint something
+ painter.setBrush(brush); // set the yellow brush
+ painter.setPen(Qt::NoPen); // do not draw outline
+ painter.drawRect(40,30, 200,100); // draw filled rectangle
+ painter.setBrush(Qt::NoBrush); // do not fill
+ painter.setPen(Qt::black); // set black pen, 0 pixel width
+ painter.drawRect(10,10, 30,20); // draw rectangle outline
+ painter.end(); // painting done
+ }
+
+ // LINEAR
+//! [0]
+ QLinearGradient linearGrad(QPointF(100, 100), QPointF(200, 200));
+ linearGrad.setColorAt(0, Qt::black);
+ linearGrad.setColorAt(1, Qt::white);
+//! [0]
+
+ // RADIAL
+//! [1]
+ QRadialGradient radialGrad(QPointF(100, 100), 100);
+ radialGrad.setColorAt(0, Qt::red);
+ radialGrad.setColorAt(0.5, Qt::blue);
+ radialGrad.setColorAt(1, Qt::green);
+//! [1]
+}
diff --git a/doc/src/snippets/brush/gradientcreationsnippet.cpp b/doc/src/snippets/brush/gradientcreationsnippet.cpp
new file mode 100644
index 0000000000..783c4c249a
--- /dev/null
+++ b/doc/src/snippets/brush/gradientcreationsnippet.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+
+//! [0]
+ QRadialGradient gradient(50, 50, 50, 50, 50);
+ gradient.setColorAt(0, QColor::fromRgbF(0, 1, 0, 1));
+ gradient.setColorAt(1, QColor::fromRgbF(0, 0, 0, 0));
+
+ QBrush brush(gradient);
+//! [0]
+
+ QWidget widget;
+ QPalette palette;
+ palette.setBrush(widget.backgroundRole(), brush);
+ widget.setPalette(palette);
+ widget.show();
+
+ return app.exec();
+}
diff --git a/doc/src/snippets/buffer/buffer.cpp b/doc/src/snippets/buffer/buffer.cpp
new file mode 100644
index 0000000000..a5e91087cd
--- /dev/null
+++ b/doc/src/snippets/buffer/buffer.cpp
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QBuffer>
+#include <QPalette>
+
+static void main_snippet()
+{
+//! [0]
+ QBuffer buffer;
+ char ch;
+
+ buffer.open(QBuffer::ReadWrite);
+ buffer.write("Qt rocks!");
+ buffer.seek(0);
+ buffer.getChar(&ch); // ch == 'Q'
+ buffer.getChar(&ch); // ch == 't'
+ buffer.getChar(&ch); // ch == ' '
+ buffer.getChar(&ch); // ch == 'r'
+//! [0]
+}
+
+static void write_datastream_snippets()
+{
+//! [1]
+ QByteArray byteArray;
+ QBuffer buffer(&byteArray);
+ buffer.open(QIODevice::WriteOnly);
+
+ QDataStream out(&buffer);
+ out << QApplication::palette();
+//! [1]
+}
+
+static void read_datastream_snippets()
+{
+ QByteArray byteArray;
+
+//! [2]
+ QPalette palette;
+ QBuffer buffer(&byteArray);
+ buffer.open(QIODevice::ReadOnly);
+
+ QDataStream in(&buffer);
+ in >> palette;
+//! [2]
+}
+
+static void bytearray_ptr_ctor_snippet()
+{
+//! [3]
+ QByteArray byteArray("abc");
+ QBuffer buffer(&byteArray);
+ buffer.open(QIODevice::WriteOnly);
+ buffer.seek(3);
+ buffer.write("def", 3);
+ buffer.close();
+ // byteArray == "abcdef"
+//! [3]
+}
+
+static void setBuffer_snippet()
+{
+//! [4]
+ QByteArray byteArray("abc");
+ QBuffer buffer;
+ buffer.setBuffer(&byteArray);
+ buffer.open(QIODevice::WriteOnly);
+ buffer.seek(3);
+ buffer.write("def", 3);
+ buffer.close();
+ // byteArray == "abcdef"
+//! [4]
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ main_snippet();
+ bytearray_ptr_ctor_snippet();
+ write_datastream_snippets();
+ read_datastream_snippets();
+ setBuffer_snippet();
+ return 0;
+}
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]
diff --git a/doc/src/snippets/complexpingpong-example.txt b/doc/src/snippets/complexpingpong-example.txt
new file mode 100644
index 0000000000..257f7029e1
--- /dev/null
+++ b/doc/src/snippets/complexpingpong-example.txt
@@ -0,0 +1,4 @@
+Ask your question: When is the next Qt release?
+Reply was: Sorry, I don't know the answer
+Ask your question: What is the answer to life, the universe and everything?
+Reply was: 42
diff --git a/doc/src/snippets/customstyle/customstyle.cpp b/doc/src/snippets/customstyle/customstyle.cpp
new file mode 100644
index 0000000000..b2e90722f2
--- /dev/null
+++ b/doc/src/snippets/customstyle/customstyle.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "customstyle.h"
+
+CustomStyle::CustomStyle()
+{
+//! [0]
+ QSpinBox *spinBox = qobject_cast<QSpinBox *>(widget);
+ if (spinBox) {
+//! [0] //! [1]
+ }
+//! [1]
+}
+
+//! [2]
+void CustomStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const
+{
+ if (element == PE_IndicatorSpinUp || element == PE_IndicatorSpinDown) {
+ QPolygon points(3);
+ int x = option->rect.x();
+ int y = option->rect.y();
+ int w = option->rect.width() / 2;
+ int h = option->rect.height() / 2;
+ x += (option->rect.width() - w) / 2;
+ y += (option->rect.height() - h) / 2;
+
+ if (element == PE_IndicatorSpinUp) {
+ points[0] = QPoint(x, y + h);
+ points[1] = QPoint(x + w, y + h);
+ points[2] = QPoint(x + w / 2, y);
+ } else { // PE_SpinBoxDown
+ points[0] = QPoint(x, y);
+ points[1] = QPoint(x + w, y);
+ points[2] = QPoint(x + w / 2, y + h);
+ }
+
+ if (option->state & State_Enabled) {
+ painter->setPen(option->palette.mid().color());
+ painter->setBrush(option->palette.buttonText());
+ } else {
+ painter->setPen(option->palette.buttonText().color());
+ painter->setBrush(option->palette.mid());
+ }
+ painter->drawPolygon(points);
+ } else {
+ QWindowsStyle::drawPrimitive(element, option, painter, widget);
+//! [2] //! [3]
+ }
+//! [3] //! [4]
+}
+//! [4]
diff --git a/doc/src/snippets/customstyle/customstyle.h b/doc/src/snippets/customstyle/customstyle.h
new file mode 100644
index 0000000000..6a87d75421
--- /dev/null
+++ b/doc/src/snippets/customstyle/customstyle.h
@@ -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$
+**
+****************************************************************************/
+
+#ifndef CUSTOMSTYLE_H
+#define CUSTOMSTYLE_H
+
+#include <QWindowsStyle>
+
+//! [0]
+class CustomStyle : public QWindowsStyle
+{
+ Q_OBJECT
+
+public:
+ CustomStyle()
+ ~CustomStyle() {}
+
+ void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const;
+};
+//! [0]
+
+#endif
diff --git a/doc/src/snippets/customviewstyle.cpp b/doc/src/snippets/customviewstyle.cpp
new file mode 100644
index 0000000000..b040f7563e
--- /dev/null
+++ b/doc/src/snippets/customviewstyle.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "customviewstyle.h"
+
+
+
+void CustomViewStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
+{
+
+//![0]
+ switch (element) {
+ case (PE_PanelItemViewItem): {
+ painter->save();
+
+ QPoint topLeft = option->rect.topLeft();
+ QPoint bottomRight = option->rect.topRight();
+ QLinearGradient backgroundGradient(topLeft, bottomRight);
+ backgroundGradient.setColorAt(0.0, QColor(Qt::yellow).lighter(190));
+ backgroundGradient.setColorAt(1.0, Qt::white);
+ painter->fillRect(option->rect, QBrush(backgroundGradient));
+
+ painter->restore();
+ break;
+ }
+ default:
+ QWindowsStyle::drawPrimitive(element, option, painter, widget);
+ }
+//![0]
+}
diff --git a/doc/src/snippets/dialogs/dialogs.cpp b/doc/src/snippets/dialogs/dialogs.cpp
new file mode 100644
index 0000000000..de9a2d1e04
--- /dev/null
+++ b/doc/src/snippets/dialogs/dialogs.cpp
@@ -0,0 +1,268 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+typedef QDialog WordCountDialog;
+typedef QDialog FindDialog;
+
+#define this 0
+#define setWordCount(x) isVisible()
+
+QString tr(const char *text)
+{
+ return QApplication::translate(text, text);
+}
+
+class EditorWindow : public QMainWindow
+{
+public:
+ void find();
+ void countWords();
+
+private:
+ FindDialog *findDialog;
+};
+
+//! [0]
+void EditorWindow::find()
+{
+ if (!findDialog) {
+ findDialog = new FindDialog(this);
+ connect(findDialog, SIGNAL(findNext()), this, SLOT(findNext()));
+ }
+
+ findDialog->show();
+ findDialog->raise();
+ findDialog->activateWindow();
+}
+//! [0]
+
+//! [1]
+void EditorWindow::countWords()
+{
+ WordCountDialog dialog(this);
+ dialog.setWordCount(document().wordCount());
+ dialog.exec();
+}
+//! [1]
+
+inline bool boo()
+{
+ QMessageBox::information(this, "Application name",
+ "Unable to find the user preferences file.\n"
+ "The factory default will be used instead.");
+
+ QString filename;
+ if (QFile::exists(filename) &&
+ QMessageBox::question(
+ this,
+ tr("Overwrite File? -- Application Name"),
+ tr("A file called %1 already exists."
+ "Do you want to overwrite it?")
+ .arg(filename),
+ tr("&Yes"), tr("&No"),
+ QString(), 0, 1))
+ return false;
+
+ switch(QMessageBox::warning(this, "Application name",
+ "Could not connect to the <mumble> server.\n"
+ "This program can't function correctly "
+ "without the server.\n\n",
+ "Retry",
+ "Quit", 0, 0, 1)) {
+ case 0: // The user clicked the Retry again button or pressed Enter
+ // try again
+ break;
+ case 1: // The user clicked the Quit or pressed Escape
+ // exit
+ break;
+ }
+
+ switch(QMessageBox::information(this, "Application name here",
+ "The document contains unsaved changes\n"
+ "Do you want to save the changes before exiting?",
+ "&Save", "&Discard", "Cancel",
+ 0, // Enter == button 0
+ 2)) { // Escape == button 2
+ case 0: // Save clicked or Alt+S pressed or Enter pressed.
+ // save
+ break;
+ case 1: // Discard clicked or Alt+D pressed
+ // don't save but exit
+ break;
+ case 2: // Cancel clicked or Escape pressed
+ // don't exit
+ break;
+ }
+
+ switch(QMessageBox::warning(this, "Application name here",
+ "Could not save the user preferences,\n"
+ "because the disk is full. You can delete\n"
+ "some files and press Retry, or you can\n"
+ "abort the Save Preferences operation.",
+ QMessageBox::Retry | QMessageBox::Default,
+ QMessageBox::Abort | QMessageBox::Escape)) {
+ case QMessageBox::Retry: // Retry clicked or Enter pressed
+ // try again
+ break;
+ case QMessageBox::Abort: // Abort clicked or Escape pressed
+ // abort
+ break;
+ }
+
+ QString errorDetails;
+ QMessageBox::critical(0, "Application name here",
+ QString("An internal error occurred. Please ") +
+ "call technical support at 1234-56789 and report\n"+
+ "these numbers:\n\n" + errorDetails +
+ "\n\nApplication will now exit.");
+
+ QMessageBox::about(this, "About <Application>",
+ "<Application> is a <one-paragraph blurb>\n\n"
+ "Copyright 1991-2003 Such-and-such. "
+ "<License words here.>\n\n"
+ "For technical support, call 1234-56789 or see\n"
+ "http://www.such-and-such.com/Application/\n");
+
+ {
+ // saving the file
+ QMessageBox mb("Application name here",
+ "Saving the file will overwrite the original file on the disk.\n"
+ "Do you really want to save?",
+ QMessageBox::Information,
+ QMessageBox::Yes | QMessageBox::Default,
+ QMessageBox::No,
+ QMessageBox::Cancel | QMessageBox::Escape);
+ mb.setButtonText(QMessageBox::Yes, "Save");
+ mb.setButtonText(QMessageBox::No, "Discard");
+ switch(mb.exec()) {
+ case QMessageBox::Yes:
+ // save and exit
+ break;
+ case QMessageBox::No:
+ // exit without saving
+ break;
+ case QMessageBox::Cancel:
+ // don't save and don't exit
+ break;
+ }
+ }
+
+ {
+ // hardware failure
+//! [2]
+ QMessageBox mb("Application Name",
+ "Hardware failure.\n\nDisk error detected\nDo you want to stop?",
+ QMessageBox::Question,
+ QMessageBox::Yes | QMessageBox::Default,
+ QMessageBox::No | QMessageBox::Escape,
+ QMessageBox::NoButton);
+ if (mb.exec() == QMessageBox::No) {
+ // try again
+//! [2]
+ }
+ }
+}
+
+inline void moo()
+{
+ int numFiles;
+//! [3]
+ QProgressDialog progress("Copying files...", "Abort Copy", 0, numFiles, this);
+ progress.setWindowModality(Qt::WindowModal);
+
+ for (int i = 0; i < numFiles; i++) {
+ progress.setValue(i);
+
+ if (progress.wasCanceled())
+ break;
+ //... copy one file
+ }
+ progress.setValue(numFiles);
+//! [3]
+}
+
+class Operation : public QObject
+{
+public:
+ Operation(QObject *parent);
+ void perform();
+ void cancel();
+
+private:
+ int steps;
+ QProgressDialog *pd;
+ QTimer *t;
+};
+
+//! [4]
+// Operation constructor
+Operation::Operation(QObject *parent)
+ : QObject(parent), steps(0)
+{
+ pd = new QProgressDialog("Operation in progress.", "Cancel", 0, 100);
+ connect(pd, SIGNAL(canceled()), this, SLOT(cancel()));
+ t = new QTimer(this);
+ connect(t, SIGNAL(timeout()), this, SLOT(perform()));
+ t->start(0);
+}
+//! [4] //! [5]
+
+void Operation::perform()
+{
+ pd->setValue(steps);
+ //... perform one percent of the operation
+ steps++;
+ if (steps > pd->maximum())
+ t->stop();
+}
+//! [5] //! [6]
+
+void Operation::cancel()
+{
+ t->stop();
+ //... cleanup
+}
+//! [6]
+
+int main()
+{
+}
diff --git a/doc/src/snippets/dockwidgets/mainwindow.cpp b/doc/src/snippets/dockwidgets/mainwindow.cpp
new file mode 100644
index 0000000000..10b7531ec4
--- /dev/null
+++ b/doc/src/snippets/dockwidgets/mainwindow.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+{
+ setWindowTitle("Dock Widgets");
+
+ setupDockWindow();
+ setupContents();
+ setupMenus();
+
+ textBrowser = new QTextBrowser(this);
+
+ connect(headingList, SIGNAL(itemClicked(QListWidgetItem *)),
+ this, SLOT(updateText(QListWidgetItem *)));
+
+ updateText(headingList->item(0));
+ headingList->setCurrentRow(0);
+ setCentralWidget(textBrowser);
+}
+
+void MainWindow::setupContents()
+{
+ QFile titlesFile(":/Resources/titles.txt");
+ titlesFile.open(QFile::ReadOnly);
+ int chapter = 0;
+
+ do {
+ QString line = titlesFile.readLine().trimmed();
+ QStringList parts = line.split("\t", QString::SkipEmptyParts);
+ if (parts.size() != 2)
+ break;
+
+ QString chapterTitle = parts[0];
+ QString fileName = parts[1];
+
+ QFile chapterFile(fileName);
+
+ chapterFile.open(QFile::ReadOnly);
+ QListWidgetItem *item = new QListWidgetItem(chapterTitle, headingList);
+ item->setData(Qt::DisplayRole, chapterTitle);
+ item->setData(Qt::UserRole, chapterFile.readAll());
+ item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
+ chapterFile.close();
+
+ chapter++;
+ } while (titlesFile.isOpen());
+
+ titlesFile.close();
+}
+
+void MainWindow::setupDockWindow()
+{
+//! [0]
+ contentsWindow = new QDockWidget(tr("Table of Contents"), this);
+ contentsWindow->setAllowedAreas(Qt::LeftDockWidgetArea
+ | Qt::RightDockWidgetArea);
+ addDockWidget(Qt::LeftDockWidgetArea, contentsWindow);
+
+ headingList = new QListWidget(contentsWindow);
+ contentsWindow->setWidget(headingList);
+//! [0]
+}
+
+void MainWindow::setupMenus()
+{
+ QAction *exitAct = new QAction(tr("E&xit"), this);
+ exitAct->setShortcut(tr("Ctrl+Q"));
+ exitAct->setStatusTip(tr("Exit the application"));
+ connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));
+
+ QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
+ fileMenu->addAction(exitAct);
+}
+
+void MainWindow::updateText(QListWidgetItem *item)
+{
+ QString text = item->data(Qt::UserRole).toString();
+ textBrowser->setHtml(text);
+}
diff --git a/doc/src/snippets/dragging/mainwindow.cpp b/doc/src/snippets/dragging/mainwindow.cpp
new file mode 100644
index 0000000000..0b3f64213a
--- /dev/null
+++ b/doc/src/snippets/dragging/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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+{
+ QFrame *centralFrame = new QFrame(this);
+
+ QLabel *nameLabel = new QLabel(tr("Comment:"), centralFrame);
+ commentEdit = new QTextEdit(centralFrame);
+ QLabel *dragLabel = new QLabel(tr("<p>Drag the icon to a filer "
+ "window or the desktop background:</p>"),
+ centralFrame);
+ iconLabel = new QLabel(centralFrame);
+ iconPixmap.load(":/images/file.png");
+ iconLabel->setPixmap(iconPixmap);
+
+ QGridLayout *grid = new QGridLayout(centralFrame);
+ grid->addWidget(nameLabel, 0, 0);
+ grid->addWidget(commentEdit, 1, 0, 1, 2);
+ grid->addWidget(dragLabel, 2, 0);
+ grid->addWidget(iconLabel, 2, 1);
+
+ statusBar();
+ setCentralWidget(centralFrame);
+ setWindowTitle(tr("Dragging"));
+}
+
+//! [0]
+void MainWindow::mousePressEvent(QMouseEvent *event)
+{
+ if (event->button() == Qt::LeftButton
+ && iconLabel->geometry().contains(event->pos())) {
+
+//! [1]
+ QDrag *drag = new QDrag(this);
+ QMimeData *mimeData = new QMimeData;
+
+ mimeData->setText(commentEdit->toPlainText());
+ drag->setMimeData(mimeData);
+//! [1]
+ drag->setPixmap(iconPixmap);
+
+ Qt::DropAction dropAction = drag->exec();
+//! [0]
+
+ QString actionText;
+ switch (dropAction) {
+ case Qt::CopyAction:
+ actionText = tr("The text was copied.");
+ break;
+ case Qt::MoveAction:
+ actionText = tr("The text was moved.");
+ break;
+ case Qt::LinkAction:
+ actionText = tr("The text was linked.");
+ break;
+ case Qt::IgnoreAction:
+ actionText = tr("The drag was ignored.");
+ break;
+ default:
+ actionText = tr("Unknown action.");
+ break;
+ }
+ statusBar()->showMessage(actionText);
+//! [2]
+ }
+}
+//! [2]
diff --git a/doc/src/snippets/droparea.cpp b/doc/src/snippets/droparea.cpp
new file mode 100644
index 0000000000..6556f05bf0
--- /dev/null
+++ b/doc/src/snippets/droparea.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "droparea.h"
+
+DropArea::DropArea(QWidget *parent)
+ : QLabel(parent)
+{
+ setMinimumSize(200, 200);
+ setFrameStyle(QFrame::Sunken | QFrame::StyledPanel);
+ setAlignment(Qt::AlignCenter);
+ setAcceptDrops(true);
+ setAutoFillBackground(true);
+ clear();
+}
+
+void DropArea::dragEnterEvent(QDragEnterEvent *event)
+{
+ setText(tr("<drop content>"));
+ setBackgroundRole(QPalette::Highlight);
+
+ event->acceptProposedAction();
+ emit changed(event->mimeData());
+}
+
+void DropArea::dragMoveEvent(QDragMoveEvent *event)
+{
+ event->acceptProposedAction();
+}
+
+void DropArea::dropEvent(QDropEvent *event)
+{
+ const QMimeData *mimeData = event->mimeData();
+
+ if (mimeData->hasImage()) {
+ setPixmap(qvariant_cast<QPixmap>(mimeData->imageData()));
+ } else if (mimeData->hasHtml()) {
+ setText(mimeData->html());
+ setTextFormat(Qt::RichText);
+ } else if (mimeData->hasText()) {
+ setText(mimeData->text());
+ setTextFormat(Qt::PlainText);
+ } else {
+ setText(tr("Cannot display data"));
+ }
+
+ setBackgroundRole(QPalette::Dark);
+ event->acceptProposedAction();
+}
+
+//![0]
+void DropArea::paste()
+{
+ const QClipboard *clipboard = QApplication::clipboard();
+ const QMimeData *mimeData = clipboard->mimeData();
+
+ if (mimeData->hasImage()) {
+ setPixmap(qvariant_cast<QPixmap>(mimeData->imageData()));
+ } else if (mimeData->hasHtml()) {
+ setText(mimeData->html());
+ setTextFormat(Qt::RichText);
+ } else if (mimeData->hasText()) {
+ setText(mimeData->text());
+ setTextFormat(Qt::PlainText);
+ } else {
+ setText(tr("Cannot display data"));
+ }
+//![0]
+
+ emit changed(mimeData);
+ setBackgroundRole(QPalette::Dark);
+ //event->acceptProposedAction();
+}
+
+void DropArea::dragLeaveEvent(QDragLeaveEvent *event)
+{
+ clear();
+ event->accept();
+}
+
+void DropArea::clear()
+{
+ setText(tr("<drop content>"));
+ setBackgroundRole(QPalette::Dark);
+
+ emit changed();
+}
+
+QPixmap DropArea::extractPixmap(const QByteArray &data, const QString &format)
+{
+ QList<QByteArray> imageFormats = QImageReader::supportedImageFormats();
+ QPixmap pixmap;
+
+ foreach (const QByteArray &imageFormat, imageFormats) {
+ if (format.mid(6) == QString(imageFormat)) {
+ pixmap.loadFromData(data, imageFormat);
+ break;
+ }
+ }
+ return pixmap;
+}
diff --git a/doc/src/snippets/file/file.cpp b/doc/src/snippets/file/file.cpp
new file mode 100644
index 0000000000..ede4aa97d2
--- /dev/null
+++ b/doc/src/snippets/file/file.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$
+**
+****************************************************************************/
+
+#include <QFile>
+#include <QTextStream>
+
+static void process_line(const QByteArray &)
+{
+}
+
+static void process_line(const QString &)
+{
+}
+
+static void noStream_snippet()
+{
+//! [0]
+ QFile file("in.txt");
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
+ return;
+
+ while (!file.atEnd()) {
+ QByteArray line = file.readLine();
+ process_line(line);
+ }
+//! [0]
+}
+
+static void readTextStream_snippet()
+{
+//! [1]
+ QFile file("in.txt");
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
+ return;
+
+ QTextStream in(&file);
+ while (!in.atEnd()) {
+ QString line = in.readLine();
+ process_line(line);
+ }
+//! [1]
+}
+
+static void writeTextStream_snippet()
+{
+//! [2]
+ QFile file("out.txt");
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
+ return;
+
+ QTextStream out(&file);
+ out << "The magic number is: " << 49 << "\n";
+//! [2]
+}
+
+static void writeTextStream_snippet()
+{
+ QFile file("out.dat");
+ if (!file.open(QIODevice::WriteOnly))
+ return;
+
+ QDataStream out(&file);
+ out << "The magic number is: " << 49 << "\n";
+}
+
+static void readRegularEmptyFile_snippet()
+{
+//! [3]
+ QFile file("/proc/modules");
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
+ return;
+
+ QTextStream in(&file);
+ QString line = in.readLine();
+ while (!line.isNull()) {
+ process_line(line);
+ line = in.readLine();
+ }
+//! [3]
+}
+
+int main()
+{
+ lineByLine_snippet();
+ writeStream_snippet();
+}
diff --git a/doc/src/snippets/filedialogurls.cpp b/doc/src/snippets/filedialogurls.cpp
new file mode 100644
index 0000000000..2b6cdaaba8
--- /dev/null
+++ b/doc/src/snippets/filedialogurls.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+
+//![0]
+ QList<QUrl> urls;
+ urls << QUrl::fromLocalFile("/home/gvatteka/dev/qt-45")
+ << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::MusicLocation));
+
+ QFileDialog dialog;
+ dialog.setSidebarUrls(urls);
+ dialog.setFileMode(QFileDialog::AnyFile);
+ if(dialog.exec()) {
+ // ...
+ }
+//![0]
+
+ return app.exec();
+}
diff --git a/doc/src/snippets/fileinfo/main.cpp b/doc/src/snippets/fileinfo/main.cpp
new file mode 100644
index 0000000000..d0fc9f54dd
--- /dev/null
+++ b/doc/src/snippets/fileinfo/main.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QPushButton>
+#include <QFileInfo>
+#include <QDir>
+#include <QGroupBox>
+#include <QVBoxLayout>
+#include <QDebug>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+//! [0]
+ QFileInfo fileInfo1("~/examples/191697/.");
+ QFileInfo fileInfo2("~/examples/191697/..");
+ QFileInfo fileInfo3("~/examples/191697/main.cpp");
+//! [0]
+//! [1]
+ QFileInfo fileInfo4(".");
+ QFileInfo fileInfo5("..");
+ QFileInfo fileInfo6("main.cpp");
+//! [1]
+
+ qDebug() << fileInfo1.fileName();
+ qDebug() << fileInfo2.fileName();
+ qDebug() << fileInfo3.fileName();
+ qDebug() << fileInfo4.fileName();
+ qDebug() << fileInfo5.fileName();
+ qDebug() << fileInfo6.fileName();
+
+ QPushButton* button1 = new QPushButton(fileInfo1.dir().path());
+ QPushButton* button2 = new QPushButton(fileInfo2.dir().path());
+ QPushButton* button3 = new QPushButton(fileInfo3.dir().path());
+ QPushButton* button4 = new QPushButton(fileInfo4.dir().path());
+ QPushButton* button5 = new QPushButton(fileInfo5.dir().path());
+ QPushButton* button6 = new QPushButton(fileInfo6.dir().path());
+
+ QVBoxLayout* vbox = new QVBoxLayout;
+ vbox->addWidget(button1);
+ vbox->addWidget(button2);
+ vbox->addWidget(button3);
+ vbox->addWidget(button4);
+ vbox->addWidget(button5);
+ vbox->addWidget(button6);
+ vbox->addStretch(1);
+
+ QGroupBox *groupBox = new QGroupBox("QFileInfo::dir() test");
+ groupBox->setLayout(vbox);
+ groupBox->show();
+
+ return app.exec();
+}
diff --git a/doc/src/snippets/graphicssceneadditemsnippet.cpp b/doc/src/snippets/graphicssceneadditemsnippet.cpp
new file mode 100644
index 0000000000..2c2c0d01a8
--- /dev/null
+++ b/doc/src/snippets/graphicssceneadditemsnippet.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+class CustomScene : public QGraphicsScene
+{
+public:
+ CustomScene()
+ { addItem(new QGraphicsEllipseItem(QRect(10, 10, 30, 30))); }
+
+ void drawItems(QPainter *painter, int numItems, QGraphicsItem *items[],
+ const QStyleOptionGraphicsItem options[],
+ QWidget *widget = 0);
+};
+
+//! [0]
+void CustomScene::drawItems(QPainter *painter, int numItems,
+ QGraphicsItem *items[],
+ const QStyleOptionGraphicsItem options[],
+ QWidget *widget)
+{
+ for (int i = 0; i < numItems; ++i) {
+ // Draw the item
+ painter->save();
+ painter->setMatrix(items[i]->sceneMatrix(), true);
+ items[i]->paint(painter, &options[i], widget);
+ painter->restore();
+ }
+}
+//! [0]
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+
+ CustomScene scene;
+ QGraphicsView view(&scene);
+
+ view.show();
+
+ return app.exec();
+}
diff --git a/doc/src/snippets/image/image.cpp b/doc/src/snippets/image/image.cpp
new file mode 100644
index 0000000000..62d83089d3
--- /dev/null
+++ b/doc/src/snippets/image/image.cpp
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+int main()
+{
+ int x, y;
+ {
+ // BIT ACCESS
+ QImage image;
+ // sets bit at (x, y) to 1
+ if (image.format() == QImage::Format_MonoLSB)
+ image.scanLine(y)[x >> 3] |= 1 << (x & 7);
+ else
+ image.scanLine(y)[x >> 3] |= 1 << (7 - (x & 7));
+ }
+
+ {
+ // 8-BIT ACCESS
+ QImage image;
+ // set entry 19 in the color table to yellow
+ image.setColor(19, qRgb(255, 255, 0));
+
+ // set 8 bit pixel at (x,y) to value yellow (in color table)
+ image.scanLine(y)[x] = 19;
+ }
+
+ {
+ // 32-BIT
+ QImage image;
+ // sets 32 bit pixel at (x,y) to yellow.
+ uint *ptr = reinterpret_cast<uint *>(image.scanLine(y)) + x;
+ *ptr = qRgb(255, 255, 0);
+ }
+
+ {
+ // SAVE
+//! [0]
+ QImage image;
+ QByteArray ba;
+ QBuffer buffer(&ba);
+ buffer.open(QIODevice::WriteOnly);
+ image.save(&buffer, "PNG"); // writes image into ba in PNG format
+//! [0]
+ }
+
+ {
+ // PIX SAVE
+//! [1]
+ QPixmap pixmap;
+ QByteArray bytes;
+ QBuffer buffer(&bytes);
+ buffer.open(QIODevice::WriteOnly);
+ pixmap.save(&buffer, "PNG"); // writes pixmap into bytes in PNG format
+//! [1]
+ }
+
+ {
+ // MASK
+//! [2]
+ QPixmap alpha("image-with-alpha.png");
+ QPixmap alphacopy = alpha;
+ alphacopy.setMask(alphacopy.mask());
+//! [2]
+ }
+}
diff --git a/doc/src/snippets/image/supportedformat.cpp b/doc/src/snippets/image/supportedformat.cpp
new file mode 100644
index 0000000000..55800d33f3
--- /dev/null
+++ b/doc/src/snippets/image/supportedformat.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+int main(int argv, char **args)
+{
+//! [0]
+ QImageWriter writer;
+ writer.setFormat("png");
+ if (writer.supportsOption(QImageIOHandler::Description))
+ qDebug() << "Png supports embedded text";
+//! [0]
+ return 0;
+}
diff --git a/doc/src/snippets/javastyle.cpp b/doc/src/snippets/javastyle.cpp
new file mode 100644
index 0000000000..1cf7e5560d
--- /dev/null
+++ b/doc/src/snippets/javastyle.cpp
@@ -0,0 +1,2745 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "javastyle.h"
+#include <math.h>
+
+static const int windowsItemFrame = 2;
+static const int windowsSepHeight = 2;
+static const int windowsItemHMargin = 3;
+static const int windowsItemVMargin = 2;
+static const int windowsArrowHMargin = 6;
+static const int windowsTabSpacing = 12;
+static const int windowsCheckMarkHMargin = 2;
+static const int windowsRightBorder = 15;
+static const int windowsCheckMarkWidth = 12;
+
+JavaStyle::JavaStyle()
+{
+ qApp->setPalette(standardPalette());
+}
+
+
+inline QPoint JavaStyle::adjustScrollPoint(const QPoint &point,
+ Qt::Orientation orientation,
+ bool add) const
+{
+ int adder = add ? -1 : 1;
+ QPoint retPoint;
+
+ if (orientation == Qt::Horizontal) {
+ retPoint = QPoint(point.y() * adder, point.x());
+ } else {
+ retPoint = QPoint(point.x(), point.y() * adder);
+ }
+
+ return retPoint;
+}
+
+QPalette JavaStyle::standardPalette() const
+{
+ QPalette palette = QWindowsStyle::standardPalette();
+
+ palette.setBrush(QPalette::Active, QPalette::Button,
+ QColor(184, 207, 229));
+ palette.setBrush(QPalette::Active, QPalette::WindowText,
+ Qt::black);
+ palette.setBrush(QPalette::Active, QPalette::Background,
+ QColor(238, 238, 238));
+ palette.setBrush(QPalette::Active, QPalette::Window,
+ QColor(238 ,238, 238));
+ palette.setBrush(QPalette::Active, QPalette::Base, Qt::white);
+ palette.setBrush(QPalette::Active, QPalette::AlternateBase, QColor(238, 238, 238));
+ palette.setBrush(QPalette::Active, QPalette::Text, Qt::black);
+ palette.setBrush(QPalette::Active, QPalette::BrightText, Qt::white);
+
+ palette.setBrush(QPalette::Active, QPalette::Light, QColor(163, 184, 204)); // focusFrameColor
+ palette.setBrush(QPalette::Active, QPalette::Midlight, QColor(99, 130, 191)); // tabBarBorderColor
+ palette.setBrush(QPalette::Active, QPalette::Dark, QColor(106, 104, 100));
+ palette.setBrush(QPalette::Active, QPalette::Mid, QColor(122, 138, 153)); //defaultFrameColor
+ palette.setBrush(QPalette::Active, QPalette::Shadow, QColor(122, 138, 153)); // defaultFrame
+
+ palette.setBrush(QPalette::Active, QPalette::Highlight, QColor(184, 207, 229));
+ palette.setBrush(QPalette::Active, QPalette::HighlightedText, Qt::black);
+
+ palette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(184, 207, 229));
+ palette.setBrush(QPalette::Inactive, QPalette::HighlightedText, Qt::black);
+
+ palette.setBrush(QPalette::Disabled, QPalette::Button,
+ QColor(238, 238, 238));
+ palette.setBrush(QPalette::Disabled, QPalette::WindowText,
+ QColor(153, 153, 153));
+ palette.setBrush(QPalette::Disabled, QPalette::Background, QColor(238, 238, 238));
+
+ palette.setBrush(QPalette::Inactive, QPalette::Button,
+ QColor(184, 207, 229));
+ palette.setBrush(QPalette::Inactive, QPalette::Background,
+ QColor(238, 238, 238));
+ palette.setBrush(QPalette::Inactive, QPalette::Window,
+ QColor(238 ,238, 238));
+ palette.setBrush(QPalette::Inactive, QPalette::Light, QColor(163, 184, 204)); // focusFrameColor
+ palette.setBrush(QPalette::Inactive, QPalette::Midlight, QColor(99, 130, 191)); // tabBarBorderColor
+ palette.setBrush(QPalette::Inactive, QPalette::Dark,QColor(106, 104, 100));
+ palette.setBrush(QPalette::Inactive, QPalette::Mid, QColor(122, 138, 153)); //defaultFrame
+ palette.setBrush(QPalette::Inactive, QPalette::Shadow, QColor(122, 138, 153)); // defaultFrame
+
+ return palette;
+}
+
+inline void JavaStyle::drawScrollBarArrow(const QRect &rect, QPainter *painter,
+ const QStyleOptionSlider *option,
+ bool add) const
+{
+
+ painter->save();
+
+ Qt::Orientation orient = option->orientation;
+ QPoint offset;
+
+ if (add) {
+ if (orient == Qt::Vertical) {
+ offset = rect.bottomLeft();
+ } else {
+ offset = rect.topRight();
+ }
+ } else {
+ offset = rect.topLeft();
+ }
+
+ QPainterPath arrow;
+ arrow.moveTo(offset + adjustScrollPoint(QPoint(4, 8), orient, add));
+ arrow.lineTo(offset + adjustScrollPoint(QPoint(7, 5), orient, add));
+ arrow.lineTo(offset + adjustScrollPoint(QPoint(8, 5), orient, add));
+ arrow.lineTo(offset + adjustScrollPoint(QPoint(11, 8), orient, add));
+ arrow.lineTo(offset + adjustScrollPoint(QPoint(4, 8), orient, add));
+
+ QColor fillColor;
+ if (option->state & State_Sunken)
+ fillColor = QColor(option->palette.color(QPalette::Button));
+ else
+ fillColor = option->palette.color(QPalette::Background);
+
+ painter->fillRect(rect, fillColor);
+
+ painter->setPen(option->palette.color(QPalette::Base));
+ int adjust = option->state & State_Sunken ? 0 : 1;
+ painter->drawRect(rect.adjusted(adjust, adjust, -1, -1));
+ painter->setPen(option->palette.color(QPalette::Mid));
+ painter->drawRect(rect.adjusted(0, 0, -1, -1));
+
+ painter->setPen(option->palette.color(QPalette::WindowText));
+ painter->setBrush(option->palette.color(QPalette::WindowText));
+ painter->drawPath(arrow);
+
+ painter->restore();
+}
+
+inline QPoint JavaStyle::adjustScrollHandlePoint(Qt::Orientation orig,
+ const QPoint &point) const
+{
+ QPoint retPoint;
+
+ if (orig == Qt::Vertical)
+ retPoint = point;
+ else
+ retPoint = QPoint(point.y(), point.x());
+
+ return retPoint;
+}
+
+void JavaStyle::drawControl(ControlElement control, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const
+{
+
+ painter->save();
+
+ switch (control) {
+ case CE_ToolBoxTabShape: {
+ const QStyleOptionToolBox *box =
+ qstyleoption_cast<const QStyleOptionToolBox *>(option);
+
+ painter->save();
+
+ if (box->direction == Qt::RightToLeft) {
+ painter->rotate(1);
+ painter->translate(box->rect.width(), -box->rect.height());
+ }
+
+ int textWidth = box->fontMetrics.width(box->text) + 20;
+
+ QPolygon innerLine;
+ innerLine << (box->rect.topLeft() + QPoint(0, 1)) <<
+ (box->rect.topLeft() + QPoint(textWidth, 1)) <<
+ (box->rect.bottomLeft() + QPoint(textWidth + 15, -3)) <<
+ (box->rect.bottomRight() + QPoint(0, -3)) <<
+ box->rect.bottomRight() <<
+ box->rect.bottomLeft() <<
+ box->rect.topLeft();
+
+ painter->setPen(box->palette.color(QPalette::Base));
+ painter->setBrush(QColor(200, 221, 242));
+ painter->drawPolygon(innerLine);
+
+ QPolygon outerLine;
+ outerLine << (box->rect.bottomRight() + QPoint(0, -3)) <<
+ box->rect.bottomRight() <<
+ box->rect.bottomLeft() <<
+ box->rect.topLeft() <<
+ (box->rect.topLeft() + QPoint(textWidth, 0)) <<
+ (box->rect.bottomLeft() + QPoint(textWidth + 15, -4)) <<
+ (box->rect.bottomRight() + QPoint(0, -4));
+
+ painter->setPen(box->palette.color(QPalette::Midlight));
+ painter->setBrush(Qt::NoBrush);
+ painter->drawPolyline(outerLine);
+
+ painter->restore();
+ break;
+ }
+ case CE_DockWidgetTitle: {
+ const QStyleOptionDockWidgetV2 *docker =
+ new QStyleOptionDockWidgetV2(
+ *qstyleoption_cast<const QStyleOptionDockWidget *>(option));
+
+ QRect rect = docker->rect;
+ QRect titleRect = rect;
+ if (docker->verticalTitleBar) {
+ QRect r = rect;
+ QSize s = r.size();
+ s.transpose();
+ r.setSize(s);
+
+ titleRect = QRect(r.left() + rect.bottom()
+ - titleRect.bottom(),
+ r.top() + titleRect.left() - rect.left(),
+ titleRect.height(), titleRect.width());
+
+ painter->translate(r.left(), r.top() + r.width());
+ painter->rotate(-90);
+ painter->translate(-r.left(), -r.top());
+
+ rect = r;
+ }
+
+ QLinearGradient gradient(rect.topLeft(),
+ rect.bottomLeft());
+ gradient.setColorAt(1.0, QColor(191, 212, 231));
+ gradient.setColorAt(0.3, Qt::white);
+ gradient.setColorAt(0.0, QColor(221, 232, 243));
+
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(gradient);
+ painter->drawRect(rect.adjusted(0, 0, -1, -1));
+
+ if (!docker->title.isEmpty()) {
+ QRect textRect = docker->fontMetrics.boundingRect(docker->title);
+ textRect.moveCenter(rect.center());
+
+ QFont font = painter->font();
+ font.setPointSize(font.pointSize() - 1);
+ painter->setFont(font);
+ painter->setPen(docker->palette.text().color());
+ painter->drawText(textRect, docker->title,
+ QTextOption(Qt::AlignHCenter |
+ Qt::AlignVCenter));
+ }
+ break;
+ }
+ case CE_RubberBand: {
+ painter->setPen(option->palette.color(QPalette::Active,
+ QPalette::WindowText));
+ painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
+ break;
+ }
+ case CE_SizeGrip: {
+ break;
+ }
+ case CE_HeaderSection: {
+ const QStyleOptionHeader *header =
+ qstyleoption_cast<const QStyleOptionHeader *>(option);
+
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(option->palette.color(QPalette::Active,
+ QPalette::Background));
+ painter->drawRect(option->rect);
+
+ painter->setPen(header->palette.color(QPalette::Mid));
+ if (header->orientation == Qt::Horizontal) {
+ if (header->position == QStyleOptionHeader::Beginning ||
+ header->position == QStyleOptionHeader::OnlyOneSection) {
+ painter->drawRect(header->rect.adjusted(0, 0, -1, -1));
+ painter->setPen(header->palette.color(QPalette::Base));
+ painter->drawLine(header->rect.bottomLeft() + QPoint(1, -1),
+ header->rect.topLeft() + QPoint(1, 1));
+ painter->drawLine(header->rect.topLeft() + QPoint(1, 1),
+ header->rect.topRight() + QPoint(-1, 1));
+ } else {
+ painter->drawLine(header->rect.bottomRight(),
+ header->rect.topRight());
+ painter->drawLine(header->rect.topLeft(),
+ header->rect.topRight());
+ painter->drawLine(header->rect.bottomLeft(),
+ header->rect.bottomRight());
+ painter->setPen(option->palette.color(QPalette::Base));
+ painter->drawLine(header->rect.bottomLeft() + QPoint(0, -1),
+ header->rect.topLeft() + QPoint(0, 1));
+ painter->drawLine(header->rect.topLeft() + QPoint(1, 1),
+ header->rect.topRight() + QPoint(-1, 1));
+ }
+ } else { // Vertical
+ if (header->position == QStyleOptionHeader::Beginning ||
+ header->position == QStyleOptionHeader::OnlyOneSection) {
+ painter->drawRect(header->rect.adjusted(0, 0, -1, -1));
+ painter->setPen(header->palette.color(QPalette::Base));
+ painter->drawLine(header->rect.bottomLeft() + QPoint(1, -1),
+ header->rect.topLeft() + QPoint(1, 1));
+ painter->drawLine(header->rect.topLeft() + QPoint(1, 1),
+ header->rect.topRight() + QPoint(-1, 1));
+ } else {
+ painter->drawLine(header->rect.bottomLeft(),
+ header->rect.bottomRight());
+ painter->drawLine(header->rect.topLeft(),
+ header->rect.bottomLeft());
+ painter->drawLine(header->rect.topRight(),
+ header->rect.bottomRight());
+ painter->setPen(header->palette.color(QPalette::Base));
+ painter->drawLine(header->rect.topLeft(),
+ header->rect.topRight() + QPoint(-1, 0));
+ painter->drawLine(header->rect.bottomLeft() + QPoint(1, -1),
+ header->rect.topLeft() + QPoint(1, 0));
+ }
+ }
+ break;
+ }
+ case CE_ToolBar: {
+ QRect rect = option->rect;
+
+ QLinearGradient gradient(rect.topLeft(), rect.bottomLeft());
+ gradient.setColorAt(1.0, QColor(221, 221, 221));
+ gradient.setColorAt(0.0, QColor(241, 241, 241));
+
+ if (option->state & State_Horizontal) {
+ painter->setPen(QColor(204, 204, 204));
+ painter->setBrush(gradient);
+ } else {
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(option->palette.color(QPalette::Background));
+ }
+ painter->drawRect(rect.adjusted(0, 0, -1, -1));
+ break;
+ }
+ case CE_ProgressBar: {
+ const QStyleOptionProgressBar *bar1 =
+ qstyleoption_cast<const QStyleOptionProgressBar *>(option);
+
+ QStyleOptionProgressBarV2 *bar = new QStyleOptionProgressBarV2(*bar1);
+
+ QRect rect = bar->rect;
+ if (bar->orientation == Qt::Vertical) {
+ rect = QRect(rect.left(), rect.top(), rect.height(), rect.width());
+ QMatrix m;
+ m.translate(rect.height()-1, 0);
+ m.rotate(90.0);
+ painter->setMatrix(m);
+ }
+
+ painter->setPen(bar->palette.color(QPalette::Mid));
+ painter->drawRect(rect.adjusted(0, 0, -1, -1));
+
+ QRect grooveRect = subElementRect(SE_ProgressBarGroove, bar,
+ widget);
+ if (bar->orientation == Qt::Vertical) {
+ grooveRect = QRect(grooveRect.left(), grooveRect.top(),
+ grooveRect.height(), grooveRect.width());
+ }
+
+ QStyleOptionProgressBar grooveBar = *bar;
+ grooveBar.rect = grooveRect;
+
+ drawControl(CE_ProgressBarGroove, &grooveBar, painter, widget);
+
+ QRect progressRect = subElementRect(SE_ProgressBarContents, bar,
+ widget);
+ if (bar->orientation == Qt::Vertical) {
+ progressRect = QRect(progressRect.left(), progressRect.top(),
+ progressRect.height(), progressRect.width());
+ progressRect.adjust(0, 0, 0, -1);
+ }
+ QStyleOptionProgressBar progressOpt = *bar;
+ progressOpt.rect = progressRect;
+ drawControl(CE_ProgressBarContents, &progressOpt, painter, widget);
+
+ QRect labelRect = subElementRect(SE_ProgressBarLabel, bar, widget);
+ if (bar->orientation == Qt::Vertical) {
+ labelRect = QRect(labelRect.left(), labelRect.top(),
+ labelRect.height(), labelRect.width());
+ }
+ QStyleOptionProgressBar subBar = *bar;
+ subBar.rect = labelRect;
+ if (bar->textVisible)
+ drawControl(CE_ProgressBarLabel, &subBar, painter, widget);
+
+ delete bar;
+ break;
+ }
+ case CE_ProgressBarGroove: {
+ painter->setBrush(option->palette.color(QPalette::Background));
+ painter->setPen(Qt::NoPen);
+ painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
+
+ painter->setPen(option->palette.color(QPalette::Button));
+ painter->drawLine(option->rect.topLeft() + QPoint(0, 0),
+ option->rect.topRight() + QPoint(0, 0));
+ break;
+ }
+ case CE_ProgressBarContents: {
+ const QStyleOptionProgressBar *bar =
+ qstyleoption_cast<const QStyleOptionProgressBar *>(option);
+ int progress = int((double(bar->progress) /
+ double(bar->maximum - bar->minimum)) *
+ bar->rect.width());
+
+ painter->setBrush(bar->palette.color(QPalette::Light));
+ painter->setPen(Qt::NoPen);
+ QRect progressRect = QRect(bar->rect.topLeft(), QPoint(progress,
+ bar->rect.bottom()));
+ painter->drawRect(progressRect);
+
+ painter->setPen(bar->palette.color(QPalette::Midlight));
+ painter->setBrush(Qt::NoBrush);
+
+ painter->drawLine(bar->rect.bottomLeft(), bar->rect.topLeft());
+ painter->drawLine(bar->rect.topLeft(), QPoint(progress,
+ bar->rect.top()));
+ break;
+ }
+ case CE_ProgressBarLabel: {
+ painter->save();
+ const QStyleOptionProgressBar *bar =
+ qstyleoption_cast<const QStyleOptionProgressBar *>(option);
+
+ QRect rect = bar->rect;
+ QRect leftRect;
+
+ int progressIndicatorPos = int((double(bar->progress) /
+ double(bar->maximum - bar->minimum)) *
+ bar->rect.width());
+
+ QFont font;
+ font.setBold(true);
+ painter->setFont(font);
+ painter->setPen(bar->palette.color(QPalette::Midlight));
+
+ if (progressIndicatorPos >= 0 &&
+ progressIndicatorPos <= rect.width()) {
+ leftRect = QRect(bar->rect.topLeft(),
+ QPoint(progressIndicatorPos,
+ bar->rect.bottom()));
+ } else if (progressIndicatorPos > rect.width()) {
+ painter->setPen(bar->palette.color(QPalette::Base));
+ } else {
+ painter->setPen(bar->palette.color(QPalette::Midlight));
+ }
+
+ QRect textRect = QFontMetrics(font).boundingRect(bar->text);
+ textRect.moveCenter(option->rect.center());
+ painter->drawText(textRect, bar->text,
+ QTextOption(Qt::AlignCenter));
+ if (!leftRect.isNull()) {
+ painter->setPen(bar->palette.color(QPalette::Base));
+ painter->setClipRect(leftRect, Qt::IntersectClip);
+ painter->drawText(textRect, bar->text,
+ QTextOption(Qt::AlignCenter));
+ }
+
+ painter->restore();
+ break;
+ }
+ case CE_MenuBarEmptyArea: {
+ QRect emptyArea = option->rect.adjusted(0, 0, -1, -1);
+ QLinearGradient gradient(emptyArea.topLeft(), emptyArea.bottomLeft()
+ - QPoint(0, 1));
+ gradient.setColorAt(0.0, option->palette.color(QPalette::Base));
+ gradient.setColorAt(1.0, QColor(223, 223, 223));
+
+ painter->setPen(QColor(238, 238, 238));
+ painter->setBrush(gradient);
+ painter->drawRect(emptyArea.adjusted(0, 0, 0, -1));
+ break;
+ }
+ case CE_MenuBarItem: {
+ if (!(option->state & State_Sunken)) {
+ QLinearGradient gradient(option->rect.topLeft(),
+ option->rect.bottomLeft());
+ gradient.setColorAt(0.0, Qt::white);
+ gradient.setColorAt(1.0, QColor(223, 223, 223));
+
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(gradient);
+ } else {
+ painter->setBrush(option->palette.color(QPalette::Light));
+ }
+
+ painter->drawRect(option->rect);
+ if (option->state & State_Sunken) {
+ painter->setPen(option->palette.color(QPalette::Mid));
+ painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
+ painter->setPen(option->palette.color(QPalette::Base));
+ painter->setBrush(Qt::NoBrush);
+ painter->drawLine(option->rect.bottomRight() + QPoint(0, -1),
+ option->rect.topRight() + QPoint(0, -1));
+ }
+ QCommonStyle::drawControl(control, option, painter, widget);
+ break;
+ }
+ case CE_MenuItem: {
+ const QStyleOptionMenuItem *menuItem =
+ qstyleoption_cast<const QStyleOptionMenuItem *>(option);
+
+ bool selected = menuItem->state & State_Selected;
+ bool checkable = menuItem->checkType !=
+ QStyleOptionMenuItem::NotCheckable;
+ bool checked = menuItem->checked;
+
+ if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
+ QPoint center = menuItem->rect.center();
+
+ painter->setPen(menuItem->palette.color(QPalette::Midlight));
+ painter->drawLine(QPoint(menuItem->rect.left() - 2, center.y()),
+ QPoint(menuItem->rect.right(), center.y()));
+ painter->setPen(menuItem->palette.color(QPalette::Base));
+ painter->drawLine(QPoint(menuItem->rect.left() - 2,
+ center.y() + 1),
+ QPoint(menuItem->rect.right(),
+ center.y() + 1));
+
+ break;
+ }
+
+ if (selected) {
+ painter->setBrush(menuItem->palette.color(QPalette::Light));
+ painter->setPen(Qt::NoPen);
+ painter->drawRect(menuItem->rect);
+ painter->setPen(menuItem->palette.color(QPalette::Midlight));
+ painter->drawLine(menuItem->rect.topLeft(),
+ menuItem->rect.topRight());
+ painter->setPen(menuItem->palette.color(QPalette::Base));
+ painter->drawLine(menuItem->rect.bottomLeft(),
+ menuItem->rect.bottomRight());
+ }
+
+ if (checkable) {
+ QRect checkRect(option->rect.left() + 5,
+ option->rect.center().y() - 5, 10, 10);
+ if (menuItem->checkType & QStyleOptionMenuItem::Exclusive) {
+ QStyleOptionButton button;
+ button.rect = checkRect;
+ button.state = menuItem->state;
+ if (button.state & State_Sunken)
+ button.state ^= State_Sunken;
+ if (checked)
+ button.state |= State_On;
+ button.palette = menuItem->palette;
+ drawPrimitive(PE_IndicatorRadioButton, &button, painter,
+ widget);
+ } else {
+ QBrush buttonBrush = gradientBrush(option->rect);
+ painter->setBrush(buttonBrush);
+ painter->setPen(option->palette.color(QPalette::Mid));
+
+ painter->drawRect(checkRect);
+
+ if (checked) {
+ QImage image(":/images/checkboxchecked.png");
+ painter->drawImage(QPoint(option->rect.left() + 5,
+ option->rect.center().y() - 8), image);
+ }
+ }
+ }
+
+ bool dis = !(menuItem->state & State_Enabled);
+ bool act = menuItem->state & State_Selected;
+ const QStyleOption *opt = option;
+ const QStyleOptionMenuItem *menuitem = menuItem;
+ int checkcol = qMax(menuitem->maxIconWidth, 20);
+ if (menuItem->icon.isNull())
+ checkcol = 0;
+
+ QPainter *p = painter;
+ QRect vCheckRect = visualRect(opt->direction, menuitem->rect,
+ QRect(menuitem->rect.x(),
+ menuitem->rect.y(),
+ checkcol, menuitem->rect.height()));
+ if (!menuItem->icon.isNull()) {
+ QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
+ if (act && !dis)
+ mode = QIcon::Active;
+ QPixmap pixmap;
+ if (checked)
+ pixmap = menuItem->icon.pixmap(
+ pixelMetric(PM_SmallIconSize), mode, QIcon::On);
+ else
+ pixmap = menuItem->icon.pixmap(
+ pixelMetric(PM_SmallIconSize), mode);
+ int pixw = pixmap.width();
+ int pixh = pixmap.height();
+
+ int adjustedIcon = checkable ? 15 : 0;
+ QRect pmr(0, 0, pixw, pixh);
+ pmr.moveCenter(vCheckRect.center());
+ painter->setPen(menuItem->palette.text().color());
+ if (checkable && checked)
+ painter->drawPixmap(QPoint(pmr.left() +
+ adjustedIcon, pmr.top() + 1), pixmap);
+ else
+ painter->drawPixmap(pmr.topLeft() +
+ QPoint(adjustedIcon, 0), pixmap);
+ }
+
+ if (selected) {
+ painter->setPen(menuItem->palette.highlightedText().color());
+ } else {
+ painter->setPen(menuItem->palette.text().color());
+ }
+ int x, y, w, h;
+ menuitem->rect.getRect(&x, &y, &w, &h);
+ int tab = menuitem->tabWidth;
+ QColor discol;
+ if (dis) {
+ discol = menuitem->palette.text().color();
+ p->setPen(discol);
+ }
+ int xm = windowsItemFrame + checkcol + windowsItemHMargin;
+ int xpos = menuitem->rect.x() + xm;
+ QRect textRect;
+ if (!menuItem->icon.isNull())
+ textRect.setRect(xpos, y + windowsItemVMargin, w - xm -
+ windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin);
+ else
+ textRect.setRect(menuItem->rect.left() + 9,
+ y + windowsItemVMargin,
+ w - xm - windowsRightBorder - tab,
+ h - 2 * windowsItemVMargin);
+
+ if (checkable)
+ textRect.adjust(10, 0, 10, 0);
+
+ QRect vTextRect = visualRect(opt->direction, menuitem->rect,
+ textRect);
+ QString s = menuitem->text;
+ if (!s.isEmpty()) {
+ int t = s.indexOf(QLatin1Char('\t'));
+ int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic |
+ Qt::TextDontClip | Qt::TextSingleLine;
+ if (!styleHint(SH_UnderlineShortcut, menuitem, widget))
+ text_flags |= Qt::TextHideMnemonic;
+ text_flags |= Qt::AlignLeft;
+ if (t >= 0) {
+ QRect vShortcutRect = visualRect(opt->direction,
+ menuitem->rect,
+ QRect(textRect.topRight(),
+ QPoint(menuitem->rect.right(), textRect.bottom())));
+ if (dis && !act) {
+ p->setPen(menuitem->palette.light().color());
+ p->drawText(vShortcutRect.adjusted(1, 1, 1, 1),
+ text_flags,
+ s.mid(t + 1));
+ p->setPen(discol);
+ }
+ p->drawText(vShortcutRect, text_flags, s.mid(t + 1));
+ s = s.left(t);
+ }
+ QFont font = menuitem->font;
+ if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
+ font.setBold(true);
+ p->setFont(font);
+ if (dis && !act) {
+ p->setPen(menuitem->palette.light().color());
+ p->drawText(vTextRect.adjusted(1,1,1,1), text_flags,
+ s.left(t));
+ p->setPen(discol);
+ }
+ p->drawText(vTextRect, text_flags, s.left(t));
+ }
+
+ if (menuItem->menuItemType & QStyleOptionMenuItem::SubMenu) {
+ QPoint center = menuItem->rect.center();
+ QPoint drawStart(menuItem->rect.right() - 6, center.y() + 4);
+
+ QPainterPath arrow;
+ arrow.moveTo(drawStart);
+ arrow.lineTo(drawStart + QPoint(0, -8));
+ arrow.lineTo(drawStart + QPoint(4, -5));
+ arrow.lineTo(drawStart + QPoint(4, -4));
+ arrow.lineTo(drawStart + QPoint(0, 0));
+
+ painter->save();
+ painter->setBrush(menuItem->palette.color(QPalette::Text));
+ painter->setPen(Qt::NoPen);
+ painter->drawPath(arrow);
+ painter->restore();
+ }
+
+ break;
+ }
+ case CE_MenuVMargin: {
+ break;
+ }
+ case CE_MenuHMargin: {
+ break;
+ }
+ case CE_Splitter: {
+ drawSplitter(option, painter, option->state & State_Horizontal);
+ break;
+ }
+ case CE_ScrollBarAddPage: {
+ case CE_ScrollBarSubPage:
+ const QStyleOptionSlider *scrollBar =
+ qstyleoption_cast<const QStyleOptionSlider *>(option);
+ QRect myRect;
+ if (scrollBar->orientation == Qt::Horizontal) {
+ myRect = QRect(option->rect.topLeft(),
+ option->rect.bottomRight()).adjusted(0, 0, 1, -1);
+ } else {
+ myRect = option->rect;
+ }
+
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(option->palette.color(QPalette::Background));
+ painter->drawRect(myRect);
+
+ painter->setBrush(Qt::NoBrush);
+ painter->setPen(scrollBar->palette.color(QPalette::Mid));
+ painter->drawRect(myRect.adjusted(0, 0, -1, 0));
+ painter->setPen(scrollBar->palette.color(QPalette::Button));
+ painter->drawLine(myRect.bottomLeft() + QPoint(1, 0),
+ myRect.topLeft() + QPoint(1, 1));
+ painter->drawLine(myRect.topLeft() + QPoint(1, 1),
+ myRect.topRight() + QPoint(-1, 1));
+ break;
+ }
+ case CE_ScrollBarSubLine: {
+ const QStyleOptionSlider *scrollBar =
+ qstyleoption_cast<const QStyleOptionSlider *>(option);
+ int scrollBarExtent = pixelMetric(PM_ScrollBarExtent);
+ QRect scrollBarSubLine = option->rect;
+
+ QRect button1;
+ QRect button2;
+
+ if (scrollBar->orientation == Qt::Horizontal) {
+ button1.setRect(scrollBarSubLine.left(), scrollBarSubLine.top(),
+ 16, scrollBarExtent);
+ button2.setRect(scrollBarSubLine.right() - 15,
+ scrollBarSubLine.top(), 16, scrollBarExtent);
+ } else {
+ button1.setRect(scrollBarSubLine.left(), scrollBarSubLine.top(),
+ scrollBarExtent, 16);
+ button2.setRect(scrollBarSubLine.left(),
+ scrollBarSubLine.bottom() - 15, scrollBarExtent, 16);
+ }
+
+ painter->fillRect(button2, Qt::blue);
+
+ drawScrollBarArrow(button1, painter, scrollBar);
+ drawScrollBarArrow(button2, painter, scrollBar);
+ break;
+ }
+ case CE_ScrollBarAddLine: {
+ const QStyleOptionSlider *scrollBar =
+ qstyleoption_cast<const QStyleOptionSlider *>(option);
+ QRect button(option->rect.left(), option->rect.top(), 16, 16);
+ drawScrollBarArrow(button, painter, scrollBar, true);
+ break;
+ }
+ case CE_ScrollBarSlider: {
+ const QStyleOptionSlider *scrollBar =
+ qstyleoption_cast<const QStyleOptionSlider *>(option);
+
+ painter->setPen(scrollBar->palette.color(QPalette::Midlight));
+ painter->drawRect(scrollBar->rect.adjusted(-1, 0, -3, -1));
+
+ QPoint g1, g2;
+ if (scrollBar->orientation == Qt::Horizontal) {
+ g1 = option->rect.topLeft();
+ g2 = option->rect.bottomLeft();
+ } else {
+ g1 = option->rect.topLeft();
+ g2 = option->rect.topRight();
+ }
+
+ if (scrollBar->state & State_Enabled) {
+ QLinearGradient gradient(g1, g2);
+ gradient.setColorAt(1.0, QColor(188, 210, 230));
+ gradient.setColorAt(0.3, Qt::white);
+ gradient.setColorAt(0.0, QColor(223, 233, 243));
+ painter->setBrush(gradient);
+ } else {
+ painter->setPen(scrollBar->palette.buttonText().color());
+ painter->setBrush(scrollBar->palette.button());
+ }
+ painter->drawRect(scrollBar->rect.adjusted(0, 0, -1, -1));
+
+ int sliderLength = option->rect.height();
+ int drawPos = scrollBar->orientation == Qt::Vertical ?
+ (sliderLength / 2) + 1 : 1 - ((option->rect.width() / 2));
+
+ QPoint origin;
+ if (scrollBar->orientation == Qt::Vertical)
+ origin = option->rect.bottomLeft();
+ else
+ origin = option->rect.topLeft();
+
+ painter->setPen(scrollBar->palette.color(QPalette::Base));
+ painter->drawLine(origin + adjustScrollHandlePoint(
+ scrollBar->orientation,
+ QPoint(4, -drawPos)),
+ origin + adjustScrollHandlePoint(
+ scrollBar->orientation,
+ QPoint(13, -drawPos)));
+ painter->drawLine(origin + adjustScrollHandlePoint(
+ scrollBar->orientation,
+ QPoint(4, 2 - drawPos)),
+ origin + adjustScrollHandlePoint(
+ scrollBar->orientation,
+ QPoint(13, 2 - drawPos)));
+ painter->drawLine(origin + adjustScrollHandlePoint(
+ scrollBar->orientation,
+ QPoint(4, 4 - drawPos)),
+ origin + adjustScrollHandlePoint(
+ scrollBar->orientation,
+ QPoint(13, 4 - drawPos)));
+
+ painter->setPen(option->palette.color(QPalette::Midlight));
+ painter->drawLine(origin + adjustScrollHandlePoint(
+ scrollBar->orientation,
+ QPoint(3, -(drawPos + 1))),
+ origin + adjustScrollHandlePoint(
+ scrollBar->orientation,
+ QPoint(12, -(drawPos + 1))));
+ painter->drawLine(origin + adjustScrollHandlePoint(
+ scrollBar->orientation,
+ QPoint(3, 1 - drawPos)),
+ origin + adjustScrollHandlePoint(
+ scrollBar->orientation,
+ QPoint(12, 1 - drawPos)));
+ painter->drawLine(origin + adjustScrollHandlePoint(
+ scrollBar->orientation,
+ QPoint(3, 3 - drawPos)),
+ origin + adjustScrollHandlePoint(
+ scrollBar->orientation,
+ QPoint(12, 3 - drawPos)));
+
+ break;
+ }
+ case CE_TabBarTabLabel: {
+ QStyleOptionTab copy =
+ *qstyleoption_cast<const QStyleOptionTab *>(option);
+ if (copy.state & State_HasFocus)
+ copy.state ^= State_HasFocus;
+ painter->setBrush(Qt::NoBrush);
+ QWindowsStyle::drawControl(CE_TabBarTabLabel, &copy, painter,
+ widget);
+ break;
+ }
+ case CE_TabBarTabShape: {
+ const QStyleOptionTab *tab =
+ qstyleoption_cast<const QStyleOptionTab *>(option);
+ QRect myRect = option->rect;
+ QPoint bottomLeft, bottomRight, topLeft, topRight;
+
+ if ((tab->position == QStyleOptionTab::Beginning) ||
+ (tab->position == QStyleOptionTab::OnlyOneTab)) {
+ if (tab->shape == QTabBar::RoundedSouth ||
+ tab->shape == QTabBar::RoundedNorth) {
+ myRect = myRect.adjusted(2, 0, 0, 0);
+ } else {
+ myRect = myRect.adjusted(0, 2, 0, 0);
+ }
+ }
+
+ switch (tab->shape) {
+ case QTabBar::RoundedNorth:
+ topLeft = myRect.topLeft();
+ topRight = myRect.topRight();
+ bottomLeft = myRect.bottomLeft();
+ bottomRight = myRect.bottomRight();
+ break;
+ case QTabBar::RoundedSouth:
+ topLeft = myRect.bottomLeft();
+ topRight = myRect.bottomRight();
+ bottomLeft = myRect.topLeft();
+ bottomRight = myRect.topRight();
+ break;
+ case QTabBar::RoundedWest:
+ topLeft = myRect.topLeft();
+ topRight = myRect.bottomLeft();
+ bottomLeft = myRect.topRight();
+ bottomRight = myRect.bottomRight();
+ break;
+ case QTabBar::RoundedEast:
+ topLeft = myRect.topRight();
+ topRight = myRect.bottomRight();
+ bottomLeft = myRect.topLeft();
+ bottomRight = myRect.bottomLeft();
+ break;
+ default:
+ ;
+ }
+
+ QPainterPath outerPath;
+ outerPath.moveTo(bottomLeft + adjustTabPoint(QPoint(0, -2),
+ tab->shape));
+ outerPath.lineTo(bottomLeft + adjustTabPoint(QPoint(0, -14),
+ tab->shape));
+ outerPath.lineTo(topLeft + adjustTabPoint(QPoint(6 , 0),
+ tab->shape));
+ outerPath.lineTo(topRight + adjustTabPoint(QPoint(0, 0),
+ tab->shape));
+ outerPath.lineTo(bottomRight + adjustTabPoint(QPoint(0, -2),
+ tab->shape));
+
+ if (tab->state & State_Selected ||
+ tab->position == QStyleOptionTab::OnlyOneTab) {
+ QPainterPath innerPath;
+ innerPath.moveTo(topLeft + adjustTabPoint(QPoint(6, 2),
+ tab->shape));
+ innerPath.lineTo(topRight + adjustTabPoint(QPoint(-1, 2),
+ tab->shape));
+ innerPath.lineTo(bottomRight + adjustTabPoint(QPoint(-1 , -2),
+ tab->shape));
+ innerPath.lineTo(bottomLeft + adjustTabPoint(QPoint(2 , -2),
+ tab->shape));
+ innerPath.lineTo(bottomLeft + adjustTabPoint(QPoint(2 , -14),
+ tab->shape));
+ innerPath.lineTo(topLeft + adjustTabPoint(QPoint(6, 2),
+ tab->shape));
+
+ QPainterPath whitePath;
+ whitePath.moveTo(bottomLeft + adjustTabPoint(QPoint(1, -2),
+ tab->shape));
+ whitePath.lineTo(bottomLeft + adjustTabPoint(QPoint(1, -14),
+ tab->shape));
+ whitePath.lineTo(topLeft + adjustTabPoint(QPoint(6, 1),
+ tab->shape));
+ whitePath.lineTo(topRight + adjustTabPoint(QPoint(-1, 1),
+ tab->shape));
+
+ painter->setPen(tab->palette.color(QPalette::Midlight));
+ painter->setBrush(QColor(200, 221, 242));
+ painter->drawPath(outerPath);
+ painter->setPen(QColor(200, 221, 242));
+ painter->drawRect(QRect(bottomLeft + adjustTabPoint(
+ QPoint(2, -3), tab->shape),
+ bottomRight + adjustTabPoint(
+ QPoint(-2, 0), tab->shape)));
+ painter->setPen(tab->palette.color(QPalette::Base));
+ painter->setBrush(Qt::NoBrush);
+ painter->drawPath(whitePath);
+
+ if (option->state & State_HasFocus) {
+ painter->setPen(option->palette.color(QPalette::Mid));
+ painter->drawPath(innerPath);
+ }
+ } else {
+ painter->setPen(tab->palette.color(QPalette::Mid));
+ painter->drawPath(outerPath);
+ }
+ break;
+ }
+ case CE_PushButtonLabel:
+ painter->save();
+
+ if (const QStyleOptionButton *button =
+ qstyleoption_cast<const QStyleOptionButton *>(option)) {
+ QRect ir = button->rect;
+ uint tf = Qt::AlignVCenter | Qt::TextShowMnemonic;
+ if (!styleHint(SH_UnderlineShortcut, button, widget))
+ tf |= Qt::TextHideMnemonic;
+
+ if (!button->icon.isNull()) {
+ QPoint point;
+
+ QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal
+ : QIcon::Disabled;
+ if (mode == QIcon::Normal && button->state & State_HasFocus)
+ mode = QIcon::Active;
+ QIcon::State state = QIcon::Off;
+ if (button->state & State_On)
+ state = QIcon::On;
+
+ QPixmap pixmap = button->icon.pixmap(button->iconSize, mode,
+ state);
+ int w = pixmap.width();
+ int h = pixmap.height();
+
+ if (!button->text.isEmpty())
+ w += button->fontMetrics.width(button->text) + 2;
+
+ point = QPoint(ir.x() + ir.width() / 2 - w / 2,
+ ir.y() + ir.height() / 2 - h / 2);
+
+ if (button->direction == Qt::RightToLeft)
+ point.rx() += pixmap.width();
+
+ painter->drawPixmap(visualPos(button->direction, button->rect,
+ point), pixmap);
+
+ if (button->direction == Qt::RightToLeft)
+ ir.translate(-point.x() - 2, 0);
+ else
+ ir.translate(point.x() + pixmap.width(), 0);
+
+ if (!button->text.isEmpty())
+ tf |= Qt::AlignLeft;
+
+ } else {
+ tf |= Qt::AlignHCenter;
+ }
+
+ if (button->fontMetrics.height() > 14)
+ ir.translate(0, 1);
+
+ drawItemText(painter, ir, tf, button->palette, (button->state &
+ State_Enabled),
+ button->text, QPalette::ButtonText);
+ }
+
+ painter->restore();
+ break;
+
+ default:
+ QWindowsStyle::drawControl(control, option, painter, widget);
+ }
+ painter->restore();
+}
+
+inline QPoint JavaStyle::adjustTabPoint(const QPoint &point,
+ QTabBar::Shape shape) const
+{
+ QPoint rPoint;
+
+ switch (shape) {
+ case QTabBar::RoundedWest:
+ rPoint = QPoint(point.y(), point.x());
+ break;
+ case QTabBar::RoundedSouth:
+ rPoint = QPoint(point.x(), point.y() * -1);
+ break;
+ case QTabBar::RoundedEast:
+ rPoint = QPoint(point.y() * -1, point.x());
+ break;
+ default:
+ rPoint = point;
+ }
+ return rPoint;
+}
+
+QRect JavaStyle::subControlRect(ComplexControl control,
+ const QStyleOptionComplex *option,
+ SubControl subControl,
+ const QWidget *widget) const
+{
+ QRect rect = QWindowsStyle::subControlRect(control, option, subControl,
+ widget);
+
+ switch (control) {
+ case CC_TitleBar: {
+ const QStyleOptionTitleBar *bar =
+ qstyleoption_cast<const QStyleOptionTitleBar *>(option);
+
+ switch (subControl) {
+ case SC_TitleBarMinButton: {
+ rect = QRect(bar->rect.topRight() + QPoint(-68, 2),
+ QSize(15, 15));
+ break;
+ }
+ case SC_TitleBarMaxButton: {
+ rect = QRect(bar->rect.topRight() + QPoint(-43, 3),
+ QSize(15, 15));
+ break;
+ }
+ case SC_TitleBarCloseButton: {
+ rect = QRect(bar->rect.topRight() + QPoint(-18, 3),
+ QSize(15, 15));
+ break;
+ }
+ case SC_TitleBarLabel: {
+ QRect labelRect = bar->fontMetrics.boundingRect(bar->text);
+ rect = labelRect;
+ rect.translate(bar->rect.left() + 30, 0);
+ rect.moveTop(bar->rect.top());
+ rect.adjust(0, 2, 2, 2);
+ break;
+ }
+ case SC_TitleBarSysMenu: {
+ rect = QRect(bar->rect.topLeft() + QPoint(6, 3),
+ QSize(16, 16));
+ break;
+ }
+ default:
+ ;
+ }
+ break;
+ }
+ case CC_GroupBox: {
+ const QStyleOptionGroupBox *box =
+ qstyleoption_cast<const QStyleOptionGroupBox *>(option);
+ bool hasCheckbox = box->subControls & SC_GroupBoxCheckBox;
+ int checkAdjust = 13;
+
+ QRect textRect = box->fontMetrics.boundingRect(box->text);
+
+ switch (subControl) {
+ case SC_GroupBoxFrame: {
+ rect = box->rect;
+ break;
+ }
+ case SC_GroupBoxCheckBox: {
+ if (hasCheckbox) {
+ rect = QRect(box->rect.topLeft() + QPoint(7, 4 +
+ (textRect.height() / 2 - checkAdjust / 2)),
+ QSize(checkAdjust, checkAdjust));
+ }
+ else {
+ rect = QRect();
+ }
+ break;
+ }
+ case SC_GroupBoxLabel: {
+ rect = QRect(box->rect.topLeft() + QPoint(7 + (hasCheckbox ?
+ checkAdjust + 2 : 0), 4), textRect.size());
+ break;
+ }
+ case SC_GroupBoxContents: {
+ rect = box->rect.adjusted(10, 10 + textRect.height(), -10,
+ -10);
+ break;
+ }
+ default:
+ ;
+ }
+ break;
+ }
+ case CC_SpinBox: {
+ const QStyleOptionSpinBox *spinBox =
+ qstyleoption_cast<const QStyleOptionSpinBox *>(option);
+ int spinnerWidth = 16;
+ QRect myRect = spinBox->rect;
+ QPoint center = myRect.center();
+ int frameWidth = pixelMetric(PM_SpinBoxFrameWidth, spinBox, widget);
+
+ switch (subControl) {
+ case SC_SpinBoxUp: {
+ rect = QRect(myRect.topRight() + QPoint(-16, 0),
+ QSize(16, center.y() - myRect.topRight().y()));
+ break;
+ }
+ case SC_SpinBoxDown: {
+ rect = QRect(QPoint(myRect.bottomRight().x() - 16,
+ center.y() + 1),
+ QSize(16, myRect.bottomRight().y() -
+ center.y() - 1));
+ break;
+ }
+ case SC_SpinBoxFrame: {
+ rect = QRect(myRect.topLeft(), myRect.bottomRight() +
+ QPoint(-16, 0));
+ break;
+ }
+ case SC_SpinBoxEditField: {
+ rect = QRect(myRect.topLeft() + QPoint(2, 2),
+ myRect.bottomRight() + QPoint(-15 - frameWidth, -2));
+ break;
+ }
+ default:
+ ;
+ }
+ break;
+ }
+ case CC_ToolButton: {
+ const QStyleOptionToolButton *button =
+ qstyleoption_cast<const QStyleOptionToolButton *>(option);
+
+ switch (subControl) {
+ case SC_ToolButton: {
+ rect = option->rect.adjusted(1, 1, -1, -1);
+ break;
+ }
+ case SC_ToolButtonMenu: {
+ rect = QRect(option->rect.bottomRight() +
+ QPoint(-11, -11), QSize(10, 10));
+ break;
+ }
+ }
+ break;
+ }
+ case CC_ComboBox: {
+ const QStyleOptionComboBox *combo =
+ qstyleoption_cast<const QStyleOptionComboBox *>(option);
+
+ bool reverse = combo->direction == Qt::RightToLeft;
+
+ switch (subControl) {
+ case SC_ComboBoxFrame:
+ rect = combo->rect;
+ break;
+ case SC_ComboBoxArrow:
+ if (reverse) {
+ rect = QRect(combo->rect.topLeft(),
+ combo->rect.bottomLeft() + QPoint(17, 0));
+ } else {
+ rect = QRect(combo->rect.topRight() + QPoint(-17, 0),
+ combo->rect.bottomRight());
+ }
+ break;
+ case SC_ComboBoxEditField:
+ if (reverse) {
+ rect = QRect(combo->rect.topLeft() + QPoint(19, 2),
+ combo->rect.bottomRight() + QPoint(-2, 2));
+ } else {
+ rect = QRect(combo->rect.topLeft() + QPoint(2, 2),
+ combo->rect.bottomRight() + QPoint(-19, -2));
+ }
+ break;
+ case SC_ComboBoxListBoxPopup:
+ rect = combo->rect;
+ break;
+ }
+ break;
+ }
+ case CC_ScrollBar: {
+ const QStyleOptionSlider *scrollBar =
+ qstyleoption_cast<const QStyleOptionSlider *>(option);
+ int scrollBarExtent = pixelMetric(PM_ScrollBarExtent, scrollBar,
+ widget);
+ int sliderMaxLength = ((scrollBar->orientation == Qt::Horizontal) ?
+ scrollBar->rect.width() :
+ scrollBar->rect.height()) - (16 * 3);
+ int sliderMinLength = pixelMetric(PM_ScrollBarSliderMin, scrollBar,
+ widget);
+ int sliderLength;
+
+ if (scrollBar->maximum != scrollBar->minimum) {
+ uint valueRange = scrollBar->maximum - scrollBar->minimum;
+ sliderLength = (scrollBar->pageStep * sliderMaxLength) /
+ (valueRange + scrollBar->pageStep);
+
+ if (sliderLength < sliderMinLength || valueRange > INT_MAX / 2)
+ sliderLength = sliderMinLength;
+ if (sliderLength > sliderMaxLength)
+ sliderLength = sliderMaxLength;
+ } else {
+ sliderLength = sliderMaxLength;
+ }
+ int sliderStart = 16 + sliderPositionFromValue(scrollBar->minimum,
+ scrollBar->maximum,
+ scrollBar->sliderPosition,
+ sliderMaxLength - sliderLength,
+ scrollBar->upsideDown);
+ QRect scrollBarRect = scrollBar->rect;
+
+ switch (subControl) {
+ case SC_ScrollBarSubLine:
+ if (scrollBar->orientation == Qt::Horizontal) {
+ rect.setRect(scrollBarRect.left(), scrollBarRect.top(),
+ scrollBarRect.width() - 16, scrollBarExtent);
+ } else {
+ rect.setRect(scrollBarRect.left(), scrollBarRect.top(),
+ scrollBarExtent, scrollBarRect.height() - 16);
+ }
+ break;
+ case SC_ScrollBarAddLine:
+ if (scrollBar->orientation == Qt::Horizontal) {
+ rect.setRect(scrollBarRect.right() - 15,
+ scrollBarRect.top(), 16, scrollBarExtent);
+ } else {
+ rect.setRect(scrollBarRect.left(), scrollBarRect.bottom()
+ - 15, scrollBarExtent, 16);
+ }
+ break;
+ case SC_ScrollBarSubPage:
+ if (scrollBar->orientation == Qt::Horizontal) {
+ rect.setRect(scrollBarRect.left() + 16, scrollBarRect.top(),
+ sliderStart - (scrollBarRect.left() + 16),
+ scrollBarExtent);
+ } else {
+ rect.setRect(scrollBarRect.left(), scrollBarRect.top() + 16,
+ scrollBarExtent,
+ sliderStart - (scrollBarRect.left() + 16));
+ }
+ break;
+ case SC_ScrollBarAddPage:
+ if (scrollBar->orientation == Qt::Horizontal)
+ rect.setRect(sliderStart + sliderLength, 0,
+ sliderMaxLength - sliderStart -
+ sliderLength + 16, scrollBarExtent);
+ else
+ rect.setRect(0, sliderStart + sliderLength,
+ scrollBarExtent, sliderMaxLength -
+ sliderStart - sliderLength + 16);
+ break;
+ case SC_ScrollBarGroove:
+ if (scrollBar->orientation == Qt::Horizontal) {
+ rect = scrollBarRect.adjusted(16, 0, -32, 0);
+ } else {
+ rect = scrollBarRect.adjusted(0, 16, 0, -32);
+ }
+ break;
+ case SC_ScrollBarSlider:
+ if (scrollBar->orientation == Qt::Horizontal) {
+ rect.setRect(sliderStart, 0, sliderLength,
+ scrollBarExtent);
+ } else {
+ rect.setRect(0, sliderStart, scrollBarExtent,
+ sliderLength);
+ }
+ break;
+ default:
+ return QWindowsStyle::subControlRect(control, option,
+ subControl, widget);
+ }
+ break;
+ }
+ case CC_Slider: {
+ const QStyleOptionSlider *slider =
+ qstyleoption_cast<const QStyleOptionSlider *>(option);
+ rect = slider->rect;
+ int tickSize = pixelMetric(PM_SliderTickmarkOffset, option, widget);
+ int handleSize = pixelMetric(PM_SliderControlThickness, option,
+ widget);
+
+ int dist = slider->orientation == Qt::Vertical ? slider->rect.height() :
+ slider->rect.width();
+ int pos = QStyle::sliderPositionFromValue(slider->minimum,
+ slider->maximum, slider->sliderValue, dist - handleSize);
+
+ switch (subControl) {
+ case SC_SliderGroove: {
+ QPoint center = rect.center();
+
+ if (slider->orientation == Qt::Horizontal) {
+ rect.setHeight(handleSize);
+ if (slider->tickPosition == QSlider::TicksBelow) {
+ center.ry() -= tickSize;
+ }
+ } else {
+ rect.adjust(0, 0, 0, 0);
+ rect.setWidth(handleSize);
+ if (slider->tickPosition == QSlider::TicksBelow) {
+ center.rx() -= tickSize;
+ }
+ }
+ rect.moveCenter(center);
+ break;
+ }
+ case SC_SliderHandle: {
+ QPoint center = rect.center();
+
+ if (slider->orientation == Qt::Horizontal) {
+ rect.setHeight(handleSize);
+ if (slider->tickPosition == QSlider::TicksBelow) {
+ center.ry() -= tickSize;
+ }
+
+ rect.moveCenter(center);
+
+ if (slider->upsideDown)
+ rect.setLeft(slider->rect.right() -
+ pos - (handleSize - 1));
+ else
+ rect.setLeft(pos);
+
+ rect.setWidth(handleSize - 1);
+ } else {
+ rect.setWidth(handleSize);
+ if (slider->tickPosition == QSlider::TicksBelow) {
+ center.rx() -= tickSize;
+ }
+
+ rect.moveCenter(center);
+
+ if (slider->upsideDown)
+ rect.setTop(slider->rect.bottom() -
+ ((pos + handleSize) - 2));
+ else
+ rect.setTop(slider->rect.top() + pos);
+
+ rect.setHeight(handleSize);
+ }
+ break;
+ }
+ case SC_SliderTickmarks: {
+ QPoint center = slider->rect.center();
+
+ if (slider->tickPosition & QSlider::TicksBelow) {
+ if (slider->orientation == Qt::Horizontal) {
+ rect.setHeight(tickSize);
+ center.ry() += tickSize / 2;
+ rect.adjust(6, 0, -10, 0);
+ } else {
+ rect.setWidth(tickSize);
+ center.rx() += tickSize / 2;
+ rect.adjust(0, 6, 0, -10);
+ }
+ } else {
+ rect = QRect();
+ }
+ rect.moveCenter(center);
+ break;
+ }
+ default:
+ ;
+ }
+ break;
+ }
+ default:
+ return QWindowsStyle::subControlRect(control, option, subControl,
+ widget);
+ }
+ return rect;
+}
+
+static const char * const sliderHandleImage[] = {
+ "15 16 7 1",
+ " c None",
+ "+ c #FFFFFF",
+ "@ c #FFFFFF",
+ "$ c #FFFFFF",
+ "( c #E5EDF5",
+ ") c #F2F6FA",
+ "[ c #FFFFFF",
+ " +++++++++++++ ",
+ "+@@@@@@@@@@@@@+",
+ "+@(((((((((((@+",
+ "+@(((((((((((@+",
+ "+@)))))))))))@+",
+ "+@[[[[[[[[[[[@+",
+ "+@[[[[[[[[[[[@+",
+ "+@)))))))))))@+",
+ "+@)))))))))))@+",
+ " +@)))))))))@+ ",
+ " +@(((((((@+ ",
+ " +@(((((@+ ",
+ " +@(((@+ ",
+ " +@(@+ ",
+ " +@+ ",
+ " + "};
+
+
+void JavaStyle::drawComplexControl(ComplexControl control,
+ const QStyleOptionComplex *option,
+ QPainter *painter,
+ const QWidget *widget) const
+{
+ painter->save();
+
+ switch (control) {
+ case CC_TitleBar: {
+ const QStyleOptionTitleBar *bar =
+ qstyleoption_cast<const QStyleOptionTitleBar *>(option);
+
+ bool sunken = bar->state & State_Sunken;
+
+ QLinearGradient gradient(bar->rect.bottomLeft(),
+ bar->rect.topLeft());
+ gradient.setColorAt(0.0, QColor(191, 212, 231));
+ gradient.setColorAt(0.7, Qt::white);
+ gradient.setColorAt(1.0, QColor(221, 232, 243));
+
+ painter->setPen(Qt::NoPen);
+ if (bar->titleBarState & State_Active) {
+ painter->setBrush(gradient);
+ }
+ else
+ painter->setBrush(bar->palette.color(QPalette::Active,
+ QPalette::Background));
+
+ painter->drawRect(bar->rect.adjusted(0, 0, -1, -1));
+
+ painter->setBrush(QColor(233, 233, 233));
+ painter->drawRect(QRect(bar->rect.bottomLeft() + QPoint(0, 1),
+ bar->rect.bottomRight() + QPoint(0, 2)));
+
+ QRect minButtonRect = subControlRect(control, bar,
+ SC_TitleBarMinButton);
+ QRect maxButtonRect = subControlRect(control, bar,
+ SC_TitleBarMaxButton);
+ QRect closeButtonRect = subControlRect(control, bar,
+ SC_TitleBarCloseButton);
+ QRect systemButtonRect = subControlRect(control, bar,
+ SC_TitleBarSysMenu);
+ QRect labelRect = subControlRect(control, bar, SC_TitleBarLabel);
+ QRect gripRect = QRect(QPoint(labelRect.right() + 5, bar->rect.top() + 5),
+ QPoint(minButtonRect.left() - 5,
+ bar->rect.bottom() - 4));
+
+ QColor textColor = option->palette.color(QPalette::Text);
+ painter->setPen(textColor);
+ painter->setBrush(Qt::NoBrush);
+
+ drawItemText(painter, labelRect, Qt::TextShowMnemonic |
+ Qt::AlignHCenter | Qt::AlignCenter,
+ bar->palette, bar->state & State_Enabled, bar->text,
+ textColor.isValid() ? QPalette::NoRole :
+ QPalette::WindowText);
+
+ for (int i = 0; i < gripRect.width(); ++i) {
+ painter->setPen(i % 2 ? bar->palette.color(QPalette::Midlight)
+ : Qt::white);
+
+ for (int j = 0; j < 4; ++j) {
+ painter->drawPoint(i + gripRect.left(),
+ gripRect.top() - 2 + i % 4 + 4 * j);
+ }
+ }
+
+ QPixmap maximizePixmap(":/images/internalmaximize.png");
+ QPixmap minimizePixmap(":/images/internalminimize.png");
+ QPixmap closePixmap(":/images/internalclose.png");
+ QPixmap internalPixmap(":/images/internalsystem.png");
+ QPixmap internalCloseDownPixmap(":/images/internalclosedown.png");
+ QPixmap minimizeDownPixmap(":/images/internalminimizedown.png");
+ QPixmap maximizeDownPixmap(":/images/internalmaximizedown.png");
+
+ if (bar->activeSubControls & SC_TitleBarCloseButton &&
+ bar->state & State_Sunken)
+ painter->drawPixmap(closeButtonRect.topLeft(),
+ internalCloseDownPixmap);
+ else
+ painter->drawPixmap(closeButtonRect.topLeft(), closePixmap);
+
+ if (bar->activeSubControls & SC_TitleBarMinButton &&
+ bar->state & State_Sunken)
+ painter->drawPixmap(minButtonRect.topLeft(),
+ minimizeDownPixmap);
+ else
+ painter->drawPixmap(minButtonRect.topLeft(), minimizePixmap);
+
+ if (bar->activeSubControls & SC_TitleBarMaxButton &&
+ bar->state & State_Sunken)
+ painter->drawPixmap(maxButtonRect.topLeft(),
+ maximizeDownPixmap);
+ else
+ painter->drawPixmap(maxButtonRect.topLeft(), maximizePixmap);
+
+ painter->drawPixmap(systemButtonRect.topLeft(), internalPixmap);
+
+ break;
+ }
+ case CC_GroupBox: {
+ const QStyleOptionGroupBox *box =
+ qstyleoption_cast<const QStyleOptionGroupBox *>(option);
+
+ QRect frameRect = subControlRect(control, box, SC_GroupBoxFrame);
+ QRect labelRect = subControlRect(control, box, SC_GroupBoxLabel);
+ QRect contentsRect = subControlRect(control, box,
+ SC_GroupBoxContents);
+ QRect checkerRect = subControlRect(control, box,
+ SC_GroupBoxCheckBox);
+
+ int y = labelRect.center().y();
+
+ painter->setPen(box->palette.color(QPalette::Button));
+ painter->drawRect(frameRect.adjusted(2, y - frameRect.top(), -2,
+ -2));
+
+ painter->setPen(box->palette.color(QPalette::Background));
+
+ if (box->subControls & SC_GroupBoxCheckBox) {
+ painter->drawLine(checkerRect.left() - 1, y,
+ checkerRect.right() + 2, y);
+ QStyleOptionButton checker;
+ checker.QStyleOption::operator=(*box);
+ checker.rect = checkerRect;
+ drawPrimitive(PE_IndicatorCheckBox, &checker, painter, widget);
+ }
+
+ if (box->subControls & SC_GroupBoxLabel && !box->text.isEmpty()) {
+ painter->drawLine(labelRect.left() - 1, y,
+ labelRect.right() +1, y);
+
+ QColor textColor = box->textColor;
+ if (textColor.isValid())
+ painter->setPen(textColor);
+
+ drawItemText(painter, labelRect, Qt::TextShowMnemonic |
+ Qt::AlignHCenter | int(box->textAlignment),
+ box->palette, box->state & State_Enabled,
+ box->text, textColor.isValid() ? QPalette::NoRole :
+ QPalette::WindowText);
+ }
+ break;
+ }
+ case CC_SpinBox: {
+ const QStyleOptionSpinBox *spinner =
+ qstyleoption_cast<const QStyleOptionSpinBox *>(option);
+
+ QRect frameRect = subControlRect(control, spinner, SC_SpinBoxFrame);
+ QRect upRect = subControlRect(control, spinner, SC_SpinBoxUp);
+ QRect downRect = subControlRect(control, spinner, SC_SpinBoxDown);
+
+ painter->setPen(Qt::white);
+ painter->drawRect(frameRect.adjusted(1, 1, -1, -1));
+ painter->drawPoint(frameRect.bottomLeft());
+
+ painter->setPen(spinner->palette.color(QPalette::Mid));
+ painter->drawRect(frameRect.adjusted(0, 0, -1, -2));
+
+ bool isEnabled = (spinner->state & State_Enabled);
+ bool hover = isEnabled && (spinner->state & State_MouseOver);
+ bool sunken = (spinner->state & State_Sunken);
+ bool upIsActive = (spinner->activeSubControls == SC_SpinBoxUp);
+ bool downIsActive = (spinner->activeSubControls == SC_SpinBoxDown);
+ bool stepUpEnabled = spinner->stepEnabled &
+ QAbstractSpinBox::StepUpEnabled;
+ bool stepDownEnabled = spinner->stepEnabled &
+ QAbstractSpinBox::StepDownEnabled;
+
+ painter->setBrush(spinner->palette.color(QPalette::Background));
+
+ painter->drawRect(upRect);
+ if (upIsActive && stepUpEnabled) {
+ if (sunken) {
+ drawSunkenButtonShadow(painter, upRect,
+ spinner->palette.color(QPalette::Mid));
+ } else if (hover) {
+ drawButtonHoverFrame(painter, upRect,
+ spinner->palette.color(QPalette::Mid),
+ spinner->palette.color(QPalette::Button));
+ }
+ }
+
+ QStyleOptionSpinBox upSpin = *spinner;
+ upSpin.rect = upRect;
+ drawPrimitive(PE_IndicatorSpinUp, &upSpin, painter, widget);
+
+ painter->drawRect(downRect);
+ if (downIsActive && stepDownEnabled) {
+ if (sunken) {
+ drawSunkenButtonShadow(painter, downRect,
+ spinner->palette.color(QPalette::Mid));
+ } else if (hover) {
+ drawButtonHoverFrame(painter, downRect,
+ spinner->palette.color(QPalette::Mid),
+ spinner->palette.color(QPalette::Button));
+ }
+ }
+
+ QStyleOptionSpinBox downSpin = *spinner;
+ downSpin.rect = downRect;
+ drawPrimitive(PE_IndicatorSpinDown, &downSpin, painter, widget);
+
+ break;
+ }
+ case CC_ToolButton: {
+ const QStyleOptionToolButton *button =
+ qstyleoption_cast<const QStyleOptionToolButton *>(option);
+
+ painter->setPen(Qt::white);
+ painter->drawRect(button->rect.adjusted(1, 1, -1, -1));
+
+ QStyleOptionToolButton panelOption = *button;
+ QRect panelRect;
+ if (!(button->state & State_MouseOver) &&
+ !(button->state & State_On)) {
+ painter->setPen(QColor(153, 153, 153));
+ painter->drawRect(button->rect.adjusted(0, 0, -2, -2));
+
+ panelRect = subControlRect(control, option, SC_ToolButton);
+ panelOption.rect = panelRect;
+ } else {
+ panelOption.rect.adjust(0, 0, -1, -1);
+ }
+
+ QRect menuRect = subControlRect(control, option, SC_ToolButtonMenu);
+
+ drawPrimitive(PE_PanelButtonTool, &panelOption, painter, widget);
+
+ QStyleOptionToolButton menuOption = *button;
+ menuOption.rect = menuRect;
+
+ QStyleOptionToolButton label = *button;
+ int fw = 5;
+
+ drawControl(CE_ToolButtonLabel, &label, painter, widget);
+ if (button->subControls & SC_ToolButtonMenu) {
+ painter->setPen(button->palette.color(QPalette::WindowText));
+ drawPrimitive(PE_IndicatorArrowDown, &menuOption, painter, widget);
+ }
+
+ if (button->state & State_HasFocus) {
+ QStyleOptionToolButton focusOption = *button;
+ focusOption.rect = label.rect.adjusted(-1, -1, 1, 1);
+
+ drawPrimitive(PE_FrameFocusRect, &focusOption, painter, widget);
+ }
+
+ break;
+ }
+ case CC_ComboBox: {
+ const QStyleOptionComboBox *combo =
+ qstyleoption_cast<const QStyleOptionComboBox *>(option);
+
+ QRect frameRect = subControlRect(control, option, SC_ComboBoxFrame,
+ widget);
+ painter->setPen(combo->palette.color(QPalette::Mid));
+
+ if (option->state & State_HasFocus)
+ painter->setBrush(option->palette.color(QPalette::Light));
+ else
+ painter->setBrush(combo->palette.color(QPalette::Background));
+
+ painter->drawRect(frameRect.adjusted(0, 0, -1, -1));
+
+ QRect arrowRect = subControlRect(control, option, SC_ComboBoxArrow,
+ widget);
+ painter->setPen(combo->palette.color(QPalette::Button));
+ painter->setBrush(Qt::NoBrush);
+
+ if (combo->direction == Qt::LeftToRight) {
+ painter->drawRect(QRect(frameRect.topLeft() + QPoint(1, 1),
+ arrowRect.bottomLeft() + QPoint(-2, -2)));
+ } else {
+ painter->drawRect(QRect(arrowRect.topLeft() + QPoint(1, 1),
+ frameRect.bottomRight() + QPoint(-2, -2)));
+ }
+
+ QStyleOptionButton button;
+ button.rect = arrowRect;
+ button.state = combo->state;
+ button.palette = combo->palette;
+
+ if (button.state & State_On)
+ button.state ^= State_On;
+
+ painter->save();
+ drawButtonBackground(&button, painter, false);
+ painter->restore();
+
+ QPoint center = arrowRect.center();
+ QPoint offset = QPoint(arrowRect.bottomLeft().x() + 1,
+ center.y() + 7);
+ QPainterPath arrow;
+ arrow.moveTo(offset + QPoint(4, -8));
+ arrow.lineTo(offset + QPoint(7, -5));
+ arrow.lineTo(offset + QPoint(8, -5));
+ arrow.lineTo(offset + QPoint(11, -8));
+ arrow.lineTo(offset + QPoint(4, -8));
+
+ painter->setBrush(combo->palette.color(QPalette::WindowText));
+ painter->setPen(combo->palette.color(QPalette::WindowText));
+
+ painter->drawPath(arrow);
+
+ QRect fieldRect = subControlRect(control, option,
+ SC_ComboBoxEditField, widget);
+
+ break;
+ }
+ case CC_Slider: {
+ const QStyleOptionSlider *slider =
+ qstyleoption_cast<const QStyleOptionSlider *>(option);
+
+ bool horizontal = slider->orientation == Qt::Horizontal;
+
+ QRect groove = subControlRect(control, option, SC_SliderGroove,
+ widget);
+ QRect ticks = subControlRect(control, option, SC_SliderTickmarks,
+ widget);
+ QRect handle = subControlRect(control, option, SC_SliderHandle,
+ widget);
+
+ QRect afterHandle = QRect(handle.topLeft() + xySwitch(QPoint(4, 6), horizontal),
+ groove.bottomRight() + xySwitch(QPoint(-4, -6), horizontal));
+ QRect beforeHandle = QRect(groove.topLeft() + xySwitch(QPoint(4, 6), horizontal),
+ handle.bottomRight() + xySwitch(QPoint(-4, -6), horizontal));
+
+ if (slider->upsideDown || !horizontal) {
+ QRect remember;
+ remember = afterHandle;
+ afterHandle = beforeHandle;
+ beforeHandle = remember;
+ }
+
+ painter->setPen(slider->palette.color(QPalette::Mid));
+ painter->setBrush(option->palette.color(QPalette::Background));
+ painter->drawRect(afterHandle);
+ painter->setPen(slider->palette.color(QPalette::Light));
+ painter->drawLine(afterHandle.topLeft() + xySwitch(QPoint(0, 1), horizontal),
+ afterHandle.topRight() + xySwitch(QPoint(0, 1), horizontal));
+ painter->setPen(option->palette.color(QPalette::Midlight));
+
+ if (horizontal) {
+ painter->setBrush(gradientBrush(QRect(QPoint(groove.x(),
+ handle.y() + 1),
+ QSize(groove.width(),
+ handle.height() + 1))));
+ } else {
+ QRect rect = QRect(QPoint(groove.x(),
+ handle.x() - 1),
+ QSize(groove.height(),
+ handle.width() + 1));
+ QLinearGradient gradient(groove.bottomLeft(),
+ groove.bottomRight());
+ gradient.setColorAt(1.0, QColor(188, 210, 230));
+ gradient.setColorAt(0.3, Qt::white);
+ gradient.setColorAt(0.0, QColor(223, 233, 243));
+
+ painter->setBrush(gradient);
+ }
+
+ painter->drawRect(beforeHandle);
+
+ QPainterPath handlePath;
+ QPainterPath innerPath;
+ QPoint topLeft, topRight, bottomLeft;
+ if (horizontal) {
+ topLeft = handle.topLeft();
+ topRight = handle.topRight();
+ bottomLeft = handle.bottomLeft();
+ } else {
+ topLeft = handle.bottomLeft();
+ topRight = handle.topLeft();
+ bottomLeft = handle.topRight();
+ }
+
+ if (horizontal) {
+ QImage image(sliderHandleImage);
+
+ image.setColor(1,
+ option->palette.color(QPalette::Midlight).rgb());
+ image.setColor(2,
+ option->palette.color(QPalette::Button).rgb());
+
+ if (!(slider->state & State_Enabled)) {
+ image.setColor(4, slider->palette.color(QPalette::Background).rgb());
+ image.setColor(5, slider->palette.color(QPalette::Background).rgb());
+ image.setColor(6, slider->palette.color(QPalette::Background).rgb());
+ }
+
+ painter->drawImage(handle.topLeft(), image);
+ } else {
+ QImage image(":/images/verticalsliderhandle.png");
+ painter->drawImage(handle.topLeft(), image);
+ }
+
+ if (slider->tickPosition & QSlider::TicksBelow) {
+ painter->setPen(slider->palette.color(QPalette::Light));
+ int tickInterval = slider->tickInterval ? slider->tickInterval :
+ slider->pageStep;
+
+ for (int i = 0; i <= slider->maximum; i += tickInterval) {
+ if (horizontal) {
+ int pos = int(((i / double(slider->maximum)) *
+ ticks.width()) - 1);
+ painter->drawLine(QPoint(ticks.left() + pos,
+ ticks.top() + 2), QPoint(ticks.left() + pos, ticks.top() + 8));
+ } else {
+ int pos = int(((i / double(slider->maximum)) *
+ ticks.height()) - 1);
+ painter->drawLine(QPoint(ticks.left() + 2, ticks.bottom() - pos),
+ QPoint(ticks.right() - 2, ticks.bottom() - pos));
+ }
+ }
+ if (horizontal) {
+ painter->drawLine(QPoint(ticks.right(), ticks.top() + 2),
+ QPoint(ticks.right(), ticks.top() + 8));
+ } else {
+ painter->drawLine(QPoint(ticks.left() + 2, ticks.top()),
+ QPoint(ticks.right() - 2, ticks.top()));
+ }
+ }
+ break;
+ }
+ default:
+ QWindowsStyle::drawComplexControl(control, option, painter, widget);
+ }
+ painter->restore();
+}
+
+inline void JavaStyle::drawSunkenButtonShadow(QPainter *painter,
+ QRect rect,
+ const QColor &frameColor,
+ bool reverse) const
+{
+ painter->save();
+
+ painter->setPen(frameColor);
+
+ if (!reverse) {
+ painter->drawLine(QLine(QPoint(rect.x() + 1, rect.y() + 1),
+ QPoint(rect.x() + rect.width() - 1, rect.y() + 1)));
+ painter->drawLine(QLine(QPoint(rect.x() + 1, rect.y()),
+ QPoint(rect.x() + 1, rect.y() + rect.height())));
+ } else {
+ painter->drawLine(QLine(QPoint(rect.right(), rect.bottom()),
+ QPoint(rect.right(), rect.top())));
+ painter->drawLine(QLine(QPoint(rect.left(), rect.top() + 1),
+ QPoint(rect.right(), rect.top() + 1)));
+ }
+ painter->restore();
+}
+
+inline void JavaStyle::drawButtonHoverFrame(QPainter *painter, QRect rect,
+ const QColor &frameColor,
+ const QColor &activeFrame) const
+{
+ painter->save();
+
+ painter->setPen(activeFrame);
+ painter->drawRect(rect);
+ rect.adjust(1, 1, -1, -1);
+ painter->setPen(frameColor);
+ painter->drawRect(rect);
+ rect.adjust(1, 1, -1, -1);
+ painter->setPen(activeFrame);
+ painter->drawRect(rect);
+
+ painter->restore();
+}
+
+QStyle::SubControl JavaStyle::hitTestComplexControl(ComplexControl control,
+ const QStyleOptionComplex *option,
+ const QPoint &pos,
+ const QWidget *widget) const
+{
+ SubControl ret = SC_None;
+
+ switch (control) {
+ case CC_TitleBar: {
+ const QStyleOptionTitleBar *bar =
+ qstyleoption_cast<const QStyleOptionTitleBar *>(option);
+
+ QRect maximize = subControlRect(control, bar, SC_TitleBarMaxButton);
+ if (maximize.contains(pos)) {
+ ret = SC_TitleBarMaxButton;
+ break;
+ }
+ QRect minimize = subControlRect(control, bar, SC_TitleBarMinButton);
+ if (minimize.contains(pos)) {
+ ret = SC_TitleBarMinButton;
+ break;
+ }
+ QRect close = subControlRect(control, bar, SC_TitleBarCloseButton);
+ if (close.contains(pos)) {
+ ret = SC_TitleBarCloseButton;
+ break;
+ }
+ QRect system = subControlRect(control, bar, SC_TitleBarSysMenu);
+ if (system.contains(pos)) {
+ ret = SC_TitleBarSysMenu;
+ break;
+ }
+ ret = SC_TitleBarLabel;
+ break;
+ }
+ case CC_ScrollBar:
+ if (const QStyleOptionSlider *scrollBar =
+ qstyleoption_cast<const QStyleOptionSlider *>(option)) {
+ QRect slider = subControlRect(control, scrollBar,
+ SC_ScrollBarSlider, widget);
+ if (slider.contains(pos)) {
+ ret = SC_ScrollBarSlider;
+ break;
+ }
+
+ QRect scrollBarAddLine = subControlRect(control, scrollBar,
+ SC_ScrollBarAddLine, widget);
+ if (scrollBarAddLine.contains(pos)) {
+ ret = SC_ScrollBarAddLine;
+ break;
+ }
+
+ QRect scrollBarSubPage = subControlRect(control, scrollBar,
+ SC_ScrollBarSubPage, widget);
+ if (scrollBarSubPage.contains(pos)) {
+ ret = SC_ScrollBarSubPage;
+ break;
+ }
+
+ QRect scrollBarAddPage = subControlRect(control, scrollBar,
+ SC_ScrollBarAddPage, widget);
+ if (scrollBarAddPage.contains(pos)) {
+ ret = SC_ScrollBarAddPage;
+ break;
+ }
+
+ QRect scrollBarSubLine = subControlRect(control, scrollBar,
+ SC_ScrollBarSubLine, widget);
+ if (scrollBarSubLine.contains(pos)) {
+ ret = SC_ScrollBarSubLine;
+ break;
+ }
+ }
+ break;
+
+ default:
+ ret = QWindowsStyle::hitTestComplexControl(control, option, pos,
+ widget);
+ }
+ return ret;
+}
+
+void JavaStyle::polish(QWidget *widget)
+{
+ if (qobject_cast<QCheckBox *>(widget) ||
+ qobject_cast<QRadioButton *>(widget) ||
+ qobject_cast<QPushButton *>(widget) ||
+ qobject_cast<QToolButton *>(widget) ||
+ qobject_cast<QSpinBox *>(widget) ||
+ qobject_cast<QGroupBox *>(widget))
+ widget->setAttribute(Qt::WA_Hover, true);
+}
+
+void JavaStyle::unpolish(QWidget *widget)
+{
+ if (qobject_cast<QPushButton *>(widget) ||
+ qobject_cast<QCheckBox *>(widget) ||
+ qobject_cast<QRadioButton *>(widget) ||
+ qobject_cast<QToolButton *>(widget) ||
+ qobject_cast<QSpinBox *>(widget) ||
+ qobject_cast<QGroupBox *>(widget))
+ widget->setAttribute(Qt::WA_Hover, false);
+}
+
+void JavaStyle::drawSplitter(const QStyleOption *option, QPainter *painter,
+ bool horizontal) const
+{
+ QRect rect = option->rect;
+
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(option->palette.color(QPalette::Background));
+
+ painter->drawRect(rect);
+
+ QColor colors[] = { Qt::white, option->palette.color(QPalette::Mid) };
+ int iterations = horizontal ? rect.height() - 1 : rect.width() - 1;
+ for (int i = 0; i < iterations; ++i) {
+ painter->setPen(colors[i % 2]);
+ painter->drawPoint(xySwitch(QPoint(rect.x() + 0 + (i % 4),
+ rect.y() + i), horizontal));
+ }
+}
+
+inline QPoint JavaStyle::xySwitch(const QPoint &point, bool horizontal) const
+{
+ QPoint retPoint = point;
+
+ if (!horizontal) {
+ retPoint = QPoint(point.y(), point.x());
+ }
+
+ return retPoint;
+}
+
+void JavaStyle::drawPrimitive(PrimitiveElement element,
+ const QStyleOption *option,
+ QPainter *painter,
+ const QWidget *widget) const
+{
+ painter->save();
+
+ switch (element) {
+ case PE_PanelButtonBevel:
+ case PE_FrameButtonBevel: {
+ painter->save();
+ painter->setBrush(option->palette.background());
+ painter->setPen(Qt::NoPen);
+ painter->drawRect(option->rect);
+ painter->restore();
+ break;
+ }
+ case PE_IndicatorBranch: {
+ painter->save();
+ QColor lineColor(204, 204, 255);
+ QPixmap openPixmap(":/images/jtreeopen.png");
+ QPixmap closedPixmap(":/images/jtreeclosed.png");
+ QRect pixmapRect(QPoint(0, 0), QSize(12, 12));
+ pixmapRect.moveCenter(option->rect.center());
+ pixmapRect.translate(2, 0);
+ QPoint center = option->rect.center();
+
+ painter->setPen(lineColor);
+ painter->setBrush(Qt::NoBrush);
+
+ if (option->state & State_Item) {
+ painter->drawLine(center,
+ QPoint(option->rect.right(), center.y()));
+
+ painter->drawLine(center, QPoint(center.x(),
+ option->rect.top()));
+
+ if (option->state & State_Sibling) {
+ painter->drawLine(center, QPoint(center.x(),
+ option->rect.bottom()));
+ }
+
+ if (option->state & State_Children)
+ if (option->state & State_Open)
+ painter->drawPixmap(pixmapRect.topLeft(), closedPixmap);
+ else
+ painter->drawPixmap(pixmapRect.topLeft(), openPixmap);
+ } else if (option->state & State_Sibling) {
+ painter->drawLine(center.x(), option->rect.top(), center.x(),
+ option->rect.bottom());
+ }
+
+ painter->restore();
+ break;
+ }
+ case PE_IndicatorViewItemCheck: {
+ break;
+ }
+ case PE_FrameWindow: {
+ painter->save();
+ bool active = option->state & State_Active;
+
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(active ? option->palette.color(QPalette::Midlight)
+ : option->palette.color(QPalette::Mid));
+
+ painter->drawRect(QRect(option->rect.topLeft(), option->rect.bottomLeft() + QPoint(5, 0)));
+ painter->drawRect(QRect(option->rect.bottomLeft(), option->rect.bottomRight() + QPoint(0, -5)));
+ painter->drawRect(QRect(option->rect.bottomRight() + QPoint(-5, 0), option->rect.topRight()));
+ painter->drawRect(QRect(option->rect.topLeft(), option->rect.topRight() + QPoint(0, 4)));
+
+ painter->setBrush(Qt::NoBrush);
+ painter->setPen(option->palette.color(QPalette::Active, QPalette::WindowText));
+ painter->drawLine(option->rect.topLeft() + QPoint(2, 14),
+ option->rect.bottomLeft() + QPoint(2, -14));
+
+ painter->drawLine(option->rect.topRight() + QPoint(-2, 14),
+ option->rect.bottomRight() + QPoint(-2, -14));
+
+ painter->drawLine(option->rect.topLeft() + QPoint(14, 2),
+ option->rect.topRight() + QPoint(-14, 2));
+
+ painter->drawLine(option->rect.bottomLeft() + QPoint(14, -2),
+ option->rect.bottomRight() + QPoint(-14, -2));
+
+ painter->setPen(active ? option->palette.color(QPalette::Light) :
+ option->palette.color(QPalette::Button));
+ painter->drawLine(option->rect.topLeft() + QPoint(3, 15),
+ option->rect.bottomLeft() + QPoint(3, -13));
+
+ painter->drawLine(option->rect.topRight() + QPoint(-1, 15),
+ option->rect.bottomRight() + QPoint(-1, -13));
+
+ painter->drawLine(option->rect.topLeft() + QPoint(15, 3),
+ option->rect.topRight() + QPoint(-13, 3));
+
+ painter->drawLine(option->rect.bottomLeft() + QPoint(15, -1),
+ option->rect.bottomRight() + QPoint(-13, -1));
+
+ painter->restore();
+ break;
+ }
+ case PE_IndicatorSpinUp: {
+ const QStyleOptionSpinBox *spinner =
+ qstyleoption_cast<const QStyleOptionSpinBox *>(option);
+ int add = spinner->state & State_Sunken &&
+ spinner->activeSubControls & SC_SpinBoxUp ? 1 : 0;
+
+ QPoint center = option->rect.center();
+ painter->drawLine(center.x() + add, center.y() + 1 + add,
+ center.x() + 2 + add, center.y() + 1 + add);
+ painter->drawPoint(center.x() + 1 + add, center.y() + add);
+ break;
+ }
+ case PE_IndicatorSpinDown: {
+ const QStyleOptionSpinBox *spinner =
+ qstyleoption_cast<const QStyleOptionSpinBox *>(option);
+
+ int add = spinner->state & State_Sunken &&
+ spinner->activeSubControls & SC_SpinBoxDown ? 1 : 0;
+ QPoint center = option->rect.center();
+ painter->drawLine(center.x() + add, center.y() + add,
+ center.x() + 2 + add, center.y() + add);
+ painter->drawPoint(center.x() + 1 + add, center.y() + 1 + add);
+ break;
+ }
+ case PE_FrameDockWidget: {
+ drawPrimitive(PE_FrameWindow, option, painter, widget);
+ break;
+ }
+ case PE_IndicatorToolBarHandle: {
+ QPoint offset;
+ bool horizontal = option->state & State_Horizontal;
+
+ if (horizontal)
+ offset = option->rect.topLeft();
+ else
+ offset = option->rect.topLeft();
+
+ int iterations = horizontal ? option->rect.height() :
+ option->rect.width();
+
+ for (int i = 0; i < iterations; ++i) {
+ painter->setPen(i % 2 ? Qt::white :
+ option->palette.color(QPalette::Mid));
+ int add = i % 4;
+ painter->drawPoint(offset + xySwitch(QPoint(add, i),
+ horizontal));
+ painter->drawPoint(offset + xySwitch(QPoint(add + 4, i),
+ horizontal));
+ if (add + 8 < 10)
+ painter->drawPoint(offset + xySwitch(QPoint(add + 8, i),
+ horizontal));
+ }
+
+ break;
+ }
+ case PE_IndicatorToolBarSeparator: {
+ break;
+ }
+ case PE_PanelButtonTool: {
+ const QStyleOptionToolButton *button =
+ qstyleoption_cast<const QStyleOptionToolButton *>(option);
+
+ if (!button) {
+ painter->setPen(Qt::red);
+ if (!(option->state & State_Enabled))
+ painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
+ drawButtonBackground(option, painter, false);
+ break;
+ }
+
+ if (button->state & State_MouseOver || button->state & State_On) {
+ QStyleOptionButton bevel;
+ bevel.state = button->state;
+ bevel.rect = button->rect;
+ bevel.palette = button->palette;
+
+ drawButtonBackground(&bevel, painter, false);
+ } else {
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(button->palette.color(QPalette::Background));
+
+ painter->drawRect(button->rect.adjusted(0, 0, -1, -1));
+ }
+ break;
+ }
+ case PE_FrameMenu: {
+ painter->setPen(option->palette.color(QPalette::Midlight));
+ painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
+ break;
+ }
+ case PE_PanelButtonCommand: {
+ const QStyleOptionButton *btn =
+ qstyleoption_cast<const QStyleOptionButton *>(option);
+ bool hover = (btn->state & State_Enabled) &&
+ (btn->state & State_MouseOver);
+ bool sunken = btn->state & State_Sunken;
+ bool isDefault = btn->features & QStyleOptionButton::DefaultButton;
+ bool on = option->state & State_On;
+
+ drawButtonBackground(option, painter, false);
+
+ QRect rect = option->rect.adjusted(0, 0, -1, -1);
+ if (hover && !sunken && !isDefault && !on) {
+ drawButtonHoverFrame(painter, rect,
+ btn->palette.color(QPalette::Mid),
+ btn->palette.color(QPalette::Button));
+ } else if (isDefault) {
+ drawPrimitive(PE_FrameDefaultButton, option, painter, widget);
+ }
+ break;
+ }
+ case PE_FrameDefaultButton: {
+ painter->setPen(option->palette.color(QPalette::Mid));
+ QRect rect = option->rect.adjusted(0, 0, -1, -1);
+ painter->drawRect(rect);
+ painter->drawRect(rect.adjusted(1, 1, -1, -1));
+ break;
+ }
+//! [0]
+ case PE_IndicatorCheckBox: {
+ painter->save();
+ drawButtonBackground(option, painter, true);
+
+ if (option->state & State_Enabled &&
+ option->state & State_MouseOver &&
+ !(option->state & State_Sunken)) {
+ painter->setPen(option->palette.color(QPalette::Button));
+ QRect rect = option->rect.adjusted(1, 1, -2, -2);
+ painter->drawRect(rect);
+ rect = rect.adjusted(1, 1, -1, -1);
+ painter->drawRect(rect);
+ }
+
+ if (option->state & State_On) {
+ QImage image(":/images/checkboxchecked.png");
+ painter->drawImage(option->rect.topLeft(), image);
+ }
+ painter->restore();
+ break;
+//! [0]
+ }
+ case PE_IndicatorRadioButton: {
+ painter->save();
+ QBrush radioBrush = option->palette.button();
+
+ if (!(option->state & State_Sunken) &&
+ option->state & State_Enabled)
+ radioBrush = gradientBrush(option->rect);
+
+ painter->setBrush(radioBrush);
+ if (option->state & State_Enabled)
+ painter->setPen(option->palette.color(QPalette::Mid));
+ else
+ painter->setPen(option->palette.color(QPalette::Disabled,
+ QPalette::WindowText));
+ painter->drawEllipse(option->rect.adjusted(0, 0, -1, -1));
+
+ if (option->state & State_MouseOver &&
+ option->state & State_Enabled &&
+ !(option->state & State_Sunken)) {
+ gradientBrush(option->rect);
+ painter->setPen(option->palette.color(QPalette::Button));
+ painter->setBrush(Qt::NoBrush);
+ QRect rect = option->rect.adjusted(1, 1, -2, -2);
+ painter->drawEllipse(rect);
+ rect = rect.adjusted(1, 1, -1, -1);
+ painter->drawEllipse(rect);
+ }
+
+ if (option->state & State_On) {
+ painter->setBrush(option->palette.color(QPalette::Text));
+ painter->setPen(Qt::NoPen);
+ painter->drawEllipse(option->rect.adjusted(3, 3, -3, -3));
+ }
+ if (option->state & State_Sunken &&
+ option->state & State_Enabled) {
+ painter->setPen(option->palette.color(QPalette::Mid));
+ painter->drawArc(option->rect.adjusted(1, 1, -2, -2), 80 * 16,
+ 100 * 16);
+ }
+ painter->restore();
+ break;
+ }
+ case PE_FrameTabWidget: {
+ painter->setPen(option->palette.color(QPalette::Midlight));
+ painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
+ painter->setPen(Qt::white);
+ painter->drawRect(option->rect.adjusted(1, 1, -2, -2));
+ break;
+ }
+ case PE_Frame:
+ case PE_FrameLineEdit: {
+ const QStyleOptionFrame *frame =
+ qstyleoption_cast<const QStyleOptionFrame *>(option);
+ const QStyleOptionFrameV2 frameV2(*frame);
+
+ painter->setPen(frame->palette.color(QPalette::Mid));
+ painter->drawRect(frameV2.rect.adjusted(0, 0, -2, -2));
+ painter->setPen(Qt::white);
+ painter->drawRect(frameV2.rect.adjusted(1, 1, -1, -1));
+ painter->setPen(frameV2.palette.color(QPalette::Active,
+ QPalette::Background));
+ painter->drawLine(frameV2.rect.bottomLeft(),
+ frameV2.rect.bottomLeft() + QPoint(1, -1));
+ painter->drawLine(frameV2.rect.topRight(),
+ frameV2.rect.topRight() + QPoint(-1, 1));
+ break;
+ }
+ case PE_FrameFocusRect: {
+ painter->setPen(option->palette.color(QPalette::Light));
+ painter->setBrush(Qt::NoBrush);
+ QRect rect = option->rect;
+ rect = rect.adjusted(0,0, -1, -1);
+ painter->drawRect(rect);
+ break;
+ }
+ default:
+ QWindowsStyle::drawPrimitive(element, option, painter, widget);
+ }
+ painter->restore();
+}
+
+//! [1]
+void JavaStyle::drawButtonBackground(const QStyleOption *option,
+ QPainter *painter, bool isCheckbox) const
+{
+ QBrush buttonBrush = option->palette.button();
+ bool sunken = option->state & State_Sunken;
+ bool disabled = !(option->state & State_Enabled);
+ bool on = option->state & State_On;
+
+ if (!sunken && !disabled && (!on || isCheckbox))
+ buttonBrush = gradientBrush(option->rect);
+
+ painter->fillRect(option->rect, buttonBrush);
+
+ QRect rect = option->rect.adjusted(0, 0, -1, -1);
+
+ if (disabled)
+ painter->setPen(option->palette.color(QPalette::Disabled,
+ QPalette::WindowText));
+ else
+ painter->setPen(option->palette.color(QPalette::Mid));
+
+ painter->drawRect(rect);
+
+ if (sunken && !disabled) {
+ drawSunkenButtonShadow(painter, rect,
+ option->palette.color(QPalette::Mid),
+ option->direction == Qt::RightToLeft);
+ }
+}
+//! [1]
+
+QBrush JavaStyle::gradientBrush(const QRect &rect) const
+{
+ QLinearGradient gradient(rect.topLeft(), rect.bottomLeft());
+ gradient.setColorAt(1.0, QColor(188, 210, 230));
+ gradient.setColorAt(0.3, Qt::white);
+ gradient.setColorAt(0.0, QColor(223, 233, 243));
+
+ return QBrush(gradient);
+}
+
+QRect JavaStyle::subElementRect(SubElement element,
+ const QStyleOption *option,
+ const QWidget *widget) const
+{
+ QRect rect;
+
+ switch (element) {
+ case SE_ToolBoxTabContents: {
+ const QStyleOptionToolBox *box =
+ qstyleoption_cast<const QStyleOptionToolBox *>(option);
+
+ rect.moveTopLeft(box->rect.topLeft() + QPoint(0, 2));
+ rect.setHeight(box->rect.height() - 4);
+ rect.setWidth(box->fontMetrics.width(box->text) + 15);
+ break;
+ }
+ case SE_ProgressBarLabel:
+ case SE_ProgressBarGroove:
+ case SE_ProgressBarContents: {
+ rect = option->rect.adjusted(1, 1, -1, -1);
+ break;
+ }
+ case SE_PushButtonFocusRect: {
+ const QStyleOptionButton *btn =
+ qstyleoption_cast<const QStyleOptionButton *>(option);
+
+ rect = btn->fontMetrics.boundingRect(btn->text);
+ rect = QRect(0, 0, btn->fontMetrics.width(btn->text),
+ rect.height());
+
+ if (!btn->icon.isNull()) {
+ rect.adjust(0, 0, btn->iconSize.width(), btn->iconSize.height()
+ > rect.height() ? btn->iconSize.height() - rect.height() : 0);
+ rect.translate(-btn->iconSize.width(), 0);
+ rect.adjust(-1, -1, 1, 1);
+ }
+ rect = QRect(int(ceil((btn->rect.width() - rect.width()) / 2.0)),
+ int(ceil((btn->rect.height() - rect.height()) / 2.0)),
+ rect.width() - 1, rect.height());
+ rect.adjust(-1, 0, 1, 0);
+
+ break;
+ }
+ default:
+ rect = QWindowsStyle::subElementRect(element, option, widget);
+ }
+ return rect;
+}
+
+int JavaStyle::pixelMetric(PixelMetric metric,
+ const QStyleOption* /* option */,
+ const QWidget* /*widget*/) const
+{
+ int value = 0;
+
+ switch (metric) {
+ case PM_ButtonShiftHorizontal:
+ case PM_ButtonShiftVertical:
+ case PM_TabBarTabShiftHorizontal:
+ case PM_ButtonDefaultIndicator:
+ case PM_TabBarTabShiftVertical:
+ value = 0;
+ break;
+ case PM_TabBarBaseOverlap:
+ case PM_DefaultFrameWidth:
+ value = 2;
+ break;
+ case PM_TabBarTabVSpace:
+ value = 4;
+ break;
+ case PM_ScrollBarExtent:
+ value = 16;
+ break;
+ case PM_ScrollBarSliderMin:
+ value = 26;
+ break;
+ case PM_SplitterWidth:
+ value = 8;
+ break;
+ case PM_SliderThickness:
+ value = 16;
+ break;
+ case PM_SliderControlThickness:
+ value = 16;
+ break;
+ case PM_SliderTickmarkOffset:
+ value = 10;
+ break;
+ case PM_SliderSpaceAvailable:
+ break;
+ case PM_MenuPanelWidth:
+ value = 1;
+ break;
+ case PM_MenuVMargin:
+ value = 2;
+ break;
+ case PM_MenuBarPanelWidth:
+ value = 1;
+ break;
+ case PM_MenuBarItemSpacing:
+ value = 0;
+ break;
+ case PM_MenuBarHMargin:
+ value = 3;
+ break;
+ case PM_MenuBarVMargin:
+ value = 0;
+ break;
+ case PM_ComboBoxFrameWidth:
+ value = 1;
+ break;
+ case PM_MenuButtonIndicator:
+ value = 15;
+ break;
+ case PM_ToolBarItemMargin:
+ value = 3;
+ break;
+ case PM_ToolBarHandleExtent:
+ value = 13;
+ break;
+ case PM_SpinBoxFrameWidth:
+ value = 2;
+ break;
+ case PM_TitleBarHeight: {
+ value = 21;
+ break;
+ case PM_MDIFrameWidth:
+ value = 6;
+ break;
+ }
+ case PM_DockWidgetFrameWidth: {
+ value = 5;
+ break;
+ }
+ default:
+ value = QWindowsStyle::pixelMetric(metric);
+ }
+ return value;
+}
+
+
+int JavaStyle::styleHint(StyleHint hint, const QStyleOption *option,
+ const QWidget *widget,
+ QStyleHintReturn *returnData) const
+{
+ int ret;
+
+ switch (hint) {
+ case SH_Table_GridLineColor: {
+ ret = static_cast<int>(option->palette.color(QPalette::Mid).rgb());
+ break;
+ }
+ case QStyle::SH_Menu_Scrollable:
+ ret = 1;
+ break;
+ default:
+ ret = QWindowsStyle::styleHint(hint, option, widget, returnData);
+ }
+ return ret;
+}
+
+QPixmap JavaStyle::standardPixmap(StandardPixmap standardPixmap,
+ const QStyleOption *option,
+ const QWidget *widget) const
+{
+ QPixmap pixmap = QWindowsStyle::standardPixmap(standardPixmap, option,
+ widget);
+
+ QPixmap maximizePixmap(":/images/internalmaximize.png");
+ QPixmap minimizePixmap(":/images/internalminimize.png");
+ QPixmap closePixmap(":/images/internalclose.png");
+ QPixmap internalPixmap(":/images/internalsystem.png");
+ QPixmap internalCloseDownPixmap(":/images/internalclosedown.png");
+ QPixmap minimizeDownPixmap(":/images/internalminimizedown.png");
+ QPixmap maximizeDownPixmap(":/images/internalmaximizedown.png");
+ QPixmap dirOpenPixmap(":/images/open24.png");
+ QPixmap filePixmap(":/images/file.png");
+
+ switch (standardPixmap) {
+ case SP_DirLinkIcon:
+ case SP_DirClosedIcon:
+ case SP_DirIcon:
+ case SP_DirOpenIcon: {
+ pixmap = closePixmap;
+ break;
+ }
+ case SP_FileIcon: {
+ pixmap = filePixmap;
+ break;
+ }
+ case SP_FileDialogBack: {
+ pixmap = QPixmap(":/images/fileback.png");
+ break;
+ }
+ case SP_FileDialogToParent: {
+ pixmap = QPixmap(":/images/fileparent.png");
+ break;
+ }
+ case SP_FileDialogNewFolder: {
+ pixmap = QPixmap(":/images/open24.png");
+ break;
+ }
+ case SP_FileDialogListView: {
+ pixmap = QPixmap(":/images/filelist.png");
+ break;
+ }
+ case SP_FileDialogDetailedView: {
+ pixmap = QPixmap(":/images/filedetail.png");
+ break;
+ }
+ case SP_MessageBoxInformation: {
+ pixmap = QPixmap(":/images/information.png");
+ break;
+ }
+ case SP_MessageBoxWarning: {
+ pixmap = QPixmap(":/images/warning.png");
+ }
+ case SP_MessageBoxCritical: {
+ pixmap = QPixmap(":/images/critical.png");
+ break;
+ }
+ case SP_MessageBoxQuestion: {
+ pixmap = QPixmap(":/images/question.png");
+ break;
+ }
+ case SP_TitleBarNormalButton:
+ pixmap = maximizePixmap;
+ break;
+ case SP_TitleBarCloseButton:
+ pixmap = closePixmap;
+ break;
+ default:
+ ;
+ }
+
+ return pixmap;
+}
+
+QSize JavaStyle::sizeFromContents(ContentsType type,
+ const QStyleOption *option,
+ const QSize &contentsSize,
+ const QWidget *widget) const
+{
+ switch (type) {
+ case CT_ComboBox: {
+ return QSize(contentsSize.width() + 27, contentsSize.height());
+ }
+ case CT_Slider: {
+ const QStyleOptionSlider *slider =
+ qstyleoption_cast<const QStyleOptionSlider *>(option);
+ if (slider->tickPosition == QSlider::TicksBelow) {
+ return QSize(contentsSize.width(), contentsSize.height() + 15);
+ } else {
+ return contentsSize;
+ }
+ }
+ case CT_MenuBarItem: {
+ const QStyleOptionMenuItem *menuItem =
+ qstyleoption_cast<const QStyleOptionMenuItem *>(option);
+ QFontMetrics metrics(menuItem->font);
+ QRect boundingRect = metrics.boundingRect(menuItem->text);
+ int width = boundingRect.width() + 14;
+ int height = boundingRect.height() + 3;
+ if (height < 20)
+ height = 20;
+
+ return QSize(width, height);
+ }
+ case CT_MenuItem: {
+ const QStyleOptionMenuItem *menuItem =
+ qstyleoption_cast<const QStyleOptionMenuItem *>(option);
+ QSize defaultSize = QWindowsStyle::sizeFromContents(type, option,
+ contentsSize, widget);
+
+ if (menuItem->menuItemType == QStyleOptionMenuItem::Separator)
+ return defaultSize;
+
+ int width = 30;
+ int height = 0;
+
+ if (!menuItem->icon.isNull()) {
+ width += 20;
+ height += 20;
+ }
+ if (!menuItem->text.isEmpty()) {
+ QFontMetrics metrics(menuItem->font);
+ QString text = menuItem->text;
+ text.remove(QLatin1Char('\t'));
+ QRect textRect = metrics.boundingRect(text);
+ width += textRect.width();
+ if (height < textRect.height())
+ height += textRect.height();
+ }
+ if (menuItem->checkType != QStyleOptionMenuItem::NotCheckable) {
+ width += 10;
+ if (height < 10)
+ height = 10;
+ }
+ return QSize(width, height);
+ }
+ default:
+ return QWindowsStyle::sizeFromContents(type, option, contentsSize,
+ widget);
+ }
+}
diff --git a/doc/src/snippets/layouts/layouts.cpp b/doc/src/snippets/layouts/layouts.cpp
new file mode 100644
index 0000000000..2fdde84990
--- /dev/null
+++ b/doc/src/snippets/layouts/layouts.cpp
@@ -0,0 +1,165 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ {
+//! [0]
+ QWidget *window = new QWidget;
+//! [0] //! [1]
+ QPushButton *button1 = new QPushButton("One");
+//! [1] //! [2]
+ QPushButton *button2 = new QPushButton("Two");
+ QPushButton *button3 = new QPushButton("Three");
+ QPushButton *button4 = new QPushButton("Four");
+ QPushButton *button5 = new QPushButton("Five");
+//! [2]
+
+//! [3]
+ QHBoxLayout *layout = new QHBoxLayout;
+//! [3] //! [4]
+ layout->addWidget(button1);
+ layout->addWidget(button2);
+ layout->addWidget(button3);
+ layout->addWidget(button4);
+ layout->addWidget(button5);
+
+ window->setLayout(layout);
+//! [4]
+ window->setWindowTitle("QHBoxLayout");
+//! [5]
+ window->show();
+//! [5]
+ }
+
+ {
+//! [6]
+ QWidget *window = new QWidget;
+//! [6] //! [7]
+ QPushButton *button1 = new QPushButton("One");
+//! [7] //! [8]
+ QPushButton *button2 = new QPushButton("Two");
+ QPushButton *button3 = new QPushButton("Three");
+ QPushButton *button4 = new QPushButton("Four");
+ QPushButton *button5 = new QPushButton("Five");
+//! [8]
+
+//! [9]
+ QVBoxLayout *layout = new QVBoxLayout;
+//! [9] //! [10]
+ layout->addWidget(button1);
+ layout->addWidget(button2);
+ layout->addWidget(button3);
+ layout->addWidget(button4);
+ layout->addWidget(button5);
+
+ window->setLayout(layout);
+//! [10]
+ window->setWindowTitle("QVBoxLayout");
+//! [11]
+ window->show();
+//! [11]
+ }
+
+ {
+//! [12]
+ QWidget *window = new QWidget;
+//! [12] //! [13]
+ QPushButton *button1 = new QPushButton("One");
+//! [13] //! [14]
+ QPushButton *button2 = new QPushButton("Two");
+ QPushButton *button3 = new QPushButton("Three");
+ QPushButton *button4 = new QPushButton("Four");
+ QPushButton *button5 = new QPushButton("Five");
+//! [14]
+
+//! [15]
+ QGridLayout *layout = new QGridLayout;
+//! [15] //! [16]
+ layout->addWidget(button1, 0, 0);
+ layout->addWidget(button2, 0, 1);
+ layout->addWidget(button3, 1, 0, 1, 2);
+ layout->addWidget(button4, 2, 0);
+ layout->addWidget(button5, 2, 1);
+
+ window->setLayout(layout);
+//! [16]
+ window->setWindowTitle("QGridLayout");
+//! [17]
+ window->show();
+//! [17]
+ }
+
+ {
+//! [18]
+ QWidget *window = new QWidget;
+//! [18]
+//! [19]
+ QPushButton *button1 = new QPushButton("One");
+ QLineEdit *lineEdit1 = new QLineEdit();
+//! [19]
+//! [20]
+ QPushButton *button2 = new QPushButton("Two");
+ QLineEdit *lineEdit2 = new QLineEdit();
+ QPushButton *button3 = new QPushButton("Three");
+ QLineEdit *lineEdit3 = new QLineEdit();
+//! [20]
+//! [21]
+ QFormLayout *layout = new QFormLayout;
+//! [21]
+//! [22]
+ layout->addRow(button1, lineEdit1);
+ layout->addRow(button2, lineEdit2);
+ layout->addRow(button3, lineEdit3);
+
+ window->setLayout(layout);
+//! [22]
+ window->setWindowTitle("QFormLayout");
+//! [23]
+ window->show();
+//! [23]
+ }
+
+ return app.exec();
+}
diff --git a/doc/src/snippets/mainwindowsnippet.cpp b/doc/src/snippets/mainwindowsnippet.cpp
new file mode 100644
index 0000000000..70e638e7af
--- /dev/null
+++ b/doc/src/snippets/mainwindowsnippet.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ createMenus();
+ createToolBars();
+ createDockWidgets();
+ //setMenuWidget(new QPushButton("Hello"));
+}
+
+void MainWindow::createMenus()
+{
+ //setMenuWidget(new QPushButton("Hello"));
+ QMenu *menu = new QMenu("File");
+ menu->addAction("Save &As");
+
+ QMenuBar *bar = new QMenuBar;
+ bar->addMenu(menu);
+
+ setMenuWidget(new QWidget());
+}
+
+void MainWindow::createToolBars()
+{
+ setToolButtonStyle(Qt::ToolButtonTextOnly);
+ QToolBar *t1 = new QToolBar;
+ t1->addAction(new QAction("t1", this));
+
+ QToolBar *t2 = new QToolBar;
+ t2->addAction(new QAction("t2", this));
+
+ addToolBar(Qt::LeftToolBarArea, t1);
+ addToolBar(Qt::LeftToolBarArea, t2);
+}
+
+void MainWindow::createDockWidgets()
+{
+ QWidget *dockWidgetContents = new QWidget;
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(new QPushButton("My Button."));
+ dockWidgetContents->setLayout(layout);
+
+//! [0]
+ QDockWidget *dockWidget = new QDockWidget(tr("Dock Widget"), this);
+ dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea |
+ Qt::RightDockWidgetArea);
+ dockWidget->setWidget(dockWidgetContents);
+ addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
+//! [0]
+}
diff --git a/doc/src/snippets/matrix/matrix.cpp b/doc/src/snippets/matrix/matrix.cpp
new file mode 100644
index 0000000000..c7eb0b5943
--- /dev/null
+++ b/doc/src/snippets/matrix/matrix.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <cmath>
+
+class SimpleTransformation : public QWidget
+{
+ void paintEvent(QPaintEvent *);
+};
+
+//! [0]
+void SimpleTransformation::paintEvent(QPaintEvent *)
+{
+ QPainter painter(this);
+ painter.setPen(QPen(Qt::blue, 1, Qt::DashLine));
+ painter.drawRect(0, 0, 100, 100);
+
+ painter.rotate(45);
+
+ painter.setFont(QFont("Helvetica", 24));
+ painter.setPen(QPen(Qt::black, 1));
+ painter.drawText(20, 10, "QMatrix");
+}
+//! [0]
+
+class CombinedTransformation : public QWidget
+{
+ void paintEvent(QPaintEvent *);
+};
+
+//! [1]
+void CombinedTransformation::paintEvent(QPaintEvent *)
+{
+ QPainter painter(this);
+ painter.setPen(QPen(Qt::blue, 1, Qt::DashLine));
+ painter.drawRect(0, 0, 100, 100);
+
+ QMatrix matrix;
+ matrix.translate(50, 50);
+ matrix.rotate(45);
+ matrix.scale(0.5, 1.0);
+ painter.setMatrix(matrix);
+
+ painter.setFont(QFont("Helvetica", 24));
+ painter.setPen(QPen(Qt::black, 1));
+ painter.drawText(20, 10, "QMatrix");
+}
+//! [1]
+
+class BasicOperations : public QWidget
+{
+ void paintEvent(QPaintEvent *);
+};
+
+//! [2]
+void BasicOperations::paintEvent(QPaintEvent *)
+{
+ double pi = 3.14;
+
+ double a = pi/180 * 45.0;
+ double sina = sin(a);
+ double cosa = cos(a);
+
+ QMatrix translationMatrix(1, 0, 0, 1, 50.0, 50.0);
+ QMatrix rotationMatrix(cosa, sina, -sina, cosa, 0, 0);
+ QMatrix scalingMatrix(0.5, 0, 0, 1.0, 0, 0);
+
+ QMatrix matrix;
+ matrix = scalingMatrix * rotationMatrix * translationMatrix;
+
+ QPainter painter(this);
+ painter.setPen(QPen(Qt::blue, 1, Qt::DashLine));
+ painter.drawRect(0, 0, 100, 100);
+
+ painter.setMatrix(matrix);
+
+ painter.setFont(QFont("Helvetica", 24));
+ painter.setPen(QPen(Qt::black, 1));
+ painter.drawText(20, 10, "QMatrix");
+}
+//! [2]
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ QWidget widget;
+
+ SimpleTransformation *simpleWidget = new SimpleTransformation;
+ CombinedTransformation *combinedWidget = new CombinedTransformation;
+ BasicOperations *basicWidget = new BasicOperations;
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(simpleWidget);
+ layout->addWidget(combinedWidget);
+ layout->addWidget(basicWidget);
+ widget.setLayout(layout);
+
+ widget.show();
+ widget.resize(130, 350);
+ return app.exec();
+}
diff --git a/doc/src/snippets/mdiareasnippets.cpp b/doc/src/snippets/mdiareasnippets.cpp
new file mode 100644
index 0000000000..9d626a3f8d
--- /dev/null
+++ b/doc/src/snippets/mdiareasnippets.cpp
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+void mainWindowExample()
+{
+ QMdiArea *mdiArea = new QMdiArea;
+//! [0]
+ QMainWindow *mainWindow = new QMainWindow;
+ mainWindow->setCentralWidget(mdiArea);
+//! [0]
+
+ mdiArea->addSubWindow(new QPushButton("Push Me Now!"));
+
+ mainWindow->show();
+}
+
+void addingSubWindowsExample()
+{
+ QWidget *internalWidget1 = new QWidget;
+ QWidget *internalWidget2 = new QWidget;
+
+//! [1]
+ QMdiArea mdiArea;
+ QMdiSubWindow *subWindow1 = new QMdiSubWindow;
+ subWindow1->setWidget(internalWidget1);
+ subWindow1->setAttribute(Qt::WA_DeleteOnClose);
+ mdiArea.addSubWindow(subWindow1);
+
+ QMdiSubWindow *subWindow2 =
+ mdiArea.addSubWindow(internalWidget2);
+
+//! [1]
+ subWindow1->show();
+ subWindow2->show();
+
+ mdiArea.show();
+}
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+
+ mainWindowExample();
+ //addingSubWindowsExample();
+
+ QAction *act = new QAction(qApp);
+ act->setShortcut(Qt::ALT + Qt::Key_S);
+ act->setShortcutContext( Qt::ApplicationShortcut );
+ QObject::connect(act, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
+
+ QWidget widget5;
+ widget5.show();
+ widget5.addAction(act);
+
+ return app.exec();
+}
+
+
diff --git a/doc/src/snippets/myscrollarea.cpp b/doc/src/snippets/myscrollarea.cpp
new file mode 100644
index 0000000000..93b487d317
--- /dev/null
+++ b/doc/src/snippets/myscrollarea.cpp
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+class MyScrollArea : public QAbstractScrollArea
+{
+public:
+ MyScrollArea(QWidget *w);
+ void setWidget(QWidget *w);
+
+protected:
+ void scrollContentsBy(int dx, int dy);
+ void resizeEvent(QResizeEvent *event);
+
+private:
+ void updateWidgetPosition();
+ void updateArea();
+
+ QWidget *widget;
+};
+
+MyScrollArea::MyScrollArea(QWidget *widget)
+ : QAbstractScrollArea()
+{
+ setWidget(widget);
+}
+
+void MyScrollArea::setWidget(QWidget *w)
+{
+ widget = w;
+ widget->setParent(viewport());
+ if (!widget->testAttribute(Qt::WA_Resized))
+ widget->resize(widget->sizeHint());
+
+ verticalScrollBar()->setValue(0);
+ verticalScrollBar()->setValue(0);
+
+ updateArea();
+}
+
+void MyScrollArea::updateWidgetPosition()
+{
+//! [0]
+ int hvalue = horizontalScrollBar()->value();
+ int vvalue = verticalScrollBar()->value();
+ QPoint topLeft = viewport()->rect().topLeft();
+
+ widget->move(topLeft.x() - hvalue, topLeft.y() - vvalue);
+//! [0]
+}
+
+void MyScrollArea::scrollContentsBy(int /*dx*/, int /*dy*/)
+{
+ updateWidgetPosition();
+}
+
+void MyScrollArea::updateArea()
+{
+//! [1]
+ QSize areaSize = viewport()->size();
+ QSize widgetSize = widget->size();
+
+ verticalScrollBar()->setPageStep(widgetSize.height());
+ horizontalScrollBar()->setPageStep(widgetSize.width());
+ verticalScrollBar()->setRange(0, widgetSize.height() - areaSize.height());
+ horizontalScrollBar()->setRange(0, widgetSize.width() - areaSize.width());
+ updateWidgetPosition();
+//! [1]
+}
+
+void MyScrollArea::resizeEvent(QResizeEvent *event)
+{
+ updateArea();
+}
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+
+ QPixmap pixmap("mypixmap.png");
+ QLabel label;
+ label.setPixmap(pixmap);
+ MyScrollArea area(&label);
+ area.resize(300, 300);
+ area.show();
+
+ area.setWidget(&label);
+
+ return app.exec();
+}
diff --git a/doc/src/snippets/network/tcpwait.cpp b/doc/src/snippets/network/tcpwait.cpp
new file mode 100644
index 0000000000..02cecb4f87
--- /dev/null
+++ b/doc/src/snippets/network/tcpwait.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QTcpSocket>
+
+#include "server.h"
+
+int main(int argv, char **args)
+{
+ QCoreApplication app(argv, args);
+
+ QTcpSocket socket;
+ socket.connectToHost("localhost", 1025);
+
+//! [0]
+ int numRead = 0, numReadTotal = 0;
+ char buffer[50];
+
+ forever {
+ numRead = socket.read(buffer, 50);
+
+ // do whatever with array
+
+ numReadTotal += numRead;
+ if (numRead == 0 && !socket.waitForReadyRead())
+ break;
+ }
+//! [0]
+
+ return app.exec();
+}
diff --git a/doc/src/snippets/ntfsp.cpp b/doc/src/snippets/ntfsp.cpp
new file mode 100644
index 0000000000..5d457124b2
--- /dev/null
+++ b/doc/src/snippets/ntfsp.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]
+extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
+//! [0]
+
+//! [1]
+qt_ntfs_permission_lookup++; // turn checking on
+qt_ntfs_permission_lookup--; // turn it off again
+//! [1]
+
diff --git a/doc/src/snippets/picture/picture.cpp b/doc/src/snippets/picture/picture.cpp
new file mode 100644
index 0000000000..3cead763e1
--- /dev/null
+++ b/doc/src/snippets/picture/picture.cpp
@@ -0,0 +1,151 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+void myProcessing(const QString &)
+{
+}
+
+int main()
+{
+ QWidget myWidget;
+ {
+ // RECORD
+//! [0]
+ QPicture picture;
+ QPainter painter;
+ painter.begin(&picture); // paint in picture
+ painter.drawEllipse(10,20, 80,70); // draw an ellipse
+ painter.end(); // painting done
+ picture.save("drawing.pic"); // save picture
+//! [0]
+ }
+
+ {
+ // REPLAY
+//! [1]
+ QPicture picture;
+ picture.load("drawing.pic"); // load picture
+ QPainter painter;
+ painter.begin(&myImage); // paint in myImage
+ painter.drawPicture(0, 0, picture); // draw the picture at (0,0)
+ painter.end(); // painting done
+//! [1]
+ }
+
+ QPicture myPicture;
+ {
+ // FORMATS
+//! [2]
+ QStringList list = QPicture::inputFormatList();
+ foreach (const QString &string, list)
+ myProcessing(string);
+//! [2]
+ }
+
+ {
+ // OUTPUT
+//! [3]
+ QStringList list = QPicture::outputFormatList();
+ foreach (const QString &string, list)
+ myProcessing(string);
+//! [3]
+ }
+
+ {
+ // PIC READ
+//! [4]
+ QPictureIO iio;
+ QPixmap pixmap;
+ iio.setFileName("vegeburger.pic");
+ if (iio.read()) { // OK
+ QPicture picture = iio.picture();
+ QPainter painter(&pixmap);
+ painter.drawPicture(0, 0, picture);
+ }
+//! [4]
+ }
+
+ {
+ QPixmap pixmap;
+ // PIC WRITE
+//! [5]
+ QPictureIO iio;
+ QPicture picture;
+ QPainter painter(&picture);
+ painter.drawPixmap(0, 0, pixmap);
+ iio.setPicture(picture);
+ iio.setFileName("vegeburger.pic");
+ iio.setFormat("PIC");
+ if (iio.write())
+ return true; // returned true if written successfully
+//! [5]
+ }
+
+}
+
+// SVG READ
+//! [6]
+void readSVG(QPictureIO *picture)
+{
+ // read the picture using the picture->ioDevice()
+}
+//! [6]
+
+// SVG WRITE
+//! [7]
+void writeSVG(QPictureIO *picture)
+{
+ // write the picture using the picture->ioDevice()
+}
+//! [7]
+
+// USE SVG
+void foo() {
+
+//! [8]
+ // add the SVG picture handler
+ // ...
+//! [8]
+ QPictureIO::defineIOHandler("SVG", 0, 0, readSVG, writeSVG);
+ // ...
+
+}
diff --git a/doc/src/snippets/pointer/pointer.cpp b/doc/src/snippets/pointer/pointer.cpp
new file mode 100644
index 0000000000..b4ff3839cb
--- /dev/null
+++ b/doc/src/snippets/pointer/pointer.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$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QLabel>
+#include <QPointer>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+//! [0]
+ QPointer<QLabel> label = new QLabel;
+ label->setText("&Status:");
+//! [0]
+
+//! [1]
+ if (label)
+//! [1] //! [2]
+ label->show();
+//! [2]
+ return 0;
+}
diff --git a/doc/src/snippets/polygon/polygon.cpp b/doc/src/snippets/polygon/polygon.cpp
new file mode 100644
index 0000000000..8b81db668d
--- /dev/null
+++ b/doc/src/snippets/polygon/polygon.cpp
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+int main()
+{
+ {
+ // STREAM
+//! [0]
+ QPolygon polygon;
+ polygon << QPoint(10, 20) << QPoint(20, 30);
+//! [0]
+ }
+
+ {
+ // STREAMF
+//! [1]
+ QPolygonF polygon;
+ polygon << QPointF(10.4, 20.5) << QPointF(20.2, 30.2);
+//! [1]
+ }
+
+ {
+ // SETPOINTS
+//! [2]
+ static const int points[] = { 10, 20, 30, 40 };
+ QPolygon polygon;
+ polygon.setPoints(2, points);
+//! [2]
+ }
+
+ {
+ // SETPOINTS2
+//! [3]
+ QPolygon polygon;
+ polygon.setPoints(2, 10, 20, 30, 40);
+//! [3]
+ }
+
+ {
+ // PUTPOINTS
+//! [4]
+ QPolygon polygon(1);
+ polygon[0] = QPoint(4, 5);
+ polygon.putPoints(1, 2, 6,7, 8,9);
+//! [4]
+ }
+
+ {
+ // PUTPOINTS2
+//! [5]
+ QPolygon polygon(3);
+ polygon.putPoints(0, 3, 4,5, 0,0, 8,9);
+ polygon.putPoints(1, 1, 6,7);
+//! [5]
+ }
+
+ {
+ // PUTPOINTS3
+//! [6]
+ QPolygon polygon1;
+ polygon1.putPoints(0, 3, 1,2, 0,0, 5,6);
+ // polygon1 is now the three-point polygon(1,2, 0,0, 5,6);
+
+ QPolygon polygon2;
+ polygon2.putPoints(0, 3, 4,4, 5,5, 6,6);
+ // polygon2 is now (4,4, 5,5, 6,6);
+
+ polygon1.putPoints(2, 3, polygon2);
+ // polygon1 is now the five-point polygon(1,2, 0,0, 4,4, 5,5, 6,6);
+//! [6]
+ }
+ return 0;
+}
diff --git a/doc/src/snippets/printing-qprinter/errors.cpp b/doc/src/snippets/printing-qprinter/errors.cpp
new file mode 100644
index 0000000000..ff3ea9053e
--- /dev/null
+++ b/doc/src/snippets/printing-qprinter/errors.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+//! [0]
+ QPrinter printer;
+ printer.setOutputFormat(QPrinter::PdfFormat);
+ printer.setOutputFileName("/foobar/nonwritable.pdf");
+ QPainter painter;
+ if (! painter.begin(&printer)) { // failed to open file
+ qWarning("failed to open file, is it writable?");
+ return 1;
+ }
+ painter.drawText(10, 10, "Test");
+ if (! printer.newPage()) {
+ qWarning("failed in flushing page to disk, disk full?");
+ return 1;
+ }
+ painter.drawText(10, 10, "Test 2");
+ painter.end();
+//! [0]
+ return 0;
+}
diff --git a/doc/src/snippets/printing-qprinter/object.cpp b/doc/src/snippets/printing-qprinter/object.cpp
new file mode 100644
index 0000000000..0ee8dbdc56
--- /dev/null
+++ b/doc/src/snippets/printing-qprinter/object.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include "object.h"
+
+Object::Object(QObject *parent)
+ : QObject(parent)
+{
+}
+
+void Object::print()
+{
+ int numberOfPages = 10;
+ int lastPage = numberOfPages - 1;
+
+//! [0]
+ QPrinter printer(QPrinter::HighResolution);
+ printer.setOutputFileName("print.ps");
+ QPainter painter;
+ painter.begin(&printer);
+
+ for (int page = 0; page < numberOfPages; ++page) {
+
+ // Use the painter to draw on the page.
+
+ if (page != lastPage)
+ printer.newPage();
+ }
+
+ painter.end();
+//! [0]
+ qApp->quit();
+}
diff --git a/doc/src/snippets/process/process.cpp b/doc/src/snippets/process/process.cpp
new file mode 100644
index 0000000000..a545b734bf
--- /dev/null
+++ b/doc/src/snippets/process/process.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$
+**
+****************************************************************************/
+
+#include <QProcess>
+
+bool zip()
+{
+//! [0]
+ QProcess gzip;
+ gzip.start("gzip", QStringList() << "-c");
+ if (!gzip.waitForStarted())
+ return false;
+
+ gzip.write("Qt rocks!");
+ gzip.closeWriteChannel();
+
+ if (!gzip.waitForFinished())
+ return false;
+
+ QByteArray result = gzip.readAll();
+//! [0]
+
+ gzip.start("gzip", QStringList() << "-d" << "-c");
+ gzip.write(result);
+ gzip.closeWriteChannel();
+
+ if (!gzip.waitForFinished())
+ return false;
+
+ qDebug("Result: %s", gzip.readAll().data());
+ return true;
+}
+
+
+int main()
+{
+ zip();
+ return 0;
+}
diff --git a/doc/src/snippets/qdbusextratypes/qdbusextratypes.cpp b/doc/src/snippets/qdbusextratypes/qdbusextratypes.cpp
new file mode 100644
index 0000000000..1ab3488780
--- /dev/null
+++ b/doc/src/snippets/qdbusextratypes/qdbusextratypes.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$
+**
+****************************************************************************/
+
+#include <QtCore>
+#include <QtDBus>
+
+static QVariant callMyDBusFunction() { return QVariant(); }
+
+int main()
+{
+ QDBusMessage myDBusMessage;
+
+//! [0]
+ QList<QVariant> arguments;
+ arguments << QVariant(42) << QVariant::fromValue(QDBusVariant(43)) << QVariant("hello");
+ myDBusMessage.setArguments(arguments);
+//! [0]
+
+//! [1]
+ // call a D-Bus function that returns a D-Bus variant
+ QVariant v = callMyDBusFunction();
+ // retrieve the D-Bus variant
+ QDBusVariant dbusVariant = qvariant_cast<QDBusVariant>(v);
+ // retrieve the actual value stored in the D-Bus variant
+ QVariant result = dbusVariant.variant();
+//! [1]
+
+ return 0;
+}
diff --git a/doc/src/snippets/qdebug/qdebugsnippet.cpp b/doc/src/snippets/qdebug/qdebugsnippet.cpp
new file mode 100644
index 0000000000..8e668d1736
--- /dev/null
+++ b/doc/src/snippets/qdebug/qdebugsnippet.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QtDebug>
+
+class Coordinate : public QObject
+{
+public:
+ int myX, myY;
+
+ int x() const { return myX; };
+ int y() const { return myY; };
+};
+
+//! [0]
+QDebug operator<<(QDebug dbg, const Coordinate &c)
+{
+ dbg.nospace() << "(" << c.x() << ", " << c.y() << ")";
+
+ return dbg.space();
+}
+//! [0]
+
+int main(int argv, char **args)
+{
+ Coordinate coordinate;
+ coordinate.myX = 10;
+ coordinate.myY = 44;
+
+//! [1]
+ qDebug() << "Date:" << QDate::currentDate();
+ qDebug() << "Types:" << QString("String") << QChar('x') << QRect(0, 10, 50, 40);
+ qDebug() << "Custom coordinate type:" << coordinate;
+//! [1]
+}
diff --git a/doc/src/snippets/qdir-listfiles/main.cpp b/doc/src/snippets/qdir-listfiles/main.cpp
new file mode 100644
index 0000000000..cdce0d545a
--- /dev/null
+++ b/doc/src/snippets/qdir-listfiles/main.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]
+#include <QDir>
+#include <iostream>
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication app(argc, argv);
+ QDir dir;
+ dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
+ dir.setSorting(QDir::Size | QDir::Reversed);
+
+ QFileInfoList list = dir.entryInfoList();
+ std::cout << " Bytes Filename" << std::endl;
+ for (int i = 0; i < list.size(); ++i) {
+ QFileInfo fileInfo = list.at(i);
+ std::cout << qPrintable(QString("%1 %2").arg(fileInfo.size(), 10)
+ .arg(fileInfo.fileName()));
+ std::cout << std::endl;
+ }
+ return 0;
+}
+//! [0]
diff --git a/doc/src/snippets/qdir-namefilters/main.cpp b/doc/src/snippets/qdir-namefilters/main.cpp
new file mode 100644
index 0000000000..a72bab1d0a
--- /dev/null
+++ b/doc/src/snippets/qdir-namefilters/main.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$
+**
+****************************************************************************/
+
+#include <QDir>
+#include <iostream>
+
+int main(int argc, char *argv[])
+{
+ QDir dir;
+ dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
+ dir.setSorting(QDir::Size | QDir::Reversed);
+
+//! [0]
+ QStringList filters;
+ filters << "*.cpp" << "*.cxx" << "*.cc";
+ dir.setNameFilters(filters);
+//! [0]
+
+ QFileInfoList list = dir.entryInfoList();
+ std::cout << " Bytes Filename" << std::endl;
+ for (int i = 0; i < list.size(); ++i) {
+ QFileInfo fileInfo = list.at(i);
+ std::cout << qPrintable(QString("%1 %2").arg(fileInfo.size(), 10)
+ .arg(fileInfo.fileName()));
+ std::cout << std::endl;
+ }
+ return 0;
+}
diff --git a/doc/src/snippets/qelapsedtimer/main.cpp b/doc/src/snippets/qelapsedtimer/main.cpp
new file mode 100644
index 0000000000..3e5b520f57
--- /dev/null
+++ b/doc/src/snippets/qelapsedtimer/main.cpp
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** 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 QtNetwork module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtCore>
+
+void slowOperation1()
+{
+ static char buf[256];
+ for (int i = 0; i < (1<<20); ++i)
+ buf[i % sizeof buf] = i;
+}
+
+void slowOperation2(int) { slowOperation1(); }
+
+void startExample()
+{
+//![0]
+ QElapsedTimer timer;
+ timer.start();
+
+ slowOperation1();
+
+ qDebug() << "The slow operation took" << timer.elapsed() << "milliseconds";
+//![0]
+}
+
+//![1]
+void executeSlowOperations(int timeout)
+{
+ QElapsedTimer timer;
+ timer.start();
+ slowOperation1();
+
+ int remainingTime = timeout - timer.elapsed();
+ if (remainingTime > 0)
+ slowOperation2(remainingTime);
+}
+//![1]
+
+//![2]
+void executeOperationsForTime(int ms)
+{
+ QElapsedTimer timer;
+ timer.start();
+
+ while (!timer.hasExpired(ms))
+ slowOperation1();
+}
+//![2]
+
+int restartExample()
+{
+//![3]
+ QElapsedTimer timer;
+
+ int count = 1;
+ timer.start();
+ do {
+ count *= 2;
+ slowOperation2(count);
+ } while (timer.restart() < 250);
+
+ return count;
+//![3]
+}
+
+int main(int argc, char **argv)
+{
+ QCoreApplication app(argc, argv);
+
+ startExample();
+ restartExample();
+ executeSlowOperations(5);
+ executeOperationsForTime(5);
+}
diff --git a/doc/src/snippets/qfontdatabase/main.cpp b/doc/src/snippets/qfontdatabase/main.cpp
new file mode 100644
index 0000000000..24ed688001
--- /dev/null
+++ b/doc/src/snippets/qfontdatabase/main.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+//! [0]
+ QFontDatabase database;
+ QTreeWidget fontTree;
+ fontTree.setColumnCount(2);
+ fontTree.setHeaderLabels(QStringList() << "Font" << "Smooth Sizes");
+
+ foreach (const QString &family, database.families()) {
+ QTreeWidgetItem *familyItem = new QTreeWidgetItem(&fontTree);
+ familyItem->setText(0, family);
+
+ foreach (const QString &style, database.styles(family)) {
+ QTreeWidgetItem *styleItem = new QTreeWidgetItem(familyItem);
+ styleItem->setText(0, style);
+
+ QString sizes;
+ foreach (int points, database.smoothSizes(family, style))
+ sizes += QString::number(points) + " ";
+
+ styleItem->setText(1, sizes.trimmed());
+ }
+//! [0] //! [1]
+ }
+//! [1]
+
+ fontTree.resizeColumnToContents(0);
+ fontTree.show();
+ return app.exec();
+}
diff --git a/doc/src/snippets/qlistwidget-using/mainwindow.cpp b/doc/src/snippets/qlistwidget-using/mainwindow.cpp
new file mode 100644
index 0000000000..0ec9c70ed3
--- /dev/null
+++ b/doc/src/snippets/qlistwidget-using/mainwindow.cpp
@@ -0,0 +1,158 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ QMenu *itemsMenu = new QMenu(tr("&Items"));
+
+ insertAction = itemsMenu->addAction(tr("&Insert Item"));
+ removeAction = itemsMenu->addAction(tr("&Remove Item"));
+ QAction *ascendingAction = itemsMenu->addAction(tr("Sort in &Ascending Order"));
+ QAction *descendingAction = itemsMenu->addAction(tr("Sort in &Descending Order"));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(itemsMenu);
+
+/* For convenient quoting:
+//! [0]
+ QListWidget *listWidget = new QListWidget(this);
+//! [0]
+*/
+ listWidget = new QListWidget(this);
+ listWidget->setSelectionMode(QAbstractItemView::SingleSelection);
+
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+ connect(ascendingAction, SIGNAL(triggered()), this, SLOT(sortAscending()));
+ connect(descendingAction, SIGNAL(triggered()), this, SLOT(sortDescending()));
+ connect(insertAction, SIGNAL(triggered()), this, SLOT(insertItem()));
+ connect(removeAction, SIGNAL(triggered()), this, SLOT(removeItem()));
+ connect(listWidget,
+ SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
+ this, SLOT(updateMenus(QListWidgetItem *)));
+
+ setupListItems();
+ updateMenus(listWidget->currentItem());
+
+ setCentralWidget(listWidget);
+ setWindowTitle(tr("List Widget"));
+}
+
+void MainWindow::setupListItems()
+{
+//! [1]
+ new QListWidgetItem(tr("Oak"), listWidget);
+ new QListWidgetItem(tr("Fir"), listWidget);
+ new QListWidgetItem(tr("Pine"), listWidget);
+//! [1]
+ new QListWidgetItem(tr("Birch"), listWidget);
+//! [2]
+ new QListWidgetItem(tr("Hazel"), listWidget);
+//! [2]
+ new QListWidgetItem(tr("Redwood"), listWidget);
+//! [3]
+ new QListWidgetItem(tr("Sycamore"), listWidget);
+ new QListWidgetItem(tr("Chestnut"), listWidget);
+ new QListWidgetItem(tr("Mahogany"), listWidget);
+//! [3]
+}
+
+void MainWindow::sortAscending()
+{
+//! [4]
+ listWidget->sortItems(Qt::AscendingOrder);
+//! [4]
+}
+
+void MainWindow::sortDescending()
+{
+//! [5]
+ listWidget->sortItems(Qt::DescendingOrder);
+//! [5]
+}
+
+void MainWindow::insertItem()
+{
+ if (!listWidget->currentItem())
+ return;
+
+ QString itemText = QInputDialog::getText(this, tr("Insert Item"),
+ tr("Input text for the new item:"));
+
+ if (itemText.isNull())
+ return;
+
+//! [6]
+ QListWidgetItem *newItem = new QListWidgetItem;
+ newItem->setText(itemText);
+//! [6]
+ int row = listWidget->row(listWidget->currentItem());
+//! [7]
+ listWidget->insertItem(row, newItem);
+//! [7]
+
+ QString toolTipText = tr("Tooltip:") + itemText;
+ QString statusTipText = tr("Status tip:") + itemText;
+ QString whatsThisText = tr("What's This?:") + itemText;
+//! [8]
+ newItem->setToolTip(toolTipText);
+ newItem->setStatusTip(toolTipText);
+ newItem->setWhatsThis(whatsThisText);
+//! [8]
+}
+
+void MainWindow::removeItem()
+{
+ listWidget->takeItem(listWidget->row(listWidget->currentItem()));
+}
+
+void MainWindow::updateMenus(QListWidgetItem *current)
+{
+ insertAction->setEnabled(current != 0);
+ removeAction->setEnabled(current != 0);
+}
diff --git a/doc/src/snippets/qmacnativewidget/main.mm b/doc/src/snippets/qmacnativewidget/main.mm
new file mode 100644
index 0000000000..a57dc19a28
--- /dev/null
+++ b/doc/src/snippets/qmacnativewidget/main.mm
@@ -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$
+**
+****************************************************************************/
+
+#include <QtGui/QtGui>
+#include <QtGui/qmacnativewidget_mac.h>
+#ifdef QT_MAC_USE_COCOA
+#import <Cocoa/Cocoa.h>
+#else
+#include <Carbon/Carbon.h>
+#endif
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+#ifdef QT_MAC_USE_COCOA
+//![0]
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect(200, app.desktop()->height() - 200, 239, 200)
+ styleMask:NSTitledWindowMask | NSClosableWindowMask
+ | NSMiniaturizableWindowMask | NSResizableWindowMask
+ backing:NSBackingStoreBuffered defer:NO];
+
+ QMacNativeWidget *nativeWidget = new QMacNativeWidget();
+ nativeWidget->move(0, 0);
+ nativeWidget->setPalette(QPalette(Qt::red));
+ nativeWidget->setAutoFillBackground(true);
+ QVBoxLayout *layout = new QVBoxLayout();
+ QPushButton *pushButton = new QPushButton("An Embedded Qt Button!", nativeWidget);
+ pushButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // Don't use the layout rect calculated from QMacStyle.
+ layout->addWidget(pushButton);
+ nativeWidget->setLayout(layout);
+
+ // Adjust Cocoa layouts
+ NSView *nativeWidgetView = reinterpret_cast<NSView *>(nativeWidget->winId());
+ NSView *contentView = [window contentView];
+ [contentView setAutoresizesSubviews:YES];
+ [nativeWidgetView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
+ [nativeWidgetView setAutoresizesSubviews:YES];
+ NSView *pushButtonView = reinterpret_cast<NSView *>(pushButton->winId());
+ [pushButtonView setAutoresizingMask:NSViewWidthSizable];
+
+ // Add the nativeWidget to the window.
+ [contentView addSubview:nativeWidgetView positioned:NSWindowAbove relativeTo:nil];
+ nativeWidget->show();
+ pushButton->show();
+
+ // Show the window.
+ [window makeKeyAndOrderFront:window];
+ [pool release];
+//![0]
+#else
+//![1]
+ Rect contentRect;
+ SetRect(&contentRect, 200, 200, 400, 400);
+ HIWindowRef windowRef;
+ CreateNewWindow(kDocumentWindowClass, kWindowStandardDocumentAttributes | kWindowCompositingAttribute | kWindowStandardHandlerAttribute | kWindowLiveResizeAttribute, &contentRect, &windowRef);
+ HIViewRef contentView = 0;
+ GetRootControl(windowRef, &contentView);
+
+ QMacNativeWidget *nativeWidget = new QMacNativeWidget();
+ nativeWidget->move(0, 0);
+ nativeWidget->setPalette(QPalette(Qt::red));
+ nativeWidget->setAutoFillBackground(true);
+ QVBoxLayout *layout = new QVBoxLayout();
+ QPushButton *pushButton = new QPushButton("An Embedded Qt Button!", nativeWidget);
+ pushButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // Don't use the layout rect calculated from QMacStyle.
+ layout->addWidget(pushButton);
+ nativeWidget->setLayout(layout);
+ HIViewRef nativeWidgetView = reinterpret_cast<HIViewRef>(nativeWidget->winId());
+ // Add the nativeWidget to the window.
+ HIViewAddSubview(contentView, nativeWidgetView);
+
+ // Adjust Carbon layouts
+ HILayoutInfo layoutInfo;
+ layoutInfo.version = kHILayoutInfoVersionZero;
+ HIViewGetLayoutInfo(nativeWidgetView, &layoutInfo);
+
+ layoutInfo.binding.top.toView = contentView;
+ layoutInfo.binding.top.kind = kHILayoutBindTop;
+ layoutInfo.binding.left.toView = contentView;
+ layoutInfo.binding.left.kind = kHILayoutBindLeft;
+ layoutInfo.binding.right.toView = contentView;
+ layoutInfo.binding.right.kind = kHILayoutBindRight;
+ layoutInfo.binding.bottom.toView = contentView;
+ layoutInfo.binding.bottom.kind = kHILayoutBindBottom;
+
+ HIViewSetLayoutInfo(nativeWidgetView, &layoutInfo);
+ HIViewApplyLayout(nativeWidgetView);
+
+ pushButton->show();
+ nativeWidget->show();
+ // Show the window.
+ ShowWindow(windowRef);
+//![1]
+#endif
+ return app.exec(); // gives us the same behavior in both
+}
diff --git a/doc/src/snippets/qprocess-environment/main.cpp b/doc/src/snippets/qprocess-environment/main.cpp
new file mode 100644
index 0000000000..974095fe02
--- /dev/null
+++ b/doc/src/snippets/qprocess-environment/main.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$
+**
+****************************************************************************/
+
+#include <QtCore>
+
+void startProcess()
+{
+ {
+//! [0]
+QProcess process;
+QStringList env = QProcess::systemEnvironment();
+env << "TMPDIR=C:\\MyApp\\temp"; // Add an environment variable
+env.replaceInStrings(QRegExp("^PATH=(.*)", Qt::CaseInsensitive), "PATH=\\1;C:\\Bin");
+process.setEnvironment(env);
+process.start("myapp");
+//! [0]
+ }
+
+ {
+//! [1]
+QProcess process;
+QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
+env.insert("TMPDIR", "C:\\MyApp\\temp"); // Add an environment variable
+env.insert("PATH", env.value("Path") + ";C:\\Bin");
+process.setProcessEnvironment(env);
+process.start("myapp");
+//! [1]
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication app(argc, argv);
+ startProcess();
+ return app.exec();
+}
diff --git a/doc/src/snippets/qprocess/qprocess-simpleexecution.cpp b/doc/src/snippets/qprocess/qprocess-simpleexecution.cpp
new file mode 100644
index 0000000000..a5d097f3fe
--- /dev/null
+++ b/doc/src/snippets/qprocess/qprocess-simpleexecution.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$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QtGui>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+//! [0]
+ QObject *parent;
+//! [0]
+ parent = &app;
+
+//! [1]
+ QString program = "./path/to/Qt/examples/widgets/analogclock";
+//! [1]
+ program = "./../../../../examples/widgets/analogclock/analogclock";
+
+//! [2]
+ QStringList arguments;
+ arguments << "-style" << "motif";
+
+ QProcess *myProcess = new QProcess(parent);
+ myProcess->start(program, arguments);
+//! [2]
+
+ return app.exec();
+}
diff --git a/doc/src/snippets/qsignalmapper/buttonwidget.cpp b/doc/src/snippets/qsignalmapper/buttonwidget.cpp
new file mode 100644
index 0000000000..35f305570f
--- /dev/null
+++ b/doc/src/snippets/qsignalmapper/buttonwidget.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "buttonwidget.h"
+
+//! [0]
+ButtonWidget::ButtonWidget(QStringList texts, QWidget *parent)
+ : QWidget(parent)
+{
+ signalMapper = new QSignalMapper(this);
+
+ QGridLayout *gridLayout = new QGridLayout;
+ for (int i = 0; i < texts.size(); ++i) {
+ QPushButton *button = new QPushButton(texts[i]);
+ connect(button, SIGNAL(clicked()), signalMapper, SLOT(map()));
+//! [0] //! [1]
+ signalMapper->setMapping(button, texts[i]);
+ gridLayout->addWidget(button, i / 3, i % 3);
+ }
+
+ connect(signalMapper, SIGNAL(mapped(const QString &)),
+//! [1] //! [2]
+ this, SIGNAL(clicked(const QString &)));
+
+ setLayout(gridLayout);
+}
+//! [2]
diff --git a/doc/src/snippets/qsignalmapper/buttonwidget.h b/doc/src/snippets/qsignalmapper/buttonwidget.h
new file mode 100644
index 0000000000..095fc2c70a
--- /dev/null
+++ b/doc/src/snippets/qsignalmapper/buttonwidget.h
@@ -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$
+**
+****************************************************************************/
+
+#ifndef BUTTONWIDGET_H
+#define BUTTONWIDGET_H
+
+#include <qwidget.h>
+
+class QSignalMapper;
+class QString;
+class QStringList;
+
+//! [0]
+class ButtonWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ ButtonWidget(QStringList texts, QWidget *parent = 0);
+
+signals:
+ void clicked(const QString &text);
+
+private:
+ QSignalMapper *signalMapper;
+//! [0] //! [1]
+};
+//! [1]
+
+#endif
diff --git a/doc/src/snippets/qsortfilterproxymodel-details/main.cpp b/doc/src/snippets/qsortfilterproxymodel-details/main.cpp
new file mode 100644
index 0000000000..9de0cea1df
--- /dev/null
+++ b/doc/src/snippets/qsortfilterproxymodel-details/main.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QApplication>
+#include <QSortFilterProxyModel>
+
+class MyItemModel : public QStandardItemModel
+{
+public:
+ MyItemModel(QWidget *parent = 0);
+};
+
+MyItemModel::MyItemModel(QWidget *parent)
+ : QStandardItemModel(parent)
+{};
+
+class Widget : public QWidget
+{
+public:
+ Widget(QWidget *parent = 0);
+};
+
+Widget::Widget(QWidget *parent)
+ : QWidget(parent)
+{
+//! [0] //! [1]
+ QTreeView *treeView = new QTreeView;
+//! [0]
+ MyItemModel *model = new MyItemModel(this);
+
+ treeView->setModel(model);
+//! [1]
+
+//! [2]
+ MyItemModel *sourceModel = new MyItemModel(this);
+ QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this);
+
+ proxyModel->setSourceModel(sourceModel);
+ treeView->setModel(proxyModel);
+//! [2]
+
+//! [3]
+ treeView->setSortingEnabled(true);
+//! [3]
+
+//! [4]
+ proxyModel->sort(2, Qt::AscendingOrder);
+//! [4] //! [5]
+ proxyModel->setFilterRegExp(QRegExp(".png", Qt::CaseInsensitive,
+ QRegExp::FixedString));
+ proxyModel->setFilterKeyColumn(1);
+//! [5]
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Widget widget;
+ widget.show();
+ return app.exec();
+}
diff --git a/doc/src/snippets/qsplashscreen/main.cpp b/doc/src/snippets/qsplashscreen/main.cpp
new file mode 100644
index 0000000000..0a4ebb5f19
--- /dev/null
+++ b/doc/src/snippets/qsplashscreen/main.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <stdlib.h>
+
+#include "mainwindow.h"
+
+//! [0]
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QPixmap pixmap(":/splash.png");
+ QSplashScreen splash(pixmap);
+ splash.show();
+ app.processEvents();
+//! [0]
+
+ sleep(5);
+//! [1]
+ QMainWindow window;
+ window.show();
+ splash.finish(&window);
+ return app.exec();
+}
+//! [1]
diff --git a/doc/src/snippets/qstack/main.cpp b/doc/src/snippets/qstack/main.cpp
new file mode 100644
index 0000000000..8b6982e9e4
--- /dev/null
+++ b/doc/src/snippets/qstack/main.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <iostream>
+using namespace std;
+
+int main(int argc, char *argv[])
+{
+//! [0]
+ QStack<int> stack;
+ stack.push(1);
+ stack.push(2);
+ stack.push(3);
+ while (!stack.isEmpty())
+ cout << stack.pop() << endl;
+//! [0]
+}
diff --git a/doc/src/snippets/qstackedlayout/main.cpp b/doc/src/snippets/qstackedlayout/main.cpp
new file mode 100644
index 0000000000..ca415e8be0
--- /dev/null
+++ b/doc/src/snippets/qstackedlayout/main.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QApplication>
+
+class Widget : public QWidget
+{
+public:
+ Widget(QWidget *parent = 0);
+};
+
+Widget::Widget(QWidget *parent)
+ : QWidget(parent)
+{
+//! [0]
+ QWidget *firstPageWidget = new QWidget;
+ QWidget *secondPageWidget = new QWidget;
+ QWidget *thirdPageWidget = new QWidget;
+
+ QStackedLayout *stackedLayout = new QStackedLayout;
+ stackedLayout->addWidget(firstPageWidget);
+ stackedLayout->addWidget(secondPageWidget);
+ stackedLayout->addWidget(thirdPageWidget);
+
+//! [0] //! [1]
+ QComboBox *pageComboBox = new QComboBox;
+ pageComboBox->addItem(tr("Page 1"));
+ pageComboBox->addItem(tr("Page 2"));
+ pageComboBox->addItem(tr("Page 3"));
+ connect(pageComboBox, SIGNAL(activated(int)),
+ stackedLayout, SLOT(setCurrentIndex(int)));
+//! [1]
+
+//! [2]
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+//! [2]
+ mainLayout->addWidget(pageComboBox);
+//! [3]
+ mainLayout->addLayout(stackedLayout);
+ setLayout(mainLayout);
+//! [3]
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Widget widget;
+ widget.show();
+ return app.exec();
+}
+
diff --git a/doc/src/snippets/qstackedwidget/main.cpp b/doc/src/snippets/qstackedwidget/main.cpp
new file mode 100644
index 0000000000..7e72bfacba
--- /dev/null
+++ b/doc/src/snippets/qstackedwidget/main.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QApplication>
+
+class Widget : public QWidget
+{
+public:
+ Widget(QWidget *parent = 0);
+};
+
+Widget::Widget(QWidget *parent)
+ : QWidget(parent)
+{
+//! [0]
+ QWidget *firstPageWidget = new QWidget;
+ QWidget *secondPageWidget = new QWidget;
+ QWidget *thirdPageWidget = new QWidget;
+
+ QStackedWidget *stackedWidget = new QStackedWidget;
+ stackedWidget->addWidget(firstPageWidget);
+ stackedWidget->addWidget(secondPageWidget);
+ stackedWidget->addWidget(thirdPageWidget);
+
+//! [0] //! [1]
+ QComboBox *pageComboBox = new QComboBox;
+ pageComboBox->addItem(tr("Page 1"));
+ pageComboBox->addItem(tr("Page 2"));
+ pageComboBox->addItem(tr("Page 3"));
+ connect(pageComboBox, SIGNAL(activated(int)),
+ stackedWidget, SLOT(setCurrentIndex(int)));
+
+//! [1] //! [2]
+ QVBoxLayout *layout = new QVBoxLayout;
+//! [2]
+ layout->addWidget(pageComboBox);
+//! [3]
+ layout->addWidget(stackedWidget);
+ setLayout(layout);
+//! [3]
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Widget widget;
+ widget.show();
+ return app.exec();
+}
diff --git a/doc/src/snippets/qstatustipevent/main.cpp b/doc/src/snippets/qstatustipevent/main.cpp
new file mode 100644
index 0000000000..b609db856c
--- /dev/null
+++ b/doc/src/snippets/qstatustipevent/main.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QApplication>
+
+class MainWindow : public QMainWindow
+{
+public:
+ MainWindow(QWidget *parent = 0);
+};
+
+//! [0] //! [1]
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+{
+//! [0]
+ QWidget *myWidget = new QWidget;
+ myWidget->setStatusTip(tr("This is my widget."));
+
+ setCentralWidget(myWidget);
+//! [1]
+
+//! [2]
+ QMenu *fileMenu = menuBar()->addMenu(tr("File"));
+
+ QAction *newAct = new QAction(tr("&New"), this);
+ newAct->setStatusTip(tr("Create a new file."));
+ fileMenu->addAction(newAct);
+//! [2]
+
+ statusBar()->showMessage(tr("Ready"));
+ setWindowTitle(tr("QStatusTipEvent"));
+//! [3]
+}
+//! [3]
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow window;
+ window.show();
+ return app.exec();
+}
+
diff --git a/doc/src/snippets/qstring/main.cpp b/doc/src/snippets/qstring/main.cpp
new file mode 100644
index 0000000000..bbc9e98901
--- /dev/null
+++ b/doc/src/snippets/qstring/main.cpp
@@ -0,0 +1,941 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QApplication>
+#include <stdio.h>
+
+class Widget : public QWidget
+{
+public:
+ Widget(QWidget *parent = 0);
+
+ void constCharPointer();
+ void constCharArray();
+ void characterReference();
+ void atFunction();
+ void stringLiteral();
+ void modify();
+ void index();
+ QString boolToString(bool b);
+ void nullVsEmpty();
+
+ void appendFunction();
+ void argFunction();
+ void chopFunction();
+ void compareFunction();
+ void compareSensitiveFunction();
+ void containsFunction();
+ void countFunction();
+ void dataFunction();
+ void endsWithFunction();
+ void fillFunction();
+ void fromRawDataFunction();
+
+ void indexOfFunction();
+ void firstIndexOfFunction();
+ void insertFunction();
+ void isNullFunction();
+ void isEmptyFunction();
+ void lastIndexOfFunction();
+ void leftFunction();
+ void leftJustifiedFunction();
+ void leftRefFunction();
+ void midFunction();
+ void midRefFunction();
+ void numberFunction();
+
+ void prependFunction();
+ void removeFunction();
+ void replaceFunction();
+ void reserveFunction();
+ void resizeFunction();
+ void rightFunction();
+ void rightJustifiedFunction();
+ void rightRefFunction();
+ void sectionFunction();
+ void setNumFunction();
+ void simplifiedFunction();
+
+ void sizeFunction();
+ void splitFunction();
+ void splitCaseSensitiveFunction();
+ void sprintfFunction();
+ void startsWithFunction();
+ void toDoubleFunction();
+ void toFloatFunction();
+ void toIntFunction();
+ void toLongFunction();
+ void toLongLongFunction();
+
+ void toLowerFunction();
+ void toShortFunction();
+ void toUIntFunction();
+ void toULongFunction();
+ void toULongLongFunction();
+ void toUShortFunction();
+ void toUpperFunction();
+ void trimmedFunction();
+ void truncateFunction();
+
+ void plusEqualOperator();
+ void arrayOperator();
+};
+
+Widget::Widget(QWidget *parent)
+ : QWidget(parent)
+{
+}
+
+void Widget::constCharPointer()
+{
+ //! [0]
+ QString str = "Hello";
+ //! [0]
+}
+
+void Widget::constCharArray()
+{
+ //! [1]
+ static const QChar data[4] = { 0x0055, 0x006e, 0x10e3, 0x03a3 };
+ QString str(data, 4);
+ //! [1]
+}
+
+void Widget::characterReference()
+{
+ //! [2]
+ QString str;
+ str.resize(4);
+
+ str[0] = QChar('U');
+ str[1] = QChar('n');
+ str[2] = QChar(0x10e3);
+ str[3] = QChar(0x03a3);
+ //! [2]
+}
+
+void Widget::atFunction()
+{
+ //! [3]
+ QString str;
+
+ for (int i = 0; i < str.size(); ++i) {
+ if (str.at(i) >= QChar('a') && str.at(i) <= QChar('f'))
+ qDebug() << "Found character in range [a-f]";
+ }
+ //! [3]
+}
+
+void Widget::stringLiteral()
+{
+ //! [4]
+ QString str;
+
+ if (str == "auto" || str == "extern"
+ || str == "static" || str == "register") {
+ // ...
+ }
+ //! [4]
+}
+
+void Widget::modify()
+{
+ //! [5]
+ QString str = "and";
+ str.prepend("rock "); // str == "rock and"
+ str.append(" roll"); // str == "rock and roll"
+ str.replace(5, 3, "&"); // str == "rock & roll"
+ //! [5]
+}
+
+void Widget::index()
+{
+ //! [6]
+ QString str = "We must be <b>bold</b>, very <b>bold</b>";
+ int j = 0;
+
+ while ((j = str.indexOf("<b>", j)) != -1) {
+ qDebug() << "Found <b> tag at index position" << j;
+ ++j;
+ }
+ //! [6]
+}
+
+//! [7]
+QString Widget::boolToString(bool b)
+{
+ QString result;
+ if (b)
+ result = "True";
+ else
+ result = "False";
+ return result;
+}
+//! [7]
+
+
+void Widget::nullVsEmpty()
+{
+ //! [8]
+ QString().isNull(); // returns true
+ QString().isEmpty(); // returns true
+
+ QString("").isNull(); // returns false
+ QString("").isEmpty(); // returns true
+
+ QString("abc").isNull(); // returns false
+ QString("abc").isEmpty(); // returns false
+ //! [8]
+}
+
+void Widget::appendFunction()
+{
+ //! [9]
+ QString x = "free";
+ QString y = "dom";
+
+ x.append(y);
+ // x == "freedom"
+ //! [9]
+
+ //! [10]
+ x.insert(x.size(), y);
+ //! [10]
+}
+
+void Widget::argFunction()
+{
+ //! [11]
+ QString i; // current file's number
+ QString total; // number of files to process
+ QString fileName; // current file's name
+
+ QString status = QString("Processing file %1 of %2: %3")
+ .arg(i).arg(total).arg(fileName);
+ //! [11]
+
+ //! [12] //! [13]
+ QString str;
+ //! [12]
+ str = "%1 %2";
+
+ str.arg("%1f", "Hello"); // returns "%1f Hello"
+ str.arg("%1f").arg("Hello"); // returns "Hellof %2"
+ //! [13]
+
+ //! [14]
+ str = QString("Decimal 63 is %1 in hexadecimal")
+ .arg(63, 0, 16);
+ // str == "Decimal 63 is 3f in hexadecimal"
+
+ 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"
+ //! [14]
+}
+
+void Widget::chopFunction()
+{
+ //! [15]
+ QString str("LOGOUT\r\n");
+ str.chop(2);
+ // str == "LOGOUT"
+ //! [15]
+}
+
+void Widget::compareFunction()
+{
+ int x = QString::compare("auto", "auto"); // x == 0
+ int y = QString::compare("auto", "car"); // y < 0
+ int z = QString::compare("car", "auto"); // z > 0
+}
+
+void Widget::compareSensitiveFunction()
+{
+ //! [16]
+ int x = QString::compare("aUtO", "AuTo", Qt::CaseInsensitive); // x == 0
+ int y = QString::compare("auto", "Car", Qt::CaseSensitive); // y > 0
+ int z = QString::compare("auto", "Car", Qt::CaseInsensitive); // z < 0
+ //! [16]
+}
+
+void Widget::containsFunction()
+{
+ //! [17]
+ QString str = "Peter Pan";
+ str.contains("peter", Qt::CaseInsensitive); // returns true
+ //! [17]
+}
+
+void Widget::countFunction()
+{
+ //! [18]
+ QString str = "banana and panama";
+ str.count(QRegExp("a[nm]a")); // returns 4
+ //! [18]
+}
+
+void Widget::dataFunction()
+{
+ //! [19]
+ QString str = "Hello world";
+ QChar *data = str.data();
+ while (!data->isNull()) {
+ qDebug() << data->unicode();
+ ++data;
+ }
+ //! [19]
+}
+
+void Widget::endsWithFunction()
+{
+ //! [20]
+ QString str = "Bananas";
+ str.endsWith("anas"); // returns true
+ str.endsWith("pple"); // returns false
+ //! [20]
+}
+
+void Widget::fillFunction()
+{
+ //! [21]
+ QString str = "Berlin";
+ str.fill('z');
+ // str == "zzzzzz"
+
+ str.fill('A', 2);
+ // str == "AA"
+ //! [21]
+}
+
+void Widget::fromRawDataFunction()
+{
+ //! [22]
+ QRegExp pattern;
+ static const QChar unicode[] = {
+ 0x005A, 0x007F, 0x00A4, 0x0060,
+ 0x1009, 0x0020, 0x0020};
+ int size = sizeof(unicode) / sizeof(QChar);
+
+ QString str = QString::fromRawData(unicode, size);
+ if (str.contains(QRegExp(pattern))) {
+ // ...
+ //! [22] //! [23]
+ }
+ //! [23]
+}
+
+void Widget::indexOfFunction()
+{
+ //! [24]
+ QString x = "sticky question";
+ QString 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
+ //! [24]
+}
+
+void Widget::firstIndexOfFunction()
+{
+ //! [25]
+ QString str = "the minimum";
+ str.indexOf(QRegExp("m[aeiou]"), 0); // returns 4
+ //! [25]
+}
+
+void Widget::insertFunction()
+{
+ //! [26]
+ QString str = "Meal";
+ str.insert(1, QString("ontr"));
+ // str == "Montreal"
+ //! [26]
+}
+
+void Widget::isEmptyFunction()
+{
+ //! [27]
+ QString().isEmpty(); // returns true
+ QString("").isEmpty(); // returns true
+ QString("x").isEmpty(); // returns false
+ QString("abc").isEmpty(); // returns false
+ //! [27]
+}
+
+void Widget::isNullFunction()
+{
+ //! [28]
+ QString().isNull(); // returns true
+ QString("").isNull(); // returns false
+ QString("abc").isNull(); // returns false
+ //! [28]
+}
+
+void Widget::lastIndexOfFunction()
+{
+ //! [29]
+ QString x = "crazy azimuths";
+ QString 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
+ //! [29]
+
+ //! [30]
+ QString str = "the minimum";
+ str.lastIndexOf(QRegExp("m[aeiou]")); // returns 8
+ //! [30]
+}
+
+void Widget::leftFunction()
+{
+ //! [31]
+ QString x = "Pineapple";
+ QString y = x.left(4); // y == "Pine"
+ //! [31]
+}
+
+void Widget::leftJustifiedFunction()
+{
+ //! [32]
+ QString s = "apple";
+ QString t = s.leftJustified(8, '.'); // t == "apple..."
+ //! [32]
+
+ //! [33]
+ QString str = "Pineapple";
+ str = str.leftJustified(5, '.', true); // str == "Pinea"
+ //! [33]
+}
+
+void Widget::midFunction()
+{
+ //! [34]
+ QString x = "Nine pineapples";
+ QString y = x.mid(5, 4); // y == "pine"
+ QString z = x.mid(5); // z == "pineapples"
+ //! [34]
+}
+
+void Widget::numberFunction()
+{
+ //! [35]
+ long a = 63;
+ QString s = QString::number(a, 16); // s == "3f"
+ QString t = QString::number(a, 16).toUpper(); // t == "3F"
+ //! [35]
+}
+
+void Widget::prependFunction()
+{
+ //! [36]
+ QString x = "ship";
+ QString y = "air";
+ x.prepend(y);
+ // x == "airship"
+ //! [36]
+}
+
+void Widget::removeFunction()
+{
+ //! [37]
+ QString s = "Montreal";
+ s.remove(1, 4);
+ // s == "Meal"
+ //! [37]
+
+ //! [38]
+ QString t = "Ali Baba";
+ t.remove(QChar('a'), Qt::CaseInsensitive);
+ // t == "li Bb"
+ //! [38]
+
+ //! [39]
+ QString r = "Telephone";
+ r.remove(QRegExp("[aeiou]."));
+ // r == "The"
+ //! [39]
+}
+
+void Widget::replaceFunction()
+{
+ //! [40]
+ QString x = "Say yes!";
+ QString y = "no";
+ x.replace(4, 3, y);
+ // x == "Say no!"
+ //! [40]
+
+ //! [41]
+ QString str = "colour behaviour flavour neighbour";
+ str.replace(QString("ou"), QString("o"));
+ // str == "color behavior flavor neighbor"
+ //! [41]
+
+ //! [42]
+ QString s = "Banana";
+ s.replace(QRegExp("a[mn]"), "ox");
+ // s == "Boxoxa"
+ //! [42]
+
+ //! [43]
+ QString t = "A <i>bon mot</i>.";
+ t.replace(QRegExp("<i>([^<]*)</i>"), "\\emph{\\1}");
+ // t == "A \\emph{bon mot}."
+ //! [43]
+
+ //! [86]
+ QString equis = "xxxxxx";
+ equis.replace("xx", "x");
+ // equis == "xxx"
+ //! [86]
+}
+
+void Widget::reserveFunction()
+{
+ //! [44]
+ QString result;
+ int maxSize;
+ bool condition;
+ QChar nextChar;
+
+ result.reserve(maxSize);
+
+ while (condition)
+ result.append(nextChar);
+
+ result.squeeze();
+ //! [44]
+}
+
+void Widget::resizeFunction()
+{
+ //! [45]
+ QString s = "Hello world";
+ s.resize(5);
+ // s == "Hello"
+
+ s.resize(8);
+ // s == "Hello???" (where ? stands for any character)
+ //! [45]
+
+ //! [46]
+ QString t = "Hello";
+ t += QString(10, 'X');
+ // t == "HelloXXXXXXXXXX"
+ //! [46]
+
+ //! [47]
+ QString r = "Hello";
+ r = r.leftJustified(10, ' ');
+ // r == "Hello "
+ //! [47]
+}
+
+void Widget::rightFunction()
+{
+ //! [48]
+ QString x = "Pineapple";
+ QString y = x.right(5); // y == "apple"
+ //! [48]
+}
+
+void Widget::rightJustifiedFunction()
+{
+ //! [49]
+ QString s = "apple";
+ QString t = s.rightJustified(8, '.'); // t == "...apple"
+ //! [49]
+
+ //! [50]
+ QString str = "Pineapple";
+ str = str.rightJustified(5, '.', true); // str == "Pinea"
+ //! [50]
+}
+
+void Widget::sectionFunction()
+{
+ //! [51] //! [52]
+ QString str;
+ //! [51]
+ QString csv = "forename,middlename,surname,phone";
+ QString path = "/usr/local/bin/myapp"; // First field is empty
+ QString::SectionFlag flag = QString::SectionSkipEmpty;
+
+
+ str = csv.section(',', 2, 2); // str == "surname"
+ str = path.section('/', 3, 4); // str == "bin/myapp"
+ str = path.section('/', 3, 3, flag); // str == "myapp"
+ //! [52]
+
+ //! [53]
+ str = csv.section(',', -3, -2); // str == "middlename,surname"
+ str = path.section('/', -1); // str == "myapp"
+ //! [53]
+
+ //! [54]
+ QString data = "forename**middlename**surname**phone";
+
+ str = data.section("**", 2, 2); // str == "surname"
+ str = data.section("**", -3, -2); // str == "middlename**surname"
+ //! [54]
+
+ //! [55]
+ QString line = "forename\tmiddlename surname \t \t phone";
+ QRegExp sep("\\s+");
+ str = line.section(sep, 2, 2); // s == "surname"
+ str = line.section(sep, -3, -2); // s == "middlename surname"
+ //! [55]
+}
+
+void Widget::setNumFunction()
+{
+ //! [56]
+ QString str;
+ str.setNum(1234); // str == "1234"
+ //! [56]
+}
+
+void Widget::simplifiedFunction()
+{
+ //! [57]
+ QString str = " lots\t of\nwhitespace\r\n ";
+ str = str.simplified();
+ // str == "lots of whitespace";
+ //! [57]
+}
+
+void Widget::sizeFunction()
+{
+ //! [58]
+ QString str = "World";
+ int n = str.size(); // n == 5
+ str.data()[0]; // returns 'W'
+ str.data()[4]; // returns 'd'
+ str.data()[5]; // returns '\0'
+ //! [58]
+}
+
+void Widget::splitFunction()
+{
+ //! [59]
+ QString str;
+ QStringList list;
+
+ str = "Some text\n\twith strange whitespace.";
+ list = str.split(QRegExp("\\s+"));
+ // list: [ "Some", "text", "with", "strange", "whitespace." ]
+ //! [59]
+
+ //! [60]
+ str = "This time, a normal English sentence.";
+ list = str.split(QRegExp("\\W+"), QString::SkipEmptyParts);
+ // list: [ "This", "time", "a", "normal", "English", "sentence" ]
+ //! [60]
+
+ //! [61]
+ str = "Now: this sentence fragment.";
+ list = str.split(QRegExp("\\b"));
+ // list: [ "", "Now", ": ", "this", " ", "sentence", " ", "fragment", "." ]
+ //! [61]
+}
+
+void Widget::splitCaseSensitiveFunction()
+{
+ //! [62]
+ QString str = "a,,b,c";
+
+ QStringList list1 = str.split(",");
+ // list1: [ "a", "", "b", "c" ]
+
+ QStringList list2 = str.split(",", QString::SkipEmptyParts);
+ // list2: [ "a", "b", "c" ]
+ //! [62]
+}
+
+void Widget::sprintfFunction()
+{
+ //! [63]
+ size_t BufSize;
+ char buf[BufSize];
+
+ ::snprintf(buf, BufSize, "%lld", 123456789LL);
+ QString str = QString::fromAscii(buf);
+ //! [63]
+
+ //! [64]
+ QString result;
+ QTextStream(&result) << "pi = " << 3.14;
+ // result == "pi = 3.14"
+ //! [64]
+}
+
+void Widget::startsWithFunction()
+{
+ //! [65]
+ QString str = "Bananas";
+ str.startsWith("Ban"); // returns true
+ str.startsWith("Car"); // returns false
+ //! [65]
+}
+
+void Widget::toDoubleFunction()
+{
+ //! [66]
+ QString str = "1234.56";
+ double val = str.toDouble(); // val == 1234.56
+ //! [66]
+
+ //! [67]
+ bool ok;
+ double d;
+
+ d = QString( "1234.56e-02" ).toDouble(&ok); // ok == true, d == 12.3456
+ //! [67]
+
+ //! [68] //! [69]
+ QLocale::setDefault(QLocale::C);
+ d = QString( "1234,56" ).toDouble(&ok); // ok == false
+ //! [68]
+ d = QString( "1234.56" ).toDouble(&ok); // ok == true, d == 1234.56
+
+ //! [69] //! [70]
+ 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
+
+ //! [70]
+ QLocale::setDefault(QLocale::C);
+ d = QString( "1,234,567.89" ).toDouble(&ok); // ok == false
+}
+
+void Widget::toFloatFunction()
+{
+ //! [71]
+ QString str1 = "1234.56";
+ str1.toFloat(); // returns 1234.56
+
+ bool ok;
+ QString str2 = "R2D2";
+ str2.toFloat(&ok); // returns 0.0, sets ok to false
+ //! [71]
+}
+
+void Widget::toIntFunction()
+{
+ //! [72]
+ QString str = "FF";
+ bool ok;
+ int hex = str.toInt(&ok, 16); // hex == 255, ok == true
+ int dec = str.toInt(&ok, 10); // dec == 0, ok == false
+ //! [72]
+}
+
+void Widget::toLongFunction()
+{
+ //! [73]
+ QString str = "FF";
+ bool ok;
+
+ long hex = str.toLong(&ok, 16); // hex == 255, ok == true
+ long dec = str.toLong(&ok, 10); // dec == 0, ok == false
+ //! [73]
+}
+
+void Widget::toLongLongFunction()
+{
+ //! [74]
+ QString str = "FF";
+ bool ok;
+
+ qint64 hex = str.toLongLong(&ok, 16); // hex == 255, ok == true
+ qint64 dec = str.toLongLong(&ok, 10); // dec == 0, ok == false
+ //! [74]
+}
+
+void Widget::toLowerFunction()
+{
+ //! [75]
+ QString str = "Qt by NOKIA";
+ str = str.toLower(); // str == "qt by nokia"
+ //! [75]
+}
+
+void Widget::toShortFunction()
+{
+ //! [76]
+ QString str = "FF";
+ bool ok;
+
+ short hex = str.toShort(&ok, 16); // hex == 255, ok == true
+ short dec = str.toShort(&ok, 10); // dec == 0, ok == false
+ //! [76]
+}
+
+void Widget::toUIntFunction()
+{
+ //! [77]
+ QString str = "FF";
+ bool ok;
+
+ uint hex = str.toUInt(&ok, 16); // hex == 255, ok == true
+ uint dec = str.toUInt(&ok, 10); // dec == 0, ok == false
+ //! [77]
+}
+
+void Widget::toULongFunction()
+{
+ //! [78]
+ QString str = "FF";
+ bool ok;
+
+ ulong hex = str.toULong(&ok, 16); // hex == 255, ok == true
+ ulong dec = str.toULong(&ok, 10); // dec == 0, ok == false
+ //! [78]
+}
+
+void Widget::toULongLongFunction()
+{
+ //! [79]
+ QString str = "FF";
+ bool ok;
+
+ quint64 hex = str.toULongLong(&ok, 16); // hex == 255, ok == true
+ quint64 dec = str.toULongLong(&ok, 10); // dec == 0, ok == false
+ //! [79]
+}
+
+void Widget::toUShortFunction()
+{
+ //! [80]
+ QString str = "FF";
+ bool ok;
+
+ ushort hex = str.toUShort(&ok, 16); // hex == 255, ok == true
+ ushort dec = str.toUShort(&ok, 10); // dec == 0, ok == false
+ //! [80]
+}
+
+void Widget::toUpperFunction()
+{
+ //! [81]
+ QString str = "TeXt";
+ str = str.toUpper(); // str == "TEXT"
+ //! [81]
+}
+
+void Widget::trimmedFunction()
+{
+ //! [82]
+ QString str = " lots\t of\nwhitespace\r\n ";
+ str = str.trimmed();
+ // str == "lots\t of\nwhitespace"
+ //! [82]
+}
+
+void Widget::truncateFunction()
+{
+ //! [83]
+ QString str = "Vladivostok";
+ str.truncate(4);
+ // str == "Vlad"
+ //! [83]
+}
+
+void Widget::plusEqualOperator()
+{
+ //! [84]
+ QString x = "free";
+ QString y = "dom";
+ x += y;
+ // x == "freedom"
+ //! [84]
+}
+
+void Widget::arrayOperator()
+{
+ //! [85]
+ QString str;
+
+ if (str[0] == QChar('?'))
+ str[0] = QChar('_');
+ //! [85]
+}
+
+void Widget::midRefFunction()
+{
+ //! [midRef]
+ QString x = "Nine pineapples";
+ QStringRef y = x.midRef(5, 4); // y == "pine"
+ QStringRef z = x.midRef(5); // z == "pineapples"
+ //! [midRef]
+}
+
+void Widget::leftRefFunction()
+{
+ //! [leftRef]
+ QString x = "Pineapple";
+ QStringRef y = x.leftRef(4); // y == "Pine"
+ //! [leftRef]
+}
+
+void Widget::rightRefFunction()
+{
+ //! [rightRef]
+ QString x = "Pineapple";
+ QStringRef y = x.rightRef(5); // y == "apple"
+ //! [rightRef]
+}
+
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Widget widget;
+ widget.show();
+ return app.exec();
+}
diff --git a/doc/src/snippets/qstring/stringbuilder.cpp b/doc/src/snippets/qstring/stringbuilder.cpp
new file mode 100644
index 0000000000..8ff1dd8206
--- /dev/null
+++ b/doc/src/snippets/qstring/stringbuilder.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]
+ QString foo;
+ QString type = "long";
+
+ foo->setText(QLatin1String("vector<") + type + QLatin1String(">::iterator"));
+
+ if (foo.startsWith("(" + type + ") 0x"))
+ ...
+//! [0]
+
+//! [3]
+ #define QT_USE_FAST_CONCATENATION
+//! [3]
+
+//! [4]
+ #define QT_USE_FAST_CONCATENATION
+ #define QT_USE_FAST_OPERATOR_PLUS
+//! [4]
+
+//! [5]
+ #include <QStringBuilder>
+
+ QString hello("hello");
+ QStringRef el(&hello, 2, 3);
+ QLatin1String world("world");
+ QString message = hello % el % world % QChar('!');
+//! [5]
diff --git a/doc/src/snippets/qstringlist/main.cpp b/doc/src/snippets/qstringlist/main.cpp
new file mode 100644
index 0000000000..3d56987b94
--- /dev/null
+++ b/doc/src/snippets/qstringlist/main.cpp
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <iostream>
+using namespace std;
+
+class Widget : public QWidget
+{
+public:
+ Widget(QWidget *parent = 0);
+};
+
+Widget::Widget(QWidget *parent)
+ : QWidget(parent)
+{
+//! [0]
+ QStringList fonts;
+ fonts << "Arial" << "Helvetica" << "Times" << "Courier";
+//! [0]
+
+//! [1]
+ for (int i = 0; i < fonts.size(); ++i)
+ cout << fonts.at(i).toLocal8Bit().constData() << endl;
+//! [1]
+
+//! [2]
+ QStringListIterator javaStyleIterator(fonts);
+ while (javaStyleIterator.hasNext())
+ cout << javaStyleIterator.next().toLocal8Bit().constData() << endl;
+//! [2]
+
+//! [3]
+ QStringList::const_iterator constIterator;
+ for (constIterator = fonts.constBegin(); constIterator != fonts.constEnd();
+ ++constIterator)
+ cout << (*constIterator).toLocal8Bit().constData() << endl;
+//! [3]
+
+//! [4]
+ QString str = fonts.join(",");
+ // str == "Arial,Helvetica,Times,Courier"
+//! [4]
+
+//! [5] //! [6]
+ QStringList list;
+//! [5]
+ list = str.split(",");
+ // list: ["Arial", "Helvetica", "Times", "Courier"]
+//! [6]
+
+//! [7]
+ QStringList monospacedFonts = fonts.filter(QRegExp("Courier|Fixed"));
+//! [7]
+
+//! [8]
+ QStringList files;
+ files << "$QTDIR/src/moc/moc.y"
+ << "$QTDIR/src/moc/moc.l"
+ << "$QTDIR/include/qconfig.h";
+
+ files.replaceInStrings("$QTDIR", "/usr/lib/qt");
+ // files: [ "/usr/lib/qt/src/moc/moc.y", ...]
+//! [8]
+
+ QString str1, str2, str3;
+//! [9]
+ QStringList longerList = (QStringList() << str1 << str2 << str3);
+//! [9]
+
+ list.clear();
+//! [10]
+ list << "Bill Murray" << "John Doe" << "Bill Clinton";
+
+//! [11]
+ QStringList result;
+//! [11]
+ result = list.filter("Bill");
+ // result: ["Bill Murray", "Bill Clinton"]
+//! [10]
+
+ result.clear();
+//! [12]
+ foreach (const QString &str, list) {
+ if (str.contains("Bill"))
+ result += str;
+ }
+//! [12]
+
+ list.clear();
+//! [13]
+ list << "alpha" << "beta" << "gamma" << "epsilon";
+ list.replaceInStrings("a", "o");
+ // list == ["olpho", "beto", "gommo", "epsilon"]
+//! [13]
+
+ list.clear();
+//! [14]
+ list << "alpha" << "beta" << "gamma" << "epsilon";
+ list.replaceInStrings(QRegExp("^a"), "o");
+ // list == ["olpha", "beta", "gamma", "epsilon"]
+//! [14]
+
+ list.clear();
+//! [15]
+ list << "Bill Clinton" << "Murray, Bill";
+ list.replaceInStrings(QRegExp("^(.*), (.*)$"), "\\2 \\1");
+ // list == ["Bill Clinton", "Bill Murray"]
+//! [15]
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Widget widget;
+ widget.show();
+ return app.exec();
+}
diff --git a/doc/src/snippets/qstringlistmodel/main.cpp b/doc/src/snippets/qstringlistmodel/main.cpp
new file mode 100644
index 0000000000..a64ba2b687
--- /dev/null
+++ b/doc/src/snippets/qstringlistmodel/main.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+class Widget : public QWidget
+{
+public:
+ Widget(QWidget *parent = 0);
+};
+
+Widget::Widget(QWidget *parent)
+ : QWidget(parent)
+{
+//! [0]
+ QStringListModel *model = new QStringListModel();
+ QStringList list;
+ list << "a" << "b" << "c";
+ model->setStringList(list);
+//! [0]
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Widget widget;
+ widget.show();
+ return app.exec();
+}
diff --git a/doc/src/snippets/qstyleoption/main.cpp b/doc/src/snippets/qstyleoption/main.cpp
new file mode 100644
index 0000000000..c3ef7298dd
--- /dev/null
+++ b/doc/src/snippets/qstyleoption/main.cpp
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QApplication>
+
+class MyPushButton : public QPushButton
+{
+public:
+ MyPushButton(QWidget *parent = 0);
+
+ void paintEvent(QPaintEvent *);
+};
+
+MyPushButton::MyPushButton(QWidget *parent)
+ : QPushButton(parent)
+{
+}
+
+//! [0]
+void MyPushButton::paintEvent(QPaintEvent *)
+{
+ QStyleOptionButton option;
+ option.initFrom(this);
+ option.state = isDown() ? QStyle::State_Sunken : QStyle::State_Raised;
+ if (isDefault())
+ option.features |= QStyleOptionButton::DefaultButton;
+ option.text = text();
+ option.icon = icon();
+
+ QPainter painter(this);
+ style()->drawControl(QStyle::CE_PushButton, &option, &painter, this);
+}
+//! [0]
+
+
+
+class MyStyle : public QStyle
+{
+public:
+ MyStyle();
+
+ void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget);
+};
+
+MyStyle::MyStyle()
+{
+//! [1]
+ QStyleOptionFrame *option;
+
+ if (const QStyleOptionFrame *frameOption =
+ qstyleoption_cast<const QStyleOptionFrame *>(option)) {
+ QStyleOptionFrameV2 frameOptionV2(*frameOption);
+
+ // draw the frame using frameOptionV2
+ }
+//! [1]
+
+//! [2]
+ if (const QStyleOptionProgressBar *progressBarOption =
+ qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
+ QStyleOptionProgressBarV2 progressBarV2(*progressBarOption);
+
+ // draw the progress bar using progressBarV2
+ }
+//! [2]
+
+//! [3]
+ if (const QStyleOptionTab *tabOption =
+ qstyleoption_cast<const QStyleOptionTab *>(option)) {
+ QStyleOptionTabV2 tabV2(*tabOption);
+
+ // draw the tab using tabV2
+ }
+//! [3]
+}
+
+//! [4]
+void MyStyle::drawPrimitive(PrimitiveElement element,
+ const QStyleOption *option,
+ QPainter *painter,
+ const QWidget *widget)
+{
+ if (element == PE_FrameFocusRect) {
+ const QStyleOptionFocusRect *focusRectOption =
+ qstyleoption_cast<const QStyleOptionFocusRect *>(option);
+ if (focusRectOption) {
+ // ...
+ }
+ }
+ // ...
+}
+//! [4]
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MyPushButton button;
+ button.show();
+ return app.exec();
+}
diff --git a/doc/src/snippets/qstyleplugin/main.cpp b/doc/src/snippets/qstyleplugin/main.cpp
new file mode 100644
index 0000000000..2c444d504b
--- /dev/null
+++ b/doc/src/snippets/qstyleplugin/main.cpp
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QtGui>
+
+class MyStylePlugin : public QStylePlugin
+{
+public:
+ MyStylePlugin(QObject *parent = 0);
+
+ QStyle *create(const QString &key);
+ QStringList keys() const;
+};
+
+class RocketStyle : public QCommonStyle
+{
+public:
+ RocketStyle() {};
+
+};
+
+class StarBusterStyle : public QCommonStyle
+{
+public:
+ StarBusterStyle() {};
+};
+
+MyStylePlugin::MyStylePlugin(QObject *parent)
+ : QStylePlugin(parent)
+{
+}
+
+//! [0]
+QStringList MyStylePlugin::keys() const
+{
+ return QStringList() << "Rocket" << "StarBuster";
+}
+//! [0]
+
+//! [1]
+QStyle *MyStylePlugin::create(const QString &key)
+{
+ QString lcKey = key;
+ if (lcKey == "rocket") {
+ return new RocketStyle;
+ } else if (lcKey == "starbuster") {
+ return new StarBusterStyle;
+ }
+ return 0;
+//! [1] //! [2]
+}
+//! [2]
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MyStylePlugin plugin;
+ return app.exec();
+}
diff --git a/doc/src/snippets/qtablewidget-resizing/mainwindow.cpp b/doc/src/snippets/qtablewidget-resizing/mainwindow.cpp
new file mode 100644
index 0000000000..e26031f678
--- /dev/null
+++ b/doc/src/snippets/qtablewidget-resizing/mainwindow.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ QMenu *tableMenu = new QMenu(tr("&Table"));
+
+ QAction *tableWidthAction = tableMenu->addAction(tr("Change Table &Width"));
+ QAction *tableHeightAction = tableMenu->addAction(tr("Change Table &Height"));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(tableMenu);
+
+//! [0]
+ tableWidget = new QTableWidget(this);
+//! [0]
+ tableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
+
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+ connect(tableWidthAction, SIGNAL(triggered()), this, SLOT(changeWidth()));
+ connect(tableHeightAction, SIGNAL(triggered()), this, SLOT(changeHeight()));
+
+ setupTableItems();
+
+ setCentralWidget(tableWidget);
+ setWindowTitle(tr("Table Widget Resizing"));
+}
+
+void MainWindow::setupTableItems()
+{
+//! [1]
+ tableWidget->setRowCount(10);
+ tableWidget->setColumnCount(5);
+//! [1]
+
+ for (int row = 0; row < tableWidget->rowCount(); ++row) {
+ for (int column = 0; column < tableWidget->columnCount(); ++column) {
+//! [2]
+ QTableWidgetItem *newItem = new QTableWidgetItem(tr("%1").arg(
+ (row+1)*(column+1)));
+ tableWidget->setItem(row, column, newItem);
+//! [2]
+ }
+ }
+}
+
+void MainWindow::changeWidth()
+{
+ bool ok;
+
+ int newWidth = QInputDialog::getInteger(this, tr("Change table width"),
+ tr("Input the number of columns required (1-20):"),
+ tableWidget->columnCount(), 1, 20, 1, &ok);
+
+ if (ok)
+ tableWidget->setColumnCount(newWidth);
+}
+
+void MainWindow::changeHeight()
+{
+ bool ok;
+
+ int newHeight = QInputDialog::getInteger(this, tr("Change table height"),
+ tr("Input the number of rows required (1-20):"),
+ tableWidget->rowCount(), 1, 20, 1, &ok);
+
+ if (ok)
+ tableWidget->setRowCount(newHeight);
+}
diff --git a/doc/src/snippets/qtablewidget-using/mainwindow.cpp b/doc/src/snippets/qtablewidget-using/mainwindow.cpp
new file mode 100644
index 0000000000..79a01f56d6
--- /dev/null
+++ b/doc/src/snippets/qtablewidget-using/mainwindow.cpp
@@ -0,0 +1,150 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include "math.h"
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ QMenu *itemsMenu = new QMenu(tr("&Items"));
+
+ QAction *sumItemsAction = itemsMenu->addAction(tr("&Sum Items"));
+ QAction *averageItemsAction = itemsMenu->addAction(tr("&Average Items"));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(itemsMenu);
+
+//! [0]
+ tableWidget = new QTableWidget(12, 3, this);
+//! [0]
+ tableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
+
+//! [1]
+ QTableWidgetItem *valuesHeaderItem = new QTableWidgetItem(tr("Values"));
+ tableWidget->setHorizontalHeaderItem(0, valuesHeaderItem);
+//! [1]
+ valuesHeaderItem->setTextAlignment(Qt::AlignVCenter);
+ QTableWidgetItem *squaresHeaderItem = new QTableWidgetItem(tr("Squares"));
+ squaresHeaderItem->setIcon(QIcon(QPixmap(":/Images/squared.png")));
+ squaresHeaderItem->setTextAlignment(Qt::AlignVCenter);
+//! [2]
+ QTableWidgetItem *cubesHeaderItem = new QTableWidgetItem(tr("Cubes"));
+ cubesHeaderItem->setIcon(QIcon(QPixmap(":/Images/cubed.png")));
+ cubesHeaderItem->setTextAlignment(Qt::AlignVCenter);
+//! [2]
+ tableWidget->setHorizontalHeaderItem(1, squaresHeaderItem);
+ tableWidget->setHorizontalHeaderItem(2, cubesHeaderItem);
+
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+ connect(sumItemsAction, SIGNAL(triggered()), this, SLOT(sumItems()));
+ connect(averageItemsAction, SIGNAL(triggered()), this, SLOT(averageItems()));
+
+ setupTableItems();
+
+ setCentralWidget(tableWidget);
+ setWindowTitle(tr("Table Widget"));
+}
+
+void MainWindow::setupTableItems()
+{
+ for (int row = 0; row < tableWidget->rowCount()-1; ++row) {
+ for (int column = 0; column < tableWidget->columnCount(); ++column) {
+//! [3]
+ QTableWidgetItem *newItem = new QTableWidgetItem(tr("%1").arg(
+ pow(row, column+1)));
+ tableWidget->setItem(row, column, newItem);
+//! [3]
+ }
+ }
+ for (int column = 0; column < tableWidget->columnCount(); ++column) {
+ QTableWidgetItem *newItem = new QTableWidgetItem;
+ newItem->setFlags(Qt::ItemIsEnabled);
+ tableWidget->setItem(tableWidget->rowCount()-1, column, newItem);
+ }
+}
+
+void MainWindow::averageItems()
+{
+ QList<QTableWidgetItem *> selected = tableWidget->selectedItems();
+ QTableWidgetItem *item;
+ int number = 0;
+ double total = 0;
+
+ foreach (item, selected) {
+ bool ok;
+ double value = item->text().toDouble(&ok);
+
+ if (ok && !item->text().isEmpty()) {
+ total += value;
+ number++;
+ }
+ }
+ if (number > 0)
+ tableWidget->currentItem()->setText(QString::number(total/number));
+}
+
+void MainWindow::sumItems()
+{
+//! [4]
+ QList<QTableWidgetItem *> selected = tableWidget->selectedItems();
+ QTableWidgetItem *item;
+ int number = 0;
+ double total = 0;
+
+ foreach (item, selected) {
+ bool ok;
+ double value = item->text().toDouble(&ok);
+
+ if (ok && !item->text().isEmpty()) {
+ total += value;
+ number++;
+ }
+ }
+//! [4]
+ if (number > 0)
+ tableWidget->currentItem()->setText(QString::number(total));
+}
diff --git a/doc/src/snippets/qtcast/qtcast.cpp b/doc/src/snippets/qtcast/qtcast.cpp
new file mode 100644
index 0000000000..68cff32ad5
--- /dev/null
+++ b/doc/src/snippets/qtcast/qtcast.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$
+**
+****************************************************************************/
+
+#include <QLabel>
+#include <QPushButton>
+
+#include "qtcast.h"
+
+MyWidget::MyWidget()
+{
+//! [0]
+ QObject *obj = new MyWidget;
+//! [0]
+
+//! [1]
+ QWidget *widget = qobject_cast<QWidget *>(obj);
+//! [1]
+
+//! [2]
+ MyWidget *myWidget = qobject_cast<MyWidget *>(obj);
+//! [2]
+
+//! [3]
+ QLabel *label = qobject_cast<QLabel *>(obj);
+//! [3] //! [4]
+ // label is 0
+//! [4]
+
+//! [5]
+ if (QLabel *label = qobject_cast<QLabel *>(obj)) {
+//! [5] //! [6]
+ label->setText(tr("Ping"));
+ } else if (QPushButton *button = qobject_cast<QPushButton *>(obj)) {
+ button->setText(tr("Pong!"));
+ }
+//! [6]
+}
+
+int main()
+{
+ return 0;
+}
diff --git a/doc/src/snippets/qtreewidget-using/mainwindow.cpp b/doc/src/snippets/qtreewidget-using/mainwindow.cpp
new file mode 100644
index 0000000000..a7e8277321
--- /dev/null
+++ b/doc/src/snippets/qtreewidget-using/mainwindow.cpp
@@ -0,0 +1,230 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ QMenu *itemsMenu = new QMenu(tr("&Items"));
+
+ insertAction = itemsMenu->addAction(tr("&Insert Item"));
+ removeAction = itemsMenu->addAction(tr("&Remove Item"));
+ removeAction->setEnabled(false);
+ itemsMenu->addSeparator();
+ ascendingAction = itemsMenu->addAction(tr("Sort in &Ascending Order"));
+ descendingAction = itemsMenu->addAction(tr("Sort in &Descending Order"));
+ autoSortAction = itemsMenu->addAction(tr("&Automatically Sort Items"));
+ autoSortAction->setCheckable(true);
+ itemsMenu->addSeparator();
+ QAction *findItemsAction = itemsMenu->addAction(tr("&Find Items"));
+ findItemsAction->setShortcut(tr("Ctrl+F"));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(itemsMenu);
+
+/* For convenient quoting:
+//! [0]
+ QTreeWidget *treeWidget = new QTreeWidget(this);
+//! [0]
+*/
+ treeWidget = new QTreeWidget(this);
+//! [1]
+ treeWidget->setColumnCount(2);
+//! [1] //! [2]
+ QStringList headers;
+ headers << tr("Subject") << tr("Default");
+ treeWidget->setHeaderLabels(headers);
+//! [2]
+
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+ connect(ascendingAction, SIGNAL(triggered()), this, SLOT(sortAscending()));
+ connect(autoSortAction, SIGNAL(triggered()), this, SLOT(updateSortItems()));
+ connect(descendingAction, SIGNAL(triggered()), this, SLOT(sortDescending()));
+ connect(findItemsAction, SIGNAL(triggered()), this, SLOT(findItems()));
+ connect(insertAction, SIGNAL(triggered()), this, SLOT(insertItem()));
+ connect(removeAction, SIGNAL(triggered()), this, SLOT(removeItem()));
+ connect(treeWidget,
+ SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
+ this, SLOT(updateMenus(QTreeWidgetItem *)));
+
+ setupTreeItems();
+ updateMenus(treeWidget->currentItem());
+
+ setCentralWidget(treeWidget);
+ setWindowTitle(tr("Tree Widget"));
+}
+
+void MainWindow::setupTreeItems()
+{
+//! [3]
+ QTreeWidgetItem *cities = new QTreeWidgetItem(treeWidget);
+ cities->setText(0, tr("Cities"));
+ QTreeWidgetItem *osloItem = new QTreeWidgetItem(cities);
+ osloItem->setText(0, tr("Oslo"));
+ osloItem->setText(1, tr("Yes"));
+//! [3]
+
+ (new QTreeWidgetItem(cities))->setText(0, tr("Stockholm"));
+ (new QTreeWidgetItem(cities))->setText(0, tr("Helsinki"));
+ (new QTreeWidgetItem(cities))->setText(0, tr("Copenhagen"));
+
+//! [4] //! [5]
+ QTreeWidgetItem *planets = new QTreeWidgetItem(treeWidget, cities);
+//! [4]
+ planets->setText(0, tr("Planets"));
+//! [5]
+ (new QTreeWidgetItem(planets))->setText(0, tr("Mercury"));
+ (new QTreeWidgetItem(planets))->setText(0, tr("Venus"));
+
+ QTreeWidgetItem *earthItem = new QTreeWidgetItem(planets);
+ earthItem->setText(0, tr("Earth"));
+ earthItem->setText(1, tr("Yes"));
+
+ (new QTreeWidgetItem(planets))->setText(0, tr("Mars"));
+ (new QTreeWidgetItem(planets))->setText(0, tr("Jupiter"));
+ (new QTreeWidgetItem(planets))->setText(0, tr("Saturn"));
+ (new QTreeWidgetItem(planets))->setText(0, tr("Uranus"));
+ (new QTreeWidgetItem(planets))->setText(0, tr("Neptune"));
+ (new QTreeWidgetItem(planets))->setText(0, tr("Pluto"));
+}
+
+void MainWindow::findItems()
+{
+ QString itemText = QInputDialog::getText(this, tr("Find Items"),
+ tr("Text to find (including wildcards):"));
+
+ if (itemText.isEmpty())
+ return;
+
+//! [6]
+ QTreeWidgetItem *item;
+//! [6]
+ foreach (item, treeWidget->selectedItems())
+ treeWidget->setItemSelected(item, false);
+
+//! [7]
+ QList<QTreeWidgetItem *> found = treeWidget->findItems(
+ itemText, Qt::MatchWildcard);
+
+ foreach (item, found) {
+ treeWidget->setItemSelected(item, true);
+ // Show the item->text(0) for each item.
+ }
+//! [7]
+}
+
+void MainWindow::insertItem()
+{
+ QTreeWidgetItem *currentItem = treeWidget->currentItem();
+
+ if (!currentItem)
+ return;
+
+ QString itemText = QInputDialog::getText(this, tr("Insert Item"),
+ tr("Input text for the new item:"));
+
+ if (itemText.isEmpty())
+ return;
+
+//! [8]
+ QTreeWidgetItem *parent = currentItem->parent();
+ QTreeWidgetItem *newItem;
+ if (parent)
+ newItem = new QTreeWidgetItem(parent, treeWidget->currentItem());
+ else
+//! [8] //! [9]
+ newItem = new QTreeWidgetItem(treeWidget, treeWidget->currentItem());
+//! [9]
+
+ newItem->setText(0, itemText);
+}
+
+void MainWindow::removeItem()
+{
+ QTreeWidgetItem *currentItem = treeWidget->currentItem();
+
+ if (!currentItem)
+ return;
+
+//! [10]
+ QTreeWidgetItem *parent = currentItem->parent();
+ int index;
+
+ if (parent) {
+ index = parent->indexOfChild(treeWidget->currentItem());
+ delete parent->takeChild(index);
+ } else {
+ index = treeWidget->indexOfTopLevelItem(treeWidget->currentItem());
+ delete treeWidget->takeTopLevelItem(index);
+//! [10] //! [11]
+ }
+//! [11]
+}
+
+void MainWindow::sortAscending()
+{
+ treeWidget->sortItems(0, Qt::AscendingOrder);
+}
+
+void MainWindow::sortDescending()
+{
+ treeWidget->sortItems(0, Qt::DescendingOrder);
+}
+
+void MainWindow::updateMenus(QTreeWidgetItem *current)
+{
+ insertAction->setEnabled(current != 0);
+ removeAction->setEnabled(current != 0);
+}
+
+void MainWindow::updateSortItems()
+{
+ ascendingAction->setEnabled(!autoSortAction->isChecked());
+ descendingAction->setEnabled(!autoSortAction->isChecked());
+
+ treeWidget->setSortingEnabled(autoSortAction->isChecked());
+}
diff --git a/doc/src/snippets/qtreewidgetitemiterator-using/mainwindow.cpp b/doc/src/snippets/qtreewidgetitemiterator-using/mainwindow.cpp
new file mode 100644
index 0000000000..497540e054
--- /dev/null
+++ b/doc/src/snippets/qtreewidgetitemiterator-using/mainwindow.cpp
@@ -0,0 +1,197 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ QMenu *itemsMenu = new QMenu(tr("&Items"));
+
+ insertAction = itemsMenu->addAction(tr("&Insert Item"));
+ removeAction = itemsMenu->addAction(tr("&Remove Item"));
+ removeAction->setEnabled(false);
+ itemsMenu->addSeparator();
+ ascendingAction = itemsMenu->addAction(tr("Sort in &Ascending Order"));
+ descendingAction = itemsMenu->addAction(tr("Sort in &Descending Order"));
+ autoSortAction = itemsMenu->addAction(tr("&Automatically Sort Items"));
+ autoSortAction->setCheckable(true);
+ itemsMenu->addSeparator();
+ QAction *findItemsAction = itemsMenu->addAction(tr("&Find Items"));
+ findItemsAction->setShortcut(tr("Ctrl+F"));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(itemsMenu);
+
+/* For convenient quoting:
+ QTreeWidget *treeWidget = new QTreeWidget(this);
+*/
+ treeWidget = new QTreeWidget(this);
+ treeWidget->setColumnCount(2);
+ QStringList headers;
+ headers << tr("Subject") << tr("Default");
+ treeWidget->setHeaderLabels(headers);
+
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+ connect(ascendingAction, SIGNAL(triggered()), this, SLOT(sortAscending()));
+ connect(autoSortAction, SIGNAL(triggered()), this, SLOT(updateSortItems()));
+ connect(descendingAction, SIGNAL(triggered()), this, SLOT(sortDescending()));
+ connect(findItemsAction, SIGNAL(triggered()), this, SLOT(findItems()));
+ connect(insertAction, SIGNAL(triggered()), this, SLOT(insertItem()));
+ connect(removeAction, SIGNAL(triggered()), this, SLOT(removeItem()));
+ connect(treeWidget,
+ SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
+ this, SLOT(updateMenus(QTreeWidgetItem *)));
+
+ setupTreeItems();
+ updateMenus(treeWidget->currentItem());
+
+ setCentralWidget(treeWidget);
+ setWindowTitle(tr("Tree Widget"));
+}
+
+void MainWindow::setupTreeItems()
+{
+ QTreeWidgetItem *planets = new QTreeWidgetItem(treeWidget);
+ planets->setText(0, tr("Planets"));
+ (new QTreeWidgetItem(planets))->setText(0, tr("Mercury"));
+ (new QTreeWidgetItem(planets))->setText(0, tr("Venus"));
+
+ QTreeWidgetItem *earthItem = new QTreeWidgetItem(planets);
+ earthItem->setText(0, tr("Earth"));
+ earthItem->setText(1, tr("Yes"));
+
+ (new QTreeWidgetItem(planets))->setText(0, tr("Mars"));
+ (new QTreeWidgetItem(planets))->setText(0, tr("Jupiter"));
+ (new QTreeWidgetItem(planets))->setText(0, tr("Saturn"));
+ (new QTreeWidgetItem(planets))->setText(0, tr("Uranus"));
+ (new QTreeWidgetItem(planets))->setText(0, tr("Neptune"));
+ (new QTreeWidgetItem(planets))->setText(0, tr("Pluto"));
+}
+
+void MainWindow::findItems()
+{
+ QString itemText = QInputDialog::getText(this, tr("Find Items"),
+ tr("Text to find:"));
+
+ if (itemText.isEmpty())
+ return;
+
+//! [0]
+ QTreeWidgetItemIterator it(treeWidget);
+ while (*it) {
+ if ((*it)->text(0) == itemText)
+ (*it)->setSelected(true);
+ ++it;
+ }
+//! [0]
+}
+
+void MainWindow::insertItem()
+{
+ QTreeWidgetItem *currentItem = treeWidget->currentItem();
+
+ if (!currentItem)
+ return;
+
+ QString itemText = QInputDialog::getText(this, tr("Insert Item"),
+ tr("Input text for the new item:"));
+
+ if (itemText.isEmpty())
+ return;
+
+ QTreeWidgetItem *parent = currentItem->parent();
+ QTreeWidgetItem *newItem;
+ if (parent)
+ newItem = new QTreeWidgetItem(parent, treeWidget->currentItem());
+ else
+ newItem = new QTreeWidgetItem(treeWidget, treeWidget->currentItem());
+
+ newItem->setText(0, itemText);
+}
+
+void MainWindow::removeItem()
+{
+ QTreeWidgetItem *currentItem = treeWidget->currentItem();
+
+ if (!currentItem)
+ return;
+
+ QTreeWidgetItem *parent = currentItem->parent();
+ int index;
+
+ if (parent) {
+ index = parent->indexOfChild(treeWidget->currentItem());
+ delete parent->takeChild(index);
+ } else {
+ index = treeWidget->indexOfTopLevelItem(treeWidget->currentItem());
+ delete treeWidget->takeTopLevelItem(index);
+ }
+}
+
+void MainWindow::sortAscending()
+{
+ treeWidget->sortItems(0, Qt::AscendingOrder);
+}
+
+void MainWindow::sortDescending()
+{
+ treeWidget->sortItems(0, Qt::DescendingOrder);
+}
+
+void MainWindow::updateMenus(QTreeWidgetItem *current)
+{
+ insertAction->setEnabled(current != 0);
+ removeAction->setEnabled(current != 0);
+}
+
+void MainWindow::updateSortItems()
+{
+ ascendingAction->setEnabled(!autoSortAction->isChecked());
+ descendingAction->setEnabled(!autoSortAction->isChecked());
+
+ treeWidget->setSortingEnabled(autoSortAction->isChecked());
+}
diff --git a/doc/src/snippets/quiloader/main.cpp b/doc/src/snippets/quiloader/main.cpp
new file mode 100644
index 0000000000..2b9acd2d3f
--- /dev/null
+++ b/doc/src/snippets/quiloader/main.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QtUiTools>
+
+#include "mywidget.h"
+
+//! [0]
+QWidget *loadCustomWidget(QWidget *parent)
+{
+ QUiLoader loader;
+ QWidget *myWidget;
+
+ QStringList availableWidgets = loader.availableWidgets();
+
+ if (availableWidgets.contains("AnalogClock"))
+ myWidget = loader.createWidget("AnalogClock", parent);
+
+ return myWidget;
+}
+//! [0]
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MyWidget widget;
+ widget.show();
+
+ QWidget *customWidget = loadCustomWidget(0);
+ customWidget->show();
+ return app.exec();
+}
diff --git a/doc/src/snippets/quiloader/mywidget.cpp b/doc/src/snippets/quiloader/mywidget.cpp
new file mode 100644
index 0000000000..989a5ef075
--- /dev/null
+++ b/doc/src/snippets/quiloader/mywidget.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QtUiTools>
+
+#include "mywidget.h"
+
+//! [0]
+MyWidget::MyWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ QUiLoader loader;
+ QFile file(":/forms/myform.ui");
+ file.open(QFile::ReadOnly);
+ QWidget *myWidget = loader.load(&file, this);
+ file.close();
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(myWidget);
+ setLayout(layout);
+}
+//! [0]
diff --git a/doc/src/snippets/quiloader/mywidget.qrc b/doc/src/snippets/quiloader/mywidget.qrc
new file mode 100644
index 0000000000..47684d68b8
--- /dev/null
+++ b/doc/src/snippets/quiloader/mywidget.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/forms">
+<file>myform.ui</file>
+</qresource>
+</RCC>
diff --git a/doc/src/snippets/qx11embedcontainer/main.cpp b/doc/src/snippets/qx11embedcontainer/main.cpp
new file mode 100644
index 0000000000..38d6d28292
--- /dev/null
+++ b/doc/src/snippets/qx11embedcontainer/main.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QX11EmbedContainer>
+
+//! [0]
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ if (app.arguments().count() != 2) {
+ qFatal("Error - expected executable path as argument");
+ return 1;
+ }
+
+ QX11EmbedContainer container;
+ container.show();
+
+ QProcess process(&container);
+ QString executable(app.arguments()[1]);
+ QStringList arguments;
+ arguments << QString::number(container.winId());
+ process.start(executable, arguments);
+
+ int status = app.exec();
+ process.close();
+ return status;
+}
+//! [0]
diff --git a/doc/src/snippets/qx11embedwidget/main.cpp b/doc/src/snippets/qx11embedwidget/main.cpp
new file mode 100644
index 0000000000..4f82399699
--- /dev/null
+++ b/doc/src/snippets/qx11embedwidget/main.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$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include "embedwidget.h"
+
+//! [0]
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ if (app.arguments().count() != 2) {
+ qFatal("Error - expected window id as argument");
+ return 1;
+ }
+
+ QString windowId(app.arguments()[1]);
+ EmbedWidget window;
+ window.embedInto(windowId.toULong());
+ window.show();
+
+ return app.exec();
+}
+//! [0]
diff --git a/doc/src/snippets/qxmlstreamwriter/main.cpp b/doc/src/snippets/qxmlstreamwriter/main.cpp
new file mode 100644
index 0000000000..2e7deff168
--- /dev/null
+++ b/doc/src/snippets/qxmlstreamwriter/main.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$
+**
+****************************************************************************/
+
+#include <QCoreApplication>
+#include <QFile>
+#include <QXmlStreamWriter>
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication app(argc, argv);
+ QFile output;
+ output.open(stdout, QIODevice::WriteOnly);
+//! [write output]
+//! [start stream]
+ QXmlStreamWriter stream(&output);
+ stream.setAutoFormatting(true);
+ stream.writeStartDocument();
+//! [start stream]
+ stream.writeDTD("<!DOCTYPE xbel>");
+ stream.writeStartElement("xbel");
+ stream.writeAttribute("version", "1.0");
+ stream.writeStartElement("folder");
+ stream.writeAttribute("folded", "no");
+//! [write element]
+ stream.writeStartElement("bookmark");
+ stream.writeAttribute("href", "http://qt.nokia.com/");
+ stream.writeTextElement("title", "Qt Home");
+ stream.writeEndElement(); // bookmark
+//! [write element]
+ stream.writeEndElement(); // folder
+ stream.writeEndElement(); // xbel
+//! [finish stream]
+ stream.writeEndDocument();
+//! [finish stream]
+//! [write output]
+ output.close();
+ return 0;
+}
diff --git a/doc/src/snippets/separations/finalwidget.cpp b/doc/src/snippets/separations/finalwidget.cpp
new file mode 100644
index 0000000000..8d2b7feacc
--- /dev/null
+++ b/doc/src/snippets/separations/finalwidget.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$
+**
+****************************************************************************/
+
+/*
+finalwidget.cpp
+
+A widget to display an image and a label containing a description.
+*/
+
+#include <QtGui>
+#include "finalwidget.h"
+
+FinalWidget::FinalWidget(QWidget *parent, const QString &name,
+ const QSize &labelSize)
+ : QFrame(parent)
+{
+ hasImage = false;
+ imageLabel = new QLabel;
+ imageLabel->setFrameShadow(QFrame::Sunken);
+ imageLabel->setFrameShape(QFrame::StyledPanel);
+ imageLabel->setMinimumSize(labelSize);
+ nameLabel = new QLabel(name);
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(imageLabel, 1);
+ layout->addWidget(nameLabel, 0);
+ setLayout(layout);
+}
+
+/*!
+ If the mouse moves far enough when the left mouse button is held down,
+ start a drag and drop operation.
+*/
+
+void FinalWidget::mouseMoveEvent(QMouseEvent *event)
+{
+ if (!(event->buttons() & Qt::LeftButton))
+ return;
+ if ((event->pos() - dragStartPosition).manhattanLength()
+ < QApplication::startDragDistance())
+ return;
+ if (!hasImage)
+ return;
+
+ QDrag *drag = new QDrag(this);
+ QMimeData *mimeData = new QMimeData;
+
+//! [0]
+ QByteArray output;
+ QBuffer outputBuffer(&output);
+ outputBuffer.open(QIODevice::WriteOnly);
+ imageLabel->pixmap()->toImage().save(&outputBuffer, "PNG");
+ mimeData->setData("image/png", output);
+//! [0]
+/*
+//! [1]
+ mimeData->setImageData(QVariant(*imageLabel->pixmap()));
+//! [1]
+*/
+ drag->setMimeData(mimeData);
+ drag->setPixmap(imageLabel->pixmap()->scaled(64, 64, Qt::KeepAspectRatio));
+//! [2]
+ drag->setHotSpot(QPoint(drag->pixmap().width()/2,
+ drag->pixmap().height()));
+//! [2]
+
+ drag->start();
+}
+
+/*!
+ Check for left mouse button presses in order to enable drag and drop.
+*/
+
+void FinalWidget::mousePressEvent(QMouseEvent *event)
+{
+ if (event->button() == Qt::LeftButton)
+ dragStartPosition = event->pos();
+}
+
+const QPixmap* FinalWidget::pixmap() const
+{
+ return imageLabel->pixmap();
+}
+
+void FinalWidget::setPixmap(const QPixmap &pixmap)
+{
+ imageLabel->setPixmap(pixmap);
+ hasImage = true;
+}
diff --git a/doc/src/snippets/settings/settings.cpp b/doc/src/snippets/settings/settings.cpp
new file mode 100644
index 0000000000..2cbe1804be
--- /dev/null
+++ b/doc/src/snippets/settings/settings.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+QWidget *win;
+QWidget *panel;
+
+void snippet_ctor1()
+{
+//! [0]
+ QSettings settings("MySoft", "Star Runner");
+//! [0]
+}
+
+void snippet_ctor2()
+{
+//! [1]
+ QCoreApplication::setOrganizationName("MySoft");
+//! [1] //! [2]
+ QCoreApplication::setOrganizationDomain("mysoft.com");
+//! [2] //! [3]
+ QCoreApplication::setApplicationName("Star Runner");
+//! [3]
+
+//! [4]
+ QSettings settings;
+//! [4]
+
+//! [5]
+ settings.setValue("editor/wrapMargin", 68);
+//! [5] //! [6]
+ int margin = settings.value("editor/wrapMargin").toInt();
+//! [6]
+ {
+//! [7]
+ int margin = settings.value("editor/wrapMargin", 80).toInt();
+//! [7]
+ }
+
+//! [8]
+ settings.setValue("mainwindow/size", win->size());
+//! [8] //! [9]
+ settings.setValue("mainwindow/fullScreen", win->isFullScreen());
+//! [9] //! [10]
+ settings.setValue("outputpanel/visible", panel->isVisible());
+//! [10]
+
+//! [11]
+ settings.beginGroup("mainwindow");
+ settings.setValue("size", win->size());
+ settings.setValue("fullScreen", win->isFullScreen());
+ settings.endGroup();
+//! [11]
+
+//! [12]
+ settings.beginGroup("outputpanel");
+ settings.setValue("visible", panel->isVisible());
+ settings.endGroup();
+//! [12]
+}
+
+void snippet_locations()
+{
+//! [13]
+ QSettings obj1("MySoft", "Star Runner");
+//! [13] //! [14]
+ QSettings obj2("MySoft");
+ QSettings obj3(QSettings::SystemScope, "MySoft", "Star Runner");
+ QSettings obj4(QSettings::SystemScope, "MySoft");
+//! [14]
+
+ {
+//! [15]
+ QSettings settings(QSettings::IniFormat, QSettings::UserScope,
+ "MySoft", "Star Runner");
+//! [15]
+ }
+
+ {
+ QSettings settings("starrunner.ini", QSettings::IniFormat);
+ }
+
+ {
+ QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft",
+ QSettings::NativeFormat);
+ }
+}
+
+class MainWindow : public QMainWindow
+{
+public:
+ MainWindow();
+
+ void writeSettings();
+ void readSettings();
+
+protected:
+ void closeEvent(QCloseEvent *event);
+};
+
+//! [16]
+void MainWindow::writeSettings()
+{
+ QSettings settings("Moose Soft", "Clipper");
+
+ settings.beginGroup("MainWindow");
+ settings.setValue("size", size());
+ settings.setValue("pos", pos());
+ settings.endGroup();
+}
+//! [16]
+
+//! [17]
+void MainWindow::readSettings()
+{
+ QSettings settings("Moose Soft", "Clipper");
+
+ settings.beginGroup("MainWindow");
+ resize(settings.value("size", QSize(400, 400)).toSize());
+ move(settings.value("pos", QPoint(200, 200)).toPoint());
+ settings.endGroup();
+}
+//! [17]
+
+//! [18]
+MainWindow::MainWindow()
+{
+//! [18] //! [19]
+ readSettings();
+//! [19] //! [20]
+}
+//! [20]
+
+bool userReallyWantsToQuit() { return true; }
+
+//! [21]
+void MainWindow::closeEvent(QCloseEvent *event)
+{
+ if (userReallyWantsToQuit()) {
+ writeSettings();
+ event->accept();
+ } else {
+ event->ignore();
+ }
+}
+//! [21]
diff --git a/doc/src/snippets/shareddirmodel/main.cpp b/doc/src/snippets/shareddirmodel/main.cpp
new file mode 100644
index 0000000000..1cd2bde1bd
--- /dev/null
+++ b/doc/src/snippets/shareddirmodel/main.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$
+**
+****************************************************************************/
+
+/*
+ main.cpp
+
+ A simple example of how to view a model in several views, and share a
+ selection model.
+*/
+
+#include <QtGui>
+
+//! [0] //! [1]
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QSplitter *splitter = new QSplitter;
+
+//! [2] //! [3]
+ QFileSystemModel *model = new QFileSystemModel;
+ model->setRootPath(QDir::currentPath());
+//! [0] //! [2] //! [4] //! [5]
+ QTreeView *tree = new QTreeView(splitter);
+//! [3] //! [6]
+ tree->setModel(model);
+//! [4] //! [6] //! [7]
+ tree->setRootIndex(model->index(QDir::currentPath()));
+//! [7]
+
+ QListView *list = new QListView(splitter);
+ list->setModel(model);
+ list->setRootIndex(model->index(QDir::currentPath()));
+
+//! [5]
+ QItemSelectionModel *selection = new QItemSelectionModel(model);
+ tree->setSelectionModel(selection);
+ list->setSelectionModel(selection);
+
+//! [8]
+ splitter->setWindowTitle("Two views onto the same file system model");
+ splitter->show();
+ return app.exec();
+}
+//! [1] //! [8]
diff --git a/doc/src/snippets/sharedemployee/employee.h b/doc/src/snippets/sharedemployee/employee.h
new file mode 100644
index 0000000000..981e007b8d
--- /dev/null
+++ b/doc/src/snippets/sharedemployee/employee.h
@@ -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$
+**
+****************************************************************************/
+
+#ifndef EMPLOYEE_H
+#define EMPLOYEE_H
+
+//! [0]
+#include <QSharedData>
+#include <QString>
+
+class EmployeeData : public QSharedData
+{
+ public:
+ EmployeeData() : id(-1) { }
+ EmployeeData(const EmployeeData &other)
+ : QSharedData(other), id(other.id), name(other.name) { }
+ ~EmployeeData() { }
+
+ int id;
+ QString name;
+};
+
+class Employee
+{
+ public:
+//! [1]
+ Employee() { d = new EmployeeData; }
+//! [1] //! [2]
+ Employee(int id, QString name) {
+ d = new EmployeeData;
+ setId(id);
+ setName(name);
+ }
+//! [2] //! [7]
+ Employee(const Employee &other)
+ : d (other.d)
+ {
+ }
+//! [7]
+//! [3]
+ void setId(int id) { d->id = id; }
+//! [3] //! [4]
+ void setName(QString name) { d->name = name; }
+//! [4]
+
+//! [5]
+ int id() const { return d->id; }
+//! [5] //! [6]
+ QString name() const { return d->name; }
+//! [6]
+
+ private:
+ QSharedDataPointer<EmployeeData> d;
+};
+//! [0]
+
+#endif
diff --git a/doc/src/snippets/sharedemployee/main.cpp b/doc/src/snippets/sharedemployee/main.cpp
new file mode 100644
index 0000000000..a8f53a738c
--- /dev/null
+++ b/doc/src/snippets/sharedemployee/main.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]
+#include "employee.h"
+
+int main()
+{
+ Employee e1(1001, "Albrecht Durer");
+ Employee e2 = e1;
+ e1.setName("Hans Holbein");
+}
+//! [0]
diff --git a/doc/src/snippets/signalmapper/filereader.cpp b/doc/src/snippets/signalmapper/filereader.cpp
new file mode 100644
index 0000000000..d7be2e854b
--- /dev/null
+++ b/doc/src/snippets/signalmapper/filereader.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 config.tests of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include "filereader.h"
+
+
+FileReader::FileReader(QWidget *parent)
+ : QWidget(parent)
+{
+ textEdit = new QTextEdit;
+
+ taxFileButton = new QPushButton("Tax File");
+ accountFileButton = new QPushButton("Accounts File");
+ reportFileButton = new QPushButton("Report File");
+
+//! [0]
+ signalMapper = new QSignalMapper(this);
+ signalMapper->setMapping(taxFileButton, QString("taxfile.txt"));
+ signalMapper->setMapping(accountFileButton, QString("accountsfile.txt"));
+ signalMapper->setMapping(reportFileButton, QString("reportfile.txt"));
+
+ connect(taxFileButton, SIGNAL(clicked()),
+ signalMapper, SLOT (map()));
+ connect(accountFileButton, SIGNAL(clicked()),
+ signalMapper, SLOT (map()));
+ connect(reportFileButton, SIGNAL(clicked()),
+ signalMapper, SLOT (map()));
+//! [0]
+
+//! [1]
+ connect(signalMapper, SIGNAL(mapped(QString)),
+ this, SLOT(readFile(QString)));
+//! [1]
+
+/*
+//! [2]
+ //slower due to signature normalization at runtime
+
+ connect(signalMapper, SIGNAL(mapped(const QString &)),
+ this, SLOT(readFile(const QString &)));
+//! [2]
+*/
+ QHBoxLayout *buttonLayout = new QHBoxLayout;
+ buttonLayout->addWidget(taxFileButton);
+ buttonLayout->addWidget(accountFileButton);
+ buttonLayout->addWidget(reportFileButton);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(textEdit);
+ mainLayout->addLayout(buttonLayout);
+
+ setLayout(mainLayout);
+}
+
+void FileReader::readFile(const QString &filename)
+{
+ QFile file(filename);
+
+ if (!file.open(QIODevice::ReadOnly)) {
+ QMessageBox::information(this, tr("Unable to open file"),
+ file.errorString());
+ return;
+ }
+
+
+ QTextStream in(&file);
+ textEdit->setPlainText(in.readAll());
+}
+
diff --git a/doc/src/snippets/signalsandslots/lcdnumber.h b/doc/src/snippets/signalsandslots/lcdnumber.h
new file mode 100644
index 0000000000..3706387d24
--- /dev/null
+++ b/doc/src/snippets/signalsandslots/lcdnumber.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** 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 LCDNUMBER_H
+//! [0] //! [1]
+#define LCDNUMBER_H
+//! [1]
+
+//! [2]
+#include <QFrame>
+//! [2]
+
+//! [3]
+class LcdNumber : public QFrame
+//! [3] //! [4]
+{
+//! [4] //! [5]
+ Q_OBJECT
+//! [5]
+
+//! [6]
+public:
+//! [6] //! [7]
+ LcdNumber(QWidget *parent = 0);
+//! [7]
+
+//! [8]
+signals:
+//! [8] //! [9]
+ void overflow();
+//! [9]
+
+//! [10]
+public slots:
+//! [10] //! [11]
+ void display(int num);
+ void display(double num);
+ void display(const QString &str);
+ void setHexMode();
+ void setDecMode();
+ void setOctMode();
+ void setBinMode();
+ void setSmallDecimalPoint(bool point);
+//! [11] //! [12]
+};
+//! [12]
+
+//! [13]
+#endif
+//! [13]
diff --git a/doc/src/snippets/signalsandslots/signalsandslots.cpp b/doc/src/snippets/signalsandslots/signalsandslots.cpp
new file mode 100644
index 0000000000..42622322ed
--- /dev/null
+++ b/doc/src/snippets/signalsandslots/signalsandslots.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$
+**
+****************************************************************************/
+
+#include <QAbstractButton>
+
+#include "signalsandslots.h"
+
+//! [0]
+void Counter::setValue(int value)
+{
+ if (value != m_value) {
+ m_value = value;
+ emit valueChanged(value);
+ }
+}
+//! [0]
+
+int main()
+{
+//! [1]
+ Counter a, b;
+//! [1] //! [2]
+ QObject::connect(&a, SIGNAL(valueChanged(int)),
+ &b, SLOT(setValue(int)));
+//! [2]
+
+//! [3]
+ a.setValue(12); // a.value() == 12, b.value() == 12
+//! [3] //! [4]
+ b.setValue(48); // a.value() == 12, b.value() == 48
+//! [4]
+
+
+ QWidget *widget = reinterpret_cast<QWidget *>(new QObject(0));
+//! [5]
+ if (widget->inherits("QAbstractButton")) {
+ QAbstractButton *button = static_cast<QAbstractButton *>(widget);
+ button->toggle();
+//! [5] //! [6]
+ }
+//! [6]
+
+//! [7]
+ if (QAbstractButton *button = qobject_cast<QAbstractButton *>(widget))
+ button->toggle();
+//! [7]
+}
diff --git a/doc/src/snippets/signalsandslots/signalsandslots.h b/doc/src/snippets/signalsandslots/signalsandslots.h
new file mode 100644
index 0000000000..0671181f5f
--- /dev/null
+++ b/doc/src/snippets/signalsandslots/signalsandslots.h
@@ -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$
+**
+****************************************************************************/
+
+#ifndef SIGNALSANDSLOTS_H
+#define SIGNALSANDSLOTS_H
+
+#define Counter PlainCounter
+
+//! [0]
+class Counter
+{
+public:
+ Counter() { m_value = 0; }
+
+ int value() const { return m_value; }
+ void setValue(int value);
+
+private:
+ int m_value;
+};
+//! [0]
+
+#undef Counter
+#define Counter ObjectCounter
+
+//! [1]
+#include <QObject>
+//! [1]
+
+//! [2]
+class Counter : public QObject
+//! [2] //! [3]
+{
+ Q_OBJECT
+
+public:
+ Counter() { m_value = 0; }
+
+ int value() const { return m_value; }
+
+public slots:
+ void setValue(int value);
+
+signals:
+ void valueChanged(int newValue);
+
+private:
+ int m_value;
+};
+//! [3]
+
+#endif
diff --git a/doc/src/snippets/splitter/splitter.cpp b/doc/src/snippets/splitter/splitter.cpp
new file mode 100644
index 0000000000..b72eb02e4c
--- /dev/null
+++ b/doc/src/snippets/splitter/splitter.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+void processSize(int)
+{
+}
+
+int main()
+{
+ QWidget *parent = 0;
+
+//! [0]
+ QSplitter *splitter = new QSplitter(parent);
+ QListView *listview = new QListView;
+ QTreeView *treeview = new QTreeView;
+ QTextEdit *textedit = new QTextEdit;
+ splitter->addWidget(listview);
+ splitter->addWidget(treeview);
+ splitter->addWidget(textedit);
+//! [0]
+
+ {
+ // SAVE STATE
+//! [1]
+ QSettings settings;
+ settings.setValue("splitterSizes", splitter->saveState());
+//! [1]
+ }
+
+ {
+ // RESTORE STATE
+//! [2]
+ QSettings settings;
+ splitter->restoreState(settings.value("splitterSizes").toByteArray());
+//! [2]
+ }
+
+//! [3]
+ QListIterator<int> it(splitter->sizes());
+ while (it.hasNext())
+ processSize(it.next());
+//! [3]
+
+ return 0;
+}
diff --git a/doc/src/snippets/splitterhandle/splitter.cpp b/doc/src/snippets/splitterhandle/splitter.cpp
new file mode 100644
index 0000000000..6f76c57b41
--- /dev/null
+++ b/doc/src/snippets/splitterhandle/splitter.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "splitter.h"
+
+SplitterHandle::SplitterHandle(Qt::Orientation orientation, QSplitter *parent)
+ : QSplitterHandle(orientation, parent)
+{
+ gradient.setColorAt(0.0, Qt::darkGreen);
+ gradient.setColorAt(0.25, Qt::white);
+ gradient.setColorAt(1.0, Qt::darkGreen);
+}
+
+//! [0]
+void SplitterHandle::paintEvent(QPaintEvent *event)
+{
+ QPainter painter(this);
+ if (orientation() == Qt::Horizontal) {
+ gradient.setStart(rect().left(), rect().height()/2);
+ gradient.setFinalStop(rect().right(), rect().height()/2);
+ } else {
+ gradient.setStart(rect().width()/2, rect().top());
+ gradient.setFinalStop(rect().width()/2, rect().bottom());
+ }
+ painter.fillRect(event->rect(), QBrush(gradient));
+}
+//! [0]
+
+Splitter::Splitter(Qt::Orientation orientation, QWidget *parent)
+ : QSplitter(orientation, parent)
+{
+}
+
+//! [1]
+QSplitterHandle *Splitter::createHandle()
+{
+ return new SplitterHandle(orientation(), this);
+}
+//! [1]
diff --git a/doc/src/snippets/splitterhandle/splitter.h b/doc/src/snippets/splitterhandle/splitter.h
new file mode 100644
index 0000000000..505c431f6d
--- /dev/null
+++ b/doc/src/snippets/splitterhandle/splitter.h
@@ -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$
+**
+****************************************************************************/
+
+#ifndef SPLITTER_H
+#define SPLITTER_H
+
+#include <QLinearGradient>
+#include <QSplitter>
+#include <QSplitterHandle>
+
+class QPaintEvent;
+
+//! [0]
+class Splitter : public QSplitter
+{
+public:
+ Splitter(Qt::Orientation orientation, QWidget *parent = 0);
+
+protected:
+ QSplitterHandle *createHandle();
+};
+//! [0]
+
+class SplitterHandle : public QSplitterHandle
+{
+public:
+ SplitterHandle(Qt::Orientation orientation, QSplitter *parent);
+
+protected:
+ void paintEvent(QPaintEvent *event);
+
+private:
+ QLinearGradient gradient;
+};
+
+#endif
diff --git a/doc/src/snippets/sqldatabase/sqldatabase.cpp b/doc/src/snippets/sqldatabase/sqldatabase.cpp
new file mode 100644
index 0000000000..4f428c7f5b
--- /dev/null
+++ b/doc/src/snippets/sqldatabase/sqldatabase.cpp
@@ -0,0 +1,559 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QtSql>
+
+#include <iostream>
+
+using namespace std;
+
+QString tr(const char *text)
+{
+ return QApplication::translate(text, text);
+}
+
+void QSqlDatabase_snippets()
+{
+ {
+//! [0]
+ QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
+ db.setHostName("acidalia");
+ db.setDatabaseName("customdb");
+ db.setUserName("mojito");
+ db.setPassword("J0a1m8");
+ bool ok = db.open();
+//! [0]
+ Q_UNUSED(ok);
+ }
+
+ {
+//! [1]
+ QSqlDatabase db = QSqlDatabase::database();
+//! [1]
+ }
+}
+
+void QSqlField_snippets()
+{
+#if 0
+ {
+//! [2]
+ QSqlField field("age", QVariant::Int);
+ field.setValue(QPixmap()); // WRONG
+//! [2]
+ }
+#endif
+
+ {
+//! [3]
+ QSqlField field("age", QVariant::Int);
+ field.setValue(QString("123")); // casts QString to int
+//! [3]
+ }
+
+ {
+//! [4]
+ QSqlQuery query;
+//! [4] //! [5]
+ QSqlRecord record = query.record();
+//! [5] //! [6]
+ QSqlField field = record.field("country");
+//! [6]
+ }
+}
+
+void doSomething(const QString &)
+{
+}
+
+void QSqlQuery_snippets()
+{
+ {
+ // typical loop
+//! [7]
+ QSqlQuery query("SELECT country FROM artist");
+ while (query.next()) {
+ QString country = query.value(0).toString();
+ doSomething(country);
+ }
+//! [7]
+ }
+
+ {
+ // field index lookup
+//! [8]
+ QSqlQuery query("SELECT * FROM artist");
+ int fieldNo = query.record().indexOf("country");
+ while (query.next()) {
+ QString country = query.value(fieldNo).toString();
+ doSomething(country);
+ }
+//! [8]
+ }
+
+ {
+ // named with named
+//! [9]
+ QSqlQuery query;
+ query.prepare("INSERT INTO person (id, forename, surname) "
+ "VALUES (:id, :forename, :surname)");
+ query.bindValue(":id", 1001);
+ query.bindValue(":forename", "Bart");
+ query.bindValue(":surname", "Simpson");
+ query.exec();
+//! [9]
+ }
+
+ {
+ // positional with named
+//! [10]
+ QSqlQuery query;
+ query.prepare("INSERT INTO person (id, forename, surname) "
+ "VALUES (:id, :forename, :surname)");
+ query.bindValue(0, 1001);
+ query.bindValue(1, "Bart");
+ query.bindValue(2, "Simpson");
+ query.exec();
+//! [10]
+ }
+
+ {
+ // positional 1
+//! [11]
+ QSqlQuery query;
+ query.prepare("INSERT INTO person (id, forename, surname) "
+ "VALUES (?, ?, ?)");
+ query.bindValue(0, 1001);
+ query.bindValue(1, "Bart");
+ query.bindValue(2, "Simpson");
+ query.exec();
+//! [11]
+ }
+
+ {
+ // positional 2
+//! [12]
+ QSqlQuery query;
+ query.prepare("INSERT INTO person (id, forename, surname) "
+ "VALUES (?, ?, ?)");
+ query.addBindValue(1001);
+ query.addBindValue("Bart");
+ query.addBindValue("Simpson");
+ query.exec();
+//! [12]
+ }
+
+ {
+ // stored
+//! [13]
+ QSqlQuery query;
+ query.prepare("CALL AsciiToInt(?, ?)");
+ query.bindValue(0, "A");
+ query.bindValue(1, 0, QSql::Out);
+ query.exec();
+ int i = query.boundValue(1).toInt(); // i is 65
+//! [13]
+ Q_UNUSED(i);
+ }
+
+ QSqlQuery query;
+
+ {
+ // examine with named binding
+//! [14]
+ QMapIterator<QString, QVariant> i(query.boundValues());
+ while (i.hasNext()) {
+ i.next();
+ cout << i.key().toAscii().data() << ": "
+ << i.value().toString().toAscii().data() << endl;
+ }
+//! [14]
+ }
+
+ {
+ // examine with positional binding
+//! [15]
+ QList<QVariant> list = query.boundValues().values();
+ for (int i = 0; i < list.size(); ++i)
+ cout << i << ": " << list.at(i).toString().toAscii().data() << endl;
+//! [15]
+ }
+}
+
+void QSqlQueryModel_snippets()
+{
+ {
+//! [16]
+ QSqlQueryModel *model = new QSqlQueryModel;
+ model->setQuery("SELECT name, salary FROM employee");
+ model->setHeaderData(0, Qt::Horizontal, tr("Name"));
+ model->setHeaderData(1, Qt::Horizontal, tr("Salary"));
+
+//! [17]
+ QTableView *view = new QTableView;
+//! [17] //! [18]
+ view->setModel(model);
+//! [18] //! [19]
+ view->show();
+//! [16] //! [19] //! [20]
+ view->setEditTriggers(QAbstractItemView::NoEditTriggers);
+//! [20]
+ }
+
+//! [21]
+ QSqlQueryModel model;
+ model.setQuery("SELECT * FROM employee");
+ int salary = model.record(4).value("salary").toInt();
+//! [21]
+ Q_UNUSED(salary);
+
+ {
+//! [22]
+ int salary = model.data(model.index(4, 2)).toInt();
+//! [22]
+ Q_UNUSED(salary);
+ }
+
+ for (int row = 0; row < model.rowCount(); ++row) {
+ for (int col = 0; col < model.columnCount(); ++col) {
+ qDebug() << model.data(model.index(row, col));
+ }
+ }
+}
+
+class MyModel : public QSqlQueryModel
+{
+public:
+ QVariant data(const QModelIndex &item, int role) const;
+
+ int m_specialColumnNo;
+};
+
+//! [23]
+QVariant MyModel::data(const QModelIndex &item, int role) const
+{
+ if (item.column() == m_specialColumnNo) {
+ // handle column separately
+ }
+ return QSqlQueryModel::data(item, role);
+}
+//! [23]
+
+void QSqlTableModel_snippets()
+{
+//! [24]
+ QSqlTableModel *model = new QSqlTableModel(parentObject, database);
+ model->setTable("employee");
+ model->setEditStrategy(QSqlTableModel::OnManualSubmit);
+ model->select();
+ model->removeColumn(0); // don't show the ID
+ model->setHeaderData(0, Qt::Horizontal, tr("Name"));
+ model->setHeaderData(1, Qt::Horizontal, tr("Salary"));
+
+ QTableView *view = new QTableView;
+ view->setModel(model);
+ view->show();
+//! [24]
+
+ {
+//! [25]
+ QSqlTableModel model;
+ model.setTable("employee");
+ QString name = model.record(4).value("name").toString();
+//! [25]
+ }
+}
+
+void sql_intro_snippets()
+{
+ {
+//! [26]
+ QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
+ db.setHostName("bigblue");
+ db.setDatabaseName("flightdb");
+ db.setUserName("acarlson");
+ db.setPassword("1uTbSbAs");
+ bool ok = db.open();
+//! [26]
+ Q_UNUSED(ok);
+ }
+
+ {
+//! [27]
+ QSqlDatabase firstDB = QSqlDatabase::addDatabase("QMYSQL", "first");
+ QSqlDatabase secondDB = QSqlDatabase::addDatabase("QMYSQL", "second");
+//! [27]
+ }
+
+ {
+//! [28]
+ QSqlDatabase defaultDB = QSqlDatabase::database();
+//! [28] //! [29]
+ QSqlDatabase firstDB = QSqlDatabase::database("first");
+//! [29] //! [30]
+ QSqlDatabase secondDB = QSqlDatabase::database("second");
+//! [30]
+ }
+
+ {
+ // SELECT1
+//! [31]
+ QSqlQuery query;
+ query.exec("SELECT name, salary FROM employee WHERE salary > 50000");
+//! [31]
+
+//! [32]
+ while (query.next()) {
+ QString name = query.value(0).toString();
+ int salary = query.value(1).toInt();
+ qDebug() << name << salary;
+ }
+//! [32]
+ }
+
+ {
+ // FEATURE
+//! [33]
+ QSqlQuery query;
+ int numRows;
+ query.exec("SELECT name, salary FROM employee WHERE salary > 50000");
+
+ QSqlDatabase defaultDB = QSqlDatabase::database();
+ if (defaultDB.driver()->hasFeature(QSqlDriver::QuerySize)) {
+ numRows = query.size();
+ } else {
+ // this can be very slow
+ query.last();
+ numRows = query.at() + 1;
+ }
+//! [33]
+ }
+
+ {
+ // INSERT1
+//! [34]
+ QSqlQuery query;
+ query.exec("INSERT INTO employee (id, name, salary) "
+ "VALUES (1001, 'Thad Beaumont', 65000)");
+//! [34]
+ }
+
+ {
+ // NAMED BINDING
+//! [35]
+ QSqlQuery query;
+ query.prepare("INSERT INTO employee (id, name, salary) "
+ "VALUES (:id, :name, :salary)");
+ query.bindValue(":id", 1001);
+ query.bindValue(":name", "Thad Beaumont");
+ query.bindValue(":salary", 65000);
+ query.exec();
+//! [35]
+ }
+
+ {
+ // POSITIONAL BINDING
+//! [36]
+ QSqlQuery query;
+ query.prepare("INSERT INTO employee (id, name, salary) "
+ "VALUES (?, ?, ?)");
+ query.addBindValue(1001);
+ query.addBindValue("Thad Beaumont");
+ query.addBindValue(65000);
+ query.exec();
+//! [36]
+ }
+
+ {
+ // UPDATE1
+//! [37]
+ QSqlQuery query;
+ query.exec("UPDATE employee SET salary = 70000 WHERE id = 1003");
+//! [37]
+ }
+
+ {
+ // DELETE1
+//! [38]
+ QSqlQuery query;
+ query.exec("DELETE FROM employee WHERE id = 1007");
+//! [38]
+ }
+
+ {
+ // TRANSACTION
+//! [39]
+ QSqlDatabase::database().transaction();
+ QSqlQuery query;
+ query.exec("SELECT id FROM employee WHERE name = 'Torild Halvorsen'");
+ if (query.next()) {
+ int employeeId = query.value(0).toInt();
+ query.exec("INSERT INTO project (id, name, ownerid) "
+ "VALUES (201, 'Manhattan Project', "
+ + QString::number(employeeId) + ')');
+ }
+ QSqlDatabase::database().commit();
+//! [39]
+ }
+
+ {
+ // SQLQUERYMODEL1
+//! [40]
+ QSqlQueryModel model;
+ model.setQuery("SELECT * FROM employee");
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ int id = model.record(i).value("id").toInt();
+ QString name = model.record(i).value("name").toString();
+ qDebug() << id << name;
+ }
+//! [40]
+ }
+
+ {
+ // SQLTABLEMODEL1
+//! [41]
+ QSqlTableModel model;
+ model.setTable("employee");
+ model.setFilter("salary > 50000");
+ model.setSort(2, Qt::DescendingOrder);
+ model.select();
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QString name = model.record(i).value("name").toString();
+ int salary = model.record(i).value("salary").toInt();
+ qDebug() << name << salary;
+ }
+//! [41]
+ }
+
+ {
+ // SQLTABLEMODEL2
+ QSqlTableModel model;
+ model.setTable("employee");
+
+//! [42]
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QSqlRecord record = model.record(i);
+ double salary = record.value("salary").toInt();
+ salary *= 1.1;
+ record.setValue("salary", salary);
+ model.setRecord(i, record);
+ }
+ model.submitAll();
+//! [42]
+
+ // SQLTABLEMODEL3
+ int row = 1;
+ int column = 2;
+//! [43]
+ model.setData(model.index(row, column), 75000);
+ model.submitAll();
+//! [43]
+
+ // SQLTABLEMODEL4
+//! [44]
+ model.insertRows(row, 1);
+ model.setData(model.index(row, 0), 1013);
+ model.setData(model.index(row, 1), "Peter Gordon");
+ model.setData(model.index(row, 2), 68500);
+ model.submitAll();
+//! [44]
+
+//! [45]
+ model.removeRows(row, 5);
+//! [45] //! [46]
+ model.submitAll();
+//! [46]
+ }
+}
+
+//! [47]
+class XyzResult : public QSqlResult
+{
+public:
+ XyzResult(const QSqlDriver *driver)
+ : QSqlResult(driver) {}
+ ~XyzResult() {}
+
+protected:
+ QVariant data(int /* index */) { return QVariant(); }
+ bool isNull(int /* index */) { return false; }
+ bool reset(const QString & /* query */) { return false; }
+ bool fetch(int /* index */) { return false; }
+ bool fetchFirst() { return false; }
+ bool fetchLast() { return false; }
+ int size() { return 0; }
+ int numRowsAffected() { return 0; }
+ QSqlRecord record() const { return QSqlRecord(); }
+};
+//! [47]
+
+//! [48]
+class XyzDriver : public QSqlDriver
+{
+public:
+ XyzDriver() {}
+ ~XyzDriver() {}
+
+ bool hasFeature(DriverFeature /* feature */) const { return false; }
+ bool open(const QString & /* db */, const QString & /* user */,
+ const QString & /* password */, const QString & /* host */,
+ int /* port */, const QString & /* options */)
+ { return false; }
+ void close() {}
+ QSqlResult *createResult() const { return new XyzResult(this); }
+};
+//! [48]
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ QSqlDatabase_snippets();
+ QSqlField_snippets();
+ QSqlQuery_snippets();
+ QSqlQueryModel_snippets();
+ QSqlTableModel_snippets();
+
+ XyzDriver driver;
+ XyzResult result(&driver);
+}
diff --git a/doc/src/snippets/styles/styles.cpp b/doc/src/snippets/styles/styles.cpp
new file mode 100644
index 0000000000..23ab71b485
--- /dev/null
+++ b/doc/src/snippets/styles/styles.cpp
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QStyleOption>
+#include <QStylePainter>
+#include <QWidget>
+
+class MyWidget : public QWidget
+{
+protected:
+ void paintEvent(QPaintEvent *event);
+ void paintEvent2(QPaintEvent *event);
+
+};
+
+//! [0] //! [1]
+void MyWidget::paintEvent(QPaintEvent * /* event */)
+//! [0]
+{
+//! [2]
+ QPainter painter(this);
+//! [2]
+
+ QStyleOptionFocusRect option;
+ option.initFrom(this);
+ option.backgroundColor = palette().color(QPalette::Background);
+
+//! [3]
+ style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &painter, this);
+//! [3]
+}
+//! [1]
+
+void MyWidget::paintEvent2(QPaintEvent * /* event */)
+//! [4]
+{
+//! [4] //! [5] //! [6]
+ QStylePainter painter(this);
+//! [5]
+
+ QStyleOptionFocusRect option;
+ option.initFrom(this);
+ option.backgroundColor = palette().color(QPalette::Background);
+
+//! [7]
+ painter.drawPrimitive(QStyle::PE_FrameFocusRect, option);
+//! [7]
+}
+//! [6]
+
+int main()
+{
+ return 0;
+}
diff --git a/doc/src/snippets/stylesheet/common-mistakes.cpp b/doc/src/snippets/stylesheet/common-mistakes.cpp
new file mode 100644
index 0000000000..8de7f7941f
--- /dev/null
+++ b/doc/src/snippets/stylesheet/common-mistakes.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$
+**
+****************************************************************************/
+
+//! [1]
+ QPushButton {
+ color: grey;
+ border-image: url(/home/kamlie/code/button.png) 3 10 3 10;
+ border-top: 3px transparent;
+ border-bottom: 3px transparent;
+ border-right: 10px transparent;
+ border-left: 10px transparent;
+ }
+//! [1]
+
+
diff --git a/doc/src/snippets/textblock-fragments/xmlwriter.cpp b/doc/src/snippets/textblock-fragments/xmlwriter.cpp
new file mode 100644
index 0000000000..252720bc14
--- /dev/null
+++ b/doc/src/snippets/textblock-fragments/xmlwriter.cpp
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "xmlwriter.h"
+
+QDomDocument *XmlWriter::toXml()
+{
+ QDomImplementation implementation;
+ QDomDocumentType docType = implementation.createDocumentType(
+ "scribe-document", "scribe", "qt.nokia.com/scribe");
+
+ document = new QDomDocument(docType);
+
+ // ### This processing instruction is required to ensure that any kind
+ // of encoding is given when the document is written.
+ QDomProcessingInstruction process = document->createProcessingInstruction(
+ "xml", "version=\"1.0\" encoding=\"utf-8\"");
+ document->appendChild(process);
+
+ QDomElement documentElement = document->createElement("document");
+ document->appendChild(documentElement);
+
+//! [0]
+ QTextBlock currentBlock = textDocument->begin();
+
+ while (currentBlock.isValid()) {
+//! [0]
+ QDomElement blockElement = document->createElement("block");
+ document->appendChild(blockElement);
+
+ readFragment(currentBlock, blockElement, document);
+
+//! [1]
+ processBlock(currentBlock);
+//! [1]
+
+//! [2]
+ currentBlock = currentBlock.next();
+ }
+//! [2]
+
+ return document;
+}
+
+void XmlWriter::readFragment(const QTextBlock &currentBlock,
+ QDomElement blockElement,
+ QDomDocument *document)
+{
+//! [3] //! [4]
+ QTextBlock::iterator it;
+ for (it = currentBlock.begin(); !(it.atEnd()); ++it) {
+ QTextFragment currentFragment = it.fragment();
+ if (currentFragment.isValid())
+//! [3] //! [5]
+ processFragment(currentFragment);
+//! [4] //! [5]
+
+ if (currentFragment.isValid()) {
+ QDomElement fragmentElement = document->createElement("fragment");
+ blockElement.appendChild(fragmentElement);
+
+ fragmentElement.setAttribute("length", currentFragment.length());
+ QDomText fragmentText = document->createTextNode(currentFragment.text());
+
+ fragmentElement.appendChild(fragmentText);
+ }
+//! [6] //! [7]
+ }
+//! [7] //! [6]
+}
+
+void XmlWriter::processBlock(const QTextBlock &currentBlock)
+{
+}
+
+void XmlWriter::processFragment(const QTextFragment &currentFragment)
+{
+}
diff --git a/doc/src/snippets/textdocument-css/main.cpp b/doc/src/snippets/textdocument-css/main.cpp
new file mode 100644
index 0000000000..8c267455e5
--- /dev/null
+++ b/doc/src/snippets/textdocument-css/main.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+//! [0]
+ QTextBrowser browser;
+ QColor linkColor(Qt::red);
+ QString sheet = QString::fromLatin1("a { text-decoration: underline; color: %1 }").arg(linkColor.name());
+ browser.document()->setDefaultStyleSheet(sheet);
+//! [0]
+ browser.setSource(QUrl("../../../html/index.html"));
+ browser.resize(800, 600);
+ browser.show();
+
+ return app.exec();
+}
+
diff --git a/doc/src/snippets/textdocument-imagedrop/textedit.cpp b/doc/src/snippets/textdocument-imagedrop/textedit.cpp
new file mode 100644
index 0000000000..735dbe55ce
--- /dev/null
+++ b/doc/src/snippets/textdocument-imagedrop/textedit.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$
+**
+****************************************************************************/
+
+#include "textedit.h"
+#include <QtGui>
+
+TextEdit::TextEdit(QWidget *parent)
+ : QTextEdit(parent)
+{
+}
+
+//! [0]
+bool TextEdit::canInsertFromMimeData( const QMimeData *source ) const
+{
+ if (source->hasImage())
+ return true;
+ else
+ return QTextEdit::canInsertFromMimeData(source);
+}
+//! [0]
+
+//! [1]
+void TextEdit::insertFromMimeData( const QMimeData *source )
+{
+ if (source->hasImage())
+ {
+ QImage image = qvariant_cast<QImage>(source->imageData());
+ QTextCursor cursor = this->textCursor();
+ QTextDocument *document = this->document();
+ document->addResource(QTextDocument::ImageResource, QUrl("image"), image);
+ cursor.insertImage("image");
+ }
+}
+//! [1]
diff --git a/doc/src/snippets/textdocument-lists/mainwindow.cpp b/doc/src/snippets/textdocument-lists/mainwindow.cpp
new file mode 100644
index 0000000000..bcbfce72b8
--- /dev/null
+++ b/doc/src/snippets/textdocument-lists/mainwindow.cpp
@@ -0,0 +1,192 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ fileMenu->addAction(tr("E&xit"), this, SLOT(close()),
+ QKeySequence(tr("Ctrl+Q", "File|Exit")));
+
+ QMenu *editMenu = new QMenu(tr("&Edit"));
+
+ cutAction = editMenu->addAction(tr("Cu&t"), this, SLOT(cutSelection()),
+ QKeySequence(tr("Ctrl+X", "Edit|Cut")));
+ copyAction = editMenu->addAction(tr("&Copy"), this, SLOT(copySelection()),
+ QKeySequence(tr("Ctrl+C", "Edit|Copy")));
+ pasteAction = editMenu->addAction(tr("&Paste"), this,
+ SLOT(pasteSelection()), QKeySequence(tr("Ctrl+V", "Edit|Paste")));
+
+ QMenu *selectMenu = new QMenu(tr("&Select"));
+ selectMenu->addAction(tr("&Word"), this, SLOT(selectWord()));
+ selectMenu->addAction(tr("&Line"), this, SLOT(selectLine()));
+ selectMenu->addAction(tr("&Block"), this, SLOT(selectBlock()));
+ selectMenu->addAction(tr("&Frame"), this, SLOT(selectFrame()));
+
+ QMenu *insertMenu = new QMenu(tr("&Insert"));
+
+ insertMenu->addAction(tr("&List"), this, SLOT(insertList()),
+ QKeySequence(tr("Ctrl+L", "Insert|List")));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(editMenu);
+ menuBar()->addMenu(selectMenu);
+ menuBar()->addMenu(insertMenu);
+
+ editor = new QTextEdit(this);
+ document = new QTextDocument(this);
+ editor->setDocument(document);
+
+ connect(editor, SIGNAL(selectionChanged()), this, SLOT(updateMenus()));
+
+ updateMenus();
+
+ setCentralWidget(editor);
+ setWindowTitle(tr("Text Document Writer"));
+}
+
+void MainWindow::cutSelection()
+{
+ QTextCursor cursor = editor->textCursor();
+ if (cursor.hasSelection()) {
+ selection = cursor.selection();
+ cursor.removeSelectedText();
+ }
+}
+
+void MainWindow::copySelection()
+{
+ QTextCursor cursor = editor->textCursor();
+ if (cursor.hasSelection()) {
+ selection = cursor.selection();
+ cursor.clearSelection();
+ }
+}
+
+void MainWindow::pasteSelection()
+{
+ QTextCursor cursor = editor->textCursor();
+ cursor.insertFragment(selection);
+}
+
+void MainWindow::selectWord()
+{
+ QTextCursor cursor = editor->textCursor();
+ QTextBlock block = cursor.block();
+
+ cursor.beginEditBlock();
+ cursor.movePosition(QTextCursor::StartOfWord);
+ cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
+ cursor.endEditBlock();
+
+ editor->setTextCursor(cursor);
+}
+
+void MainWindow::selectLine()
+{
+ QTextCursor cursor = editor->textCursor();
+ QTextBlock block = cursor.block();
+
+ cursor.beginEditBlock();
+ cursor.movePosition(QTextCursor::StartOfLine);
+ cursor.movePosition(QTextCursor::EndOfLine, QTextCursor::KeepAnchor);
+ cursor.endEditBlock();
+
+ editor->setTextCursor(cursor);
+}
+
+void MainWindow::selectBlock()
+{
+ QTextCursor cursor = editor->textCursor();
+ QTextBlock block = cursor.block();
+
+ cursor.beginEditBlock();
+ cursor.movePosition(QTextCursor::StartOfBlock);
+ cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
+ cursor.endEditBlock();
+
+ editor->setTextCursor(cursor);
+}
+
+void MainWindow::selectFrame()
+{
+ QTextCursor cursor = editor->textCursor();
+ QTextFrame *frame = cursor.currentFrame();
+
+ cursor.beginEditBlock();
+ cursor.setPosition(frame->firstPosition());
+ cursor.setPosition(frame->lastPosition(), QTextCursor::KeepAnchor);
+ cursor.endEditBlock();
+
+ editor->setTextCursor(cursor);
+}
+
+void MainWindow::insertList()
+{
+ QTextCursor cursor = editor->textCursor();
+ cursor.beginEditBlock();
+
+ QTextList *list = cursor.currentList();
+//! [0]
+ QTextListFormat listFormat;
+ if (list) {
+ listFormat = list->format();
+ listFormat.setIndent(listFormat.indent() + 1);
+ }
+
+ listFormat.setStyle(QTextListFormat::ListDisc);
+ cursor.insertList(listFormat);
+//! [0]
+
+ cursor.endEditBlock();
+}
+
+void MainWindow::updateMenus()
+{
+ QTextCursor cursor = editor->textCursor();
+ cutAction->setEnabled(cursor.hasSelection());
+ copyAction->setEnabled(cursor.hasSelection());
+
+ pasteAction->setEnabled(!selection.isEmpty());
+}
diff --git a/doc/src/snippets/textdocument-tables/mainwindow.cpp b/doc/src/snippets/textdocument-tables/mainwindow.cpp
new file mode 100644
index 0000000000..c432f4c8cd
--- /dev/null
+++ b/doc/src/snippets/textdocument-tables/mainwindow.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+#include "xmlwriter.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction *saveAction = fileMenu->addAction(tr("&Save..."));
+ saveAction->setShortcut(tr("Ctrl+S"));
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ QMenu *showMenu = new QMenu(tr("&Show"));
+
+ QAction *showTableAction = showMenu->addAction(tr("&Table"));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(showMenu);
+
+ editor = new QTextEdit();
+
+//! [0] //! [1]
+ QTextCursor cursor(editor->textCursor());
+//! [0]
+ cursor.movePosition(QTextCursor::Start);
+//! [1]
+
+ int rows = 11;
+ int columns = 4;
+
+//! [2]
+ QTextTableFormat tableFormat;
+ tableFormat.setBackground(QColor("#e0e0e0"));
+ QVector<QTextLength> constraints;
+ constraints << QTextLength(QTextLength::PercentageLength, 16);
+ constraints << QTextLength(QTextLength::PercentageLength, 28);
+ constraints << QTextLength(QTextLength::PercentageLength, 28);
+ constraints << QTextLength(QTextLength::PercentageLength, 28);
+ tableFormat.setColumnWidthConstraints(constraints);
+//! [3]
+ QTextTable *table = cursor.insertTable(rows, columns, tableFormat);
+//! [2] //! [3]
+
+ int column;
+ int row;
+ QTextTableCell cell;
+ QTextCursor cellCursor;
+
+ QTextCharFormat charFormat;
+ charFormat.setForeground(Qt::black);
+
+//! [4]
+ cell = table->cellAt(0, 0);
+ cellCursor = cell.firstCursorPosition();
+ cellCursor.insertText(tr("Week"), charFormat);
+//! [4]
+
+//! [5]
+ for (column = 1; column < columns; ++column) {
+ cell = table->cellAt(0, column);
+ cellCursor = cell.firstCursorPosition();
+ cellCursor.insertText(tr("Team %1").arg(column), charFormat);
+ }
+
+ for (row = 1; row < rows; ++row) {
+ cell = table->cellAt(row, 0);
+ cellCursor = cell.firstCursorPosition();
+ cellCursor.insertText(tr("%1").arg(row), charFormat);
+
+ for (column = 1; column < columns; ++column) {
+ if ((row-1) % 3 == column-1) {
+//! [5] //! [6]
+ cell = table->cellAt(row, column);
+ QTextCursor cellCursor = cell.firstCursorPosition();
+ cellCursor.insertText(tr("On duty"), charFormat);
+ }
+//! [6] //! [7]
+ }
+//! [7] //! [8]
+ }
+//! [8]
+
+ connect(saveAction, SIGNAL(triggered()), this, SLOT(saveFile()));
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+ connect(showTableAction, SIGNAL(triggered()), this, SLOT(showTable()));
+
+ setCentralWidget(editor);
+ setWindowTitle(tr("Text Document Tables"));
+}
+
+void MainWindow::saveFile()
+{
+ QString fileName = QFileDialog::getSaveFileName(this,
+ tr("Save document as:"), "", tr("XML (*.xml)"));
+
+ if (!fileName.isEmpty()) {
+ if (writeXml(fileName))
+ setWindowTitle(fileName);
+ else
+ QMessageBox::warning(this, tr("Warning"),
+ tr("Failed to save the document."), QMessageBox::Cancel,
+ QMessageBox::NoButton);
+ }
+}
+
+void MainWindow::showTable()
+{
+ QTextCursor cursor = editor->textCursor();
+ QTextTable *table = cursor.currentTable();
+
+ if (!table)
+ return;
+
+ QTableWidget *tableWidget = new QTableWidget(table->rows(), table->columns());
+
+//! [9]
+ for (int row = 0; row < table->rows(); ++row) {
+ for (int column = 0; column < table->columns(); ++column) {
+ QTextTableCell tableCell = table->cellAt(row, column);
+//! [9]
+ QTextFrame::iterator it;
+ QString text;
+ for (it = tableCell.begin(); !(it.atEnd()); ++it) {
+ QTextBlock childBlock = it.currentBlock();
+ if (childBlock.isValid())
+ text += childBlock.text();
+ }
+ QTableWidgetItem *newItem = new QTableWidgetItem(text);
+ tableWidget->setItem(row, column, newItem);
+ /*
+//! [10]
+ processTableCell(tableCell);
+//! [10]
+ */
+//! [11]
+ }
+//! [11] //! [12]
+ }
+//! [12]
+
+ tableWidget->setWindowTitle(tr("Table Contents"));
+ tableWidget->show();
+}
+
+bool MainWindow::writeXml(const QString &fileName)
+{
+ XmlWriter documentWriter(editor->document());
+
+ QDomDocument *domDocument = documentWriter.toXml();
+ QFile file(fileName);
+
+ if (file.open(QFile::WriteOnly)) {
+ QTextStream textStream(&file);
+ textStream.setCodec(QTextCodec::codecForName("UTF-8"));
+
+ textStream << domDocument->toString(1).toUtf8();
+ file.close();
+ return true;
+ }
+ else
+ return false;
+}
diff --git a/doc/src/snippets/textdocument-texttable/main.cpp b/doc/src/snippets/textdocument-texttable/main.cpp
new file mode 100644
index 0000000000..1e3b7c2a89
--- /dev/null
+++ b/doc/src/snippets/textdocument-texttable/main.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+int main(int argc, char * argv[])
+{
+ int rows = 6;
+ int columns = 2;
+
+ QApplication app(argc, argv);
+ QTextEdit *textEdit = new QTextEdit;
+ QTextCursor cursor(textEdit->textCursor());
+ cursor.movePosition(QTextCursor::Start);
+
+ QTextTableFormat tableFormat;
+ tableFormat.setAlignment(Qt::AlignHCenter);
+ tableFormat.setCellPadding(2);
+ tableFormat.setCellSpacing(2);
+ QTextTable *table = cursor.insertTable(rows, columns);
+ table->setFormat(tableFormat);
+
+ QTextCharFormat boldFormat;
+ boldFormat.setFontWeight(QFont::Bold);
+
+ QTextBlockFormat centerFormat;
+ centerFormat.setAlignment(Qt::AlignHCenter);
+ cursor.mergeBlockFormat(centerFormat);
+
+ cursor = table->cellAt(0, 0).firstCursorPosition();
+ cursor.insertText(("Details"), boldFormat);
+
+ cursor = table->cellAt(1, 0).firstCursorPosition();
+ cursor.insertText("Alan");
+
+ cursor = table->cellAt(1, 1).firstCursorPosition();
+ cursor.insertText("5, Pickety Street");
+
+//! [0]
+ table->mergeCells(0, 0, 1, 2);
+//! [0] //! [1]
+ table->splitCell(0, 0, 1, 1);
+//! [1]
+
+ textEdit->show();
+ return app.exec();
+}
diff --git a/doc/src/snippets/textdocumentendsnippet.cpp b/doc/src/snippets/textdocumentendsnippet.cpp
new file mode 100644
index 0000000000..3b28700ac3
--- /dev/null
+++ b/doc/src/snippets/textdocumentendsnippet.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <iostream.h>
+
+int main(int argv, char **args)
+{
+ QString contentString("One\nTwp\nThree");
+
+ QTextDocument *doc = new QTextDocument(contentString);
+
+//! [0]
+ for (QTextBlock it = doc->begin(); it != doc->end(); it = it.next())
+ cout << it.text().toStdString() << endl;
+//! [0]
+
+ return 0;
+}
diff --git a/doc/src/snippets/threads/threads.cpp b/doc/src/snippets/threads/threads.cpp
new file mode 100644
index 0000000000..5661757c9c
--- /dev/null
+++ b/doc/src/snippets/threads/threads.cpp
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QCache>
+#include <QMutex>
+#include <QThreadStorage>
+
+#include "threads.h"
+
+//! [0]
+void MyThread::run()
+//! [0] //! [1]
+{
+//! [1] //! [2]
+}
+//! [2]
+
+#define Counter ReentrantCounter
+
+//! [3]
+class Counter
+//! [3] //! [4]
+{
+public:
+ Counter() { n = 0; }
+
+ void increment() { ++n; }
+ void decrement() { --n; }
+ int value() const { return n; }
+
+private:
+ int n;
+};
+//! [4]
+
+#undef Counter
+#define Counter ThreadSafeCounter
+
+//! [5]
+class Counter
+//! [5] //! [6]
+{
+public:
+ Counter() { n = 0; }
+
+ void increment() { QMutexLocker locker(&mutex); ++n; }
+ void decrement() { QMutexLocker locker(&mutex); --n; }
+ int value() const { QMutexLocker locker(&mutex); return n; }
+
+private:
+ mutable QMutex mutex;
+ int n;
+};
+//! [6]
+
+typedef int SomeClass;
+
+//! [7]
+QThreadStorage<QCache<QString, SomeClass> > caches;
+
+void cacheObject(const QString &key, SomeClass *object)
+//! [7] //! [8]
+{
+ caches.localData().insert(key, object);
+}
+
+void removeFromCache(const QString &key)
+//! [8] //! [9]
+{
+ if (!caches.hasLocalData())
+ return;
+
+ caches.localData().remove(key);
+}
+//! [9]
+
+int main()
+{
+ return 0;
+}
diff --git a/doc/src/snippets/timeline/main.cpp b/doc/src/snippets/timeline/main.cpp
new file mode 100644
index 0000000000..b652069d68
--- /dev/null
+++ b/doc/src/snippets/timeline/main.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <math.h>
+
+int main(int argv, char *args[])
+{
+ QApplication app(argv, args);
+
+//! [0]
+ QGraphicsItem *ball = new QGraphicsEllipseItem(0, 0, 20, 20);
+
+ QTimeLine *timer = new QTimeLine(5000);
+ timer->setFrameRange(0, 100);
+
+ QGraphicsItemAnimation *animation = new QGraphicsItemAnimation;
+ animation->setItem(ball);
+ animation->setTimeLine(timer);
+
+ for (int i = 0; i < 200; ++i)
+ animation->setPosAt(i / 200.0, QPointF(i, i));
+
+ QGraphicsScene *scene = new QGraphicsScene();
+ scene->setSceneRect(0, 0, 250, 250);
+ scene->addItem(ball);
+
+ QGraphicsView *view = new QGraphicsView(scene);
+ view->show();
+
+ timer->start();
+//! [0]
+
+ return app.exec();
+}
diff --git a/doc/src/snippets/timers/timers.cpp b/doc/src/snippets/timers/timers.cpp
new file mode 100644
index 0000000000..015ab27387
--- /dev/null
+++ b/doc/src/snippets/timers/timers.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$
+**
+****************************************************************************/
+
+#include <QTimer>
+
+class Foo : public QObject
+{
+public:
+ Foo();
+};
+
+Foo::Foo()
+{
+//! [0]
+ QTimer *timer = new QTimer(this);
+//! [0] //! [1]
+ connect(timer, SIGNAL(timeout()), this, SLOT(updateCaption()));
+//! [1] //! [2]
+ timer->start(1000);
+//! [2]
+
+//! [3]
+ QTimer::singleShot(200, this, SLOT(updateCaption()));
+//! [3]
+
+ {
+ // ZERO-CASE
+//! [4]
+ QTimer *timer = new QTimer(this);
+//! [4] //! [5]
+ connect(timer, SIGNAL(timeout()), this, SLOT(processOneThing()));
+//! [5] //! [6]
+ timer->start();
+//! [6]
+ }
+}
+
+int main()
+{
+
+}
diff --git a/doc/src/snippets/transform/main.cpp b/doc/src/snippets/transform/main.cpp
new file mode 100644
index 0000000000..b1e3d74094
--- /dev/null
+++ b/doc/src/snippets/transform/main.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <cmath>
+
+class SimpleTransformation : public QWidget
+{
+ void paintEvent(QPaintEvent *);
+};
+
+//! [0]
+void SimpleTransformation::paintEvent(QPaintEvent *)
+{
+ QPainter painter(this);
+ painter.setPen(QPen(Qt::blue, 1, Qt::DashLine));
+ painter.drawRect(0, 0, 100, 100);
+
+ painter.rotate(45);
+
+ painter.setFont(QFont("Helvetica", 24));
+ painter.setPen(QPen(Qt::black, 1));
+ painter.drawText(20, 10, "QTransform");
+}
+//! [0]
+
+class CombinedTransformation : public QWidget
+{
+ void paintEvent(QPaintEvent *);
+};
+
+//! [1]
+void CombinedTransformation::paintEvent(QPaintEvent *)
+{
+ QPainter painter(this);
+ painter.setPen(QPen(Qt::blue, 1, Qt::DashLine));
+ painter.drawRect(0, 0, 100, 100);
+
+ QTransform transform;
+ transform.translate(50, 50);
+ transform.rotate(45);
+ transform.scale(0.5, 1.0);
+ painter.setTransform(transform);
+
+ painter.setFont(QFont("Helvetica", 24));
+ painter.setPen(QPen(Qt::black, 1));
+ painter.drawText(20, 10, "QTransform");
+}
+//! [1]
+
+class BasicOperations : public QWidget
+{
+ void paintEvent(QPaintEvent *);
+};
+
+//! [2]
+void BasicOperations::paintEvent(QPaintEvent *)
+{
+ double pi = 3.14;
+
+ double a = pi/180 * 45.0;
+ double sina = sin(a);
+ double cosa = cos(a);
+
+ QTransform translationTransform(1, 0, 0, 1, 50.0, 50.0);
+ QTransform rotationTransform(cosa, sina, -sina, cosa, 0, 0);
+ QTransform scalingTransform(0.5, 0, 0, 1.0, 0, 0);
+
+ QTransform transform;
+ transform = scalingTransform * rotationTransform * translationTransform;
+
+ QPainter painter(this);
+ painter.setPen(QPen(Qt::blue, 1, Qt::DashLine));
+ painter.drawRect(0, 0, 100, 100);
+
+ painter.setTransform(transform);
+
+ painter.setFont(QFont("Helvetica", 24));
+ painter.setPen(QPen(Qt::black, 1));
+ painter.drawText(20, 10, "QTransform");
+}
+//! [2]
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ QWidget widget;
+
+ SimpleTransformation *simpleWidget = new SimpleTransformation;
+ CombinedTransformation *combinedWidget = new CombinedTransformation;
+ BasicOperations *basicWidget = new BasicOperations;
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(simpleWidget);
+ layout->addWidget(combinedWidget);
+ layout->addWidget(basicWidget);
+ widget.setLayout(layout);
+
+ widget.show();
+ widget.resize(130, 350);
+ return app.exec();
+}
diff --git a/doc/src/snippets/whatsthis/whatsthis.cpp b/doc/src/snippets/whatsthis/whatsthis.cpp
new file mode 100644
index 0000000000..608fa3e62f
--- /dev/null
+++ b/doc/src/snippets/whatsthis/whatsthis.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+class MainWindow : public QMainWindow
+{
+public:
+ MainWindow();
+
+ QAction *newAct;
+};
+
+MainWindow()
+{
+//! [0]
+ newAct = new QAction(tr("&New"), this);
+ newAct->setShortcut(tr("Ctrl+N"));
+ newAct->setStatusTip(tr("Create a new file"));
+ newAct->setWhatsThis(tr("Click this option to create a new file."));
+//! [0]
+}
+
+int main()
+{
+ return 0;
+}
diff --git a/doc/src/snippets/widget-mask/main.cpp b/doc/src/snippets/widget-mask/main.cpp
new file mode 100644
index 0000000000..2d7defc02c
--- /dev/null
+++ b/doc/src/snippets/widget-mask/main.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+//! [0]
+ QLabel topLevelLabel;
+ QPixmap pixmap(":/images/tux.png");
+ topLevelLabel.setPixmap(pixmap);
+ topLevelLabel.setMask(pixmap.mask());
+//! [0]
+ topLevelLabel.show();
+ return app.exec();
+}
diff --git a/doc/src/snippets/widgetdelegate.cpp b/doc/src/snippets/widgetdelegate.cpp
new file mode 100644
index 0000000000..c6d3963807
--- /dev/null
+++ b/doc/src/snippets/widgetdelegate.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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "widgetdelegate.h"
+
+//![0]
+void WidgetDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
+ const QModelIndex &index) const
+{
+ if (index.column() == 1) {
+ int progress = index.data().toInt();
+
+ QStyleOptionProgressBar progressBarOption;
+ progressBarOption.rect = option.rect;
+ progressBarOption.minimum = 0;
+ progressBarOption.maximum = 100;
+ progressBarOption.progress = progress;
+ progressBarOption.text = QString::number(progress) + "%";
+ progressBarOption.textVisible = true;
+
+ QApplication::style()->drawControl(QStyle::CE_ProgressBar,
+ &progressBarOption, painter);
+ } else
+ QStyledItemDelegate::paint(painter, option, index);
+
+//![0]
+}
diff --git a/doc/src/snippets/widgetprinting.cpp b/doc/src/snippets/widgetprinting.cpp
new file mode 100644
index 0000000000..a6ea3cb5d3
--- /dev/null
+++ b/doc/src/snippets/widgetprinting.cpp
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+class Window : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Window() {
+ myWidget = new QPushButton("Print Me");
+ connect(myWidget, SIGNAL(clicked()), this, SLOT(print()));
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(myWidget);
+ setLayout(layout);
+ }
+
+private slots:
+ void print() {
+ QPrinter printer(QPrinter::HighResolution);
+
+ printer.setOutputFileName("test.pdf");
+
+//! [0]
+ QPainter painter;
+ painter.begin(&printer);
+ double xscale = printer.pageRect().width()/double(myWidget->width());
+ double yscale = printer.pageRect().height()/double(myWidget->height());
+ double scale = qMin(xscale, yscale);
+ painter.translate(printer.paperRect().x() + printer.pageRect().width()/2,
+ printer.paperRect().y() + printer.pageRect().height()/2);
+ painter.scale(scale, scale);
+ painter.translate(-width()/2, -height()/2);
+
+ myWidget->render(&painter);
+//! [0]
+ }
+
+private:
+ QPushButton *myWidget;
+};
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+
+ Window window;
+ window.show();
+
+ return app.exec();
+}
+
+#include "main.moc"
+
diff --git a/doc/src/snippets/widgets-tutorial/template.cpp b/doc/src/snippets/widgets-tutorial/template.cpp
new file mode 100644
index 0000000000..e2a2f61ab1
--- /dev/null
+++ b/doc/src/snippets/widgets-tutorial/template.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$
+**
+****************************************************************************/
+
+//! [main.cpp body]
+#include <QtGui>
+
+// Include header files for application components.
+// ...
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ // Set up and show widgets.
+ // ...
+
+ return app.exec();
+}
+//! [main.cpp body]
diff --git a/doc/src/snippets/xml/rsslisting/handler.cpp b/doc/src/snippets/xml/rsslisting/handler.cpp
new file mode 100644
index 0000000000..fe9ef5cbe9
--- /dev/null
+++ b/doc/src/snippets/xml/rsslisting/handler.cpp
@@ -0,0 +1,182 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+/*
+handler.cpp
+
+Provides a handler for processing XML elements found by the reader.
+
+The handler looks for <title> and <link> elements within <item> elements,
+and records the text found within them. Link information stored within
+rdf:about attributes of <item> elements is also recorded when it is
+available.
+
+For each item found, a signal is emitted which specifies its title and
+link information. This may be used by user interfaces for the purpose of
+displaying items as they are read.
+*/
+
+#include <QtGui>
+
+#include "handler.h"
+
+/*
+ Reset the state of the handler to ensure that new documents are
+ read correctly.
+
+ We return true to indicate that parsing should continue.
+*/
+
+bool Handler::startDocument()
+{
+ inItem = false;
+ inTitle = false;
+ inLink = false;
+
+ return true;
+}
+
+/*
+ Process each starting element in the XML document.
+
+ Nested item, title, or link elements are not allowed, so we return false
+ if we encounter any of these. We also prohibit multiple definitions of
+ title strings.
+
+ Link destinations are read by this function if they are specified as
+ attributes in item elements.
+
+ For all cases not explicitly checked for, we return true to indicate that
+ the element is acceptable, and that parsing should continue. By doing
+ this, we can ignore elements in which we are not interested.
+*/
+
+bool Handler::startElement(const QString &, const QString &,
+ const QString & qName, const QXmlAttributes &attr)
+{
+ if (qName == "item") {
+
+ if (inItem)
+ return false;
+ else {
+ inItem = true;
+ linkString = attr.value("rdf:about");
+ }
+ }
+ else if (qName == "title") {
+
+ if (inTitle)
+ return false;
+ else if (!titleString.isEmpty())
+ return false;
+ else if (inItem)
+ inTitle = true;
+ }
+ else if (qName == "link") {
+
+ if (inLink)
+ return false;
+ else if (inItem)
+ inLink = true;
+ }
+
+ return true;
+}
+
+/*
+ Process each ending element in the XML document.
+
+ For recognized elements, we reset flags to ensure that we can read new
+ instances of these elements. If we have read an item element, emit a
+ signal to indicate that a new item is available for display.
+
+ We return true to indicate that parsing should continue.
+*/
+
+bool Handler::endElement(const QString &, const QString &,
+ const QString & qName)
+{
+ if (qName == "title" && inTitle)
+ inTitle = false;
+ else if (qName == "link" && inLink)
+ inLink = false;
+ else if (qName == "item") {
+ if (!titleString.isEmpty() && !linkString.isEmpty())
+ emit newItem(titleString, linkString);
+ inItem = false;
+ titleString = "";
+ linkString = "";
+ }
+
+ return true;
+}
+
+/*
+ Collect characters when reading the contents of title or link elements
+ when they occur within an item element.
+
+ We return true to indicate that parsing should continue.
+*/
+
+bool Handler::characters (const QString &chars)
+{
+ if (inTitle)
+ titleString += chars;
+ else if (inLink)
+ linkString += chars;
+
+ return true;
+}
+
+/*
+ Report a fatal parsing error, and return false to indicate to the reader
+ that parsing should stop.
+*/
+
+//! [0]
+bool Handler::fatalError (const QXmlParseException & exception)
+{
+ qWarning() << "Fatal error on line" << exception.lineNumber()
+ << ", column" << exception.columnNumber() << ":"
+ << exception.message();
+
+ return false;
+}
+//! [0]
diff --git a/doc/src/snippets/xml/rsslisting/rsslisting.cpp b/doc/src/snippets/xml/rsslisting/rsslisting.cpp
new file mode 100644
index 0000000000..5047d0840d
--- /dev/null
+++ b/doc/src/snippets/xml/rsslisting/rsslisting.cpp
@@ -0,0 +1,251 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+/*
+rsslisting.cpp
+
+Provides a widget for displaying news items from RDF news sources.
+RDF is an XML-based format for storing items of information (see
+http://www.w3.org/RDF/ for details).
+
+The widget itself provides a simple user interface for specifying
+the URL of a news source, and controlling the downloading of news.
+
+The widget downloads and parses the XML asynchronously, feeding the
+data to an XML reader in pieces. This allows the user to interrupt
+its operation, and also allows very large data sources to be read.
+*/
+
+
+#include <QtCore>
+#include <QtGui>
+#include <QtNetwork>
+#include <QtXml>
+
+#include "rsslisting.h"
+
+
+/*
+ Constructs an RSSListing widget with a simple user interface, and sets
+ up the XML reader to use a custom handler class.
+
+ The user interface consists of a line edit, two push buttons, and a
+ list view widget. The line edit is used for entering the URLs of news
+ sources; the push buttons start and abort the process of reading the
+ news.
+*/
+
+RSSListing::RSSListing(QWidget *parent)
+ : QWidget(parent)
+{
+ lineEdit = new QLineEdit(this);
+
+ fetchButton = new QPushButton(tr("Fetch"), this);
+ abortButton = new QPushButton(tr("Abort"), this);
+ abortButton->setEnabled(false);
+
+ treeWidget = new QTreeWidget(this);
+ QStringList headerLabels;
+ headerLabels << tr("Title") << tr("Link");
+ treeWidget->setHeaderLabels(headerLabels);
+
+ handler = 0;
+
+ connect(&http, SIGNAL(readyRead(const QHttpResponseHeader &)),
+ this, SLOT(readData(const QHttpResponseHeader &)));
+
+ connect(&http, SIGNAL(requestFinished(int, bool)),
+ this, SLOT(finished(int, bool)));
+
+ connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(fetch()));
+ connect(fetchButton, SIGNAL(clicked()), this, SLOT(fetch()));
+ connect(abortButton, SIGNAL(clicked()), &http, SLOT(abort()));
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+
+ QHBoxLayout *hboxLayout = new QHBoxLayout;
+
+ hboxLayout->addWidget(lineEdit);
+ hboxLayout->addWidget(fetchButton);
+ hboxLayout->addWidget(abortButton);
+
+ layout->addLayout(hboxLayout);
+ layout->addWidget(treeWidget);
+
+ setWindowTitle(tr("RSS listing example"));
+}
+
+/*
+ Starts fetching data from a news source specified in the line
+ edit widget.
+
+ The line edit is made read only to prevent the user from modifying its
+ contents during the fetch; this is only for cosmetic purposes.
+ The fetch button is disabled, and the abort button is enabled to allow
+ the user to interrupt processing. The list view is cleared, and we
+ define the last list view item to be 0, meaning that there are no
+ existing items in the list.
+
+ We reset the flag used to determine whether parsing should begin again
+ or continue. A new handler is created, if required, and made available
+ to the reader.
+
+ The HTTP handler is supplied with the raw contents of the line edit and
+ a fetch is initiated. We keep the ID value returned by the HTTP handler
+ for future reference.
+*/
+
+void RSSListing::fetch()
+{
+ lineEdit->setReadOnly(true);
+ fetchButton->setEnabled(false);
+ abortButton->setEnabled(true);
+ treeWidget->clear();
+
+ lastItemCreated = 0;
+
+ newInformation = true;
+
+ if (handler != 0)
+ delete handler;
+ handler = new Handler;
+
+//! [0]
+ xmlReader.setContentHandler(handler);
+ xmlReader.setErrorHandler(handler);
+//! [0]
+
+ connect(handler, SIGNAL(newItem(QString &, QString &)),
+ this, SLOT(addItem(QString &, QString &)));
+
+ QUrl url(lineEdit->text());
+
+ http.setHost(url.host());
+ connectionId = http.get(url.path());
+}
+
+/*
+ Reads data received from the RDF source.
+
+ We read all the available data, and pass it to the XML
+ input source. The first time we receive new information,
+ the reader is set up for a new incremental parse;
+ we continue parsing using a different function on
+ subsequent calls involving the same data source.
+
+ If parsing fails for any reason, we abort the fetch.
+*/
+
+//! [1]
+void RSSListing::readData(const QHttpResponseHeader &resp)
+{
+ bool ok;
+
+ if (resp.statusCode() != 200)
+ http.abort();
+ else {
+ xmlInput.setData(http.readAll());
+
+ if (newInformation) {
+ ok = xmlReader.parse(&xmlInput, true);
+ newInformation = false;
+ }
+ else
+ ok = xmlReader.parseContinue();
+
+ if (!ok)
+ http.abort();
+ }
+}
+//! [1]
+
+/*
+ Finishes processing an HTTP request.
+
+ The default behavior is to keep the text edit read only.
+
+ If an error has occurred, the user interface is made available
+ to the user for further input, allowing a new fetch to be
+ started.
+
+ If the HTTP get request has finished, we perform a final
+ parsing operation on the data returned to ensure that it was
+ well-formed. Whether this is successful or not, we make the
+ user interface available to the user for further input.
+*/
+
+void RSSListing::finished(int id, bool error)
+{
+ if (error) {
+ qWarning("Received error during HTTP fetch.");
+ lineEdit->setReadOnly(false);
+ abortButton->setEnabled(false);
+ fetchButton->setEnabled(true);
+ }
+ else if (id == connectionId) {
+
+ bool ok = xmlReader.parseContinue();
+ if (!ok)
+ qWarning("Parse error at the end of input.");
+
+ lineEdit->setReadOnly(false);
+ abortButton->setEnabled(false);
+ fetchButton->setEnabled(true);
+ }
+}
+
+/*
+ Adds an item to the list view as it is reported by the handler.
+
+ We keep a record of the last item created to ensure that the
+ items are created in sequence.
+*/
+
+void RSSListing::addItem(QString &title, QString &link)
+{
+ QTreeWidgetItem *item;
+
+ item = new QTreeWidgetItem(treeWidget, lastItemCreated);
+ item->setText(0, title);
+ item->setText(1, link);
+
+ lastItemCreated = item;
+}
+
diff --git a/doc/src/snippets/xml/simpleparse/main.cpp b/doc/src/snippets/xml/simpleparse/main.cpp
new file mode 100644
index 0000000000..5d9994d63e
--- /dev/null
+++ b/doc/src/snippets/xml/simpleparse/main.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$
+**
+****************************************************************************/
+
+#include <qfile.h>
+#include <qxml.h>
+#include "handler.h"
+
+#include <iostream>
+
+int main(int argc, char **argv)
+{
+ if (argc != 2) {
+ std::cout << "Usage: " << argv[0] << " <filename>" << std::endl;
+ return 1;
+ }
+
+ QFile *file = new QFile(argv[1]);
+
+//! [0]
+ QXmlSimpleReader xmlReader;
+ QXmlInputSource *source = new QXmlInputSource(file);
+//! [0]
+
+//! [1]
+ Handler *handler = new Handler;
+ xmlReader.setContentHandler(handler);
+ xmlReader.setErrorHandler(handler);
+//! [1]
+
+//! [2]
+ bool ok = xmlReader.parse(source);
+
+ if (!ok)
+ std::cout << "Parsing failed." << std::endl;
+//! [2]
+ else {
+ QStringList names = handler->names();
+ QList<int> indentations = handler->indentations();
+
+ int items = names.count();
+
+ for (int i = 0; i < items; ++i) {
+ for (int j = 0; j < indentations[i]; ++j)
+ std::cout << " ";
+ std::cout << names[i].toLocal8Bit().constData() << std::endl;
+ }
+ }
+
+ return 0;
+}