aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorLauro Neto <lauro.neto@openbossa.org>2010-04-27 18:12:50 -0300
committerRenato Filho <renato.filho@openbossa.org>2010-04-28 16:36:47 -0300
commitaaece960d3cf1c9d19dd84fe8171769517647724 (patch)
treeea2e20d2c8738cc407f60b10b6cccfb4e1fc2b70 /doc
parent685246809debe672a0007b67fe78f7c77bad6739 (diff)
Adding ./doc from boost
Reviewer: Lauro Moura <lauro.neto@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'doc')
-rw-r--r--doc/CMakeLists.txt82
-rw-r--r--doc/Makefile89
-rw-r--r--doc/_static/.gitignore0
-rw-r--r--doc/_static/basic.css417
-rw-r--r--doc/_static/default.css248
-rwxr-xr-xdoc/_static/images/._background_search.jpgbin0 -> 4096 bytes
-rwxr-xr-xdoc/_static/images/._bread_crumb.pngbin0 -> 4096 bytes
-rwxr-xr-xdoc/_static/images/._button_search.jpgbin0 -> 4096 bytes
-rwxr-xr-xdoc/_static/images/._side_background.jpgbin0 -> 25192 bytes
-rwxr-xr-xdoc/_static/images/._top_background.jpgbin0 -> 4096 bytes
-rw-r--r--doc/_static/images/background_search.jpgbin0 -> 2129 bytes
-rw-r--r--doc/_static/images/bg.jpgbin0 -> 5749 bytes
-rw-r--r--doc/_static/images/bread_crumb.pngbin0 -> 743 bytes
-rw-r--r--doc/_static/images/button_search.pngbin0 -> 3259 bytes
-rw-r--r--doc/_static/images/side_background.jpgbin0 -> 13760 bytes
-rw-r--r--doc/_static/images/top_background.jpgbin0 -> 500 bytes
-rw-r--r--doc/_templates/index.html68
-rw-r--r--doc/_themes/pysidedocs/defindex.html26
-rw-r--r--doc/_themes/pysidedocs/genindex-single.html46
-rw-r--r--doc/_themes/pysidedocs/genindex-split.html30
-rw-r--r--doc/_themes/pysidedocs/genindex.html57
-rw-r--r--doc/_themes/pysidedocs/layout.html147
-rw-r--r--doc/_themes/pysidedocs/modindex.html42
-rw-r--r--doc/_themes/pysidedocs/opensearch.xml10
-rw-r--r--doc/_themes/pysidedocs/page.html4
-rw-r--r--doc/_themes/pysidedocs/search.html26
-rw-r--r--doc/_themes/pysidedocs/static/.directory3
-rw-r--r--doc/_themes/pysidedocs/static/bg_header.pngbin0 -> 36012 bytes
-rw-r--r--doc/_themes/pysidedocs/static/bg_topo.jpgbin0 -> 14237 bytes
-rw-r--r--doc/_themes/pysidedocs/static/doctools.js232
-rw-r--r--doc/_themes/pysidedocs/static/fakebar.pngbin0 -> 101 bytes
-rw-r--r--doc/_themes/pysidedocs/static/jquery.js32
-rw-r--r--doc/_themes/pysidedocs/static/logo_indt.jpgbin0 -> 3138 bytes
-rw-r--r--doc/_themes/pysidedocs/static/logo_openbossa.pngbin0 -> 4702 bytes
-rw-r--r--doc/_themes/pysidedocs/static/logo_python.jpgbin0 -> 2660 bytes
-rw-r--r--doc/_themes/pysidedocs/static/logo_qt.pngbin0 -> 4618 bytes
-rw-r--r--doc/_themes/pysidedocs/static/pysidedocs.css412
-rw-r--r--doc/_themes/pysidedocs/static/pysidelogo.pngbin0 -> 12969 bytes
-rw-r--r--doc/_themes/pysidedocs/static/relbar_bg.pngbin0 -> 130 bytes
-rw-r--r--doc/_themes/pysidedocs/static/searchtools.js467
-rw-r--r--doc/_themes/pysidedocs/theme.conf7
-rw-r--r--doc/codesnippets/doc/src/snippets/accessibilityfactorysnippet.cpp68
-rw-r--r--doc/codesnippets/doc/src/snippets/accessibilitypluginsnippet.cpp75
-rw-r--r--doc/codesnippets/doc/src/snippets/accessibilityslidersnippet.cpp262
-rw-r--r--doc/codesnippets/doc/src/snippets/alphachannel.cpp55
-rw-r--r--doc/codesnippets/doc/src/snippets/audioeffects.cpp42
-rw-r--r--doc/codesnippets/doc/src/snippets/brush/brush.cpp87
-rw-r--r--doc/codesnippets/doc/src/snippets/brush/brush.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/brush/gradientcreationsnippet.cpp63
-rw-r--r--doc/codesnippets/doc/src/snippets/brushstyles/brushstyles.pro12
-rw-r--r--doc/codesnippets/doc/src/snippets/brushstyles/main.cpp52
-rw-r--r--doc/codesnippets/doc/src/snippets/brushstyles/qt-logo.pngbin0 -> 1422 bytes
-rw-r--r--doc/codesnippets/doc/src/snippets/brushstyles/renderarea.cpp79
-rw-r--r--doc/codesnippets/doc/src/snippets/brushstyles/renderarea.h62
-rw-r--r--doc/codesnippets/doc/src/snippets/brushstyles/stylewidget.cpp145
-rw-r--r--doc/codesnippets/doc/src/snippets/brushstyles/stylewidget.h99
-rw-r--r--doc/codesnippets/doc/src/snippets/buffer/buffer.cpp124
-rw-r--r--doc/codesnippets/doc/src/snippets/buffer/buffer.pro14
-rw-r--r--doc/codesnippets/doc/src/snippets/clipboard/clipboard.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/clipboard/clipwindow.cpp97
-rw-r--r--doc/codesnippets/doc/src/snippets/clipboard/clipwindow.h73
-rw-r--r--doc/codesnippets/doc/src/snippets/clipboard/main.cpp53
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc.src.qtscripttools.qdoc8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_activeqt-dumpcpp.qdoc25
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_appicon.qdoc23
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_assistant-manual.qdoc110
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_atomic-operations.qdoc71
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_compiler-notes.qdoc8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_containers.qdoc235
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_coordsys.qdoc47
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_debug.qdoc24
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_deployment.qdoc414
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_designer-manual.qdoc98
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_dnd.qdoc34
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_emb-charinput.qdoc20
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_emb-crosscompiling.qdoc36
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_emb-envvars.qdoc38
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_emb-features.qdoc18
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_emb-fonts.qdoc3
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_emb-install.qdoc37
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_emb-performance.qdoc36
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_emb-pointer.qdoc68
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_emb-qvfb.qdoc70
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_emb-running.qdoc61
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_emb-vnc.qdoc25
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_examples_activeqt_comapp.qdoc39
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_examples_activeqt_dotnet.qdoc4
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_examples_activeqt_menus.qdoc6
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_examples_ahigl.qdoc8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_examples_application.qdoc5
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_examples_arrowpad.qdoc19
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_examples_containerextension.qdoc4
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_examples_customwidgetplugin.qdoc4
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_examples_dropsite.qdoc3
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_examples_editabletreemodel.qdoc8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_examples_hellotr.qdoc31
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_examples_icons.qdoc14
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_examples_imageviewer.qdoc24
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_examples_qtscriptcustomclass.qdoc35
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_examples_simpledommodel.qdoc20
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_examples_simpletreemodel.qdoc12
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_examples_svgalib.qdoc3
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_examples_taskmenuextension.qdoc4
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_examples_textfinder.qdoc6
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_examples_trollprint.qdoc35
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_examples_tutorial.qdoc10
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_examples_worldtimeclockplugin.qdoc4
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_exportedfunctions.qdoc17
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_gpl.qdoc679
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_graphicsview.qdoc77
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_groups.qdoc26
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_i18n.qdoc155
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_installation.qdoc127
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_introtodbus.qdoc3
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_layout.qdoc126
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_lgpl.qdoc507
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_licenses.qdoc108
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_linguist-manual.qdoc183
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_moc.qdoc124
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_model-view-programming.qdoc36
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_modules.qdoc3
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_objecttrees.qdoc20
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_phonon-api.qdoc224
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_phonon.qdoc13
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_platform-notes.qdoc39
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_plugins-howto.qdoc67
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_porting-qsa.qdoc187
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_porting4-canvas.qdoc116
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_porting4-designer.qdoc159
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_porting4.qdoc473
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_properties.qdoc78
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_q3asciidict.qdoc52
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_q3dict.qdoc29
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_q3intdict.qdoc51
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_q3memarray.qdoc80
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_q3ptrdict.qdoc66
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_q3ptrlist.qdoc82
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_q3valuelist.qdoc95
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_q3valuestack.qdoc13
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_q3valuevector.qdoc85
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qalgorithms.qdoc314
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qaxcontainer.qdoc8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qaxserver.qdoc223
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qcache.qdoc17
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qdbusadaptors.qdoc253
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qiterator.qdoc380
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qmake-manual.qdoc813
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qnamespace.qdoc24
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qpair.qdoc15
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qplugin.qdoc24
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qset.qdoc126
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qsignalspy.qdoc41
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qt-conf.qdoc14
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qt-embedded-displaymanagement.qdoc51
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qt3support.qdoc8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qt3to4.qdoc26
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qt4-accessibility.qdoc59
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qt4-arthur.qdoc104
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qt4-intro.qdoc101
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc70
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qt4-sql.qdoc19
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qt4-styles.qdoc42
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qt4-tulip.qdoc100
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qtcore.qdoc3
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qtdbus.qdoc8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qtdesigner.qdoc293
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qtestevent.qdoc11
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qtestlib.qdoc102
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qtgui.qdoc3
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qthelp.qdoc161
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qtmac-as-native.qdoc3
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qtnetwork.qdoc8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qtopengl.qdoc8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qtscript.qdoc948
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qtscriptextensions.qdoc7
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qtsql.qdoc8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qtsvg.qdoc8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qttest.qdoc8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qtuiloader.qdoc8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qtxml.qdoc77
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qtxmlpatterns.qdoc349
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_qvarlengtharray.qdoc38
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_rcc.qdoc3
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_resources.qdoc41
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_richtext.qdoc50
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_session.qdoc3
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_sql-driver.qdoc239
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_styles.qdoc94
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_stylesheet.qdoc1911
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_uic.qdoc15
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_unicode.qdoc18
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_unix-signal-handlers.qdoc110
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src.gui.text.qtextdocumentwriter.cpp5
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src.qdbus.qdbuspendingcall.cpp24
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src.qdbus.qdbuspendingreply.cpp23
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src.scripttools.qscriptenginedebugger.cpp9
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_activeqt_container_qaxbase.cpp159
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_activeqt_container_qaxscript.cpp18
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_activeqt_control_qaxbindable.cpp60
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_activeqt_control_qaxfactory.cpp155
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_codecs_qtextcodec.cpp32
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_codecs_qtextcodecplugin.cpp12
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qfuture.cpp24
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qfuturesynchronizer.cpp13
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qfuturewatcher.cpp10
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentexception.cpp35
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentfilter.cpp131
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp144
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentrun.cpp60
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qthreadpool.cpp9
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_global_qglobal.cpp466
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_io_qabstractfileengine.cpp62
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdatastream.cpp85
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdir.cpp130
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdiriterator.cpp12
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_io_qfile.cpp32
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp99
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_io_qiodevice.cpp48
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_io_qprocess.cpp82
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_io_qsettings.cpp280
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_io_qtemporaryfile.cpp12
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_io_qtextstream.cpp90
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_io_qurl.cpp46
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qabstracteventdispatcher.cpp3
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp28
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp86
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp87
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp69
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qmimedata.cpp57
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qobject.cpp319
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp21
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qtimer.cpp10
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qvariant.cpp99
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp44
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_plugin_quuid.cpp4
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qatomic.cpp58
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qmutex.cpp115
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qmutexpool.cpp12
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qreadwritelock.cpp61
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qsemaphore.cpp33
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qthread.cpp9
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp45
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qbitarray.cpp189
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qbytearray.cpp355
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qdatetime.cpp106
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qhash.cpp259
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp164
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qlistdata.cpp227
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qlocale.cpp48
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qmap.cpp273
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qpoint.cpp111
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qqueue.cpp8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qrect.cpp10
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qregexp.cpp175
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qsize.cpp96
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qstring.cpp45
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qtimeline.cpp15
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qvector.cpp143
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_xml_qxmlstream.cpp27
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_accessible_qaccessible.cpp7
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qabstractprintdialog.cpp5
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp86
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp40
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp102
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qwizard.cpp31
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsgridlayout.cpp13
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp185
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicslinearlayout.cpp13
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp46
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp75
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicssceneevent.cpp5
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp86
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp25
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_image_qbitmap.cpp4
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_image_qicon.cpp26
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_image_qimage.cpp36
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_image_qimagereader.cpp25
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_image_qimagewriter.cpp19
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_image_qmovie.cpp13
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_image_qpixmap.cpp12
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_image_qpixmapcache.cpp16
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_image_qpixmapfilter.cpp22
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qabstractitemview.cpp17
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp23
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qitemeditorfactory.cpp23
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qitemselectionmodel.cpp10
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp37
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qtablewidget.cpp5
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qtreewidget.cpp8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qaction.cpp9
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qapplication.cpp127
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qapplication_x11.cpp5
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qclipboard.cpp13
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qevent.cpp11
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qformlayout.cpp36
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qkeysequence.cpp19
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qlayout.cpp25
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qlayoutitem.cpp8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qshortcut.cpp15
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qshortcutmap.cpp3
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qsound.cpp9
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qwidget.cpp100
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_painting_qbrush.cpp11
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_painting_qcolor.cpp9
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_painting_qdrawutil.cpp58
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_painting_qmatrix.cpp22
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_painting_qpainter.cpp195
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_painting_qpainterpath.cpp110
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_painting_qpen.cpp35
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_painting_qregion.cpp13
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_painting_qregion_unix.cpp18
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_painting_qtransform.cpp38
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_styles_qstyle.cpp8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_styles_qstyleoption.cpp7
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_text_qfont.cpp27
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_text_qfontmetrics.cpp14
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_text_qsyntaxhighlighter.cpp74
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_text_qtextcursor.cpp40
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_text_qtextdocument.cpp10
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_text_qtextlayout.cpp23
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_util_qcompleter.cpp25
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_util_qdesktopservices.cpp15
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_util_qundostack.cpp70
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qabstractbutton.cpp19
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qabstractspinbox.cpp8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qcalendarwidget.cpp33
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qcheckbox.cpp3
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qdatetimeedit.cpp39
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qdockwidget.cpp7
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qframe.cpp8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qgroupbox.cpp3
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qlabel.cpp24
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qlineedit.cpp7
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qmenu.cpp37
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qmenubar.cpp8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qplaintextedit.cpp14
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qpushbutton.cpp3
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qradiobutton.cpp3
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qrubberband.cpp17
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qscrollarea.cpp9
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qspinbox.cpp40
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qsplashscreen.cpp15
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qsplitter.cpp7
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qstatusbar.cpp3
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qtextbrowser.cpp4
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qtextedit.cpp19
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qvalidator.cpp105
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qworkspace.cpp7
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_network_access_qftp.cpp59
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_network_access_qhttp.cpp82
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp21
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_network_access_qnetworkrequest.cpp3
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_network_kernel_qhostaddress.cpp7
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_network_kernel_qhostinfo.cpp42
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_network_kernel_qnetworkproxy.cpp14
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_network_socket_qabstractsocket.cpp28
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_network_socket_qlocalsocket_unix.cpp12
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_network_socket_qnativesocketengine.cpp21
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_network_socket_qtcpserver.cpp3
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_network_socket_qudpsocket.cpp17
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_network_ssl_qsslcertificate.cpp4
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_network_ssl_qsslconfiguration.cpp5
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_network_ssl_qsslsocket.cpp50
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_opengl_qgl.cpp118
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_opengl_qglcolormap.cpp24
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_opengl_qglpixelbuffer.cpp19
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qdbus_qdbusabstractinterface.cpp20
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qdbus_qdbusargument.cpp151
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qdbus_qdbuscontext.cpp32
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qdbus_qdbusinterface.cpp11
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qdbus_qdbusmetatype.cpp3
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qdbus_qdbusreply.cpp14
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_canvas_q3canvas.cpp51
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_dialogs_q3filedialog.cpp229
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_dialogs_q3progressdialog.cpp41
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_itemviews_q3iconview.cpp75
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_itemviews_q3listview.cpp73
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_itemviews_q3table.cpp57
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3dns.cpp58
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3ftp.cpp65
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3http.cpp74
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3localfs.cpp4
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3networkprotocol.cpp8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3socket.cpp4
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3socketdevice.cpp4
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3url.cpp43
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3urloperator.cpp37
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_other_q3accel.cpp40
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_other_q3mimefactory.cpp32
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_other_q3process.cpp8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_other_q3process_unix.cpp4
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_painting_q3paintdevicemetrics.cpp4
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_painting_q3painter.cpp4
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_painting_q3picture.cpp14
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3databrowser.cpp8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3datatable.cpp8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3dataview.cpp4
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlcursor.cpp100
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlform.cpp26
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlmanager_p.cpp11
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlpropertymap.cpp35
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlselectcursor.cpp11
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_text_q3simplerichtext.cpp3
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_text_q3textbrowser.cpp3
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_text_q3textedit.cpp31
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_text_q3textstream.cpp29
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_tools_q3cstring.cpp40
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_tools_q3deepcopy.cpp58
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_tools_q3garray.cpp20
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_tools_q3signal.cpp38
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3combobox.cpp15
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3datetimeedit.cpp28
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3dockarea.cpp8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3dockwindow.cpp4
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3gridview.cpp6
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3header.cpp6
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3mainwindow.cpp45
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3scrollview.cpp61
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3whatsthis.cpp3
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qtestlib_qtestcase.cpp188
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_script_qscriptable.cpp19
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_script_qscriptclass.cpp9
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_script_qscriptcontext.cpp23
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_script_qscriptengine.cpp270
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_script_qscriptengineagent.cpp12
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_script_qscriptvalue.cpp41
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_script_qscriptvalueiterator.cpp28
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqldatabase.cpp96
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqldriver.cpp23
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlerror.cpp6
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlindex.cpp5
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlquery.cpp40
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlresult.cpp38
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_sql_models_qsqlquerymodel.cpp12
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_svg_qgraphicssvgitem.cpp11
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_xml_dom_qdom.cpp180
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_xml_sax_qxml.cpp3
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstracturiresolver.cpp3
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstractxmlforwarditerator.cpp3
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstractxmlnodemodel.cpp22
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstractxmlreceiver.cpp7
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qsimplexmlnodemodel.cpp19
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlformatter.cpp8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlname.cpp8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlquery.cpp152
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlresultitems.cpp16
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlserializer.cpp7
-rw-r--r--doc/codesnippets/doc/src/snippets/code/tools_assistant_compat_lib_qassistantclient.cpp25
-rw-r--r--doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_extension_default_extensionfactory.cpp35
-rw-r--r--doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_extension_extension.cpp15
-rw-r--r--doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_extension_qextensionmanager.cpp17
-rw-r--r--doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformeditor.cpp11
-rw-r--r--doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindow.cpp25
-rw-r--r--doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindowcursor.cpp8
-rw-r--r--doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindowmanager.cpp11
-rw-r--r--doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractobjectinspector.cpp11
-rw-r--r--doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractpropertyeditor.cpp23
-rw-r--r--doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractwidgetbox.cpp30
-rw-r--r--doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_uilib_abstractformbuilder.cpp17
-rw-r--r--doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_uilib_formbuilder.cpp26
-rw-r--r--doc/codesnippets/doc/src/snippets/code/tools_patternist_qapplicationargumentparser.cpp5
-rw-r--r--doc/codesnippets/doc/src/snippets/code/tools_shared_qtgradienteditor_qtgradientdialog.cpp44
-rw-r--r--doc/codesnippets/doc/src/snippets/code/tools_shared_qtpropertybrowser_qtpropertybrowser.cpp47
-rw-r--r--doc/codesnippets/doc/src/snippets/code/tools_shared_qtpropertybrowser_qtvariantproperty.cpp16
-rw-r--r--doc/codesnippets/doc/src/snippets/code/tools_shared_qttoolbardialog_qttoolbardialog.cpp12
-rw-r--r--doc/codesnippets/doc/src/snippets/complexpingpong-example.qdoc4
-rw-r--r--doc/codesnippets/doc/src/snippets/console/dbus_pingpong.txt3
-rw-r--r--doc/codesnippets/doc/src/snippets/coordsys/coordsys.cpp77
-rw-r--r--doc/codesnippets/doc/src/snippets/coordsys/coordsys.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/customstyle/customstyle.cpp89
-rw-r--r--doc/codesnippets/doc/src/snippets/customstyle/customstyle.h60
-rw-r--r--doc/codesnippets/doc/src/snippets/customstyle/customstyle.pro2
-rw-r--r--doc/codesnippets/doc/src/snippets/customstyle/main.cpp55
-rw-r--r--doc/codesnippets/doc/src/snippets/customviewstyle.cpp29
-rw-r--r--doc/codesnippets/doc/src/snippets/dbus-pingpong-example.qdoc3
-rw-r--r--doc/codesnippets/doc/src/snippets/designer/autoconnection/autoconnection.pro5
-rw-r--r--doc/codesnippets/doc/src/snippets/designer/autoconnection/imagedialog.cpp70
-rw-r--r--doc/codesnippets/doc/src/snippets/designer/autoconnection/imagedialog.h60
-rw-r--r--doc/codesnippets/doc/src/snippets/designer/autoconnection/imagedialog.ui389
-rw-r--r--doc/codesnippets/doc/src/snippets/designer/autoconnection/main.cpp52
-rw-r--r--doc/codesnippets/doc/src/snippets/designer/designer.pro6
-rw-r--r--doc/codesnippets/doc/src/snippets/designer/imagedialog/imagedialog.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/designer/imagedialog/imagedialog.ui389
-rw-r--r--doc/codesnippets/doc/src/snippets/designer/imagedialog/main.cpp54
-rw-r--r--doc/codesnippets/doc/src/snippets/designer/multipleinheritance/imagedialog.cpp60
-rw-r--r--doc/codesnippets/doc/src/snippets/designer/multipleinheritance/imagedialog.h55
-rw-r--r--doc/codesnippets/doc/src/snippets/designer/multipleinheritance/imagedialog.ui389
-rw-r--r--doc/codesnippets/doc/src/snippets/designer/multipleinheritance/main.cpp52
-rw-r--r--doc/codesnippets/doc/src/snippets/designer/multipleinheritance/multipleinheritance.pro5
-rw-r--r--doc/codesnippets/doc/src/snippets/designer/noautoconnection/imagedialog.cpp77
-rw-r--r--doc/codesnippets/doc/src/snippets/designer/noautoconnection/imagedialog.h60
-rw-r--r--doc/codesnippets/doc/src/snippets/designer/noautoconnection/imagedialog.ui389
-rw-r--r--doc/codesnippets/doc/src/snippets/designer/noautoconnection/main.cpp52
-rw-r--r--doc/codesnippets/doc/src/snippets/designer/noautoconnection/noautoconnection.pro5
-rw-r--r--doc/codesnippets/doc/src/snippets/designer/singleinheritance/imagedialog.cpp60
-rw-r--r--doc/codesnippets/doc/src/snippets/designer/singleinheritance/imagedialog.h58
-rw-r--r--doc/codesnippets/doc/src/snippets/designer/singleinheritance/imagedialog.ui389
-rw-r--r--doc/codesnippets/doc/src/snippets/designer/singleinheritance/main.cpp52
-rw-r--r--doc/codesnippets/doc/src/snippets/designer/singleinheritance/singleinheritance.pro5
-rw-r--r--doc/codesnippets/doc/src/snippets/dialogs/dialogs.cpp120
-rw-r--r--doc/codesnippets/doc/src/snippets/dialogs/dialogs.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/dockwidgets/Resources/modules.html28
-rw-r--r--doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtcore.html122
-rw-r--r--doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtgui.html276
-rw-r--r--doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtnetwork.html35
-rw-r--r--doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtopengl.html27
-rw-r--r--doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtsql.html39
-rw-r--r--doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtxml.html53
-rw-r--r--doc/codesnippets/doc/src/snippets/dockwidgets/Resources/titles.txt7
-rw-r--r--doc/codesnippets/doc/src/snippets/dockwidgets/dockwidgets.pro4
-rw-r--r--doc/codesnippets/doc/src/snippets/dockwidgets/dockwidgets.qrc12
-rw-r--r--doc/codesnippets/doc/src/snippets/dockwidgets/main.cpp53
-rw-r--r--doc/codesnippets/doc/src/snippets/dockwidgets/mainwindow.cpp123
-rw-r--r--doc/codesnippets/doc/src/snippets/dockwidgets/mainwindow.h71
-rw-r--r--doc/codesnippets/doc/src/snippets/draganddrop/draganddrop.pro5
-rw-r--r--doc/codesnippets/doc/src/snippets/draganddrop/dragwidget.cpp154
-rw-r--r--doc/codesnippets/doc/src/snippets/draganddrop/dragwidget.h80
-rw-r--r--doc/codesnippets/doc/src/snippets/draganddrop/main.cpp54
-rw-r--r--doc/codesnippets/doc/src/snippets/draganddrop/mainwindow.cpp85
-rw-r--r--doc/codesnippets/doc/src/snippets/draganddrop/mainwindow.h72
-rw-r--r--doc/codesnippets/doc/src/snippets/dragging/dragging.pro4
-rw-r--r--doc/codesnippets/doc/src/snippets/dragging/images.qrc5
-rw-r--r--doc/codesnippets/doc/src/snippets/dragging/images/file.pngbin0 -> 313 bytes
-rw-r--r--doc/codesnippets/doc/src/snippets/dragging/main.cpp52
-rw-r--r--doc/codesnippets/doc/src/snippets/dragging/mainwindow.cpp63
-rw-r--r--doc/codesnippets/doc/src/snippets/dragging/mainwindow.h72
-rw-r--r--doc/codesnippets/doc/src/snippets/dropactions/dropactions.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/dropactions/main.cpp52
-rw-r--r--doc/codesnippets/doc/src/snippets/dropactions/window.cpp106
-rw-r--r--doc/codesnippets/doc/src/snippets/dropactions/window.h72
-rw-r--r--doc/codesnippets/doc/src/snippets/droparea.cpp136
-rw-r--r--doc/codesnippets/doc/src/snippets/dropevents/dropevents.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/dropevents/main.cpp53
-rw-r--r--doc/codesnippets/doc/src/snippets/dropevents/window.cpp88
-rw-r--r--doc/codesnippets/doc/src/snippets/dropevents/window.h72
-rw-r--r--doc/codesnippets/doc/src/snippets/droprectangle/droprectangle.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/droprectangle/main.cpp52
-rw-r--r--doc/codesnippets/doc/src/snippets/droprectangle/window.cpp97
-rw-r--r--doc/codesnippets/doc/src/snippets/droprectangle/window.h72
-rw-r--r--doc/codesnippets/doc/src/snippets/eventfilters/eventfilters.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/eventfilters/filterobject.cpp75
-rw-r--r--doc/codesnippets/doc/src/snippets/eventfilters/filterobject.h60
-rw-r--r--doc/codesnippets/doc/src/snippets/eventfilters/main.cpp55
-rw-r--r--doc/codesnippets/doc/src/snippets/events/events.cpp98
-rw-r--r--doc/codesnippets/doc/src/snippets/events/events.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/explicitlysharedemployee/employee.cpp110
-rw-r--r--doc/codesnippets/doc/src/snippets/explicitlysharedemployee/employee.h75
-rw-r--r--doc/codesnippets/doc/src/snippets/explicitlysharedemployee/explicitlysharedemployee.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/explicitlysharedemployee/main.cpp51
-rw-r--r--doc/codesnippets/doc/src/snippets/file/file.cpp121
-rw-r--r--doc/codesnippets/doc/src/snippets/file/file.pro14
-rw-r--r--doc/codesnippets/doc/src/snippets/filedialogurls.cpp22
-rw-r--r--doc/codesnippets/doc/src/snippets/fileinfo/fileinfo.pro11
-rw-r--r--doc/codesnippets/doc/src/snippets/fileinfo/main.cpp93
-rw-r--r--doc/codesnippets/doc/src/snippets/graphicssceneadditemsnippet.cpp81
-rw-r--r--doc/codesnippets/doc/src/snippets/i18n-non-qt-class/i18n-non-qt-class.pro7
-rw-r--r--doc/codesnippets/doc/src/snippets/i18n-non-qt-class/main.cpp55
-rw-r--r--doc/codesnippets/doc/src/snippets/i18n-non-qt-class/myclass.cpp48
-rw-r--r--doc/codesnippets/doc/src/snippets/i18n-non-qt-class/myclass.h60
-rw-r--r--doc/codesnippets/doc/src/snippets/i18n-non-qt-class/myclass.ts12
-rw-r--r--doc/codesnippets/doc/src/snippets/i18n-non-qt-class/resources.qrc6
-rw-r--r--doc/codesnippets/doc/src/snippets/i18n-non-qt-class/translations/i18n-non-qt-class_en.ts12
-rw-r--r--doc/codesnippets/doc/src/snippets/i18n-non-qt-class/translations/i18n-non-qt-class_fr.ts13
-rw-r--r--doc/codesnippets/doc/src/snippets/image/image.cpp60
-rw-r--r--doc/codesnippets/doc/src/snippets/image/image.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/image/supportedformat.cpp47
-rw-r--r--doc/codesnippets/doc/src/snippets/inherited-slot/button.cpp54
-rw-r--r--doc/codesnippets/doc/src/snippets/inherited-slot/button.h60
-rw-r--r--doc/codesnippets/doc/src/snippets/inherited-slot/inherited-slot.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/inherited-slot/main.cpp67
-rw-r--r--doc/codesnippets/doc/src/snippets/itemselection/itemselection.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/itemselection/main.cpp116
-rw-r--r--doc/codesnippets/doc/src/snippets/itemselection/model.cpp239
-rw-r--r--doc/codesnippets/doc/src/snippets/itemselection/model.h75
-rw-r--r--doc/codesnippets/doc/src/snippets/javastyle.cpp2746
-rw-r--r--doc/codesnippets/doc/src/snippets/layouts/layouts.cpp117
-rw-r--r--doc/codesnippets/doc/src/snippets/layouts/layouts.pro12
-rw-r--r--doc/codesnippets/doc/src/snippets/mainwindowsnippet.cpp49
-rw-r--r--doc/codesnippets/doc/src/snippets/matrix/matrix.cpp103
-rw-r--r--doc/codesnippets/doc/src/snippets/matrix/matrix.pro11
-rw-r--r--doc/codesnippets/doc/src/snippets/mdiareasnippets.cpp57
-rw-r--r--doc/codesnippets/doc/src/snippets/medianodesnippet.cpp29
-rw-r--r--doc/codesnippets/doc/src/snippets/moc/main.cpp66
-rw-r--r--doc/codesnippets/doc/src/snippets/moc/moc.pro2
-rw-r--r--doc/codesnippets/doc/src/snippets/moc/myclass1.h66
-rw-r--r--doc/codesnippets/doc/src/snippets/moc/myclass2.h67
-rw-r--r--doc/codesnippets/doc/src/snippets/moc/myclass3.h60
-rw-r--r--doc/codesnippets/doc/src/snippets/modelview-subclasses/main.cpp69
-rw-r--r--doc/codesnippets/doc/src/snippets/modelview-subclasses/model.cpp153
-rw-r--r--doc/codesnippets/doc/src/snippets/modelview-subclasses/model.h71
-rw-r--r--doc/codesnippets/doc/src/snippets/modelview-subclasses/view.cpp315
-rw-r--r--doc/codesnippets/doc/src/snippets/modelview-subclasses/view.h91
-rw-r--r--doc/codesnippets/doc/src/snippets/modelview-subclasses/window.cpp113
-rw-r--r--doc/codesnippets/doc/src/snippets/modelview-subclasses/window.h69
-rw-r--r--doc/codesnippets/doc/src/snippets/myscrollarea.cpp103
-rw-r--r--doc/codesnippets/doc/src/snippets/network/tcpwait.cpp63
-rw-r--r--doc/codesnippets/doc/src/snippets/ntfsp.cpp11
-rw-r--r--doc/codesnippets/doc/src/snippets/painterpath/painterpath.cpp77
-rw-r--r--doc/codesnippets/doc/src/snippets/painterpath/painterpath.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/anyHTMLElement.xq1
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/anyXLinkAttribute.xq2
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/bracesIncluded.xq1
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/bracesIncludedResult.xml1
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/bracesOmitted.xq1
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/bracesOmittedResult.xml2
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/computedTreeFragment.xq14
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/copyAttribute.xq9
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/copyID.xq3
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/directTreeFragment.xq7
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/doc.txt35
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/docPlainHTML.xq1
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/docPlainHTML2.xq1
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/embedDataInXHTML.xq10
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/embedDataInXHTML2.xq10
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/emptyParagraphs.xq1
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/escapeCurlyBraces.xq4
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/escapeStringLiterals.xml2
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/escapeStringLiterals.xq7
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/expressionInsideAttribute.xq2
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/filterOnPath.xq2
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/filterOnStep.xq2
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/firstParagraph.xq1
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/fnStringOnAttribute.xq9
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/forClause.xq3
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/forClause2.xq3
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/forClauseOnFeed.xq6
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/indented.xml5
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/introAcneRemover.xq8
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/introExample2.xq5
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/introFileHierarchy.xml14
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/introNavigateFS.xq12
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/introductionExample.xq3
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/invalidLetOrderBy.xq3
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/items.xq5
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/letOrderBy.xq4
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/literalsAndOperators.xq2
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/mobeyDick.xml4
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/nextLastParagraph.xq1
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/nodeConstructorsAreExpressions.xq4
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/nodeConstructorsInPaths.xq1
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/nodeTestChildElement.xq1
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/notIndented.xml1
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/oneElementConstructor.xq1
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/paragraphsExceptTheFiveFirst.xq1
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/paragraphsWithTables.xq1
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/pathAB.xq1
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/pathsAllParagraphs.xq1
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/simpleHTML.xq1
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/simpleXHTML.xq2
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/svgDocumentElement.xml1
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/tablesInParagraphs.xq1
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/twoSVGElements.xq5
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/xmlStylesheet.xq1
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/xsBooleanTrue.xq1
-rw-r--r--doc/codesnippets/doc/src/snippets/patternist/xsvgDocumentElement.xml1
-rw-r--r--doc/codesnippets/doc/src/snippets/persistentindexes/main.cpp52
-rw-r--r--doc/codesnippets/doc/src/snippets/persistentindexes/mainwindow.cpp121
-rw-r--r--doc/codesnippets/doc/src/snippets/persistentindexes/mainwindow.h71
-rw-r--r--doc/codesnippets/doc/src/snippets/persistentindexes/model.cpp169
-rw-r--r--doc/codesnippets/doc/src/snippets/persistentindexes/model.h72
-rw-r--r--doc/codesnippets/doc/src/snippets/persistentindexes/persistentindexes.pro5
-rw-r--r--doc/codesnippets/doc/src/snippets/phonon.cpp96
-rw-r--r--doc/codesnippets/doc/src/snippets/phonon/samplebackend/main.cpp115
-rw-r--r--doc/codesnippets/doc/src/snippets/phononeffectparameter.cpp35
-rw-r--r--doc/codesnippets/doc/src/snippets/phononobjectdescription.cpp40
-rw-r--r--doc/codesnippets/doc/src/snippets/picture/picture.cpp112
-rw-r--r--doc/codesnippets/doc/src/snippets/picture/picture.pro12
-rw-r--r--doc/codesnippets/doc/src/snippets/plaintextlayout/main.cpp53
-rw-r--r--doc/codesnippets/doc/src/snippets/plaintextlayout/plaintextlayout.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/plaintextlayout/window.cpp109
-rw-r--r--doc/codesnippets/doc/src/snippets/plaintextlayout/window.h62
-rw-r--r--doc/codesnippets/doc/src/snippets/pointer/pointer.cpp61
-rw-r--r--doc/codesnippets/doc/src/snippets/polygon/polygon.cpp87
-rw-r--r--doc/codesnippets/doc/src/snippets/polygon/polygon.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/porting4-dropevents/main.cpp53
-rw-r--r--doc/codesnippets/doc/src/snippets/porting4-dropevents/porting4-dropevents.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/porting4-dropevents/window.cpp125
-rw-r--r--doc/codesnippets/doc/src/snippets/porting4-dropevents/window.h73
-rw-r--r--doc/codesnippets/doc/src/snippets/printing-qprinter/errors.cpp18
-rw-r--r--doc/codesnippets/doc/src/snippets/printing-qprinter/main.cpp54
-rw-r--r--doc/codesnippets/doc/src/snippets/printing-qprinter/object.cpp72
-rw-r--r--doc/codesnippets/doc/src/snippets/printing-qprinter/object.h53
-rw-r--r--doc/codesnippets/doc/src/snippets/printing-qprinter/printing-qprinter.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/process/process.cpp77
-rw-r--r--doc/codesnippets/doc/src/snippets/process/process.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/qabstractsliderisnippet.cpp510
-rw-r--r--doc/codesnippets/doc/src/snippets/qcalendarwidget/main.cpp65
-rw-r--r--doc/codesnippets/doc/src/snippets/qcalendarwidget/qcalendarwidget.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/qcolumnview/main.cpp80
-rw-r--r--doc/codesnippets/doc/src/snippets/qcolumnview/qcolumnview.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/qdbusextratypes/qdbusextratypes.cpp67
-rw-r--r--doc/codesnippets/doc/src/snippets/qdbusextratypes/qdbusextratypes.pro2
-rw-r--r--doc/codesnippets/doc/src/snippets/qdebug/qdebug.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/qdebug/qdebugsnippet.cpp74
-rw-r--r--doc/codesnippets/doc/src/snippets/qdir-filepaths/main.cpp55
-rw-r--r--doc/codesnippets/doc/src/snippets/qdir-filepaths/qdir-filepaths.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/qdir-listfiles/main.cpp55
-rw-r--r--doc/codesnippets/doc/src/snippets/qdir-listfiles/qdir-listfiles.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/qdir-namefilters/main.cpp66
-rw-r--r--doc/codesnippets/doc/src/snippets/qdir-namefilters/qdir-namefilters.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/qfontdatabase/main.cpp65
-rw-r--r--doc/codesnippets/doc/src/snippets/qfontdatabase/qfontdatabase.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/qgl-namespace/main.cpp47
-rw-r--r--doc/codesnippets/doc/src/snippets/qgl-namespace/qgl-namespace.pro2
-rw-r--r--doc/codesnippets/doc/src/snippets/qlabel/main.cpp89
-rw-r--r--doc/codesnippets/doc/src/snippets/qlabel/qlabel.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/qlineargradient/main.cpp51
-rw-r--r--doc/codesnippets/doc/src/snippets/qlineargradient/paintwidget.cpp68
-rw-r--r--doc/codesnippets/doc/src/snippets/qlineargradient/paintwidget.h60
-rw-r--r--doc/codesnippets/doc/src/snippets/qlineargradient/qlineargradient.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/qlistview-dnd/main.cpp52
-rw-r--r--doc/codesnippets/doc/src/snippets/qlistview-dnd/mainwindow.cpp84
-rw-r--r--doc/codesnippets/doc/src/snippets/qlistview-dnd/mainwindow.h62
-rw-r--r--doc/codesnippets/doc/src/snippets/qlistview-dnd/model.cpp168
-rw-r--r--doc/codesnippets/doc/src/snippets/qlistview-dnd/model.h74
-rw-r--r--doc/codesnippets/doc/src/snippets/qlistview-dnd/qlistview-dnd.pro5
-rw-r--r--doc/codesnippets/doc/src/snippets/qlistview-using/main.cpp52
-rw-r--r--doc/codesnippets/doc/src/snippets/qlistview-using/mainwindow.cpp138
-rw-r--r--doc/codesnippets/doc/src/snippets/qlistview-using/mainwindow.h73
-rw-r--r--doc/codesnippets/doc/src/snippets/qlistview-using/model.cpp175
-rw-r--r--doc/codesnippets/doc/src/snippets/qlistview-using/model.h83
-rw-r--r--doc/codesnippets/doc/src/snippets/qlistview-using/qlistview-using.pro5
-rw-r--r--doc/codesnippets/doc/src/snippets/qlistwidget-dnd/main.cpp52
-rw-r--r--doc/codesnippets/doc/src/snippets/qlistwidget-dnd/mainwindow.cpp88
-rw-r--r--doc/codesnippets/doc/src/snippets/qlistwidget-dnd/mainwindow.h63
-rw-r--r--doc/codesnippets/doc/src/snippets/qlistwidget-dnd/qlistwidget-dnd.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/qlistwidget-using/main.cpp52
-rw-r--r--doc/codesnippets/doc/src/snippets/qlistwidget-using/mainwindow.cpp159
-rw-r--r--doc/codesnippets/doc/src/snippets/qlistwidget-using/mainwindow.h73
-rw-r--r--doc/codesnippets/doc/src/snippets/qlistwidget-using/qlistwidget-using.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/qmacnativewidget/main.mm94
-rw-r--r--doc/codesnippets/doc/src/snippets/qmacnativewidget/qmacnativewidget.pro8
-rw-r--r--doc/codesnippets/doc/src/snippets/qmake/comments.pro10
-rw-r--r--doc/codesnippets/doc/src/snippets/qmake/configscopes.pro23
-rw-r--r--doc/codesnippets/doc/src/snippets/qmake/debug_and_release.pro14
-rw-r--r--doc/codesnippets/doc/src/snippets/qmake/delegate.h41
-rw-r--r--doc/codesnippets/doc/src/snippets/qmake/dereferencing.pro5
-rw-r--r--doc/codesnippets/doc/src/snippets/qmake/destdir.pro2
-rw-r--r--doc/codesnippets/doc/src/snippets/qmake/dirname.pro6
-rw-r--r--doc/codesnippets/doc/src/snippets/qmake/environment.pro9
-rw-r--r--doc/codesnippets/doc/src/snippets/qmake/functions.pro34
-rw-r--r--doc/codesnippets/doc/src/snippets/qmake/include.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/qmake/main.cpp41
-rw-r--r--doc/codesnippets/doc/src/snippets/qmake/model.cpp41
-rw-r--r--doc/codesnippets/doc/src/snippets/qmake/model.h41
-rw-r--r--doc/codesnippets/doc/src/snippets/qmake/other.pro0
-rw-r--r--doc/codesnippets/doc/src/snippets/qmake/paintwidget_unix.cpp45
-rw-r--r--doc/codesnippets/doc/src/snippets/qmake/project_location.pro6
-rw-r--r--doc/codesnippets/doc/src/snippets/qmake/qtconfiguration.pro19
-rw-r--r--doc/codesnippets/doc/src/snippets/qmake/quoting.pro8
-rw-r--r--doc/codesnippets/doc/src/snippets/qmake/replace.pro4
-rw-r--r--doc/codesnippets/doc/src/snippets/qmake/replacefunction.pro46
-rw-r--r--doc/codesnippets/doc/src/snippets/qmake/scopes.pro42
-rw-r--r--doc/codesnippets/doc/src/snippets/qmake/shared_or_static.pro8
-rw-r--r--doc/codesnippets/doc/src/snippets/qmake/specifications.pro7
-rw-r--r--doc/codesnippets/doc/src/snippets/qmake/testfunction.pro20
-rw-r--r--doc/codesnippets/doc/src/snippets/qmake/variables.pro7
-rw-r--r--doc/codesnippets/doc/src/snippets/qmake/view.h41
-rw-r--r--doc/codesnippets/doc/src/snippets/qmetaobject-invokable/main.cpp53
-rw-r--r--doc/codesnippets/doc/src/snippets/qmetaobject-invokable/qmetaobject-invokable.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/qmetaobject-invokable/window.cpp58
-rw-r--r--doc/codesnippets/doc/src/snippets/qmetaobject-invokable/window.h59
-rw-r--r--doc/codesnippets/doc/src/snippets/qprocess-environment/main.cpp61
-rw-r--r--doc/codesnippets/doc/src/snippets/qprocess-environment/qprocess-environment.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/qprocess/qprocess-simpleexecution.cpp67
-rw-r--r--doc/codesnippets/doc/src/snippets/qprocess/qprocess.pro11
-rw-r--r--doc/codesnippets/doc/src/snippets/qsignalmapper/buttonwidget.cpp68
-rw-r--r--doc/codesnippets/doc/src/snippets/qsignalmapper/buttonwidget.h61
-rw-r--r--doc/codesnippets/doc/src/snippets/qsignalmapper/main.cpp62
-rw-r--r--doc/codesnippets/doc/src/snippets/qsignalmapper/mainwindow.h60
-rw-r--r--doc/codesnippets/doc/src/snippets/qsignalmapper/qsignalmapper.pro10
-rw-r--r--doc/codesnippets/doc/src/snippets/qsortfilterproxymodel-details/main.cpp70
-rw-r--r--doc/codesnippets/doc/src/snippets/qsortfilterproxymodel-details/qsortfilterproxymodel-details.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/qsortfilterproxymodel/main.cpp78
-rw-r--r--doc/codesnippets/doc/src/snippets/qsortfilterproxymodel/qsortfilterproxymodel.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/qsplashscreen/main.cpp57
-rw-r--r--doc/codesnippets/doc/src/snippets/qsplashscreen/mainwindow.cpp51
-rw-r--r--doc/codesnippets/doc/src/snippets/qsplashscreen/mainwindow.h55
-rw-r--r--doc/codesnippets/doc/src/snippets/qsplashscreen/qsplashscreen.pro4
-rw-r--r--doc/codesnippets/doc/src/snippets/qsplashscreen/qsplashscreen.qrc5
-rw-r--r--doc/codesnippets/doc/src/snippets/qsplashscreen/splash.pngbin0 -> 27926 bytes
-rw-r--r--doc/codesnippets/doc/src/snippets/qsql-namespace/main.cpp47
-rw-r--r--doc/codesnippets/doc/src/snippets/qsql-namespace/qsql-namespace.pro2
-rw-r--r--doc/codesnippets/doc/src/snippets/qstack/main.cpp56
-rw-r--r--doc/codesnippets/doc/src/snippets/qstack/qstack.pro11
-rw-r--r--doc/codesnippets/doc/src/snippets/qstackedlayout/main.cpp90
-rw-r--r--doc/codesnippets/doc/src/snippets/qstackedlayout/qstackedlayout.pro11
-rw-r--r--doc/codesnippets/doc/src/snippets/qstackedwidget/main.cpp69
-rw-r--r--doc/codesnippets/doc/src/snippets/qstackedwidget/qstackedwidget.pro11
-rw-r--r--doc/codesnippets/doc/src/snippets/qstandarditemmodel/main.cpp72
-rw-r--r--doc/codesnippets/doc/src/snippets/qstandarditemmodel/qstandarditemmodel.pro11
-rw-r--r--doc/codesnippets/doc/src/snippets/qstatustipevent/main.cpp65
-rw-r--r--doc/codesnippets/doc/src/snippets/qstatustipevent/qstatustipevent.pro11
-rw-r--r--doc/codesnippets/doc/src/snippets/qstring/main.cpp917
-rw-r--r--doc/codesnippets/doc/src/snippets/qstring/qstring.pro11
-rw-r--r--doc/codesnippets/doc/src/snippets/qstringlist/main.cpp155
-rw-r--r--doc/codesnippets/doc/src/snippets/qstringlist/qstringlist.pro11
-rw-r--r--doc/codesnippets/doc/src/snippets/qstringlistmodel/main.cpp69
-rw-r--r--doc/codesnippets/doc/src/snippets/qstringlistmodel/qstringlistmodel.pro11
-rw-r--r--doc/codesnippets/doc/src/snippets/qstyleoption/main.cpp96
-rw-r--r--doc/codesnippets/doc/src/snippets/qstyleoption/qstyleoption.pro11
-rw-r--r--doc/codesnippets/doc/src/snippets/qstyleplugin/main.cpp98
-rw-r--r--doc/codesnippets/doc/src/snippets/qstyleplugin/qstyleplugin.pro11
-rw-r--r--doc/codesnippets/doc/src/snippets/qsvgwidget/main.cpp60
-rw-r--r--doc/codesnippets/doc/src/snippets/qsvgwidget/qsvgwidget.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/qsvgwidget/qsvgwidget.qrc5
-rw-r--r--doc/codesnippets/doc/src/snippets/qsvgwidget/spheres.svg79
-rw-r--r--doc/codesnippets/doc/src/snippets/qsvgwidget/sunflower.svg188
-rw-r--r--doc/codesnippets/doc/src/snippets/qt-namespace/main.cpp47
-rw-r--r--doc/codesnippets/doc/src/snippets/qt-namespace/qt-namespace.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/qtablewidget-dnd/Images/cubed.pngbin0 -> 437 bytes
-rw-r--r--doc/codesnippets/doc/src/snippets/qtablewidget-dnd/Images/squared.pngbin0 -> 440 bytes
-rw-r--r--doc/codesnippets/doc/src/snippets/qtablewidget-dnd/images.qrc6
-rw-r--r--doc/codesnippets/doc/src/snippets/qtablewidget-dnd/main.cpp52
-rw-r--r--doc/codesnippets/doc/src/snippets/qtablewidget-dnd/mainwindow.cpp144
-rw-r--r--doc/codesnippets/doc/src/snippets/qtablewidget-dnd/mainwindow.h69
-rw-r--r--doc/codesnippets/doc/src/snippets/qtablewidget-dnd/qtablewidget-dnd.pro4
-rw-r--r--doc/codesnippets/doc/src/snippets/qtablewidget-resizing/main.cpp52
-rw-r--r--doc/codesnippets/doc/src/snippets/qtablewidget-resizing/mainwindow.cpp115
-rw-r--r--doc/codesnippets/doc/src/snippets/qtablewidget-resizing/mainwindow.h68
-rw-r--r--doc/codesnippets/doc/src/snippets/qtablewidget-resizing/qtablewidget-resizing.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/qtablewidget-using/Images/cubed.pngbin0 -> 437 bytes
-rw-r--r--doc/codesnippets/doc/src/snippets/qtablewidget-using/Images/squared.pngbin0 -> 440 bytes
-rw-r--r--doc/codesnippets/doc/src/snippets/qtablewidget-using/images.qrc6
-rw-r--r--doc/codesnippets/doc/src/snippets/qtablewidget-using/main.cpp52
-rw-r--r--doc/codesnippets/doc/src/snippets/qtablewidget-using/mainwindow.cpp150
-rw-r--r--doc/codesnippets/doc/src/snippets/qtablewidget-using/mainwindow.h71
-rw-r--r--doc/codesnippets/doc/src/snippets/qtablewidget-using/qtablewidget-using.pro4
-rw-r--r--doc/codesnippets/doc/src/snippets/qtcast/qtcast.cpp80
-rw-r--r--doc/codesnippets/doc/src/snippets/qtcast/qtcast.h55
-rw-r--r--doc/codesnippets/doc/src/snippets/qtcast/qtcast.pro2
-rw-r--r--doc/codesnippets/doc/src/snippets/qtest-namespace/main.cpp48
-rw-r--r--doc/codesnippets/doc/src/snippets/qtest-namespace/qtest-namespace.pro2
-rw-r--r--doc/codesnippets/doc/src/snippets/qtreeview-dnd/dragdropmodel.cpp147
-rw-r--r--doc/codesnippets/doc/src/snippets/qtreeview-dnd/dragdropmodel.h73
-rw-r--r--doc/codesnippets/doc/src/snippets/qtreeview-dnd/main.cpp52
-rw-r--r--doc/codesnippets/doc/src/snippets/qtreeview-dnd/mainwindow.cpp91
-rw-r--r--doc/codesnippets/doc/src/snippets/qtreeview-dnd/mainwindow.h62
-rw-r--r--doc/codesnippets/doc/src/snippets/qtreeview-dnd/qtreeview-dnd.pro9
-rw-r--r--doc/codesnippets/doc/src/snippets/qtreeview-dnd/treeitem.cpp126
-rw-r--r--doc/codesnippets/doc/src/snippets/qtreeview-dnd/treeitem.h72
-rw-r--r--doc/codesnippets/doc/src/snippets/qtreeview-dnd/treemodel.cpp263
-rw-r--r--doc/codesnippets/doc/src/snippets/qtreeview-dnd/treemodel.h80
-rw-r--r--doc/codesnippets/doc/src/snippets/qtreewidget-using/main.cpp52
-rw-r--r--doc/codesnippets/doc/src/snippets/qtreewidget-using/mainwindow.cpp102
-rw-r--r--doc/codesnippets/doc/src/snippets/qtreewidget-using/mainwindow.h78
-rw-r--r--doc/codesnippets/doc/src/snippets/qtreewidget-using/qtreewidget-using.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/main.cpp52
-rw-r--r--doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/mainwindow.cpp50
-rw-r--r--doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/mainwindow.h78
-rw-r--r--doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/qtreewidgetitemiterator-using.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/qtscript/evaluation/evaluation.pro2
-rw-r--r--doc/codesnippets/doc/src/snippets/qtscript/evaluation/main.cpp51
-rw-r--r--doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/main.cpp57
-rw-r--r--doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/myobject.cpp54
-rw-r--r--doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/myobject.h58
-rw-r--r--doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/registeringobjects.pro4
-rw-r--r--doc/codesnippets/doc/src/snippets/qtscript/registeringvalues/main.cpp53
-rw-r--r--doc/codesnippets/doc/src/snippets/qtscript/registeringvalues/registeringvalues.pro2
-rw-r--r--doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/main.cpp73
-rw-r--r--doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/object.js18
-rw-r--r--doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/scriptedslot.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/scriptedslot.qrc5
-rw-r--r--doc/codesnippets/doc/src/snippets/quiloader/main.cpp68
-rw-r--r--doc/codesnippets/doc/src/snippets/quiloader/myform.ui130
-rw-r--r--doc/codesnippets/doc/src/snippets/quiloader/mywidget.cpp59
-rw-r--r--doc/codesnippets/doc/src/snippets/quiloader/mywidget.h53
-rw-r--r--doc/codesnippets/doc/src/snippets/quiloader/mywidget.qrc5
-rw-r--r--doc/codesnippets/doc/src/snippets/quiloader/quiloader.pro4
-rw-r--r--doc/codesnippets/doc/src/snippets/qx11embedcontainer/main.cpp68
-rw-r--r--doc/codesnippets/doc/src/snippets/qx11embedcontainer/qx11embedcontainer.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/qx11embedwidget/embedwidget.cpp67
-rw-r--r--doc/codesnippets/doc/src/snippets/qx11embedwidget/embedwidget.h66
-rw-r--r--doc/codesnippets/doc/src/snippets/qx11embedwidget/main.cpp62
-rw-r--r--doc/codesnippets/doc/src/snippets/qx11embedwidget/qx11embedwidget.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/qxmlquery/bindingExample.cpp9
-rw-r--r--doc/codesnippets/doc/src/snippets/qxmlstreamwriter/main.cpp77
-rw-r--r--doc/codesnippets/doc/src/snippets/qxmlstreamwriter/qxmlstreamwriter.pro2
-rw-r--r--doc/codesnippets/doc/src/snippets/reading-selections/main.cpp60
-rw-r--r--doc/codesnippets/doc/src/snippets/reading-selections/model.cpp239
-rw-r--r--doc/codesnippets/doc/src/snippets/reading-selections/model.h75
-rw-r--r--doc/codesnippets/doc/src/snippets/reading-selections/reading-selections.pro2
-rw-r--r--doc/codesnippets/doc/src/snippets/reading-selections/window.cpp121
-rw-r--r--doc/codesnippets/doc/src/snippets/reading-selections/window.h68
-rw-r--r--doc/codesnippets/doc/src/snippets/scribe-overview/main.cpp72
-rw-r--r--doc/codesnippets/doc/src/snippets/scribe-overview/scribe-overview.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/scriptdebugger.cpp64
-rw-r--r--doc/codesnippets/doc/src/snippets/seekslider.cpp26
-rw-r--r--doc/codesnippets/doc/src/snippets/separations/finalwidget.cpp127
-rw-r--r--doc/codesnippets/doc/src/snippets/separations/finalwidget.h78
-rw-r--r--doc/codesnippets/doc/src/snippets/separations/main.cpp51
-rw-r--r--doc/codesnippets/doc/src/snippets/separations/screenwidget.cpp218
-rw-r--r--doc/codesnippets/doc/src/snippets/separations/screenwidget.h87
-rw-r--r--doc/codesnippets/doc/src/snippets/separations/separations.pro7
-rw-r--r--doc/codesnippets/doc/src/snippets/separations/separations.qdoc55
-rw-r--r--doc/codesnippets/doc/src/snippets/separations/viewer.cpp329
-rw-r--r--doc/codesnippets/doc/src/snippets/separations/viewer.h90
-rw-r--r--doc/codesnippets/doc/src/snippets/settings/settings.cpp179
-rw-r--r--doc/codesnippets/doc/src/snippets/shareddirmodel/main.cpp80
-rw-r--r--doc/codesnippets/doc/src/snippets/shareddirmodel/shareddirmodel.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/sharedemployee/employee.cpp42
-rw-r--r--doc/codesnippets/doc/src/snippets/sharedemployee/employee.h95
-rw-r--r--doc/codesnippets/doc/src/snippets/sharedemployee/main.cpp51
-rw-r--r--doc/codesnippets/doc/src/snippets/sharedemployee/sharedemployee.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/sharedtablemodel/main.cpp90
-rw-r--r--doc/codesnippets/doc/src/snippets/sharedtablemodel/model.cpp237
-rw-r--r--doc/codesnippets/doc/src/snippets/sharedtablemodel/model.h75
-rw-r--r--doc/codesnippets/doc/src/snippets/sharedtablemodel/sharedtablemodel.pro2
-rw-r--r--doc/codesnippets/doc/src/snippets/signalmapper/accountsfile.txt1
-rw-r--r--doc/codesnippets/doc/src/snippets/signalmapper/filereader.cpp59
-rw-r--r--doc/codesnippets/doc/src/snippets/signalmapper/filereader.h28
-rw-r--r--doc/codesnippets/doc/src/snippets/signalmapper/main.cpp13
-rw-r--r--doc/codesnippets/doc/src/snippets/signalmapper/reportfile.txt2
-rw-r--r--doc/codesnippets/doc/src/snippets/signalmapper/signalmapper.pro12
-rw-r--r--doc/codesnippets/doc/src/snippets/signalmapper/taxfile.txt1
-rw-r--r--doc/codesnippets/doc/src/snippets/signalsandslots/lcdnumber.cpp78
-rw-r--r--doc/codesnippets/doc/src/snippets/signalsandslots/lcdnumber.h89
-rw-r--r--doc/codesnippets/doc/src/snippets/signalsandslots/signalsandslots.cpp85
-rw-r--r--doc/codesnippets/doc/src/snippets/signalsandslots/signalsandslots.h90
-rw-r--r--doc/codesnippets/doc/src/snippets/simplemodel-use/main.cpp96
-rw-r--r--doc/codesnippets/doc/src/snippets/simplemodel-use/simplemodel-use.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/snippets.pro109
-rw-r--r--doc/codesnippets/doc/src/snippets/splitter/splitter.cpp67
-rw-r--r--doc/codesnippets/doc/src/snippets/splitter/splitter.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/splitterhandle/main.cpp58
-rw-r--r--doc/codesnippets/doc/src/snippets/splitterhandle/splitter.cpp79
-rw-r--r--doc/codesnippets/doc/src/snippets/splitterhandle/splitter.h52
-rw-r--r--doc/codesnippets/doc/src/snippets/splitterhandle/splitterhandle.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/sqldatabase/sqldatabase.cpp480
-rw-r--r--doc/codesnippets/doc/src/snippets/sqldatabase/sqldatabase.pro2
-rw-r--r--doc/codesnippets/doc/src/snippets/streaming/main.cpp109
-rw-r--r--doc/codesnippets/doc/src/snippets/streaming/streaming.pro2
-rw-r--r--doc/codesnippets/doc/src/snippets/stringlistmodel/main.cpp84
-rw-r--r--doc/codesnippets/doc/src/snippets/stringlistmodel/model.cpp182
-rw-r--r--doc/codesnippets/doc/src/snippets/stringlistmodel/model.h83
-rw-r--r--doc/codesnippets/doc/src/snippets/stringlistmodel/stringlistmodel.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/styles/styles.cpp71
-rw-r--r--doc/codesnippets/doc/src/snippets/stylesheet/common-mistakes.cpp12
-rw-r--r--doc/codesnippets/doc/src/snippets/textblock-formats/main.cpp119
-rw-r--r--doc/codesnippets/doc/src/snippets/textblock-formats/textblock-formats.pro2
-rw-r--r--doc/codesnippets/doc/src/snippets/textblock-fragments/main.cpp53
-rw-r--r--doc/codesnippets/doc/src/snippets/textblock-fragments/mainwindow.cpp149
-rw-r--r--doc/codesnippets/doc/src/snippets/textblock-fragments/mainwindow.h66
-rw-r--r--doc/codesnippets/doc/src/snippets/textblock-fragments/textblock-fragments.pro6
-rw-r--r--doc/codesnippets/doc/src/snippets/textblock-fragments/xmlwriter.cpp119
-rw-r--r--doc/codesnippets/doc/src/snippets/textblock-fragments/xmlwriter.h65
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-blocks/main.cpp53
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-blocks/mainwindow.cpp157
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-blocks/mainwindow.h66
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-blocks/textdocument-blocks.pro6
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-blocks/xmlwriter.cpp85
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-blocks/xmlwriter.h62
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-charformats/main.cpp93
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-charformats/textdocument-charformats.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-css/main.cpp49
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-css/textdocument-css.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-cursors/main.cpp80
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-cursors/textdocument-cursors.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-find/main.cpp92
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-find/textdocument-find.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-frames/main.cpp54
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-frames/mainwindow.cpp162
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-frames/mainwindow.h65
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-frames/textdocument-frames.pro6
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-frames/xmlwriter.cpp117
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-frames/xmlwriter.h65
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-imagedrop/main.cpp53
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-imagedrop/textdocument-imagedrop.pro2
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-imagedrop/textedit.cpp72
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-imagedrop/textedit.h57
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-imageformat/images.qrc6
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-imageformat/images/advert.pngbin0 -> 16291 bytes
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-imageformat/images/newimage.pngbin0 -> 5490 bytes
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-imageformat/main.cpp99
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-imageformat/textdocument-imageformat.pro2
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-images/images.qrc5
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-images/images/advert.pngbin0 -> 16291 bytes
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-images/main.cpp73
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-images/textdocument-images.pro2
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-listitems/main.cpp53
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-listitems/mainwindow.cpp198
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-listitems/mainwindow.h76
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-listitems/textdocument-listitems.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-lists/main.cpp53
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-lists/mainwindow.cpp192
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-lists/mainwindow.h80
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-lists/textdocument-lists.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-printing/main.cpp53
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-printing/mainwindow.cpp125
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-printing/mainwindow.h73
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-printing/textdocument-printing.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-selections/main.cpp53
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-selections/mainwindow.cpp204
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-selections/mainwindow.h80
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-selections/textdocument-selections.pro4
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-tables/main.cpp53
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-tables/mainwindow.cpp116
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-tables/mainwindow.h66
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-tables/textdocument-tables.pro6
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-tables/xmlwriter.cpp154
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-tables/xmlwriter.h65
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocument-texttable/main.cpp47
-rw-r--r--doc/codesnippets/doc/src/snippets/textdocumentendsnippet.cpp59
-rw-r--r--doc/codesnippets/doc/src/snippets/threads/threads.cpp121
-rw-r--r--doc/codesnippets/doc/src/snippets/threads/threads.h52
-rw-r--r--doc/codesnippets/doc/src/snippets/timeline/main.cpp73
-rw-r--r--doc/codesnippets/doc/src/snippets/timeline/timeline.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/timers/timers.cpp79
-rw-r--r--doc/codesnippets/doc/src/snippets/timers/timers.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/transform/main.cpp101
-rw-r--r--doc/codesnippets/doc/src/snippets/transform/transform.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/uitools/calculatorform/calculatorform.pro5
-rw-r--r--doc/codesnippets/doc/src/snippets/uitools/calculatorform/calculatorform.ui303
-rw-r--r--doc/codesnippets/doc/src/snippets/uitools/calculatorform/main.cpp58
-rw-r--r--doc/codesnippets/doc/src/snippets/updating-selections/main.cpp60
-rw-r--r--doc/codesnippets/doc/src/snippets/updating-selections/model.cpp237
-rw-r--r--doc/codesnippets/doc/src/snippets/updating-selections/model.h75
-rw-r--r--doc/codesnippets/doc/src/snippets/updating-selections/updating-selections.pro2
-rw-r--r--doc/codesnippets/doc/src/snippets/updating-selections/window.cpp110
-rw-r--r--doc/codesnippets/doc/src/snippets/updating-selections/window.h68
-rw-r--r--doc/codesnippets/doc/src/snippets/videomedia.cpp19
-rw-r--r--doc/codesnippets/doc/src/snippets/volumeslider.cpp29
-rw-r--r--doc/codesnippets/doc/src/snippets/webkit/webpage/main.cpp44
-rw-r--r--doc/codesnippets/doc/src/snippets/whatsthis/whatsthis.cpp48
-rw-r--r--doc/codesnippets/doc/src/snippets/whatsthis/whatsthis.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/widget-mask/main.cpp55
-rw-r--r--doc/codesnippets/doc/src/snippets/widget-mask/mask.qrc5
-rw-r--r--doc/codesnippets/doc/src/snippets/widget-mask/tux.pngbin0 -> 12191 bytes
-rw-r--r--doc/codesnippets/doc/src/snippets/widget-mask/widget-mask.pro3
-rw-r--r--doc/codesnippets/doc/src/snippets/widgetdelegate.cpp23
-rw-r--r--doc/codesnippets/doc/src/snippets/widgets-tutorial/childwidget/childwidget.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/widgets-tutorial/childwidget/main.cpp17
-rw-r--r--doc/codesnippets/doc/src/snippets/widgets-tutorial/nestedlayouts/main.cpp48
-rw-r--r--doc/codesnippets/doc/src/snippets/widgets-tutorial/nestedlayouts/nestedlayouts.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/widgets-tutorial/toplevel/main.cpp13
-rw-r--r--doc/codesnippets/doc/src/snippets/widgets-tutorial/toplevel/toplevel.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/widgets-tutorial/windowlayout/main.cpp19
-rw-r--r--doc/codesnippets/doc/src/snippets/widgets-tutorial/windowlayout/windowlayout.pro1
-rw-r--r--doc/codesnippets/doc/src/snippets/xml/prettyprint/main.cpp144
-rw-r--r--doc/codesnippets/doc/src/snippets/xml/prettyprint/prettyprint.pro4
-rw-r--r--doc/codesnippets/doc/src/snippets/xml/rsslisting/handler.cpp179
-rw-r--r--doc/codesnippets/doc/src/snippets/xml/rsslisting/handler.h75
-rw-r--r--doc/codesnippets/doc/src/snippets/xml/rsslisting/main.cpp64
-rw-r--r--doc/codesnippets/doc/src/snippets/xml/rsslisting/rsslisting.cpp246
-rw-r--r--doc/codesnippets/doc/src/snippets/xml/rsslisting/rsslisting.h87
-rw-r--r--doc/codesnippets/doc/src/snippets/xml/simpleparse/handler.cpp139
-rw-r--r--doc/codesnippets/doc/src/snippets/xml/simpleparse/handler.h68
-rw-r--r--doc/codesnippets/doc/src/snippets/xml/simpleparse/main.cpp88
-rw-r--r--doc/codesnippets/doc/src/snippets/xml/simpleparse/simpleparse.pro4
-rw-r--r--doc/codesnippets/doc/src/snippets/xml/xml.pro8
-rw-r--r--doc/codesnippets/examples/dialogs/classwizard/classwizard.cpp250
-rw-r--r--doc/codesnippets/examples/dialogs/classwizard/classwizard.qrc11
-rw-r--r--doc/codesnippets/examples/dialogs/classwizard/images/background.pngbin0 -> 22578 bytes
-rw-r--r--doc/codesnippets/examples/dialogs/classwizard/images/banner.pngbin0 -> 3947 bytes
-rw-r--r--doc/codesnippets/examples/dialogs/classwizard/images/logo1.pngbin0 -> 1619 bytes
-rw-r--r--doc/codesnippets/examples/dialogs/classwizard/images/logo2.pngbin0 -> 1619 bytes
-rw-r--r--doc/codesnippets/examples/dialogs/classwizard/images/logo3.pngbin0 -> 1619 bytes
-rw-r--r--doc/codesnippets/examples/dialogs/classwizard/images/watermark1.pngbin0 -> 14516 bytes
-rw-r--r--doc/codesnippets/examples/dialogs/classwizard/images/watermark2.pngbin0 -> 14912 bytes
-rw-r--r--doc/codesnippets/examples/dialogs/classwizard/main.cpp64
-rw-r--r--doc/codesnippets/examples/dialogs/extension/finddialog.cpp110
-rw-r--r--doc/codesnippets/examples/dialogs/licensewizard/images/logo.pngbin0 -> 1810 bytes
-rw-r--r--doc/codesnippets/examples/dialogs/licensewizard/images/watermark.pngbin0 -> 34998 bytes
-rw-r--r--doc/codesnippets/examples/dialogs/licensewizard/licensewizard.cpp349
-rw-r--r--doc/codesnippets/examples/dialogs/licensewizard/licensewizard.h164
-rw-r--r--doc/codesnippets/examples/dialogs/licensewizard/licensewizard.pro10
-rw-r--r--doc/codesnippets/examples/dialogs/licensewizard/licensewizard.qrc6
-rw-r--r--doc/codesnippets/examples/dialogs/licensewizard/main.cpp64
-rw-r--r--doc/codesnippets/examples/dialogs/standarddialogs/dialog.cpp71
-rw-r--r--doc/codesnippets/examples/dialogs/trivialwizard/trivialwizard.cpp134
-rw-r--r--doc/codesnippets/examples/dialogs/trivialwizard/trivialwizard.pro7
-rw-r--r--doc/codesnippets/examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp102
-rw-r--r--doc/codesnippets/examples/itemviews/pixelator/pixeldelegate.cpp94
-rw-r--r--doc/codesnippets/examples/itemviews/simpledommodel/dommodel.cpp188
-rw-r--r--doc/codesnippets/examples/linguist/hellotr/main.cpp69
-rw-r--r--doc/codesnippets/examples/mainwindows/application/mainwindow.cpp350
-rw-r--r--doc/codesnippets/examples/mainwindows/dockwidgets/mainwindow.cpp246
-rw-r--r--doc/codesnippets/examples/mainwindows/mainwindow.cpp358
-rw-r--r--doc/codesnippets/examples/mainwindows/mdi/mainwindow.cpp372
-rw-r--r--doc/codesnippets/examples/mainwindows/menus/mainwindow.cpp358
-rw-r--r--doc/codesnippets/examples/painting/svggenerator/window.cpp98
-rw-r--r--doc/codesnippets/examples/richtext/textobject/svgtextobject.h70
-rw-r--r--doc/codesnippets/examples/sql/querymodel/editablesqlmodel.cpp103
-rw-r--r--doc/codesnippets/examples/sql/relationaltablemodel/relationaltablemodel.cpp111
-rw-r--r--doc/codesnippets/examples/widgets/analogclock/analogclock.cpp146
-rw-r--r--doc/codesnippets/examples/widgets/icons/iconsizespinbox.cpp63
-rw-r--r--doc/codesnippets/examples/widgets/spinboxes/window.cpp240
-rw-r--r--doc/codesnippets/examples/xml/streambookmarks/xbelreader.cpp201
-rw-r--r--doc/codesnippets/examples/xml/streambookmarks/xbelreader.h81
-rw-r--r--doc/codesnippets/examples/xml/streambookmarks/xbelwriter.cpp91
-rw-r--r--doc/codesnippets/snippets/textdocument-resources/main.cpp84
-rw-r--r--doc/codesnippets/snippets/textdocument-resources/textdocument-resources.pro1
-rw-r--r--doc/conf.py166
-rw-r--r--doc/contents.rst20
-rw-r--r--doc/dbus.rst30
-rw-r--r--doc/generatingdocs.rst56
-rw-r--r--doc/howto-build/cmake-primer.rst72
-rw-r--r--doc/howto-build/index.rst19
-rw-r--r--doc/howto-build/setup-apiextractor.rst49
-rw-r--r--doc/howto-build/setup-bindings.rst76
-rw-r--r--doc/howto-build/setup-boostpython.rst51
-rw-r--r--doc/howto-build/setup-generator.rst50
-rw-r--r--doc/inheritance_diagram.py369
-rw-r--r--doc/issuesdiff.rst26
-rw-r--r--doc/modules.rst19
-rw-r--r--doc/pyhtml2devhelp.py225
-rw-r--r--doc/pyside.qdocconf11
1107 files changed, 70654 insertions, 0 deletions
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
new file mode 100644
index 000000000..0e8851b7c
--- /dev/null
+++ b/doc/CMakeLists.txt
@@ -0,0 +1,82 @@
+find_program(graphviz_exec dot)
+
+if (QT_SRC_DIR)
+
+if (NOT ${graphviz_exec} STREQUAL graphviz_exec-NOTFOUND)
+add_custom_target(apidoc
+ #temporarily create a symlink for the generated .rst files inside ../doc
+ #this allows Sphinx to see them, and output goes to the correct dir
+ COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_BINARY_DIR}/PySide" "${CMAKE_CURRENT_SOURCE_DIR}/PySide"
+ COMMAND make html BUILDDIR=${CMAKE_BINARY_DIR}/apidoc WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMAND ${CMAKE_COMMAND} -E remove -f "${CMAKE_CURRENT_SOURCE_DIR}/PySide")
+
+
+# copy pyside.qdocconf to qt source dir.
+configure_file("pyside.qdocconf" "${QT_SRC_DIR}/tools/qdoc3/test/pyside.qdocconf" @ONLY)
+set(DOC_DATA_DIR "${CMAKE_CURRENT_BINARY_DIR}/qt4xmldoc")
+set(ENV{QTDIR} ${QT_SRC_DIR} )
+
+add_custom_target(qdoc3
+ COMMAND QTDIR=${QT_SRC_DIR} qdoc3 pyside.qdocconf
+ WORKING_DIRECTORY "${QT_SRC_DIR}/tools/qdoc3/test"
+ COMMENT "Running qdoc3 against Qt source code..."
+ SOURCE "pyside.qdocconf")
+
+macro(create_doc module typesystem_path)
+string(REGEX REPLACE "^Qt" "" module_name ${module})
+string(TOLOWER ${module_name} module_name)
+add_custom_target("${module}-apidoc"
+COMMAND ${GENERATOR} --generatorSet=qtdoc
+ ${pyside_SOURCE_DIR}/global.h
+ --include-paths=${QT_INCLUDE_DIR}:${QT_QTCORE_INCLUDE_DIR}
+ --typesystem-paths=${pyside_SOURCE_DIR}:${${module}_BINARY_DIR}:${typesystem_path}
+ ${pyside_SOURCE_DIR}/${module}/typesystem_${module_name}.xml
+ --library-source-dir=${QT_SRC_DIR}
+ --documentation-only
+ --documentation-data-dir=${DOC_DATA_DIR}
+ --documentation-out-dir=${CMAKE_BINARY_DIR}
+ --documentation-code-snippets-dir=${CMAKE_CURRENT_SOURCE_DIR}/codesnippets
+WORKING_DIRECTORY ${${module}_SOURCE_DIR}
+
+COMMENT "Running generator to generate documentation of ${module}..."
+)
+add_dependencies("${module}-apidoc" qdoc3)
+add_dependencies(apidoc "${module}-apidoc")
+endmacro(create_doc module)
+
+create_doc(QtCore "")
+create_doc(QtGui "${QtCore_SOURCE_DIR}")
+create_doc(QtHelp "${QtCore_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtGui_SOURCE_DIR}:${QtHelp_SOURCE_DIR}")
+create_doc(QtNetwork "${QtCore_SOURCE_DIR}")
+create_doc(QtOpengl "${QtCore_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtGui_SOURCE_DIR}:${QtOpenGL_SOURCE_DIR}")
+create_doc(QtSql "${QtCore_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtGui_SOURCE_DIR}:${QtSql_SOURCE_DIR}")
+create_doc(QtSvg "${QtCore_SOURCE_DIR}:${QtGui_SOURCE_DIR}:${QtGui_BINARY_DIR}")
+create_doc(QtUitools "${QtCore_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtGui_SOURCE_DIR}:${QtXml_SOURCE_DIR}:${QtUiTools_SOURCE_DIR}")
+create_doc(QtXml "${QtCore_SOURCE_DIR}")
+create_doc(QtWebKit "${QtCore_SOURCE_DIR}:${QtGui_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtNetwork_SOURCE_DIR}")
+create_doc(QtMultimedia "${QtCore_SOURCE_DIR}:${QtGui_SOURCE_DIR}:${QtGui_BINARY_DIR}")
+
+#create devhelp file
+add_custom_target(apidevhelp
+ COMMAND python;${CMAKE_CURRENT_SOURCE_DIR}/pyhtml2devhelp.py;${CMAKE_BINARY_DIR}/apidoc/html;index.html >
+ ${CMAKE_BINARY_DIR}/apidoc/html/PySide.devhelp;${BINDING_API_VERSION}&&;
+ gzip;-9v;-f;${CMAKE_BINARY_DIR}/apidoc/html/PySide.devhelp
+ COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_INSTALL_PREFIX}/share/devhelp/books"
+ COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_INSTALL_PREFIX}/share/doc/${BINDING_NAME}/html" "${CMAKE_INSTALL_PREFIX}/share/devhelp/books/${BINDING_NAME}"
+)
+
+#install files
+add_custom_target(apidocinstall
+ COMMAND mkdir -p ${CMAKE_INSTALL_PREFIX}/share/doc/${BINDING_NAME} && cp -rv ${CMAKE_BINARY_DIR}/apidoc/* ${CMAKE_INSTALL_PREFIX}/share/doc/${BINDING_NAME}
+)
+
+add_dependencies(apidocinstall apidevhelp)
+
+else (NOT ${graphviz_exec} STREQUAL graphviz_exec-NOTFOUND)
+ message(STATUS "Missing graphviz tool (dot), apidoc generation targets disabled.")
+endif (NOT ${graphviz_exec} STREQUAL graphviz_exec-NOTFOUND)
+
+else (QT_SRC_DIR)
+ message(STATUS "QT_SRC_DIR variable not set, apidoc generation targets disabled.")
+endif (QT_SRC_DIR)
+
diff --git a/doc/Makefile b/doc/Makefile
new file mode 100644
index 000000000..32a7c0db4
--- /dev/null
+++ b/doc/Makefile
@@ -0,0 +1,89 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS =
+SPHINXBUILD = sphinx-build
+PAPER =
+BUILDDIR = _build
+
+# Internal variables.
+PAPEROPT_a4 = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
+
+help:
+ @echo "Please use \`make <target>' where <target> is one of"
+ @echo " html to make standalone HTML files"
+ @echo " dirhtml to make HTML files named index.html in directories"
+ @echo " pickle to make pickle files"
+ @echo " json to make JSON files"
+ @echo " htmlhelp to make HTML files and a HTML help project"
+ @echo " qthelp to make HTML files and a qthelp project"
+ @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+ @echo " changes to make an overview of all changed/added/deprecated items"
+ @echo " linkcheck to check all external links for integrity"
+ @echo " doctest to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+ -rm -rf $(BUILDDIR)/*
+
+html:
+ $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+ $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+pickle:
+ $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+ @echo
+ @echo "Build finished; now you can process the pickle files."
+
+json:
+ $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+ @echo
+ @echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+ $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+ @echo
+ @echo "Build finished; now you can run HTML Help Workshop with the" \
+ ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+ $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+ @echo
+ @echo "Build finished; now you can run "qcollectiongenerator" with the" \
+ ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+ @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/PySide.qhcp"
+ @echo "To view the help file:"
+ @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/PySide.qhc"
+
+latex:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo
+ @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+ @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
+ "run these through (pdf)latex."
+
+changes:
+ $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+ @echo
+ @echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+ $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+ @echo
+ @echo "Link check complete; look for any errors in the above output " \
+ "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+ $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+ @echo "Testing of doctests in the sources finished, look at the " \
+ "results in $(BUILDDIR)/doctest/output.txt."
diff --git a/doc/_static/.gitignore b/doc/_static/.gitignore
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/doc/_static/.gitignore
diff --git a/doc/_static/basic.css b/doc/_static/basic.css
new file mode 100644
index 000000000..2509c227f
--- /dev/null
+++ b/doc/_static/basic.css
@@ -0,0 +1,417 @@
+/**
+ * Sphinx stylesheet -- basic theme
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+/* -- main layout ----------------------------------------------------------- */
+
+div.documentwrapper {
+ float: left;
+ width: 100%;
+}
+
+div.bodywrapper {
+ margin: 0 0 0 230px;
+}
+
+div.clearer {
+ clear: both;
+}
+
+/* -- relbar ---------------------------------------------------------------- */
+
+div.related {
+ width: 100%;
+ font-size: 90%;
+}
+
+div.related h3 {
+ display: none;
+}
+
+div.related ul {
+ margin: 0;
+ padding: 0 0 0 0px;
+ list-style: none;
+}
+
+div.related li {
+ float: left;
+ display: inline;
+ padding-right:17px;
+ padding-left:10px;
+ background-image:url(images/bread_crumb.png);
+ background-position:right;
+ background-repeat:no-repeat;
+}
+
+div.related li.right {
+ float: right;
+ margin-right: 5px;
+ padding: 0 0 0 0px;
+ background-image:none;
+}
+
+/* -- sidebar --------------------------------------------------------------- */
+
+div.sphinxsidebarwrapper {
+ padding: 10px 5px 0 10px;
+}
+
+div.sphinxsidebar {
+ float: left;
+ width: 230px;
+ margin-left: -100%;
+ font-size: 90%;
+}
+
+div.sphinxsidebar ul {
+ list-style: none;
+}
+
+div.sphinxsidebar ul ul,
+div.sphinxsidebar ul.want-points {
+ margin-left: 20px;
+ list-style: square;
+}
+
+div.sphinxsidebar ul ul {
+ margin-top: 0;
+ margin-bottom: 0;
+}
+
+div.sphinxsidebar form {
+ margin-top: 10px;
+}
+
+img {
+ border: 0;
+}
+
+/* -- search page ----------------------------------------------------------- */
+
+ul.search {
+ margin: 10px 0 0 20px;
+ padding: 0;
+}
+
+ul.search li {
+ padding: 5px 0 5px 20px;
+ background-image: url(file.png);
+ background-repeat: no-repeat;
+ background-position: 0 7px;
+}
+
+ul.search li a {
+ font-weight: bold;
+}
+
+ul.search li div.context {
+ color: #888;
+ margin: 2px 0 0 30px;
+ text-align: left;
+}
+
+ul.keywordmatches li.goodmatch a {
+ font-weight: bold;
+}
+
+/* -- index page ------------------------------------------------------------ */
+
+table.contentstable {
+ text-align: left;
+ width: 90%;
+}
+
+table.contentstable p.biglink {
+ line-height: 150%;
+}
+
+a.biglink {
+ font-size: 1.3em;
+}
+
+span.linkdescr {
+ text-align: left;
+ padding-top: 5px;
+ font-size: 90%;
+}
+
+/* -- general index --------------------------------------------------------- */
+
+table.indextable td {
+ text-align: left;
+ vertical-align: top;
+}
+
+table.indextable dl, table.indextable dd {
+ margin-top: 0;
+ margin-bottom: 0;
+}
+
+table.indextable tr.pcap {
+ height: 10px;
+}
+
+table.indextable tr.cap {
+ margin-top: 10px;
+ background-color: #f2f2f2;
+}
+
+img.toggler {
+ margin-right: 3px;
+ margin-top: 3px;
+ cursor: pointer;
+}
+
+/* -- general body styles --------------------------------------------------- */
+
+a.headerlink {
+ visibility: hidden;
+}
+
+h1:hover > a.headerlink,
+h2:hover > a.headerlink,
+h3:hover > a.headerlink,
+h4:hover > a.headerlink,
+h5:hover > a.headerlink,
+h6:hover > a.headerlink,
+dt:hover > a.headerlink {
+ visibility: visible;
+}
+
+div.body p.caption {
+ text-align: inherit;
+}
+
+div.body td {
+ text-align: left;
+}
+
+.field-list ul {
+ padding-left: 1em;
+}
+
+.first {
+ margin-top: 0 !important;
+}
+
+p.rubric {
+ margin-top: 30px;
+ font-weight: bold;
+}
+
+/* -- sidebars -------------------------------------------------------------- */
+
+div.sidebar {
+ margin: 0 0 0.5em 1em;
+ border: 1px solid #ddb;
+ padding: 7px 7px 0 7px;
+ background-color: #ffe;
+ width: 40%;
+ float: right;
+}
+
+p.sidebar-title {
+ font-weight: bold;
+}
+
+/* -- topics ---------------------------------------------------------------- */
+
+div.topic {
+ border: 1px solid #ccc;
+ padding: 7px 7px 0 7px;
+ margin: 10px 0 10px 0;
+}
+
+p.topic-title {
+ font-size: 1.1em;
+ font-weight: bold;
+ margin-top: 10px;
+}
+
+/* -- admonitions ----------------------------------------------------------- */
+
+div.admonition {
+ margin-top: 10px;
+ margin-bottom: 10px;
+ padding: 7px;
+}
+
+div.admonition dt {
+ font-weight: bold;
+}
+
+div.admonition dl {
+ margin-bottom: 0;
+}
+
+p.admonition-title {
+ margin: 0px 10px 5px 0px;
+ font-weight: bold;
+}
+
+div.body p.centered {
+ text-align: center;
+ margin-top: 25px;
+}
+
+/* -- tables ---------------------------------------------------------------- */
+
+table.docutils {
+ border: 0;
+ border-collapse: collapse;
+}
+
+table.docutils td, table.docutils th {
+ padding: 2px 8px 2px 8px;
+ border-top: 0;
+ border-left: 0;
+ border-right: 0;
+ border-bottom: 1px solid #aaa;
+}
+
+table.field-list td, table.field-list th {
+ border: 0 !important;
+}
+
+table.footnote td, table.footnote th {
+ border: 0 !important;
+}
+
+th {
+ text-align: left;
+ padding-right: 5px;
+}
+
+/* -- other body styles ----------------------------------------------------- */
+
+dl {
+ margin-bottom: 15px;
+}
+
+dd p {
+ margin-top: 0px;
+}
+
+dd ul, dd table {
+ margin-bottom: 10px;
+}
+
+dd {
+ margin-top: 3px;
+ margin-bottom: 10px;
+ margin-left: 30px;
+}
+
+dt:target, .highlight {
+ background-color: #fbe54e;
+}
+
+dl.glossary dt {
+ font-weight: bold;
+ font-size: 1.1em;
+}
+
+.field-list ul {
+ margin: 0;
+ padding-left: 1em;
+}
+
+.field-list p {
+ margin: 0;
+}
+
+.refcount {
+ color: #060;
+}
+
+.optional {
+ font-size: 1.3em;
+}
+
+.versionmodified {
+ font-style: italic;
+}
+
+.system-message {
+ background-color: #fda;
+ padding: 5px;
+ border: 3px solid red;
+}
+
+.footnote:target {
+ background-color: #ffa
+}
+
+/* -- code displays --------------------------------------------------------- */
+
+pre {
+ overflow: auto;
+}
+
+td.linenos pre {
+ padding: 5px 0px;
+ border: 0;
+ background-color: transparent;
+ color: #aaa;
+}
+
+table.highlighttable {
+ margin-left: 0.5em;
+}
+
+table.highlighttable td {
+ padding: 0 0.5em 0 0.5em;
+}
+
+tt.descname {
+ background-color: transparent;
+ font-weight: bold;
+ font-size: 1.2em;
+}
+
+tt.descclassname {
+ background-color: transparent;
+}
+
+tt.xref, a tt {
+ background-color: transparent;
+ font-weight: bold;
+}
+
+h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt {
+ background-color: transparent;
+}
+
+/* -- math display ---------------------------------------------------------- */
+
+img.math {
+ vertical-align: middle;
+}
+
+div.math p {
+ text-align: center;
+}
+
+span.eqno {
+ float: right;
+}
+
+/* -- printout stylesheet --------------------------------------------------- */
+
+@media print {
+ div.document,
+ div.documentwrapper,
+ div.bodywrapper {
+ margin: 0;
+ width: 100%;
+ }
+
+ div.sphinxsidebar,
+ div.related,
+ div.footer,
+ #top-link {
+ display: none;
+ }
+}
diff --git a/doc/_static/default.css b/doc/_static/default.css
new file mode 100644
index 000000000..721ceb71b
--- /dev/null
+++ b/doc/_static/default.css
@@ -0,0 +1,248 @@
+/**
+ * Sphinx stylesheet -- default theme
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+@import url("basic.css");
+
+/* -- page layout ----------------------------------------------------------- */
+
+body {
+ font-family: sans-serif;
+ font-size: 100%;
+ background-color: #000000;
+ color: #000;
+ margin: 0;
+ padding: 0;
+}
+
+div.document {
+ background-image:url(images/side_background.jpg);
+ background-repeat:repeat-y;
+ background-color:#ffd800;
+}
+
+div.body {
+ position:relative;
+ background-color:#fff;
+ color: #000000;
+ padding: 0 20px 30px 20px;
+}
+
+div.footer {
+ color: #ffffff;
+ width: 100%;
+ padding: 9px 0 9px 0;
+ text-align: center;
+ font-size: 75%;
+}
+
+div.footer a {
+ color: #ffffff;
+ text-decoration: underline;
+}
+
+div.related {
+ background-image:url(images/top_background.jpg);
+ background-repeat:repeat-x;
+ background-color: #d7aa00;
+ line-height:33px;
+ height:33px;
+ color: #000000;
+}
+
+div.related a {
+ color: #000000;
+}
+
+div.related img {
+ padding-top:3px;
+}
+
+div.sphinxsidebar {
+}
+
+div.sphinxsidebar h3 {
+ font-family: Arial, Verdana, sans-serif;
+ color: #000000;
+ font-size: 1.4em;
+ font-weight: normal;
+ margin: 0;
+ padding: 0;
+}
+
+div.sphinxsidebar h3 a {
+ color: #000000;
+}
+
+div.sphinxsidebar h4 {
+ font-family: Arial, Verdana, sans-serif;
+ color: #000000;
+ font-size: 1.3em;
+ font-weight: normal;
+ margin: 5px 0 0 0;
+ padding: 0;
+}
+
+div.sphinxsidebar p {
+ color: #ffffff;
+}
+
+div.sphinxsidebar p.topless {
+ margin: 5px 10px 10px 10px;
+}
+
+div.sphinxsidebar ul {
+ margin: 10px;
+ padding: 0;
+ color: #ffffff;
+}
+
+div#searchbox p.searchtip {
+ color:#000000;
+ font-size:90%;
+ padding-top:50px;
+}
+
+div#searchbox {
+ background-image:url(images/background_search.jpg);
+ background-repeat:no-repeat;
+ background-position:center;
+ border:none;
+}
+
+div.sphinxsidebar a {
+ color: #009491;
+}
+
+
+/* -- body styles ----------------------------------------------------------- */
+
+a {
+ color: #009491;
+ text-decoration: underline;
+}
+
+a:hover {
+ text-decoration: underline;
+}
+
+div.body p, div.body dd, div.body li {
+ text-align: left;
+ line-height: 130%;
+}
+
+div.body h1 {
+ font-family: Arial, Verdana, sans-serif;
+ background-color: #f2f2f2;
+ font-weight: normal;
+ color: #20435c;
+ border-bottom: 1px solid #ccc;
+ margin: 20px -20px 10px -20px;
+ padding: 3px 0 3px 10px;
+}
+
+div.body h2,
+div.body h3,
+div.body h4,
+div.body h5,
+div.body h6 {
+ font-family: Arial, Verdana, Helvetica, sans-serif;
+ font-size:12px;
+ font-weight:normal;
+ border-left-width: 1px;
+ border-right-width: 1px;
+ border-top-width: 1px;
+ border-bottom-width: 2px;
+ border-style: solid;
+ border-left-color: #b1b1b1;
+ border-right-color: #b1b1b1;
+ border-top-color: #b1b1b1;
+ border-bottom-color: #009491;
+ background-color: #e0e0e0;
+ padding-left:5px;
+}
+
+div.body h1 { margin-top: 0; font-size: 200%; }
+div.body h2 { font-size: 120%; }
+div.body h3 { font-size: 115%; }
+div.body h4 { font-size: 110%; }
+div.body h5 { font-size: 105%; }
+div.body h6 { font-size: 100%; }
+
+a.headerlink {
+ color: #c60f0f;
+ font-size: 0.8em;
+ padding: 0 4px 0 4px;
+ text-decoration: none;
+}
+
+a.headerlink:hover {
+ background-color: #c60f0f;
+ color: white;
+}
+
+div.body p, div.body dd, div.body li {
+ text-align: left;
+ line-height: 130%;
+}
+
+div.admonition p.admonition-title + p {
+ display: inline;
+}
+
+div.note {
+ background-color: #eee;
+ border: 1px solid #ccc;
+}
+
+div.seealso {
+ background-color: #ffc;
+ border: 1px solid #ff6;
+}
+
+div.topic {
+ background-color: #eee;
+}
+
+div.warning {
+ background-color: #ffe4e4;
+ border: 1px solid #f66;
+}
+
+p.admonition-title {
+ display: inline;
+}
+
+p.admonition-title:after {
+ content: ":";
+}
+
+input[type=text]{
+ background-color: #009491;
+ font: 11px verdana, arial, helvetica, sans-serif;
+ color:#FFFFFF;
+ width: 150px;
+ height: 18px;
+ border: 1px solid #009491;
+ margin-left:13px;
+ margin-top:15px;
+ margin-bottom:4px;
+ border:none;
+}
+
+pre {
+ padding: 5px;
+ background-color: #eeffcc;
+ color: #333333;
+ line-height: 120%;
+ border: 1px solid #ac9;
+ border-left: none;
+ border-right: none;
+}
+
+tt {
+ background-color: #ecf0f3;
+ padding: 0 1px 0 1px;
+ font-size: 0.95em;
+}
diff --git a/doc/_static/images/._background_search.jpg b/doc/_static/images/._background_search.jpg
new file mode 100755
index 000000000..d5c689c31
--- /dev/null
+++ b/doc/_static/images/._background_search.jpg
Binary files differ
diff --git a/doc/_static/images/._bread_crumb.png b/doc/_static/images/._bread_crumb.png
new file mode 100755
index 000000000..46b8591c6
--- /dev/null
+++ b/doc/_static/images/._bread_crumb.png
Binary files differ
diff --git a/doc/_static/images/._button_search.jpg b/doc/_static/images/._button_search.jpg
new file mode 100755
index 000000000..d5c689c31
--- /dev/null
+++ b/doc/_static/images/._button_search.jpg
Binary files differ
diff --git a/doc/_static/images/._side_background.jpg b/doc/_static/images/._side_background.jpg
new file mode 100755
index 000000000..a79b91c97
--- /dev/null
+++ b/doc/_static/images/._side_background.jpg
Binary files differ
diff --git a/doc/_static/images/._top_background.jpg b/doc/_static/images/._top_background.jpg
new file mode 100755
index 000000000..d5c689c31
--- /dev/null
+++ b/doc/_static/images/._top_background.jpg
Binary files differ
diff --git a/doc/_static/images/background_search.jpg b/doc/_static/images/background_search.jpg
new file mode 100644
index 000000000..c0481c561
--- /dev/null
+++ b/doc/_static/images/background_search.jpg
Binary files differ
diff --git a/doc/_static/images/bg.jpg b/doc/_static/images/bg.jpg
new file mode 100644
index 000000000..2ceb19583
--- /dev/null
+++ b/doc/_static/images/bg.jpg
Binary files differ
diff --git a/doc/_static/images/bread_crumb.png b/doc/_static/images/bread_crumb.png
new file mode 100644
index 000000000..f7ebd20e4
--- /dev/null
+++ b/doc/_static/images/bread_crumb.png
Binary files differ
diff --git a/doc/_static/images/button_search.png b/doc/_static/images/button_search.png
new file mode 100644
index 000000000..0160b81ab
--- /dev/null
+++ b/doc/_static/images/button_search.png
Binary files differ
diff --git a/doc/_static/images/side_background.jpg b/doc/_static/images/side_background.jpg
new file mode 100644
index 000000000..6e6667542
--- /dev/null
+++ b/doc/_static/images/side_background.jpg
Binary files differ
diff --git a/doc/_static/images/top_background.jpg b/doc/_static/images/top_background.jpg
new file mode 100644
index 000000000..aafe1f72e
--- /dev/null
+++ b/doc/_static/images/top_background.jpg
Binary files differ
diff --git a/doc/_templates/index.html b/doc/_templates/index.html
new file mode 100644
index 000000000..560f92ab8
--- /dev/null
+++ b/doc/_templates/index.html
@@ -0,0 +1,68 @@
+{% extends "layout.html" %}
+{% set title = 'Overview' %}
+{% block body %}
+<div class="section">
+ <h1>PySide {{ version }}</h1>
+
+ <p><a href="http://www.qtsoftware.com/">Qt</a> is a cross-platform application framework from Qt Software (owned by Nokia).
+ It features a large number of libraries providing services like network abstraction and XML handling, along with a very rich
+ GUI package, allowing C++ developers to write their applications once and run them unmodified in different systems.
+ PySide aims to provide Python developers access to the Qt libraries in the most natural way.</p>
+
+ <p>PySide is built using the BoostPythonGenerator.</p>
+
+ <h2>Documentation</h2>
+ <table class="contentstable" align="center" style="margin-left: 30px"><tr>
+ <td width="50%">
+ <p class="biglink"><a class="biglink" href="{{ pathto("issuesdiff") }}">PyQt Incompatibilities</a><br/>
+ <span class="linkdescr">PySide issues and specificities</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("howto-build/index") }}">How to build</a><br/>
+ <span class="linkdescr">building compiling and installing PySide</span></p>
+ </td>
+ <td width="50%">
+ <p class="biglink"><a class="biglink" href="{{ pathto("contents") }}">Contents</a><br/>
+ <span class="linkdescr">for a complete overview</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("dbus") }}">DBus</a><br/>
+ <span class="linkdescr">DBus integration</span></p>
+
+ </td></tr>
+ </table>
+
+ <h2>Modules</h2>
+ <table class="contentstable" align="center" style="margin-left: 30px"><tr>
+ <td width="50%">
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/QtCore/index") }}">QtCore</a><br/>
+ <span class="linkdescr">core non-GUI functionality</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/QtGui/index") }}">QtGui</a><br/>
+ <span class="linkdescr">extends QtCore with GUI functionality.</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/QtHelp/index") }}">QtHelp</a><br/>
+ <span class="linkdescr">provides classes for integrating online documentation in applications</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/QtNetwork/index") }}">QtNetwork</a><br/>
+ <span class="linkdescr">offers classes that allow you to write TCP/IP clients and servers</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/QtOpenGL/index") }}">QtOpenGL</a><br/>
+ <span class="linkdescr">offers classes that make it easy to use OpenGL in Qt applications</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/QtScript/index") }}">QtScript</a><br/>
+ <span class="linkdescr">provides classes for making Qt applications scriptable</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/QtMultimedia/index") }}">QtMultimedia</a><br/>
+ <span class="linkdescr"></span>provides low-level multimedia functionality</p>
+ </td>
+ <td width="50%">
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/QtScriptTools/index") }}">QtScriptTools</a><br/>
+ <span class="linkdescr">provides additional components for applications that use Qt Script</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/QtSql/index") }}">QtSql</a><br/>
+ <span class="linkdescr">helps you provide seamless database integration to your Qt applications</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/QtSvg/index") }}">QtSvg</a><br/>
+ <span class="linkdescr">provides classes for displaying the contents of SVG files</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/QtUiTools/index") }}">QtUiTools</a><br/>
+ <span class="linkdescr">provides classes to handle forms created with Qt Designer</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/QtXml/index") }}">QtXml</a><br/>
+ <span class="linkdescr">provides a stream reader and writer for XML documents</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/QtWebKit/index") }}">QtWebkit</a><br/>
+ <span class="linkdescr">provides a Web browser engine</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/phonon/index") }}">Phonon</a><br/>
+ <span class="linkdescr">cross-platform multimedia framework that enables the use of audio and video
+ content in Qt applications</span></p>
+ </td></tr>
+ </table>
+</div>
+{% endblock %}
diff --git a/doc/_themes/pysidedocs/defindex.html b/doc/_themes/pysidedocs/defindex.html
new file mode 100644
index 000000000..40f4f4c90
--- /dev/null
+++ b/doc/_themes/pysidedocs/defindex.html
@@ -0,0 +1,26 @@
+{% extends "layout.html" %}
+{% set title = _('Overview') %}
+{% block body %}
+ <h1>{{ docstitle|e }}</h1>
+ <p>
+ Welcome! This is
+ {% block description %}the documentation for {{ project|e }}
+ {{ release|e }}{% if last_updated %}, last updated {{ last_updated|e }}{% endif %}{% endblock %}.
+ </p>
+ {% block tables %}
+ <p><strong>{{ _('Indices and tables:') }}</strong></p>
+ <table class="contentstable" align="center"><tr>
+ <td width="50%">
+ <p class="biglink"><a class="biglink" href="{{ pathto("contents") }}">{{ _('Complete Table of Contents') }}</a><br>
+ <span class="linkdescr">{{ _('lists all sections and subsections') }}</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("search") }}">{{ _('Search Page') }}</a><br>
+ <span class="linkdescr">{{ _('search this documentation') }}</span></p>
+ </td><td width="50%">
+ <p class="biglink"><a class="biglink" href="{{ pathto("modindex") }}">{{ _('Global Module Index') }}</a><br>
+ <span class="linkdescr">{{ _('quick access to all modules') }}</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("genindex") }}">{{ _('General Index') }}</a><br>
+ <span class="linkdescr">{{ _('all functions, classes, terms') }}</span></p>
+ </td></tr>
+ </table>
+ {% endblock %}
+{% endblock %}
diff --git a/doc/_themes/pysidedocs/genindex-single.html b/doc/_themes/pysidedocs/genindex-single.html
new file mode 100644
index 000000000..9aaaeb0ca
--- /dev/null
+++ b/doc/_themes/pysidedocs/genindex-single.html
@@ -0,0 +1,46 @@
+{% extends "layout.html" %}
+{% set title = _('Index') %}
+{% block body %}
+
+ <h1 id="index">{% trans key=key %}Index &ndash; {{ key }}{% endtrans %}</h1>
+
+<table width="100%" class="indextable"><tr><td width="33%" valign="top">
+<dl>
+{%- set breakat = count // 2 %}
+{%- set numcols = 1 %}
+{%- set numitems = 0 %}
+{% for entryname, (links, subitems) in entries %}
+<dt>{%- if links -%}<a href="{{ links[0] }}">{{ entryname|e }}</a>
+ {%- for link in links[1:] %}, <a href="{{ link }}">[{{ loop.index }}]</a>{% endfor -%}
+ {%- else -%}
+{{ entryname|e }}
+ {%- endif -%}</dt>
+ {%- if subitems %}
+ <dd><dl>
+ {%- for subentryname, subentrylinks in subitems %}
+ <dt><a href="{{ subentrylinks[0] }}">{{ subentryname|e }}</a>
+ {%- for link in subentrylinks[1:] %}, <a href="{{ link }}">[{{ loop.index }}]</a>{% endfor -%}
+ </dt>
+ {%- endfor %}
+ </dl></dd>
+ {%- endif -%}
+{%- set numitems = numitems + 1 + (subitems|length) -%}
+{%- if numcols < 2 and numitems > breakat -%}
+{%- set numcols = numcols+1 -%}
+</dl></td><td width="33%" valign="top"><dl>
+{%- endif -%}
+{%- endfor %}
+</dl></td></tr></table>
+
+{% endblock %}
+
+{% block sidebarrel %}
+ <h4>Index</h4>
+ <p>{% for key, dummy in genindexentries -%}
+ <a href="{{ pathto('genindex-' + key) }}"><strong>{{ key }}</strong></a>
+ {% if not loop.last %}| {% endif %}
+ {%- endfor %}</p>
+
+ <p><a href="{{ pathto('genindex-all') }}"><strong>{{ _('Full index on one page') }}</strong></a></p>
+ {{ super() }}
+{% endblock %}
diff --git a/doc/_themes/pysidedocs/genindex-split.html b/doc/_themes/pysidedocs/genindex-split.html
new file mode 100644
index 000000000..ab099e5bd
--- /dev/null
+++ b/doc/_themes/pysidedocs/genindex-split.html
@@ -0,0 +1,30 @@
+{% extends "layout.html" %}
+{% set title = _('Index') %}
+{% block body %}
+
+ <h1 id="index">{{ _('Index') }}</h1>
+
+ <p>{{ _('Index pages by letter') }}:</p>
+
+ <p>{% for key, dummy in genindexentries -%}
+ <a href="{{ pathto('genindex-' + key) }}"><strong>{{ key }}</strong></a>
+ {% if not loop.last %}| {% endif %}
+ {%- endfor %}</p>
+
+ <p><a href="{{ pathto('genindex-all') }}"><strong>{{ _('Full index on one page') }}</strong>
+ ({{ _('can be huge') }})</a></p>
+
+{% endblock %}
+
+{% block sidebarrel %}
+{% if split_index %}
+ <h4>Index</h4>
+ <p>{% for key, dummy in genindexentries -%}
+ <a href="{{ pathto('genindex-' + key) }}"><strong>{{ key }}</strong></a>
+ {% if not loop.last %}| {% endif %}
+ {%- endfor %}</p>
+
+ <p><a href="{{ pathto('genindex-all') }}"><strong>{{ _('Full index on one page') }}</strong></a></p>
+{% endif %}
+ {{ super() }}
+{% endblock %}
diff --git a/doc/_themes/pysidedocs/genindex.html b/doc/_themes/pysidedocs/genindex.html
new file mode 100644
index 000000000..a19aa80f4
--- /dev/null
+++ b/doc/_themes/pysidedocs/genindex.html
@@ -0,0 +1,57 @@
+{% extends "layout.html" %}
+{% set title = _('Index') %}
+{% block body %}
+
+ <h1 id="index">{{ _('Index') }}</h1>
+
+ {% for key, dummy in genindexentries -%}
+ <a href="#{{ key }}"><strong>{{ key }}</strong></a> {% if not loop.last %}| {% endif %}
+ {%- endfor %}
+
+ <hr />
+
+ {% for key, entries in genindexentries %}
+<h2 id="{{ key }}">{{ key }}</h2>
+<table width="100%" class="indextable"><tr><td width="33%" valign="top">
+<dl>
+{%- set breakat = genindexcounts[loop.index0] // 2 %}
+{%- set numcols = 1 %}
+{%- set numitems = 0 %}
+{% for entryname, (links, subitems) in entries %}
+<dt>{%- if links -%}<a href="{{ links[0] }}">{{ entryname|e }}</a>
+ {%- for link in links[1:] %}, <a href="{{ link }}">[{{ loop.index }}]</a>{% endfor -%}
+ {%- else -%}
+{{ entryname|e }}
+ {%- endif -%}</dt>
+ {%- if subitems %}
+ <dd><dl>
+ {%- for subentryname, subentrylinks in subitems %}
+ <dt><a href="{{ subentrylinks[0] }}">{{ subentryname|e }}</a>
+ {%- for link in subentrylinks[1:] %}, <a href="{{ link }}">[{{ loop.index }}]</a>{% endfor -%}
+ </dt>
+ {%- endfor %}
+ </dl></dd>
+ {%- endif -%}
+{%- set numitems = numitems + 1 + (subitems|length) -%}
+{%- if numcols < 2 and numitems > breakat -%}
+{%- set numcols = numcols+1 -%}
+</dl></td><td width="33%" valign="top"><dl>
+{%- endif -%}
+{%- endfor %}
+</dl></td></tr></table>
+{% endfor %}
+
+{% endblock %}
+
+{% block sidebarrel %}
+{% if split_index %}
+ <h4>{{ _('Index') }}</h4>
+ <p>{% for key, dummy in genindexentries -%}
+ <a href="{{ pathto('genindex-' + key) }}"><strong>{{ key }}</strong></a>
+ {% if not loop.last %}| {% endif %}
+ {%- endfor %}</p>
+
+ <p><a href="{{ pathto('genindex-all') }}"><strong>{{ _('Full index on one page') }}</strong></a></p>
+{% endif %}
+ {{ super() }}
+{% endblock %}
diff --git a/doc/_themes/pysidedocs/layout.html b/doc/_themes/pysidedocs/layout.html
new file mode 100644
index 000000000..eb5743106
--- /dev/null
+++ b/doc/_themes/pysidedocs/layout.html
@@ -0,0 +1,147 @@
+{%- block doctype -%}
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+{%- endblock %}
+{%- set reldelim1 = reldelim1 is not defined and ' &raquo;' or reldelim1 %}
+{%- set reldelim2 = reldelim2 is not defined and ' |' or reldelim2 %}
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ {{ metatags }}
+ <title>{{ project }} &mdash; {{ title }}</title>
+ <link rel="stylesheet" href="{{ pathto('_static/pysidedocs.css', 1) }}" type="text/css" />
+ <link rel="stylesheet" href="{{ pathto('_static/pygments.css', 1) }}" type="text/css" />
+
+ {%- if not embedded %}
+ <script type="text/javascript">
+ var DOCUMENTATION_OPTIONS = {
+ URL_ROOT: '{{ pathto("", 1) }}',
+ VERSION: '{{ release|e }}',
+ COLLAPSE_MODINDEX: false,
+ FILE_SUFFIX: '{{ file_suffix }}',
+ HAS_SOURCE: {{ has_source|lower }}
+ };
+ </script>
+ {%- for scriptfile in script_files %}
+ <script type="text/javascript" src="{{ pathto(scriptfile, 1) }}"></script>
+ {%- endfor %}
+ {%- if pagename == "screenshots" %}
+ {%- endif %}
+ <!--[if lt IE 7]>
+ <style media="screen" type="text/css">
+ #container {
+ height:100%;
+ }
+ </style>
+ <![endif]-->
+
+ {%- if use_opensearch %}
+ <link rel="search" type="application/opensearchdescription+xml"
+ title="{% trans docstitle=docstitle|e %}Search within {{ docstitle }}{% endtrans %}"
+ href="{{ pathto('_static/opensearch.xml', 1) }}"/>
+ {%- endif %}
+ {%- if favicon %}
+ <link rel="shortcut icon" href="{{ pathto('_static/' + favicon, 1) }}"/>
+ {%- endif %}
+ {%- endif %}
+{%- block linktags %}
+ {%- if hasdoc('about') %}
+ <link rel="author" title="{{ _('About these documents') }}" href="{{ pathto('about') }}" />
+ {%- endif %}
+ {%- if hasdoc('genindex') %}
+ <link rel="index" title="{{ _('Index') }}" href="{{ pathto('genindex') }}" />
+ {%- endif %}
+ {%- if hasdoc('search') %}
+ <link rel="search" title="{{ _('Search') }}" href="{{ pathto('search') }}" />
+ {%- endif %}
+ {%- if hasdoc('copyright') %}
+ <link rel="copyright" title="{{ _('Copyright') }}" href="{{ pathto('copyright') }}" />
+ {%- endif %}
+ <link rel="top" title="{{ docstitle|e }}" href="{{ pathto('index') }}" />
+ {%- if parents %}
+ <link rel="up" title="{{ parents[-1].title|striptags }}" href="{{ parents[-1].link|e }}" />
+ {%- endif %}
+ {%- if next %}
+ <link rel="next" title="{{ next.title|striptags }}" href="{{ next.link|e }}" />
+ {%- endif %}
+ {%- if prev %}
+ <link rel="prev" title="{{ prev.title|striptags }}" href="{{ prev.link|e }}" />
+ {%- endif %}
+{%- endblock %}
+{%- block extrahead %} {% endblock %}
+ </head>
+ <body id="{{ pagename }}">
+{%- block header %}{% endblock %}
+
+<div id="container">
+<div id="header">
+ <div id="header_container">
+ <div id="logo"></div>
+ <ul id="relbar">
+ {%- for rellink in rellinks %}
+ <li class="right">
+ <a href="{{ pathto(rellink[0]) }}" title="{{ rellink[1]|striptags }}"
+ {{ accesskey(rellink[2]) }}>{{ rellink[3] }}</a>
+ {%- if not loop.first %}{{ reldelim2 }}{% endif %}</li>
+ {%- endfor %}
+ {%- block rootrellink %}
+ <li><a href="{{ pathto(master_doc) }}">{{ shorttitle|e }}</a>{{ reldelim1 }}</li>
+ {%- endblock %}
+ {%- for parent in parents %}
+ <li><a href="{{ parent.link|e }}" {% if loop.last %}{{ accesskey("U") }}{% endif %}>{{ parent.title }}</a>{{ reldelim1 }}</li>
+ {%- endfor %}
+ {%- block relbaritems %} {% endblock %}
+ </ul>
+ </div>
+</div>
+
+<div id="body" >
+ <div id="sidebar">
+ {%- block sidebartoc %}
+ {%- if display_toc %}
+ <h3><a href="{{ pathto(master_doc) }}">{{ _('Table Of Contents') }}</a></h3>
+ {{ toc }}
+ {%- endif %}
+ {%- endblock %}
+ {%- block sidebarrel %}
+ {%- if prev %}
+ <h3>{{ _('Previous topic') }}</h3>
+ <p class="topless"><a href="{{ prev.link|e }}"
+ title="{{ _('previous chapter') }}">{{ prev.title }}</a></p>
+ {%- endif %}
+ {%- if next %}
+ <h3>{{ _('Next topic') }}</h3>
+ <p class="topless"><a href="{{ next.link|e }}"
+ title="{{ _('next chapter') }}">{{ next.title }}</a></p>
+ {%- endif %}
+ {%- endblock %}
+
+ <div id="search_box">
+ <h3>Quick search</h3>
+ <form action="{{ pathto('search') }}" method="get">
+ <input type="text" name="q" id="q" />
+ <input type="submit" value="Go" id="search_button" />
+ <input type="hidden" name="check_keywords" value="yes" />
+ <input type="hidden" name="area" value="default" />
+ </form>
+ </div>
+
+ </div>
+
+ {%- block document %}
+ {% block body %} {% endblock %}
+ {%- endblock %}
+</div> <!-- container -->
+
+{%- block footer %}
+<div id="footer">
+ <a href="http://www.indt.org.br"><img src="{{ pathto('_static/logo_indt.jpg', 1) }}" alt="Indt" border="0" /></a>
+ <a href="http://www.openbossa.org"><img src="{{ pathto('_static/logo_openbossa.png', 1) }}" alt="Openbossa" border="0" /></a>
+ <a href="http://qt.nokia.com/"><img src="{{ pathto('_static/logo_qt.png', 1) }}" alt="Qt" border="0" /></a>
+ <a href="http://www.python.org"><img src="{{ pathto('_static/logo_python.jpg', 1) }}" alt="Python" border="0" /></a>
+</div>
+{%- endblock %}
+</div>
+</body>
+</html>
diff --git a/doc/_themes/pysidedocs/modindex.html b/doc/_themes/pysidedocs/modindex.html
new file mode 100644
index 000000000..0392edc80
--- /dev/null
+++ b/doc/_themes/pysidedocs/modindex.html
@@ -0,0 +1,42 @@
+{% extends "layout.html" %}
+{% set title = _('Global Module Index') %}
+{% block extrahead %}
+{{ super() }}
+{% if not embedded and collapse_modindex %}
+ <script type="text/javascript">
+ DOCUMENTATION_OPTIONS.COLLAPSE_MODINDEX = true;
+ </script>
+{% endif %}
+{% endblock %}
+{% block body %}
+
+ <h1 id="global-module-index">{{ _('Global Module Index') }}</h1>
+
+ {%- for letter in letters %}
+ <a href="#cap-{{ letter }}"><strong>{{ letter }}</strong></a> {% if not loop.last %}| {% endif %}
+ {%- endfor %}
+ <hr/>
+
+ <table width="100%" class="indextable" cellspacing="0" cellpadding="2">
+ {%- for modname, collapse, cgroup, indent, fname, synops, pform, dep, stripped in modindexentries %}
+ {%- if not modname -%}
+ <tr class="pcap"><td></td><td>&nbsp;</td><td></td></tr>
+ <tr class="cap"><td></td><td><a name="cap-{{ fname }}"><strong>{{ fname }}</strong></a></td><td></td></tr>
+ {%- else -%}
+ <tr{% if indent %} class="cg-{{ cgroup }}"{% endif %}>
+ <td>{% if collapse -%}
+ <img src="{{ pathto('_static/minus.png', 1) }}" id="toggle-{{ cgroup }}"
+ class="toggler" style="display: none" alt="-" />
+ {%- endif %}</td>
+ <td>{% if indent %}&nbsp;&nbsp;&nbsp;{% endif %}
+ {% if fname %}<a href="{{ fname }}">{% endif -%}
+ <tt class="xref">{{ stripped|e }}{{ modname|e }}</tt>
+ {%- if fname %}</a>{% endif %}
+ {%- if pform and pform[0] %} <em>({{ pform|join(', ') }})</em>{% endif -%}
+ </td><td>{% if dep %}<strong>{{ _('Deprecated')}}:</strong>{% endif %}
+ <em>{{ synops|e }}</em></td></tr>
+ {%- endif -%}
+ {% endfor %}
+ </table>
+
+{% endblock %}
diff --git a/doc/_themes/pysidedocs/opensearch.xml b/doc/_themes/pysidedocs/opensearch.xml
new file mode 100644
index 000000000..03875be49
--- /dev/null
+++ b/doc/_themes/pysidedocs/opensearch.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
+ <ShortName>{{ project|e }}</ShortName>
+ <Description>{% trans docstitle=docstitle|e %}Search {{ docstitle }}{% endtrans %}</Description>
+ <InputEncoding>utf-8</InputEncoding>
+ <Url type="text/html" method="get"
+ template="{{ use_opensearch }}/{{ pathto('search') }}?q={searchTerms}&amp;check_keywords=yes&amp;area=default"/>
+ <LongName>{{ docstitle|e }}</LongName>
+{% block extra %} {# Put e.g. an <Image> element here. #} {% endblock %}
+</OpenSearchDescription>
diff --git a/doc/_themes/pysidedocs/page.html b/doc/_themes/pysidedocs/page.html
new file mode 100644
index 000000000..17a930165
--- /dev/null
+++ b/doc/_themes/pysidedocs/page.html
@@ -0,0 +1,4 @@
+{% extends "layout.html" %}
+{% block body %}
+ {{ body }}
+{% endblock %}
diff --git a/doc/_themes/pysidedocs/search.html b/doc/_themes/pysidedocs/search.html
new file mode 100644
index 000000000..d7455327a
--- /dev/null
+++ b/doc/_themes/pysidedocs/search.html
@@ -0,0 +1,26 @@
+{% extends "layout.html" %}
+{% set title = _('Search') %}
+{% set script_files = script_files + ['_static/searchtools.js'] %}
+{% block body %}
+<div class="section">
+ <h1 id="search-documentation">Search Results</h1>
+ <div id="fallback" class="admonition warning">
+ <script type="text/javascript">$('#fallback').hide();</script>
+ <p>
+ {% trans %}Please activate JavaScript to enable the search
+ functionality.{% endtrans %}
+ </p>
+ </div>
+ {% if search_performed %}
+ {% if not search_results %}
+ <p>{{ _('Your search did not match any results.') }}</p>
+ {% endif %}
+ {% endif %}
+ <div id="search-results">
+ </div>
+</div>
+{% endblock %}
+{% block footer %}
+ {{ super() }}
+ <script type="text/javascript" src="searchindex.js"></script>
+{% endblock %}
diff --git a/doc/_themes/pysidedocs/static/.directory b/doc/_themes/pysidedocs/static/.directory
new file mode 100644
index 000000000..176338d67
--- /dev/null
+++ b/doc/_themes/pysidedocs/static/.directory
@@ -0,0 +1,3 @@
+[Dolphin]
+ShowPreview=true
+Timestamp=2009,10,13,10,27,39
diff --git a/doc/_themes/pysidedocs/static/bg_header.png b/doc/_themes/pysidedocs/static/bg_header.png
new file mode 100644
index 000000000..843e7e2c5
--- /dev/null
+++ b/doc/_themes/pysidedocs/static/bg_header.png
Binary files differ
diff --git a/doc/_themes/pysidedocs/static/bg_topo.jpg b/doc/_themes/pysidedocs/static/bg_topo.jpg
new file mode 100644
index 000000000..4229ae8db
--- /dev/null
+++ b/doc/_themes/pysidedocs/static/bg_topo.jpg
Binary files differ
diff --git a/doc/_themes/pysidedocs/static/doctools.js b/doc/_themes/pysidedocs/static/doctools.js
new file mode 100644
index 000000000..9447678cd
--- /dev/null
+++ b/doc/_themes/pysidedocs/static/doctools.js
@@ -0,0 +1,232 @@
+/// XXX: make it cross browser
+
+/**
+ * make the code below compatible with browsers without
+ * an installed firebug like debugger
+ */
+if (!window.console || !console.firebug) {
+ var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
+ "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
+ window.console = {};
+ for (var i = 0; i < names.length; ++i)
+ window.console[names[i]] = function() {}
+}
+
+/**
+ * small helper function to urldecode strings
+ */
+jQuery.urldecode = function(x) {
+ return decodeURIComponent(x).replace(/\+/g, ' ');
+}
+
+/**
+ * small helper function to urlencode strings
+ */
+jQuery.urlencode = encodeURIComponent;
+
+/**
+ * This function returns the parsed url parameters of the
+ * current request. Multiple values per key are supported,
+ * it will always return arrays of strings for the value parts.
+ */
+jQuery.getQueryParameters = function(s) {
+ if (typeof s == 'undefined')
+ s = document.location.search;
+ var parts = s.substr(s.indexOf('?') + 1).split('&');
+ var result = {};
+ for (var i = 0; i < parts.length; i++) {
+ var tmp = parts[i].split('=', 2);
+ var key = jQuery.urldecode(tmp[0]);
+ var value = jQuery.urldecode(tmp[1]);
+ if (key in result)
+ result[key].push(value);
+ else
+ result[key] = [value];
+ }
+ return result;
+}
+
+/**
+ * small function to check if an array contains
+ * a given item.
+ */
+jQuery.contains = function(arr, item) {
+ for (var i = 0; i < arr.length; i++) {
+ if (arr[i] == item)
+ return true;
+ }
+ return false;
+}
+
+/**
+ * highlight a given string on a jquery object by wrapping it in
+ * span elements with the given class name.
+ */
+jQuery.fn.highlightText = function(text, className) {
+ function highlight(node) {
+ if (node.nodeType == 3) {
+ var val = node.nodeValue;
+ var pos = val.toLowerCase().indexOf(text);
+ if (pos >= 0 && !jQuery.className.has(node.parentNode, className)) {
+ var span = document.createElement("span");
+ span.className = className;
+ span.appendChild(document.createTextNode(val.substr(pos, text.length)));
+ node.parentNode.insertBefore(span, node.parentNode.insertBefore(
+ document.createTextNode(val.substr(pos + text.length)),
+ node.nextSibling));
+ node.nodeValue = val.substr(0, pos);
+ }
+ }
+ else if (!jQuery(node).is("button, select, textarea")) {
+ jQuery.each(node.childNodes, function() {
+ highlight(this)
+ });
+ }
+ }
+ return this.each(function() {
+ highlight(this);
+ });
+}
+
+/**
+ * Small JavaScript module for the documentation.
+ */
+var Documentation = {
+
+ init : function() {
+ this.fixFirefoxAnchorBug();
+ this.highlightSearchWords();
+ this.initModIndex();
+ },
+
+ /**
+ * i18n support
+ */
+ TRANSLATIONS : {},
+ PLURAL_EXPR : function(n) { return n == 1 ? 0 : 1; },
+ LOCALE : 'unknown',
+
+ // gettext and ngettext don't access this so that the functions
+ // can savely bound to a different name (_ = Documentation.gettext)
+ gettext : function(string) {
+ var translated = Documentation.TRANSLATIONS[string];
+ if (typeof translated == 'undefined')
+ return string;
+ return (typeof translated == 'string') ? translated : translated[0];
+ },
+
+ ngettext : function(singular, plural, n) {
+ var translated = Documentation.TRANSLATIONS[singular];
+ if (typeof translated == 'undefined')
+ return (n == 1) ? singular : plural;
+ return translated[Documentation.PLURALEXPR(n)];
+ },
+
+ addTranslations : function(catalog) {
+ for (var key in catalog.messages)
+ this.TRANSLATIONS[key] = catalog.messages[key];
+ this.PLURAL_EXPR = new Function('n', 'return +(' + catalog.plural_expr + ')');
+ this.LOCALE = catalog.locale;
+ },
+
+ /**
+ * add context elements like header anchor links
+ */
+ addContextElements : function() {
+ $('div[id] > :header:first').each(function() {
+ $('<a class="headerlink">\u00B6</a>').
+ attr('href', '#' + this.id).
+ attr('title', _('Permalink to this headline')).
+ appendTo(this);
+ });
+ $('dt[id]').each(function() {
+ $('<a class="headerlink">\u00B6</a>').
+ attr('href', '#' + this.id).
+ attr('title', _('Permalink to this definition')).
+ appendTo(this);
+ });
+ },
+
+ /**
+ * workaround a firefox stupidity
+ */
+ fixFirefoxAnchorBug : function() {
+ if (document.location.hash && $.browser.mozilla)
+ window.setTimeout(function() {
+ document.location.href += '';
+ }, 10);
+ },
+
+ /**
+ * highlight the search words provided in the url in the text
+ */
+ highlightSearchWords : function() {
+ var params = $.getQueryParameters();
+ var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : [];
+ if (terms.length) {
+ var body = $('div.body');
+ window.setTimeout(function() {
+ $.each(terms, function() {
+ body.highlightText(this.toLowerCase(), 'highlight');
+ });
+ }, 10);
+ $('<li class="highlight-link"><a href="javascript:Documentation.' +
+ 'hideSearchWords()">' + _('Hide Search Matches') + '</a></li>')
+ .appendTo($('.sidebar .this-page-menu'));
+ }
+ },
+
+ /**
+ * init the modindex toggle buttons
+ */
+ initModIndex : function() {
+ var togglers = $('img.toggler').click(function() {
+ var src = $(this).attr('src');
+ var idnum = $(this).attr('id').substr(7);
+ console.log($('tr.cg-' + idnum).toggle());
+ if (src.substr(-9) == 'minus.png')
+ $(this).attr('src', src.substr(0, src.length-9) + 'plus.png');
+ else
+ $(this).attr('src', src.substr(0, src.length-8) + 'minus.png');
+ }).css('display', '');
+ if (DOCUMENTATION_OPTIONS.COLLAPSE_MODINDEX) {
+ togglers.click();
+ }
+ },
+
+ /**
+ * helper function to hide the search marks again
+ */
+ hideSearchWords : function() {
+ $('.sidebar .this-page-menu li.highlight-link').fadeOut(300);
+ $('span.highlight').removeClass('highlight');
+ },
+
+ /**
+ * make the url absolute
+ */
+ makeURL : function(relativeURL) {
+ return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL;
+ },
+
+ /**
+ * get the current relative url
+ */
+ getCurrentURL : function() {
+ var path = document.location.pathname;
+ var parts = path.split(/\//);
+ $.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() {
+ if (this == '..')
+ parts.pop();
+ });
+ var url = parts.join('/');
+ return path.substring(url.lastIndexOf('/') + 1, path.length - 1);
+ }
+};
+
+// quick alias for translations
+_ = Documentation.gettext;
+
+$(document).ready(function() {
+ Documentation.init();
+});
diff --git a/doc/_themes/pysidedocs/static/fakebar.png b/doc/_themes/pysidedocs/static/fakebar.png
new file mode 100644
index 000000000..b45830e00
--- /dev/null
+++ b/doc/_themes/pysidedocs/static/fakebar.png
Binary files differ
diff --git a/doc/_themes/pysidedocs/static/jquery.js b/doc/_themes/pysidedocs/static/jquery.js
new file mode 100644
index 000000000..82b98e1d7
--- /dev/null
+++ b/doc/_themes/pysidedocs/static/jquery.js
@@ -0,0 +1,32 @@
+/*
+ * jQuery 1.2.6 - New Wave Javascript
+ *
+ * Copyright (c) 2008 John Resig (jquery.com)
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ *
+ * $Date: 2008-05-24 14:22:17 -0400 (Sat, 24 May 2008) $
+ * $Rev: 5685 $
+ */
+(function(){var _jQuery=window.jQuery,_$=window.$;var jQuery=window.jQuery=window.$=function(selector,context){return new jQuery.fn.init(selector,context);};var quickExpr=/^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/,isSimple=/^.[^:#\[\.]*$/,undefined;jQuery.fn=jQuery.prototype={init:function(selector,context){selector=selector||document;if(selector.nodeType){this[0]=selector;this.length=1;return this;}if(typeof selector=="string"){var match=quickExpr.exec(selector);if(match&&(match[1]||!context)){if(match[1])selector=jQuery.clean([match[1]],context);else{var elem=document.getElementById(match[3]);if(elem){if(elem.id!=match[3])return jQuery().find(selector);return jQuery(elem);}selector=[];}}else
+return jQuery(context).find(selector);}else if(jQuery.isFunction(selector))return jQuery(document)[jQuery.fn.ready?"ready":"load"](selector);return this.setArray(jQuery.makeArray(selector));},jquery:"1.2.6",size:function(){return this.length;},length:0,get:function(num){return num==undefined?jQuery.makeArray(this):this[num];},pushStack:function(elems){var ret=jQuery(elems);ret.prevObject=this;return ret;},setArray:function(elems){this.length=0;Array.prototype.push.apply(this,elems);return this;},each:function(callback,args){return jQuery.each(this,callback,args);},index:function(elem){var ret=-1;return jQuery.inArray(elem&&elem.jquery?elem[0]:elem,this);},attr:function(name,value,type){var options=name;if(name.constructor==String)if(value===undefined)return this[0]&&jQuery[type||"attr"](this[0],name);else{options={};options[name]=value;}return this.each(function(i){for(name in options)jQuery.attr(type?this.style:this,name,jQuery.prop(this,options[name],type,i,name));});},css:function(key,value){if((key=='width'||key=='height')&&parseFloat(value)<0)value=undefined;return this.attr(key,value,"curCSS");},text:function(text){if(typeof text!="object"&&text!=null)return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(text));var ret="";jQuery.each(text||this,function(){jQuery.each(this.childNodes,function(){if(this.nodeType!=8)ret+=this.nodeType!=1?this.nodeValue:jQuery.fn.text([this]);});});return ret;},wrapAll:function(html){if(this[0])jQuery(html,this[0].ownerDocument).clone().insertBefore(this[0]).map(function(){var elem=this;while(elem.firstChild)elem=elem.firstChild;return elem;}).append(this);return this;},wrapInner:function(html){return this.each(function(){jQuery(this).contents().wrapAll(html);});},wrap:function(html){return this.each(function(){jQuery(this).wrapAll(html);});},append:function(){return this.domManip(arguments,true,false,function(elem){if(this.nodeType==1)this.appendChild(elem);});},prepend:function(){return this.domManip(arguments,true,true,function(elem){if(this.nodeType==1)this.insertBefore(elem,this.firstChild);});},before:function(){return this.domManip(arguments,false,false,function(elem){this.parentNode.insertBefore(elem,this);});},after:function(){return this.domManip(arguments,false,true,function(elem){this.parentNode.insertBefore(elem,this.nextSibling);});},end:function(){return this.prevObject||jQuery([]);},find:function(selector){var elems=jQuery.map(this,function(elem){return jQuery.find(selector,elem);});return this.pushStack(/[^+>] [^+>]/.test(selector)||selector.indexOf("..")>-1?jQuery.unique(elems):elems);},clone:function(events){var ret=this.map(function(){if(jQuery.browser.msie&&!jQuery.isXMLDoc(this)){var clone=this.cloneNode(true),container=document.createElement("div");container.appendChild(clone);return jQuery.clean([container.innerHTML])[0];}else
+return this.cloneNode(true);});var clone=ret.find("*").andSelf().each(function(){if(this[expando]!=undefined)this[expando]=null;});if(events===true)this.find("*").andSelf().each(function(i){if(this.nodeType==3)return;var events=jQuery.data(this,"events");for(var type in events)for(var handler in events[type])jQuery.event.add(clone[i],type,events[type][handler],events[type][handler].data);});return ret;},filter:function(selector){return this.pushStack(jQuery.isFunction(selector)&&jQuery.grep(this,function(elem,i){return selector.call(elem,i);})||jQuery.multiFilter(selector,this));},not:function(selector){if(selector.constructor==String)if(isSimple.test(selector))return this.pushStack(jQuery.multiFilter(selector,this,true));else
+selector=jQuery.multiFilter(selector,this);var isArrayLike=selector.length&&selector[selector.length-1]!==undefined&&!selector.nodeType;return this.filter(function(){return isArrayLike?jQuery.inArray(this,selector)<0:this!=selector;});},add:function(selector){return this.pushStack(jQuery.unique(jQuery.merge(this.get(),typeof selector=='string'?jQuery(selector):jQuery.makeArray(selector))));},is:function(selector){return!!selector&&jQuery.multiFilter(selector,this).length>0;},hasClass:function(selector){return this.is("."+selector);},val:function(value){if(value==undefined){if(this.length){var elem=this[0];if(jQuery.nodeName(elem,"select")){var index=elem.selectedIndex,values=[],options=elem.options,one=elem.type=="select-one";if(index<0)return null;for(var i=one?index:0,max=one?index+1:options.length;i<max;i++){var option=options[i];if(option.selected){value=jQuery.browser.msie&&!option.attributes.value.specified?option.text:option.value;if(one)return value;values.push(value);}}return values;}else
+return(this[0].value||"").replace(/\r/g,"");}return undefined;}if(value.constructor==Number)value+='';return this.each(function(){if(this.nodeType!=1)return;if(value.constructor==Array&&/radio|checkbox/.test(this.type))this.checked=(jQuery.inArray(this.value,value)>=0||jQuery.inArray(this.name,value)>=0);else if(jQuery.nodeName(this,"select")){var values=jQuery.makeArray(value);jQuery("option",this).each(function(){this.selected=(jQuery.inArray(this.value,values)>=0||jQuery.inArray(this.text,values)>=0);});if(!values.length)this.selectedIndex=-1;}else
+this.value=value;});},html:function(value){return value==undefined?(this[0]?this[0].innerHTML:null):this.empty().append(value);},replaceWith:function(value){return this.after(value).remove();},eq:function(i){return this.slice(i,i+1);},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments));},map:function(callback){return this.pushStack(jQuery.map(this,function(elem,i){return callback.call(elem,i,elem);}));},andSelf:function(){return this.add(this.prevObject);},data:function(key,value){var parts=key.split(".");parts[1]=parts[1]?"."+parts[1]:"";if(value===undefined){var data=this.triggerHandler("getData"+parts[1]+"!",[parts[0]]);if(data===undefined&&this.length)data=jQuery.data(this[0],key);return data===undefined&&parts[1]?this.data(parts[0]):data;}else
+return this.trigger("setData"+parts[1]+"!",[parts[0],value]).each(function(){jQuery.data(this,key,value);});},removeData:function(key){return this.each(function(){jQuery.removeData(this,key);});},domManip:function(args,table,reverse,callback){var clone=this.length>1,elems;return this.each(function(){if(!elems){elems=jQuery.clean(args,this.ownerDocument);if(reverse)elems.reverse();}var obj=this;if(table&&jQuery.nodeName(this,"table")&&jQuery.nodeName(elems[0],"tr"))obj=this.getElementsByTagName("tbody")[0]||this.appendChild(this.ownerDocument.createElement("tbody"));var scripts=jQuery([]);jQuery.each(elems,function(){var elem=clone?jQuery(this).clone(true)[0]:this;if(jQuery.nodeName(elem,"script"))scripts=scripts.add(elem);else{if(elem.nodeType==1)scripts=scripts.add(jQuery("script",elem).remove());callback.call(obj,elem);}});scripts.each(evalScript);});}};jQuery.fn.init.prototype=jQuery.fn;function evalScript(i,elem){if(elem.src)jQuery.ajax({url:elem.src,async:false,dataType:"script"});else
+jQuery.globalEval(elem.text||elem.textContent||elem.innerHTML||"");if(elem.parentNode)elem.parentNode.removeChild(elem);}function now(){return+new Date;}jQuery.extend=jQuery.fn.extend=function(){var target=arguments[0]||{},i=1,length=arguments.length,deep=false,options;if(target.constructor==Boolean){deep=target;target=arguments[1]||{};i=2;}if(typeof target!="object"&&typeof target!="function")target={};if(length==i){target=this;--i;}for(;i<length;i++)if((options=arguments[i])!=null)for(var name in options){var src=target[name],copy=options[name];if(target===copy)continue;if(deep&&copy&&typeof copy=="object"&&!copy.nodeType)target[name]=jQuery.extend(deep,src||(copy.length!=null?[]:{}),copy);else if(copy!==undefined)target[name]=copy;}return target;};var expando="jQuery"+now(),uuid=0,windowData={},exclude=/z-?index|font-?weight|opacity|zoom|line-?height/i,defaultView=document.defaultView||{};jQuery.extend({noConflict:function(deep){window.$=_$;if(deep)window.jQuery=_jQuery;return jQuery;},isFunction:function(fn){return!!fn&&typeof fn!="string"&&!fn.nodeName&&fn.constructor!=Array&&/^[\s[]?function/.test(fn+"");},isXMLDoc:function(elem){return elem.documentElement&&!elem.body||elem.tagName&&elem.ownerDocument&&!elem.ownerDocument.body;},globalEval:function(data){data=jQuery.trim(data);if(data){var head=document.getElementsByTagName("head")[0]||document.documentElement,script=document.createElement("script");script.type="text/javascript";if(jQuery.browser.msie)script.text=data;else
+script.appendChild(document.createTextNode(data));head.insertBefore(script,head.firstChild);head.removeChild(script);}},nodeName:function(elem,name){return elem.nodeName&&elem.nodeName.toUpperCase()==name.toUpperCase();},cache:{},data:function(elem,name,data){elem=elem==window?windowData:elem;var id=elem[expando];if(!id)id=elem[expando]=++uuid;if(name&&!jQuery.cache[id])jQuery.cache[id]={};if(data!==undefined)jQuery.cache[id][name]=data;return name?jQuery.cache[id][name]:id;},removeData:function(elem,name){elem=elem==window?windowData:elem;var id=elem[expando];if(name){if(jQuery.cache[id]){delete jQuery.cache[id][name];name="";for(name in jQuery.cache[id])break;if(!name)jQuery.removeData(elem);}}else{try{delete elem[expando];}catch(e){if(elem.removeAttribute)elem.removeAttribute(expando);}delete jQuery.cache[id];}},each:function(object,callback,args){var name,i=0,length=object.length;if(args){if(length==undefined){for(name in object)if(callback.apply(object[name],args)===false)break;}else
+for(;i<length;)if(callback.apply(object[i++],args)===false)break;}else{if(length==undefined){for(name in object)if(callback.call(object[name],name,object[name])===false)break;}else
+for(var value=object[0];i<length&&callback.call(value,i,value)!==false;value=object[++i]){}}return object;},prop:function(elem,value,type,i,name){if(jQuery.isFunction(value))value=value.call(elem,i);return value&&value.constructor==Number&&type=="curCSS"&&!exclude.test(name)?value+"px":value;},className:{add:function(elem,classNames){jQuery.each((classNames||"").split(/\s+/),function(i,className){if(elem.nodeType==1&&!jQuery.className.has(elem.className,className))elem.className+=(elem.className?" ":"")+className;});},remove:function(elem,classNames){if(elem.nodeType==1)elem.className=classNames!=undefined?jQuery.grep(elem.className.split(/\s+/),function(className){return!jQuery.className.has(classNames,className);}).join(" "):"";},has:function(elem,className){return jQuery.inArray(className,(elem.className||elem).toString().split(/\s+/))>-1;}},swap:function(elem,options,callback){var old={};for(var name in options){old[name]=elem.style[name];elem.style[name]=options[name];}callback.call(elem);for(var name in options)elem.style[name]=old[name];},css:function(elem,name,force){if(name=="width"||name=="height"){var val,props={position:"absolute",visibility:"hidden",display:"block"},which=name=="width"?["Left","Right"]:["Top","Bottom"];function getWH(){val=name=="width"?elem.offsetWidth:elem.offsetHeight;var padding=0,border=0;jQuery.each(which,function(){padding+=parseFloat(jQuery.curCSS(elem,"padding"+this,true))||0;border+=parseFloat(jQuery.curCSS(elem,"border"+this+"Width",true))||0;});val-=Math.round(padding+border);}if(jQuery(elem).is(":visible"))getWH();else
+jQuery.swap(elem,props,getWH);return Math.max(0,val);}return jQuery.curCSS(elem,name,force);},curCSS:function(elem,name,force){var ret,style=elem.style;function color(elem){if(!jQuery.browser.safari)return false;var ret=defaultView.getComputedStyle(elem,null);return!ret||ret.getPropertyValue("color")=="";}if(name=="opacity"&&jQuery.browser.msie){ret=jQuery.attr(style,"opacity");return ret==""?"1":ret;}if(jQuery.browser.opera&&name=="display"){var save=style.outline;style.outline="0 solid black";style.outline=save;}if(name.match(/float/i))name=styleFloat;if(!force&&style&&style[name])ret=style[name];else if(defaultView.getComputedStyle){if(name.match(/float/i))name="float";name=name.replace(/([A-Z])/g,"-$1").toLowerCase();var computedStyle=defaultView.getComputedStyle(elem,null);if(computedStyle&&!color(elem))ret=computedStyle.getPropertyValue(name);else{var swap=[],stack=[],a=elem,i=0;for(;a&&color(a);a=a.parentNode)stack.unshift(a);for(;i<stack.length;i++)if(color(stack[i])){swap[i]=stack[i].style.display;stack[i].style.display="block";}ret=name=="display"&&swap[stack.length-1]!=null?"none":(computedStyle&&computedStyle.getPropertyValue(name))||"";for(i=0;i<swap.length;i++)if(swap[i]!=null)stack[i].style.display=swap[i];}if(name=="opacity"&&ret=="")ret="1";}else if(elem.currentStyle){var camelCase=name.replace(/\-(\w)/g,function(all,letter){return letter.toUpperCase();});ret=elem.currentStyle[name]||elem.currentStyle[camelCase];if(!/^\d+(px)?$/i.test(ret)&&/^\d/.test(ret)){var left=style.left,rsLeft=elem.runtimeStyle.left;elem.runtimeStyle.left=elem.currentStyle.left;style.left=ret||0;ret=style.pixelLeft+"px";style.left=left;elem.runtimeStyle.left=rsLeft;}}return ret;},clean:function(elems,context){var ret=[];context=context||document;if(typeof context.createElement=='undefined')context=context.ownerDocument||context[0]&&context[0].ownerDocument||document;jQuery.each(elems,function(i,elem){if(!elem)return;if(elem.constructor==Number)elem+='';if(typeof elem=="string"){elem=elem.replace(/(<(\w+)[^>]*?)\/>/g,function(all,front,tag){return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?all:front+"></"+tag+">";});var tags=jQuery.trim(elem).toLowerCase(),div=context.createElement("div");var wrap=!tags.indexOf("<opt")&&[1,"<select multiple='multiple'>","</select>"]||!tags.indexOf("<leg")&&[1,"<fieldset>","</fieldset>"]||tags.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"<table>","</table>"]||!tags.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!tags.indexOf("<td")||!tags.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||!tags.indexOf("<col")&&[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"]||jQuery.browser.msie&&[1,"div<div>","</div>"]||[0,"",""];div.innerHTML=wrap[1]+elem+wrap[2];while(wrap[0]--)div=div.lastChild;if(jQuery.browser.msie){var tbody=!tags.indexOf("<table")&&tags.indexOf("<tbody")<0?div.firstChild&&div.firstChild.childNodes:wrap[1]=="<table>"&&tags.indexOf("<tbody")<0?div.childNodes:[];for(var j=tbody.length-1;j>=0;--j)if(jQuery.nodeName(tbody[j],"tbody")&&!tbody[j].childNodes.length)tbody[j].parentNode.removeChild(tbody[j]);if(/^\s/.test(elem))div.insertBefore(context.createTextNode(elem.match(/^\s*/)[0]),div.firstChild);}elem=jQuery.makeArray(div.childNodes);}if(elem.length===0&&(!jQuery.nodeName(elem,"form")&&!jQuery.nodeName(elem,"select")))return;if(elem[0]==undefined||jQuery.nodeName(elem,"form")||elem.options)ret.push(elem);else
+ret=jQuery.merge(ret,elem);});return ret;},attr:function(elem,name,value){if(!elem||elem.nodeType==3||elem.nodeType==8)return undefined;var notxml=!jQuery.isXMLDoc(elem),set=value!==undefined,msie=jQuery.browser.msie;name=notxml&&jQuery.props[name]||name;if(elem.tagName){var special=/href|src|style/.test(name);if(name=="selected"&&jQuery.browser.safari)elem.parentNode.selectedIndex;if(name in elem&&notxml&&!special){if(set){if(name=="type"&&jQuery.nodeName(elem,"input")&&elem.parentNode)throw"type property can't be changed";elem[name]=value;}if(jQuery.nodeName(elem,"form")&&elem.getAttributeNode(name))return elem.getAttributeNode(name).nodeValue;return elem[name];}if(msie&&notxml&&name=="style")return jQuery.attr(elem.style,"cssText",value);if(set)elem.setAttribute(name,""+value);var attr=msie&&notxml&&special?elem.getAttribute(name,2):elem.getAttribute(name);return attr===null?undefined:attr;}if(msie&&name=="opacity"){if(set){elem.zoom=1;elem.filter=(elem.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(value)+''=="NaN"?"":"alpha(opacity="+value*100+")");}return elem.filter&&elem.filter.indexOf("opacity=")>=0?(parseFloat(elem.filter.match(/opacity=([^)]*)/)[1])/100)+'':"";}name=name.replace(/-([a-z])/ig,function(all,letter){return letter.toUpperCase();});if(set)elem[name]=value;return elem[name];},trim:function(text){return(text||"").replace(/^\s+|\s+$/g,"");},makeArray:function(array){var ret=[];if(array!=null){var i=array.length;if(i==null||array.split||array.setInterval||array.call)ret[0]=array;else
+while(i)ret[--i]=array[i];}return ret;},inArray:function(elem,array){for(var i=0,length=array.length;i<length;i++)if(array[i]===elem)return i;return-1;},merge:function(first,second){var i=0,elem,pos=first.length;if(jQuery.browser.msie){while(elem=second[i++])if(elem.nodeType!=8)first[pos++]=elem;}else
+while(elem=second[i++])first[pos++]=elem;return first;},unique:function(array){var ret=[],done={};try{for(var i=0,length=array.length;i<length;i++){var id=jQuery.data(array[i]);if(!done[id]){done[id]=true;ret.push(array[i]);}}}catch(e){ret=array;}return ret;},grep:function(elems,callback,inv){var ret=[];for(var i=0,length=elems.length;i<length;i++)if(!inv!=!callback(elems[i],i))ret.push(elems[i]);return ret;},map:function(elems,callback){var ret=[];for(var i=0,length=elems.length;i<length;i++){var value=callback(elems[i],i);if(value!=null)ret[ret.length]=value;}return ret.concat.apply([],ret);}});var userAgent=navigator.userAgent.toLowerCase();jQuery.browser={version:(userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1],safari:/webkit/.test(userAgent),opera:/opera/.test(userAgent),msie:/msie/.test(userAgent)&&!/opera/.test(userAgent),mozilla:/mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent)};var styleFloat=jQuery.browser.msie?"styleFloat":"cssFloat";jQuery.extend({boxModel:!jQuery.browser.msie||document.compatMode=="CSS1Compat",props:{"for":"htmlFor","class":"className","float":styleFloat,cssFloat:styleFloat,styleFloat:styleFloat,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing"}});jQuery.each({parent:function(elem){return elem.parentNode;},parents:function(elem){return jQuery.dir(elem,"parentNode");},next:function(elem){return jQuery.nth(elem,2,"nextSibling");},prev:function(elem){return jQuery.nth(elem,2,"previousSibling");},nextAll:function(elem){return jQuery.dir(elem,"nextSibling");},prevAll:function(elem){return jQuery.dir(elem,"previousSibling");},siblings:function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);},children:function(elem){return jQuery.sibling(elem.firstChild);},contents:function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);}},function(name,fn){jQuery.fn[name]=function(selector){var ret=jQuery.map(this,fn);if(selector&&typeof selector=="string")ret=jQuery.multiFilter(selector,ret);return this.pushStack(jQuery.unique(ret));};});jQuery.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(name,original){jQuery.fn[name]=function(){var args=arguments;return this.each(function(){for(var i=0,length=args.length;i<length;i++)jQuery(args[i])[original](this);});};});jQuery.each({removeAttr:function(name){jQuery.attr(this,name,"");if(this.nodeType==1)this.removeAttribute(name);},addClass:function(classNames){jQuery.className.add(this,classNames);},removeClass:function(classNames){jQuery.className.remove(this,classNames);},toggleClass:function(classNames){jQuery.className[jQuery.className.has(this,classNames)?"remove":"add"](this,classNames);},remove:function(selector){if(!selector||jQuery.filter(selector,[this]).r.length){jQuery("*",this).add(this).each(function(){jQuery.event.remove(this);jQuery.removeData(this);});if(this.parentNode)this.parentNode.removeChild(this);}},empty:function(){jQuery(">*",this).remove();while(this.firstChild)this.removeChild(this.firstChild);}},function(name,fn){jQuery.fn[name]=function(){return this.each(fn,arguments);};});jQuery.each(["Height","Width"],function(i,name){var type=name.toLowerCase();jQuery.fn[type]=function(size){return this[0]==window?jQuery.browser.opera&&document.body["client"+name]||jQuery.browser.safari&&window["inner"+name]||document.compatMode=="CSS1Compat"&&document.documentElement["client"+name]||document.body["client"+name]:this[0]==document?Math.max(Math.max(document.body["scroll"+name],document.documentElement["scroll"+name]),Math.max(document.body["offset"+name],document.documentElement["offset"+name])):size==undefined?(this.length?jQuery.css(this[0],type):null):this.css(type,size.constructor==String?size:size+"px");};});function num(elem,prop){return elem[0]&&parseInt(jQuery.curCSS(elem[0],prop,true),10)||0;}var chars=jQuery.browser.safari&&parseInt(jQuery.browser.version)<417?"(?:[\\w*_-]|\\\\.)":"(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",quickChild=new RegExp("^>\\s*("+chars+"+)"),quickID=new RegExp("^("+chars+"+)(#)("+chars+"+)"),quickClass=new RegExp("^([#.]?)("+chars+"*)");jQuery.extend({expr:{"":function(a,i,m){return m[2]=="*"||jQuery.nodeName(a,m[2]);},"#":function(a,i,m){return a.getAttribute("id")==m[2];},":":{lt:function(a,i,m){return i<m[3]-0;},gt:function(a,i,m){return i>m[3]-0;},nth:function(a,i,m){return m[3]-0==i;},eq:function(a,i,m){return m[3]-0==i;},first:function(a,i){return i==0;},last:function(a,i,m,r){return i==r.length-1;},even:function(a,i){return i%2==0;},odd:function(a,i){return i%2;},"first-child":function(a){return a.parentNode.getElementsByTagName("*")[0]==a;},"last-child":function(a){return jQuery.nth(a.parentNode.lastChild,1,"previousSibling")==a;},"only-child":function(a){return!jQuery.nth(a.parentNode.lastChild,2,"previousSibling");},parent:function(a){return a.firstChild;},empty:function(a){return!a.firstChild;},contains:function(a,i,m){return(a.textContent||a.innerText||jQuery(a).text()||"").indexOf(m[3])>=0;},visible:function(a){return"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden";},hidden:function(a){return"hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden";},enabled:function(a){return!a.disabled;},disabled:function(a){return a.disabled;},checked:function(a){return a.checked;},selected:function(a){return a.selected||jQuery.attr(a,"selected");},text:function(a){return"text"==a.type;},radio:function(a){return"radio"==a.type;},checkbox:function(a){return"checkbox"==a.type;},file:function(a){return"file"==a.type;},password:function(a){return"password"==a.type;},submit:function(a){return"submit"==a.type;},image:function(a){return"image"==a.type;},reset:function(a){return"reset"==a.type;},button:function(a){return"button"==a.type||jQuery.nodeName(a,"button");},input:function(a){return/input|select|textarea|button/i.test(a.nodeName);},has:function(a,i,m){return jQuery.find(m[3],a).length;},header:function(a){return/h\d/i.test(a.nodeName);},animated:function(a){return jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length;}}},parse:[/^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,/^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,new RegExp("^([:.#]*)("+chars+"+)")],multiFilter:function(expr,elems,not){var old,cur=[];while(expr&&expr!=old){old=expr;var f=jQuery.filter(expr,elems,not);expr=f.t.replace(/^\s*,\s*/,"");cur=not?elems=f.r:jQuery.merge(cur,f.r);}return cur;},find:function(t,context){if(typeof t!="string")return[t];if(context&&context.nodeType!=1&&context.nodeType!=9)return[];context=context||document;var ret=[context],done=[],last,nodeName;while(t&&last!=t){var r=[];last=t;t=jQuery.trim(t);var foundToken=false,re=quickChild,m=re.exec(t);if(m){nodeName=m[1].toUpperCase();for(var i=0;ret[i];i++)for(var c=ret[i].firstChild;c;c=c.nextSibling)if(c.nodeType==1&&(nodeName=="*"||c.nodeName.toUpperCase()==nodeName))r.push(c);ret=r;t=t.replace(re,"");if(t.indexOf(" ")==0)continue;foundToken=true;}else{re=/^([>+~])\s*(\w*)/i;if((m=re.exec(t))!=null){r=[];var merge={};nodeName=m[2].toUpperCase();m=m[1];for(var j=0,rl=ret.length;j<rl;j++){var n=m=="~"||m=="+"?ret[j].nextSibling:ret[j].firstChild;for(;n;n=n.nextSibling)if(n.nodeType==1){var id=jQuery.data(n);if(m=="~"&&merge[id])break;if(!nodeName||n.nodeName.toUpperCase()==nodeName){if(m=="~")merge[id]=true;r.push(n);}if(m=="+")break;}}ret=r;t=jQuery.trim(t.replace(re,""));foundToken=true;}}if(t&&!foundToken){if(!t.indexOf(",")){if(context==ret[0])ret.shift();done=jQuery.merge(done,ret);r=ret=[context];t=" "+t.substr(1,t.length);}else{var re2=quickID;var m=re2.exec(t);if(m){m=[0,m[2],m[3],m[1]];}else{re2=quickClass;m=re2.exec(t);}m[2]=m[2].replace(/\\/g,"");var elem=ret[ret.length-1];if(m[1]=="#"&&elem&&elem.getElementById&&!jQuery.isXMLDoc(elem)){var oid=elem.getElementById(m[2]);if((jQuery.browser.msie||jQuery.browser.opera)&&oid&&typeof oid.id=="string"&&oid.id!=m[2])oid=jQuery('[@id="'+m[2]+'"]',elem)[0];ret=r=oid&&(!m[3]||jQuery.nodeName(oid,m[3]))?[oid]:[];}else{for(var i=0;ret[i];i++){var tag=m[1]=="#"&&m[3]?m[3]:m[1]!=""||m[0]==""?"*":m[2];if(tag=="*"&&ret[i].nodeName.toLowerCase()=="object")tag="param";r=jQuery.merge(r,ret[i].getElementsByTagName(tag));}if(m[1]==".")r=jQuery.classFilter(r,m[2]);if(m[1]=="#"){var tmp=[];for(var i=0;r[i];i++)if(r[i].getAttribute("id")==m[2]){tmp=[r[i]];break;}r=tmp;}ret=r;}t=t.replace(re2,"");}}if(t){var val=jQuery.filter(t,r);ret=r=val.r;t=jQuery.trim(val.t);}}if(t)ret=[];if(ret&&context==ret[0])ret.shift();done=jQuery.merge(done,ret);return done;},classFilter:function(r,m,not){m=" "+m+" ";var tmp=[];for(var i=0;r[i];i++){var pass=(" "+r[i].className+" ").indexOf(m)>=0;if(!not&&pass||not&&!pass)tmp.push(r[i]);}return tmp;},filter:function(t,r,not){var last;while(t&&t!=last){last=t;var p=jQuery.parse,m;for(var i=0;p[i];i++){m=p[i].exec(t);if(m){t=t.substring(m[0].length);m[2]=m[2].replace(/\\/g,"");break;}}if(!m)break;if(m[1]==":"&&m[2]=="not")r=isSimple.test(m[3])?jQuery.filter(m[3],r,true).r:jQuery(r).not(m[3]);else if(m[1]==".")r=jQuery.classFilter(r,m[2],not);else if(m[1]=="["){var tmp=[],type=m[3];for(var i=0,rl=r.length;i<rl;i++){var a=r[i],z=a[jQuery.props[m[2]]||m[2]];if(z==null||/href|src|selected/.test(m[2]))z=jQuery.attr(a,m[2])||'';if((type==""&&!!z||type=="="&&z==m[5]||type=="!="&&z!=m[5]||type=="^="&&z&&!z.indexOf(m[5])||type=="$="&&z.substr(z.length-m[5].length)==m[5]||(type=="*="||type=="~=")&&z.indexOf(m[5])>=0)^not)tmp.push(a);}r=tmp;}else if(m[1]==":"&&m[2]=="nth-child"){var merge={},tmp=[],test=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(m[3]=="even"&&"2n"||m[3]=="odd"&&"2n+1"||!/\D/.test(m[3])&&"0n+"+m[3]||m[3]),first=(test[1]+(test[2]||1))-0,last=test[3]-0;for(var i=0,rl=r.length;i<rl;i++){var node=r[i],parentNode=node.parentNode,id=jQuery.data(parentNode);if(!merge[id]){var c=1;for(var n=parentNode.firstChild;n;n=n.nextSibling)if(n.nodeType==1)n.nodeIndex=c++;merge[id]=true;}var add=false;if(first==0){if(node.nodeIndex==last)add=true;}else if((node.nodeIndex-last)%first==0&&(node.nodeIndex-last)/first>=0)add=true;if(add^not)tmp.push(node);}r=tmp;}else{var fn=jQuery.expr[m[1]];if(typeof fn=="object")fn=fn[m[2]];if(typeof fn=="string")fn=eval("false||function(a,i){return "+fn+";}");r=jQuery.grep(r,function(elem,i){return fn(elem,i,m,r);},not);}}return{r:r,t:t};},dir:function(elem,dir){var matched=[],cur=elem[dir];while(cur&&cur!=document){if(cur.nodeType==1)matched.push(cur);cur=cur[dir];}return matched;},nth:function(cur,result,dir,elem){result=result||1;var num=0;for(;cur;cur=cur[dir])if(cur.nodeType==1&&++num==result)break;return cur;},sibling:function(n,elem){var r=[];for(;n;n=n.nextSibling){if(n.nodeType==1&&n!=elem)r.push(n);}return r;}});jQuery.event={add:function(elem,types,handler,data){if(elem.nodeType==3||elem.nodeType==8)return;if(jQuery.browser.msie&&elem.setInterval)elem=window;if(!handler.guid)handler.guid=this.guid++;if(data!=undefined){var fn=handler;handler=this.proxy(fn,function(){return fn.apply(this,arguments);});handler.data=data;}var events=jQuery.data(elem,"events")||jQuery.data(elem,"events",{}),handle=jQuery.data(elem,"handle")||jQuery.data(elem,"handle",function(){if(typeof jQuery!="undefined"&&!jQuery.event.triggered)return jQuery.event.handle.apply(arguments.callee.elem,arguments);});handle.elem=elem;jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];handler.type=parts[1];var handlers=events[type];if(!handlers){handlers=events[type]={};if(!jQuery.event.special[type]||jQuery.event.special[type].setup.call(elem)===false){if(elem.addEventListener)elem.addEventListener(type,handle,false);else if(elem.attachEvent)elem.attachEvent("on"+type,handle);}}handlers[handler.guid]=handler;jQuery.event.global[type]=true;});elem=null;},guid:1,global:{},remove:function(elem,types,handler){if(elem.nodeType==3||elem.nodeType==8)return;var events=jQuery.data(elem,"events"),ret,index;if(events){if(types==undefined||(typeof types=="string"&&types.charAt(0)=="."))for(var type in events)this.remove(elem,type+(types||""));else{if(types.type){handler=types.handler;types=types.type;}jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];if(events[type]){if(handler)delete events[type][handler.guid];else
+for(handler in events[type])if(!parts[1]||events[type][handler].type==parts[1])delete events[type][handler];for(ret in events[type])break;if(!ret){if(!jQuery.event.special[type]||jQuery.event.special[type].teardown.call(elem)===false){if(elem.removeEventListener)elem.removeEventListener(type,jQuery.data(elem,"handle"),false);else if(elem.detachEvent)elem.detachEvent("on"+type,jQuery.data(elem,"handle"));}ret=null;delete events[type];}}});}for(ret in events)break;if(!ret){var handle=jQuery.data(elem,"handle");if(handle)handle.elem=null;jQuery.removeData(elem,"events");jQuery.removeData(elem,"handle");}}},trigger:function(type,data,elem,donative,extra){data=jQuery.makeArray(data);if(type.indexOf("!")>=0){type=type.slice(0,-1);var exclusive=true;}if(!elem){if(this.global[type])jQuery("*").add([window,document]).trigger(type,data);}else{if(elem.nodeType==3||elem.nodeType==8)return undefined;var val,ret,fn=jQuery.isFunction(elem[type]||null),event=!data[0]||!data[0].preventDefault;if(event){data.unshift({type:type,target:elem,preventDefault:function(){},stopPropagation:function(){},timeStamp:now()});data[0][expando]=true;}data[0].type=type;if(exclusive)data[0].exclusive=true;var handle=jQuery.data(elem,"handle");if(handle)val=handle.apply(elem,data);if((!fn||(jQuery.nodeName(elem,'a')&&type=="click"))&&elem["on"+type]&&elem["on"+type].apply(elem,data)===false)val=false;if(event)data.shift();if(extra&&jQuery.isFunction(extra)){ret=extra.apply(elem,val==null?data:data.concat(val));if(ret!==undefined)val=ret;}if(fn&&donative!==false&&val!==false&&!(jQuery.nodeName(elem,'a')&&type=="click")){this.triggered=true;try{elem[type]();}catch(e){}}this.triggered=false;}return val;},handle:function(event){var val,ret,namespace,all,handlers;event=arguments[0]=jQuery.event.fix(event||window.event);namespace=event.type.split(".");event.type=namespace[0];namespace=namespace[1];all=!namespace&&!event.exclusive;handlers=(jQuery.data(this,"events")||{})[event.type];for(var j in handlers){var handler=handlers[j];if(all||handler.type==namespace){event.handler=handler;event.data=handler.data;ret=handler.apply(this,arguments);if(val!==false)val=ret;if(ret===false){event.preventDefault();event.stopPropagation();}}}return val;},fix:function(event){if(event[expando]==true)return event;var originalEvent=event;event={originalEvent:originalEvent};var props="altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target timeStamp toElement type view wheelDelta which".split(" ");for(var i=props.length;i;i--)event[props[i]]=originalEvent[props[i]];event[expando]=true;event.preventDefault=function(){if(originalEvent.preventDefault)originalEvent.preventDefault();originalEvent.returnValue=false;};event.stopPropagation=function(){if(originalEvent.stopPropagation)originalEvent.stopPropagation();originalEvent.cancelBubble=true;};event.timeStamp=event.timeStamp||now();if(!event.target)event.target=event.srcElement||document;if(event.target.nodeType==3)event.target=event.target.parentNode;if(!event.relatedTarget&&event.fromElement)event.relatedTarget=event.fromElement==event.target?event.toElement:event.fromElement;if(event.pageX==null&&event.clientX!=null){var doc=document.documentElement,body=document.body;event.pageX=event.clientX+(doc&&doc.scrollLeft||body&&body.scrollLeft||0)-(doc.clientLeft||0);event.pageY=event.clientY+(doc&&doc.scrollTop||body&&body.scrollTop||0)-(doc.clientTop||0);}if(!event.which&&((event.charCode||event.charCode===0)?event.charCode:event.keyCode))event.which=event.charCode||event.keyCode;if(!event.metaKey&&event.ctrlKey)event.metaKey=event.ctrlKey;if(!event.which&&event.button)event.which=(event.button&1?1:(event.button&2?3:(event.button&4?2:0)));return event;},proxy:function(fn,proxy){proxy.guid=fn.guid=fn.guid||proxy.guid||this.guid++;return proxy;},special:{ready:{setup:function(){bindReady();return;},teardown:function(){return;}},mouseenter:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseover",jQuery.event.special.mouseenter.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseover",jQuery.event.special.mouseenter.handler);return true;},handler:function(event){if(withinElement(event,this))return true;event.type="mouseenter";return jQuery.event.handle.apply(this,arguments);}},mouseleave:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseout",jQuery.event.special.mouseleave.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseout",jQuery.event.special.mouseleave.handler);return true;},handler:function(event){if(withinElement(event,this))return true;event.type="mouseleave";return jQuery.event.handle.apply(this,arguments);}}}};jQuery.fn.extend({bind:function(type,data,fn){return type=="unload"?this.one(type,data,fn):this.each(function(){jQuery.event.add(this,type,fn||data,fn&&data);});},one:function(type,data,fn){var one=jQuery.event.proxy(fn||data,function(event){jQuery(this).unbind(event,one);return(fn||data).apply(this,arguments);});return this.each(function(){jQuery.event.add(this,type,one,fn&&data);});},unbind:function(type,fn){return this.each(function(){jQuery.event.remove(this,type,fn);});},trigger:function(type,data,fn){return this.each(function(){jQuery.event.trigger(type,data,this,true,fn);});},triggerHandler:function(type,data,fn){return this[0]&&jQuery.event.trigger(type,data,this[0],false,fn);},toggle:function(fn){var args=arguments,i=1;while(i<args.length)jQuery.event.proxy(fn,args[i++]);return this.click(jQuery.event.proxy(fn,function(event){this.lastToggle=(this.lastToggle||0)%i;event.preventDefault();return args[this.lastToggle++].apply(this,arguments)||false;}));},hover:function(fnOver,fnOut){return this.bind('mouseenter',fnOver).bind('mouseleave',fnOut);},ready:function(fn){bindReady();if(jQuery.isReady)fn.call(document,jQuery);else
+jQuery.readyList.push(function(){return fn.call(this,jQuery);});return this;}});jQuery.extend({isReady:false,readyList:[],ready:function(){if(!jQuery.isReady){jQuery.isReady=true;if(jQuery.readyList){jQuery.each(jQuery.readyList,function(){this.call(document);});jQuery.readyList=null;}jQuery(document).triggerHandler("ready");}}});var readyBound=false;function bindReady(){if(readyBound)return;readyBound=true;if(document.addEventListener&&!jQuery.browser.opera)document.addEventListener("DOMContentLoaded",jQuery.ready,false);if(jQuery.browser.msie&&window==top)(function(){if(jQuery.isReady)return;try{document.documentElement.doScroll("left");}catch(error){setTimeout(arguments.callee,0);return;}jQuery.ready();})();if(jQuery.browser.opera)document.addEventListener("DOMContentLoaded",function(){if(jQuery.isReady)return;for(var i=0;i<document.styleSheets.length;i++)if(document.styleSheets[i].disabled){setTimeout(arguments.callee,0);return;}jQuery.ready();},false);if(jQuery.browser.safari){var numStyles;(function(){if(jQuery.isReady)return;if(document.readyState!="loaded"&&document.readyState!="complete"){setTimeout(arguments.callee,0);return;}if(numStyles===undefined)numStyles=jQuery("style, link[rel=stylesheet]").length;if(document.styleSheets.length!=numStyles){setTimeout(arguments.callee,0);return;}jQuery.ready();})();}jQuery.event.add(window,"load",jQuery.ready);}jQuery.each(("blur,focus,load,resize,scroll,unload,click,dblclick,"+"mousedown,mouseup,mousemove,mouseover,mouseout,change,select,"+"submit,keydown,keypress,keyup,error").split(","),function(i,name){jQuery.fn[name]=function(fn){return fn?this.bind(name,fn):this.trigger(name);};});var withinElement=function(event,elem){var parent=event.relatedTarget;while(parent&&parent!=elem)try{parent=parent.parentNode;}catch(error){parent=elem;}return parent==elem;};jQuery(window).bind("unload",function(){jQuery("*").add(document).unbind();});jQuery.fn.extend({_load:jQuery.fn.load,load:function(url,params,callback){if(typeof url!='string')return this._load(url);var off=url.indexOf(" ");if(off>=0){var selector=url.slice(off,url.length);url=url.slice(0,off);}callback=callback||function(){};var type="GET";if(params)if(jQuery.isFunction(params)){callback=params;params=null;}else{params=jQuery.param(params);type="POST";}var self=this;jQuery.ajax({url:url,type:type,dataType:"html",data:params,complete:function(res,status){if(status=="success"||status=="notmodified")self.html(selector?jQuery("<div/>").append(res.responseText.replace(/<script(.|\s)*?\/script>/g,"")).find(selector):res.responseText);self.each(callback,[res.responseText,status,res]);}});return this;},serialize:function(){return jQuery.param(this.serializeArray());},serializeArray:function(){return this.map(function(){return jQuery.nodeName(this,"form")?jQuery.makeArray(this.elements):this;}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password/i.test(this.type));}).map(function(i,elem){var val=jQuery(this).val();return val==null?null:val.constructor==Array?jQuery.map(val,function(val,i){return{name:elem.name,value:val};}):{name:elem.name,value:val};}).get();}});jQuery.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(i,o){jQuery.fn[o]=function(f){return this.bind(o,f);};});var jsc=now();jQuery.extend({get:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data=null;}return jQuery.ajax({type:"GET",url:url,data:data,success:callback,dataType:type});},getScript:function(url,callback){return jQuery.get(url,null,callback,"script");},getJSON:function(url,data,callback){return jQuery.get(url,data,callback,"json");},post:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data={};}return jQuery.ajax({type:"POST",url:url,data:data,success:callback,dataType:type});},ajaxSetup:function(settings){jQuery.extend(jQuery.ajaxSettings,settings);},ajaxSettings:{url:location.href,global:true,type:"GET",timeout:0,contentType:"application/x-www-form-urlencoded",processData:true,async:true,data:null,username:null,password:null,accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(s){s=jQuery.extend(true,s,jQuery.extend(true,{},jQuery.ajaxSettings,s));var jsonp,jsre=/=\?(&|$)/g,status,data,type=s.type.toUpperCase();if(s.data&&s.processData&&typeof s.data!="string")s.data=jQuery.param(s.data);if(s.dataType=="jsonp"){if(type=="GET"){if(!s.url.match(jsre))s.url+=(s.url.match(/\?/)?"&":"?")+(s.jsonp||"callback")+"=?";}else if(!s.data||!s.data.match(jsre))s.data=(s.data?s.data+"&":"")+(s.jsonp||"callback")+"=?";s.dataType="json";}if(s.dataType=="json"&&(s.data&&s.data.match(jsre)||s.url.match(jsre))){jsonp="jsonp"+jsc++;if(s.data)s.data=(s.data+"").replace(jsre,"="+jsonp+"$1");s.url=s.url.replace(jsre,"="+jsonp+"$1");s.dataType="script";window[jsonp]=function(tmp){data=tmp;success();complete();window[jsonp]=undefined;try{delete window[jsonp];}catch(e){}if(head)head.removeChild(script);};}if(s.dataType=="script"&&s.cache==null)s.cache=false;if(s.cache===false&&type=="GET"){var ts=now();var ret=s.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+ts+"$2");s.url=ret+((ret==s.url)?(s.url.match(/\?/)?"&":"?")+"_="+ts:"");}if(s.data&&type=="GET"){s.url+=(s.url.match(/\?/)?"&":"?")+s.data;s.data=null;}if(s.global&&!jQuery.active++)jQuery.event.trigger("ajaxStart");var remote=/^(?:\w+:)?\/\/([^\/?#]+)/;if(s.dataType=="script"&&type=="GET"&&remote.test(s.url)&&remote.exec(s.url)[1]!=location.host){var head=document.getElementsByTagName("head")[0];var script=document.createElement("script");script.src=s.url;if(s.scriptCharset)script.charset=s.scriptCharset;if(!jsonp){var done=false;script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){done=true;success();complete();head.removeChild(script);}};}head.appendChild(script);return undefined;}var requestDone=false;var xhr=window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();if(s.username)xhr.open(type,s.url,s.async,s.username,s.password);else
+xhr.open(type,s.url,s.async);try{if(s.data)xhr.setRequestHeader("Content-Type",s.contentType);if(s.ifModified)xhr.setRequestHeader("If-Modified-Since",jQuery.lastModified[s.url]||"Thu, 01 Jan 1970 00:00:00 GMT");xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");xhr.setRequestHeader("Accept",s.dataType&&s.accepts[s.dataType]?s.accepts[s.dataType]+", */*":s.accepts._default);}catch(e){}if(s.beforeSend&&s.beforeSend(xhr,s)===false){s.global&&jQuery.active--;xhr.abort();return false;}if(s.global)jQuery.event.trigger("ajaxSend",[xhr,s]);var onreadystatechange=function(isTimeout){if(!requestDone&&xhr&&(xhr.readyState==4||isTimeout=="timeout")){requestDone=true;if(ival){clearInterval(ival);ival=null;}status=isTimeout=="timeout"&&"timeout"||!jQuery.httpSuccess(xhr)&&"error"||s.ifModified&&jQuery.httpNotModified(xhr,s.url)&&"notmodified"||"success";if(status=="success"){try{data=jQuery.httpData(xhr,s.dataType,s.dataFilter);}catch(e){status="parsererror";}}if(status=="success"){var modRes;try{modRes=xhr.getResponseHeader("Last-Modified");}catch(e){}if(s.ifModified&&modRes)jQuery.lastModified[s.url]=modRes;if(!jsonp)success();}else
+jQuery.handleError(s,xhr,status);complete();if(s.async)xhr=null;}};if(s.async){var ival=setInterval(onreadystatechange,13);if(s.timeout>0)setTimeout(function(){if(xhr){xhr.abort();if(!requestDone)onreadystatechange("timeout");}},s.timeout);}try{xhr.send(s.data);}catch(e){jQuery.handleError(s,xhr,null,e);}if(!s.async)onreadystatechange();function success(){if(s.success)s.success(data,status);if(s.global)jQuery.event.trigger("ajaxSuccess",[xhr,s]);}function complete(){if(s.complete)s.complete(xhr,status);if(s.global)jQuery.event.trigger("ajaxComplete",[xhr,s]);if(s.global&&!--jQuery.active)jQuery.event.trigger("ajaxStop");}return xhr;},handleError:function(s,xhr,status,e){if(s.error)s.error(xhr,status,e);if(s.global)jQuery.event.trigger("ajaxError",[xhr,s,e]);},active:0,httpSuccess:function(xhr){try{return!xhr.status&&location.protocol=="file:"||(xhr.status>=200&&xhr.status<300)||xhr.status==304||xhr.status==1223||jQuery.browser.safari&&xhr.status==undefined;}catch(e){}return false;},httpNotModified:function(xhr,url){try{var xhrRes=xhr.getResponseHeader("Last-Modified");return xhr.status==304||xhrRes==jQuery.lastModified[url]||jQuery.browser.safari&&xhr.status==undefined;}catch(e){}return false;},httpData:function(xhr,type,filter){var ct=xhr.getResponseHeader("content-type"),xml=type=="xml"||!type&&ct&&ct.indexOf("xml")>=0,data=xml?xhr.responseXML:xhr.responseText;if(xml&&data.documentElement.tagName=="parsererror")throw"parsererror";if(filter)data=filter(data,type);if(type=="script")jQuery.globalEval(data);if(type=="json")data=eval("("+data+")");return data;},param:function(a){var s=[];if(a.constructor==Array||a.jquery)jQuery.each(a,function(){s.push(encodeURIComponent(this.name)+"="+encodeURIComponent(this.value));});else
+for(var j in a)if(a[j]&&a[j].constructor==Array)jQuery.each(a[j],function(){s.push(encodeURIComponent(j)+"="+encodeURIComponent(this));});else
+s.push(encodeURIComponent(j)+"="+encodeURIComponent(jQuery.isFunction(a[j])?a[j]():a[j]));return s.join("&").replace(/%20/g,"+");}});jQuery.fn.extend({show:function(speed,callback){return speed?this.animate({height:"show",width:"show",opacity:"show"},speed,callback):this.filter(":hidden").each(function(){this.style.display=this.oldblock||"";if(jQuery.css(this,"display")=="none"){var elem=jQuery("<"+this.tagName+" />").appendTo("body");this.style.display=elem.css("display");if(this.style.display=="none")this.style.display="block";elem.remove();}}).end();},hide:function(speed,callback){return speed?this.animate({height:"hide",width:"hide",opacity:"hide"},speed,callback):this.filter(":visible").each(function(){this.oldblock=this.oldblock||jQuery.css(this,"display");this.style.display="none";}).end();},_toggle:jQuery.fn.toggle,toggle:function(fn,fn2){return jQuery.isFunction(fn)&&jQuery.isFunction(fn2)?this._toggle.apply(this,arguments):fn?this.animate({height:"toggle",width:"toggle",opacity:"toggle"},fn,fn2):this.each(function(){jQuery(this)[jQuery(this).is(":hidden")?"show":"hide"]();});},slideDown:function(speed,callback){return this.animate({height:"show"},speed,callback);},slideUp:function(speed,callback){return this.animate({height:"hide"},speed,callback);},slideToggle:function(speed,callback){return this.animate({height:"toggle"},speed,callback);},fadeIn:function(speed,callback){return this.animate({opacity:"show"},speed,callback);},fadeOut:function(speed,callback){return this.animate({opacity:"hide"},speed,callback);},fadeTo:function(speed,to,callback){return this.animate({opacity:to},speed,callback);},animate:function(prop,speed,easing,callback){var optall=jQuery.speed(speed,easing,callback);return this[optall.queue===false?"each":"queue"](function(){if(this.nodeType!=1)return false;var opt=jQuery.extend({},optall),p,hidden=jQuery(this).is(":hidden"),self=this;for(p in prop){if(prop[p]=="hide"&&hidden||prop[p]=="show"&&!hidden)return opt.complete.call(this);if(p=="height"||p=="width"){opt.display=jQuery.css(this,"display");opt.overflow=this.style.overflow;}}if(opt.overflow!=null)this.style.overflow="hidden";opt.curAnim=jQuery.extend({},prop);jQuery.each(prop,function(name,val){var e=new jQuery.fx(self,opt,name);if(/toggle|show|hide/.test(val))e[val=="toggle"?hidden?"show":"hide":val](prop);else{var parts=val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),start=e.cur(true)||0;if(parts){var end=parseFloat(parts[2]),unit=parts[3]||"px";if(unit!="px"){self.style[name]=(end||1)+unit;start=((end||1)/e.cur(true))*start;self.style[name]=start+unit;}if(parts[1])end=((parts[1]=="-="?-1:1)*end)+start;e.custom(start,end,unit);}else
+e.custom(start,val,"");}});return true;});},queue:function(type,fn){if(jQuery.isFunction(type)||(type&&type.constructor==Array)){fn=type;type="fx";}if(!type||(typeof type=="string"&&!fn))return queue(this[0],type);return this.each(function(){if(fn.constructor==Array)queue(this,type,fn);else{queue(this,type).push(fn);if(queue(this,type).length==1)fn.call(this);}});},stop:function(clearQueue,gotoEnd){var timers=jQuery.timers;if(clearQueue)this.queue([]);this.each(function(){for(var i=timers.length-1;i>=0;i--)if(timers[i].elem==this){if(gotoEnd)timers[i](true);timers.splice(i,1);}});if(!gotoEnd)this.dequeue();return this;}});var queue=function(elem,type,array){if(elem){type=type||"fx";var q=jQuery.data(elem,type+"queue");if(!q||array)q=jQuery.data(elem,type+"queue",jQuery.makeArray(array));}return q;};jQuery.fn.dequeue=function(type){type=type||"fx";return this.each(function(){var q=queue(this,type);q.shift();if(q.length)q[0].call(this);});};jQuery.extend({speed:function(speed,easing,fn){var opt=speed&&speed.constructor==Object?speed:{complete:fn||!fn&&easing||jQuery.isFunction(speed)&&speed,duration:speed,easing:fn&&easing||easing&&easing.constructor!=Function&&easing};opt.duration=(opt.duration&&opt.duration.constructor==Number?opt.duration:jQuery.fx.speeds[opt.duration])||jQuery.fx.speeds.def;opt.old=opt.complete;opt.complete=function(){if(opt.queue!==false)jQuery(this).dequeue();if(jQuery.isFunction(opt.old))opt.old.call(this);};return opt;},easing:{linear:function(p,n,firstNum,diff){return firstNum+diff*p;},swing:function(p,n,firstNum,diff){return((-Math.cos(p*Math.PI)/2)+0.5)*diff+firstNum;}},timers:[],timerId:null,fx:function(elem,options,prop){this.options=options;this.elem=elem;this.prop=prop;if(!options.orig)options.orig={};}});jQuery.fx.prototype={update:function(){if(this.options.step)this.options.step.call(this.elem,this.now,this);(jQuery.fx.step[this.prop]||jQuery.fx.step._default)(this);if(this.prop=="height"||this.prop=="width")this.elem.style.display="block";},cur:function(force){if(this.elem[this.prop]!=null&&this.elem.style[this.prop]==null)return this.elem[this.prop];var r=parseFloat(jQuery.css(this.elem,this.prop,force));return r&&r>-10000?r:parseFloat(jQuery.curCSS(this.elem,this.prop))||0;},custom:function(from,to,unit){this.startTime=now();this.start=from;this.end=to;this.unit=unit||this.unit||"px";this.now=this.start;this.pos=this.state=0;this.update();var self=this;function t(gotoEnd){return self.step(gotoEnd);}t.elem=this.elem;jQuery.timers.push(t);if(jQuery.timerId==null){jQuery.timerId=setInterval(function(){var timers=jQuery.timers;for(var i=0;i<timers.length;i++)if(!timers[i]())timers.splice(i--,1);if(!timers.length){clearInterval(jQuery.timerId);jQuery.timerId=null;}},13);}},show:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);this.options.show=true;this.custom(0,this.cur());if(this.prop=="width"||this.prop=="height")this.elem.style[this.prop]="1px";jQuery(this.elem).show();},hide:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);this.options.hide=true;this.custom(this.cur(),0);},step:function(gotoEnd){var t=now();if(gotoEnd||t>this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var done=true;for(var i in this.options.curAnim)if(this.options.curAnim[i]!==true)done=false;if(done){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(jQuery.css(this.elem,"display")=="none")this.elem.style.display="block";}if(this.options.hide)this.elem.style.display="none";if(this.options.hide||this.options.show)for(var p in this.options.curAnim)jQuery.attr(this.elem.style,p,this.options.orig[p]);}if(done)this.options.complete.call(this.elem);return false;}else{var n=t-this.startTime;this.state=n/this.options.duration;this.pos=jQuery.easing[this.options.easing||(jQuery.easing.swing?"swing":"linear")](this.state,n,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update();}return true;}};jQuery.extend(jQuery.fx,{speeds:{slow:600,fast:200,def:400},step:{scrollLeft:function(fx){fx.elem.scrollLeft=fx.now;},scrollTop:function(fx){fx.elem.scrollTop=fx.now;},opacity:function(fx){jQuery.attr(fx.elem.style,"opacity",fx.now);},_default:function(fx){fx.elem.style[fx.prop]=fx.now+fx.unit;}}});jQuery.fn.offset=function(){var left=0,top=0,elem=this[0],results;if(elem)with(jQuery.browser){var parent=elem.parentNode,offsetChild=elem,offsetParent=elem.offsetParent,doc=elem.ownerDocument,safari2=safari&&parseInt(version)<522&&!/adobeair/i.test(userAgent),css=jQuery.curCSS,fixed=css(elem,"position")=="fixed";if(elem.getBoundingClientRect){var box=elem.getBoundingClientRect();add(box.left+Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),box.top+Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));add(-doc.documentElement.clientLeft,-doc.documentElement.clientTop);}else{add(elem.offsetLeft,elem.offsetTop);while(offsetParent){add(offsetParent.offsetLeft,offsetParent.offsetTop);if(mozilla&&!/^t(able|d|h)$/i.test(offsetParent.tagName)||safari&&!safari2)border(offsetParent);if(!fixed&&css(offsetParent,"position")=="fixed")fixed=true;offsetChild=/^body$/i.test(offsetParent.tagName)?offsetChild:offsetParent;offsetParent=offsetParent.offsetParent;}while(parent&&parent.tagName&&!/^body|html$/i.test(parent.tagName)){if(!/^inline|table.*$/i.test(css(parent,"display")))add(-parent.scrollLeft,-parent.scrollTop);if(mozilla&&css(parent,"overflow")!="visible")border(parent);parent=parent.parentNode;}if((safari2&&(fixed||css(offsetChild,"position")=="absolute"))||(mozilla&&css(offsetChild,"position")!="absolute"))add(-doc.body.offsetLeft,-doc.body.offsetTop);if(fixed)add(Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));}results={top:top,left:left};}function border(elem){add(jQuery.curCSS(elem,"borderLeftWidth",true),jQuery.curCSS(elem,"borderTopWidth",true));}function add(l,t){left+=parseInt(l,10)||0;top+=parseInt(t,10)||0;}return results;};jQuery.fn.extend({position:function(){var left=0,top=0,results;if(this[0]){var offsetParent=this.offsetParent(),offset=this.offset(),parentOffset=/^body|html$/i.test(offsetParent[0].tagName)?{top:0,left:0}:offsetParent.offset();offset.top-=num(this,'marginTop');offset.left-=num(this,'marginLeft');parentOffset.top+=num(offsetParent,'borderTopWidth');parentOffset.left+=num(offsetParent,'borderLeftWidth');results={top:offset.top-parentOffset.top,left:offset.left-parentOffset.left};}return results;},offsetParent:function(){var offsetParent=this[0].offsetParent;while(offsetParent&&(!/^body|html$/i.test(offsetParent.tagName)&&jQuery.css(offsetParent,'position')=='static'))offsetParent=offsetParent.offsetParent;return jQuery(offsetParent);}});jQuery.each(['Left','Top'],function(i,name){var method='scroll'+name;jQuery.fn[method]=function(val){if(!this[0])return;return val!=undefined?this.each(function(){this==window||this==document?window.scrollTo(!i?val:jQuery(window).scrollLeft(),i?val:jQuery(window).scrollTop()):this[method]=val;}):this[0]==window||this[0]==document?self[i?'pageYOffset':'pageXOffset']||jQuery.boxModel&&document.documentElement[method]||document.body[method]:this[0][method];};});jQuery.each(["Height","Width"],function(i,name){var tl=i?"Left":"Top",br=i?"Right":"Bottom";jQuery.fn["inner"+name]=function(){return this[name.toLowerCase()]()+num(this,"padding"+tl)+num(this,"padding"+br);};jQuery.fn["outer"+name]=function(margin){return this["inner"+name]()+num(this,"border"+tl+"Width")+num(this,"border"+br+"Width")+(margin?num(this,"margin"+tl)+num(this,"margin"+br):0);};});})(); \ No newline at end of file
diff --git a/doc/_themes/pysidedocs/static/logo_indt.jpg b/doc/_themes/pysidedocs/static/logo_indt.jpg
new file mode 100644
index 000000000..2a1fbe7a1
--- /dev/null
+++ b/doc/_themes/pysidedocs/static/logo_indt.jpg
Binary files differ
diff --git a/doc/_themes/pysidedocs/static/logo_openbossa.png b/doc/_themes/pysidedocs/static/logo_openbossa.png
new file mode 100644
index 000000000..51e868d6e
--- /dev/null
+++ b/doc/_themes/pysidedocs/static/logo_openbossa.png
Binary files differ
diff --git a/doc/_themes/pysidedocs/static/logo_python.jpg b/doc/_themes/pysidedocs/static/logo_python.jpg
new file mode 100644
index 000000000..cd474efba
--- /dev/null
+++ b/doc/_themes/pysidedocs/static/logo_python.jpg
Binary files differ
diff --git a/doc/_themes/pysidedocs/static/logo_qt.png b/doc/_themes/pysidedocs/static/logo_qt.png
new file mode 100644
index 000000000..37800f454
--- /dev/null
+++ b/doc/_themes/pysidedocs/static/logo_qt.png
Binary files differ
diff --git a/doc/_themes/pysidedocs/static/pysidedocs.css b/doc/_themes/pysidedocs/static/pysidedocs.css
new file mode 100644
index 000000000..2d99138d4
--- /dev/null
+++ b/doc/_themes/pysidedocs/static/pysidedocs.css
@@ -0,0 +1,412 @@
+* {
+ font: 100% Verdana, Arial, Helvetica, sans-serif;
+ font-size:12px;
+}
+
+html {
+ height: 100%;
+}
+
+body {
+ margin: 0;
+ padding: 0;
+ background-color: #EBEBEB;
+ height: 100%;
+ color: #333;
+}
+
+strong {
+ font-weight:bold;
+}
+
+#body {
+ padding-bottom: 90px;
+}
+
+#container {
+ position: relative;
+ min-height: 100%;
+ background-image: url(fakebar.png);
+ background-repeat: repeat-y;
+ background-color: white;
+}
+
+#footer {
+ position:absolute;
+ bottom: 0px;
+ margin-top: 50px;
+ text-align:center;
+ background-color: white;
+ border-top: 2px solid #e0e0e0;
+ white-space: nowrap;
+ height: 90px;
+ width: 100%;
+}
+
+#footer img {
+ margin-left: 8px;
+ margin-right: 8px;
+}
+
+#sidebar {
+ float: left;
+ width: 250px;
+ padding: 0px 10px 0px 10px;
+ text-align: left;
+}
+
+#sidebar ul {
+ padding: 0px;
+ margin: 0px;
+ list-style-position: inside;
+}
+
+#sidebar > ul {
+ padding: 0px;
+ margin: 0px;
+}
+
+#sidebar ul li {
+ margin-left: 10px;
+ padding: 0px;
+}
+
+#sidebar h3, #sidebar h3 a {
+ font-weight: bold;
+ color: #333;
+}
+
+#body > div.section {
+ margin-left: 270px;
+ text-align: left;
+ background-color: #ffffff;
+ border-left: 1px solid #989898;
+ font-size:18px;
+ padding: 10px 50px 15px 50px;
+ height: 100%;
+}
+
+h1 {
+ font-size:18px;
+ padding-left: 50px;
+ padding-bottom: 15px;
+ padding-top: 15px;
+ border-bottom: 1px solid #c2c2c2;
+ text-transform:uppercase;
+ margin-right: -100px;
+ position: relative;
+ left: -50px;
+ top: -10px;
+}
+
+h2 {
+ font-size:12px;
+ font-weight:bold;
+ border-left-width: 1px;
+ border-right-width: 1px;
+ border-top-width: 1px;
+ border-bottom-width: 2px;
+ border-style: solid;
+ border-left-color: #b1b1b1;
+ border-right-color: #b1b1b1;
+ border-top-color: #b1b1b1;
+ border-bottom-color: #009491;
+ background-color: #e0e0e0;
+ padding:5px;
+ margin-top: 20px;
+ -moz-border-radius:5px;
+ -webkit-border-radius:5px;
+ -khtml-border-radius:5px;
+}
+
+h3, h4 {
+ font-weight: bolder;
+}
+
+pre {
+ border-top: 1px solid #e0e0e0;
+ border-bottom: 1px solid #e0e0e0;
+ background-color: #fafafa;
+ padding: 5px;
+ font: 100% monospace;
+ overflow: auto;
+}
+
+pre * {
+ font: 100% monospace;
+}
+
+.headerlink {
+ display: none;
+}
+
+a, a:visited {
+ color: #009491;
+ text-decoration: none;
+}
+
+a:hover {
+ text-decoration: underline;
+}
+
+/* -- admonitions ----------------------------------------------------------- */
+
+div.admonition {
+ margin-top: 10px;
+ margin-bottom: 10px;
+ padding: 7px;
+}
+
+div.admonition dt {
+ font-weight: bold;
+}
+
+div.admonition dl {
+ margin-bottom: 0;
+}
+
+p.admonition-title {
+ margin: 0px 10px 5px 0px;
+ font-weight: bold;
+}
+
+div.body p.centered {
+ text-align: center;
+ margin-top: 25px;
+}
+
+div.warning {
+ background-color: #ffe4e4;
+ border: 1px solid #f66;
+}
+
+div.seealso {
+ background-color: #ffffcc;
+ border: 1px solid #ffff66;
+}
+
+div.note {
+ border: 1px solid #e3e3e3;
+}
+
+table.docutils {
+ margin-left: auto;
+ margin-right: auto;
+ margin-bottom: 10px;
+ border: none;
+}
+
+table.docutils td {
+ border: none;
+}
+
+table.docutils th {
+ border: none;
+ font-weight: bold;
+ vertical-align: top;
+}
+
+h2 em {
+ float: right;
+ font-size: 10px;
+ position: relative;
+ top: -20px;
+}
+
+/* Table of pymaemo components */
+
+#development table.docutils td {
+ border-bottom: 1px solid #EBEBEB;
+}
+
+#development th {
+ background-color: #EBEBEB;
+ color: #FC7E00;
+ padding: 5px;
+}
+
+#development th:first-child {
+ -moz-border-radius: 20px 0px 0px 0px;
+ -webkit-border-radius: 20px 0px 0px 0px;
+ -khtml-border-radius: 20px 0px 0px 0px;
+ padding-left: 10px;
+}
+#development th:last-child {
+ -moz-border-radius: 0px 20px 0px 0px;
+ -webkit-border-radius: 0px 20px 0px 0px;
+ -khtml-border-radius: 0px 20px 0px 0px;
+ padding-right: 10px;
+ width: 100px;
+}
+
+hr {
+ border: none;
+ border-bottom: 1px dashed #EBEBEB;
+ width: 70%
+}
+
+.oldnews {
+ text-align: right;
+}
+
+/******************* TOPO *****************************/
+#header {
+ background-image: url(bg_topo.jpg);
+ background-repeat: repeat-x;
+ height: 147px;
+}
+
+#header_container {
+ background-image: url(bg_header.png);
+ background-repeat: no-repeat;
+ background-position: 100px 0px;
+}
+
+#logo {
+ background-image: url(pysidelogo.png);
+ background-repeat: no-repeat;
+/* background-position: 0px 4px; */
+ height: 112px;
+}
+
+#search_box {
+ border-top: 1px solid #989898;
+ padding-top: 10px;
+ margin-left: -10px;
+ margin-right: -10px;
+ padding-left: 10px;
+ padding-right: 10px;
+}
+
+#search_button {
+ border: 1px solid #3A393A;
+ background-color: #3A393A;
+ color: white;
+ cursor: pointer;
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ -khtml-border-radius: 5px;
+
+}
+
+form {
+ margin: 0px;
+ padding: 0px;
+}
+
+/* search field */
+form #q {
+ width: 136px;
+/* height: 22px; */
+ border: none;
+ margin: 0px;
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ -khtml-border-radius: 5px;
+ margin-top: 2px;
+ padding: 4px;
+ line-height: 22px
+}
+
+#search-results h2 {
+ display: none;
+}
+
+#search-results h2 {
+ display: none;
+}
+
+#search-results ul.search {
+ margin: 0px;
+ padding: 0px;
+}
+
+ul.search div.context {
+ padding-left: 40px;
+}
+
+#installation td {
+ text-align: center;
+ font-weight: bold;
+}
+
+em {
+ color: inherit;
+ font-style:italic;
+}
+
+/******** REL bar *********/
+
+#relbar {
+ padding: 0px 10px 0px 10px;
+ margin: 0px;
+ text-align: left;
+ background-image: url(relbar_bg.png);
+}
+
+#relbar li {
+ display: inline;
+ color: white;
+ font-weight: bold;
+}
+
+#relbar li a {
+ color: inherit;
+ line-height: 35px;
+ font-weight: bold;
+ vertical-align: middle;
+}
+
+#relbar li.right {
+ float: right;
+ margin-right: 5px;
+}
+
+.align-center {
+ text-align: center;
+}
+
+.contentstable {
+ width: 100%;
+}
+
+.contentstable td {
+ padding-left: 30px;
+ vertical-align: top;
+}
+
+p.biglink a {
+ font-size: 20px;
+}
+
+dt:target, .highlight {
+ background-color: #fbe54e;
+}
+
+img {
+ border: 0px;
+}
+
+.figure .caption {
+ font-style:italic;
+}
+
+table.footnote {
+ margin: 0px;
+}
+
+#synopsis table, table.field-list {
+ margin: 0px;
+}
+
+tt.descname {
+ font-weight: bold;
+}
+
+dl.method {
+ border-top: 1px solid #c2c2c2;
+ margin-right: -100px;
+ position: relative;
+ left: -50px;
+ padding: 10px 50px 0px 50px;
+}
diff --git a/doc/_themes/pysidedocs/static/pysidelogo.png b/doc/_themes/pysidedocs/static/pysidelogo.png
new file mode 100644
index 000000000..076c1057c
--- /dev/null
+++ b/doc/_themes/pysidedocs/static/pysidelogo.png
Binary files differ
diff --git a/doc/_themes/pysidedocs/static/relbar_bg.png b/doc/_themes/pysidedocs/static/relbar_bg.png
new file mode 100644
index 000000000..4036733a7
--- /dev/null
+++ b/doc/_themes/pysidedocs/static/relbar_bg.png
Binary files differ
diff --git a/doc/_themes/pysidedocs/static/searchtools.js b/doc/_themes/pysidedocs/static/searchtools.js
new file mode 100644
index 000000000..e0226258a
--- /dev/null
+++ b/doc/_themes/pysidedocs/static/searchtools.js
@@ -0,0 +1,467 @@
+/**
+ * helper function to return a node containing the
+ * search summary for a given text. keywords is a list
+ * of stemmed words, hlwords is the list of normal, unstemmed
+ * words. the first one is used to find the occurance, the
+ * latter for highlighting it.
+ */
+
+jQuery.makeSearchSummary = function(text, keywords, hlwords) {
+ var textLower = text.toLowerCase();
+ var start = 0;
+ $.each(keywords, function() {
+ var i = textLower.indexOf(this.toLowerCase());
+ if (i > -1)
+ start = i;
+ });
+ start = Math.max(start - 120, 0);
+ var excerpt = ((start > 0) ? '...' : '') +
+ $.trim(text.substr(start, 240)) +
+ ((start + 240 - text.length) ? '...' : '');
+ var rv = $('<div class="context"></div>').text(excerpt);
+ $.each(hlwords, function() {
+ rv = rv.highlightText(this, 'highlight');
+ });
+ return rv;
+}
+
+/**
+ * Porter Stemmer
+ */
+var PorterStemmer = function() {
+
+ var step2list = {
+ ational: 'ate',
+ tional: 'tion',
+ enci: 'ence',
+ anci: 'ance',
+ izer: 'ize',
+ bli: 'ble',
+ alli: 'al',
+ entli: 'ent',
+ eli: 'e',
+ ousli: 'ous',
+ ization: 'ize',
+ ation: 'ate',
+ ator: 'ate',
+ alism: 'al',
+ iveness: 'ive',
+ fulness: 'ful',
+ ousness: 'ous',
+ aliti: 'al',
+ iviti: 'ive',
+ biliti: 'ble',
+ logi: 'log'
+ };
+
+ var step3list = {
+ icate: 'ic',
+ ative: '',
+ alize: 'al',
+ iciti: 'ic',
+ ical: 'ic',
+ ful: '',
+ ness: ''
+ };
+
+ var c = "[^aeiou]"; // consonant
+ var v = "[aeiouy]"; // vowel
+ var C = c + "[^aeiouy]*"; // consonant sequence
+ var V = v + "[aeiou]*"; // vowel sequence
+
+ var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0
+ var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1
+ var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1
+ var s_v = "^(" + C + ")?" + v; // vowel in stem
+
+ this.stemWord = function (w) {
+ var stem;
+ var suffix;
+ var firstch;
+ var origword = w;
+
+ if (w.length < 3)
+ return w;
+
+ var re;
+ var re2;
+ var re3;
+ var re4;
+
+ firstch = w.substr(0,1);
+ if (firstch == "y")
+ w = firstch.toUpperCase() + w.substr(1);
+
+ // Step 1a
+ re = /^(.+?)(ss|i)es$/;
+ re2 = /^(.+?)([^s])s$/;
+
+ if (re.test(w))
+ w = w.replace(re,"$1$2");
+ else if (re2.test(w))
+ w = w.replace(re2,"$1$2");
+
+ // Step 1b
+ re = /^(.+?)eed$/;
+ re2 = /^(.+?)(ed|ing)$/;
+ if (re.test(w)) {
+ var fp = re.exec(w);
+ re = new RegExp(mgr0);
+ if (re.test(fp[1])) {
+ re = /.$/;
+ w = w.replace(re,"");
+ }
+ }
+ else if (re2.test(w)) {
+ var fp = re2.exec(w);
+ stem = fp[1];
+ re2 = new RegExp(s_v);
+ if (re2.test(stem)) {
+ w = stem;
+ re2 = /(at|bl|iz)$/;
+ re3 = new RegExp("([^aeiouylsz])\\1$");
+ re4 = new RegExp("^" + C + v + "[^aeiouwxy]$");
+ if (re2.test(w))
+ w = w + "e";
+ else if (re3.test(w)) {
+ re = /.$/;
+ w = w.replace(re,"");
+ }
+ else if (re4.test(w))
+ w = w + "e";
+ }
+ }
+
+ // Step 1c
+ re = /^(.+?)y$/;
+ if (re.test(w)) {
+ var fp = re.exec(w);
+ stem = fp[1];
+ re = new RegExp(s_v);
+ if (re.test(stem))
+ w = stem + "i";
+ }
+
+ // Step 2
+ re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;
+ if (re.test(w)) {
+ var fp = re.exec(w);
+ stem = fp[1];
+ suffix = fp[2];
+ re = new RegExp(mgr0);
+ if (re.test(stem))
+ w = stem + step2list[suffix];
+ }
+
+ // Step 3
+ re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;
+ if (re.test(w)) {
+ var fp = re.exec(w);
+ stem = fp[1];
+ suffix = fp[2];
+ re = new RegExp(mgr0);
+ if (re.test(stem))
+ w = stem + step3list[suffix];
+ }
+
+ // Step 4
+ re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;
+ re2 = /^(.+?)(s|t)(ion)$/;
+ if (re.test(w)) {
+ var fp = re.exec(w);
+ stem = fp[1];
+ re = new RegExp(mgr1);
+ if (re.test(stem))
+ w = stem;
+ }
+ else if (re2.test(w)) {
+ var fp = re2.exec(w);
+ stem = fp[1] + fp[2];
+ re2 = new RegExp(mgr1);
+ if (re2.test(stem))
+ w = stem;
+ }
+
+ // Step 5
+ re = /^(.+?)e$/;
+ if (re.test(w)) {
+ var fp = re.exec(w);
+ stem = fp[1];
+ re = new RegExp(mgr1);
+ re2 = new RegExp(meq1);
+ re3 = new RegExp("^" + C + v + "[^aeiouwxy]$");
+ if (re.test(stem) || (re2.test(stem) && !(re3.test(stem))))
+ w = stem;
+ }
+ re = /ll$/;
+ re2 = new RegExp(mgr1);
+ if (re.test(w) && re2.test(w)) {
+ re = /.$/;
+ w = w.replace(re,"");
+ }
+
+ // and turn initial Y back to y
+ if (firstch == "y")
+ w = firstch.toLowerCase() + w.substr(1);
+ return w;
+ }
+}
+
+
+/**
+ * Search Module
+ */
+var Search = {
+
+ _index : null,
+ _queued_query : null,
+ _pulse_status : -1,
+
+ init : function() {
+ var params = $.getQueryParameters();
+ if (params.q) {
+ var query = params.q[0];
+ $('input[name="q"]')[0].value = query;
+ this.performSearch(query);
+ }
+ },
+
+ /**
+ * Sets the index
+ */
+ setIndex : function(index) {
+ var q;
+ this._index = index;
+ if ((q = this._queued_query) !== null) {
+ this._queued_query = null;
+ Search.query(q);
+ }
+ },
+
+ hasIndex : function() {
+ return this._index !== null;
+ },
+
+ deferQuery : function(query) {
+ this._queued_query = query;
+ },
+
+ stopPulse : function() {
+ this._pulse_status = 0;
+ },
+
+ startPulse : function() {
+ if (this._pulse_status >= 0)
+ return;
+ function pulse() {
+ Search._pulse_status = (Search._pulse_status + 1) % 4;
+ var dotString = '';
+ for (var i = 0; i < Search._pulse_status; i++)
+ dotString += '.';
+ Search.dots.text(dotString);
+ if (Search._pulse_status > -1)
+ window.setTimeout(pulse, 500);
+ };
+ pulse();
+ },
+
+ /**
+ * perform a search for something
+ */
+ performSearch : function(query) {
+ // create the required interface elements
+ this.out = $('#search-results');
+ this.title = $('<h2>' + _('Searching') + '</h2>').appendTo(this.out);
+ this.dots = $('<span></span>').appendTo(this.title);
+ this.status = $('<p style="display: none"></p>').appendTo(this.out);
+ this.output = $('<ul class="search"/>').appendTo(this.out);
+
+ $('#search-progress').text(_('Preparing search...'));
+ this.startPulse();
+
+ // index already loaded, the browser was quick!
+ if (this.hasIndex())
+ this.query(query);
+ else
+ this.deferQuery(query);
+ },
+
+ query : function(query) {
+ // stem the searchterms and add them to the
+ // correct list
+ var stemmer = new PorterStemmer();
+ var searchterms = [];
+ var excluded = [];
+ var hlterms = [];
+ var tmp = query.split(/\s+/);
+ var object = (tmp.length == 1) ? tmp[0].toLowerCase() : null;
+ for (var i = 0; i < tmp.length; i++) {
+ // stem the word
+ var word = stemmer.stemWord(tmp[i]).toLowerCase();
+ // select the correct list
+ if (word[0] == '-') {
+ var toAppend = excluded;
+ word = word.substr(1);
+ }
+ else {
+ var toAppend = searchterms;
+ hlterms.push(tmp[i].toLowerCase());
+ }
+ // only add if not already in the list
+ if (!$.contains(toAppend, word))
+ toAppend.push(word);
+ };
+ var highlightstring = '?highlight=' + $.urlencode(hlterms.join(" "));
+
+ console.debug('SEARCH: searching for:');
+ console.info('required: ', searchterms);
+ console.info('excluded: ', excluded);
+
+ // prepare search
+ var filenames = this._index.filenames;
+ var titles = this._index.titles;
+ var terms = this._index.terms;
+ var descrefs = this._index.descrefs;
+ var modules = this._index.modules;
+ var desctypes = this._index.desctypes;
+ var fileMap = {};
+ var files = null;
+ var objectResults = [];
+ var regularResults = [];
+ $('#search-progress').empty();
+
+ // lookup as object
+ if (object != null) {
+ for (var module in modules) {
+ if (module.indexOf(object) > -1) {
+ fn = modules[module];
+ descr = _('module, in ') + titles[fn];
+ objectResults.push([filenames[fn], module, '#module-'+module, descr]);
+ }
+ }
+ for (var prefix in descrefs) {
+ for (var name in descrefs[prefix]) {
+ var fullname = (prefix ? prefix + '.' : '') + name;
+ if (fullname.toLowerCase().indexOf(object) > -1) {
+ match = descrefs[prefix][name];
+ descr = desctypes[match[1]] + _(', in ') + titles[match[0]];
+ objectResults.push([filenames[match[0]], fullname, '#'+fullname, descr]);
+ }
+ }
+ }
+ }
+
+ // sort results descending
+ objectResults.sort(function(a, b) {
+ return (a[1] > b[1]) ? -1 : ((a[1] < b[1]) ? 1 : 0);
+ });
+
+
+ // perform the search on the required terms
+ for (var i = 0; i < searchterms.length; i++) {
+ var word = searchterms[i];
+ // no match but word was a required one
+ if ((files = terms[word]) == null)
+ break;
+ if (files.length == undefined) {
+ files = [files];
+ }
+ // create the mapping
+ for (var j = 0; j < files.length; j++) {
+ var file = files[j];
+ if (file in fileMap)
+ fileMap[file].push(word);
+ else
+ fileMap[file] = [word];
+ }
+ }
+
+ // now check if the files don't contain excluded terms
+ for (var file in fileMap) {
+ var valid = true;
+
+ // check if all requirements are matched
+ if (fileMap[file].length != searchterms.length)
+ continue;
+
+ // ensure that none of the excluded terms is in the
+ // search result.
+ for (var i = 0; i < excluded.length; i++) {
+ if (terms[excluded[i]] == file ||
+ $.contains(terms[excluded[i]] || [], file)) {
+ valid = false;
+ break;
+ }
+ }
+
+ // if we have still a valid result we can add it
+ // to the result list
+ if (valid)
+ regularResults.push([filenames[file], titles[file], '', null]);
+ }
+
+ // delete unused variables in order to not waste
+ // memory until list is retrieved completely
+ delete filenames, titles, terms;
+
+ // now sort the regular results descending by title
+ regularResults.sort(function(a, b) {
+ var left = a[1].toLowerCase();
+ var right = b[1].toLowerCase();
+ return (left > right) ? -1 : ((left < right) ? 1 : 0);
+ });
+
+ // combine both
+ var results = regularResults.concat(objectResults);
+
+ // print the results
+ var resultCount = results.length;
+ function displayNextItem() {
+ // results left, load the summary and display it
+ if (results.length) {
+ var item = results.pop();
+ var listItem = $('<li style="display:none"></li>');
+ listItem.append($('<a/>').attr(
+ 'href',
+ item[0] + DOCUMENTATION_OPTIONS.FILE_SUFFIX +
+ highlightstring + item[2]).html(item[1]));
+ if (item[3]) {
+ listItem.append($('<span> (' + item[3] + ')</span>'));
+ Search.output.append(listItem);
+ listItem.slideDown(5, function() {
+ displayNextItem();
+ });
+ } else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) {
+ $.get('_sources/' + item[0] + '.txt', function(data) {
+ listItem.append($.makeSearchSummary(data, searchterms, hlterms));
+ Search.output.append(listItem);
+ listItem.slideDown(5, function() {
+ displayNextItem();
+ });
+ });
+ } else {
+ // no source available, just display title
+ Search.output.append(listItem);
+ listItem.slideDown(5, function() {
+ displayNextItem();
+ });
+ }
+ }
+ // search finished, update title and status message
+ else {
+ Search.stopPulse();
+ Search.title.text(_('Search Results'));
+ if (!resultCount)
+ Search.status.text(_('Your search did not match any documents. Please make sure that all words are spelled correctly and that you\'ve selected enough categories.'));
+ else
+ Search.status.text(_('Search finished, found %s page(s) matching the search query.').replace('%s', resultCount));
+ Search.status.fadeIn(500);
+ }
+ }
+ displayNextItem();
+ }
+}
+
+$(document).ready(function() {
+ Search.init();
+});
diff --git a/doc/_themes/pysidedocs/theme.conf b/doc/_themes/pysidedocs/theme.conf
new file mode 100644
index 000000000..d1fe6d1f9
--- /dev/null
+++ b/doc/_themes/pysidedocs/theme.conf
@@ -0,0 +1,7 @@
+[theme]
+inherit = none
+stylesheet = basic.css
+pygments_style = none
+
+[options]
+nosidebar = false
diff --git a/doc/codesnippets/doc/src/snippets/accessibilityfactorysnippet.cpp b/doc/codesnippets/doc/src/snippets/accessibilityfactorysnippet.cpp
new file mode 100644
index 000000000..1bdeb98c5
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/accessibilityfactorysnippet.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+//! [0]
+QAccessibleInterface *sliderFactory(const QString &classname, QObject *object)
+{
+ QAccessibleInterface *interface = 0;
+
+ if (classname == "QSlider" && object && object->isWidgetType())
+ interface = new SliderInterface(classname,
+ static_cast<QWidget *>(object));
+
+ return interface;
+}
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+ QAccessible::installFactory(sliderFactory);
+//! [0]
+
+ QMainWindow mainWindow;
+ mainWindow.show();
+
+ return app.exec();
+//! [1]
+}
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/accessibilitypluginsnippet.cpp b/doc/codesnippets/doc/src/snippets/accessibilitypluginsnippet.cpp
new file mode 100644
index 000000000..f2f509d13
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/accessibilitypluginsnippet.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+class SliderPlugin : public QAccessiblePlugin
+{
+public:
+ SliderPlugin() {}
+
+ QStringList keys() const;
+ QAccessibleInterface *create(const QString &classname, QObject *object);
+};
+
+//! [0]
+QStringList SliderPlugin::keys() const
+{
+ return QStringList() << "QSlider";
+}
+//! [0]
+
+//! [1]
+QAccessibleInterface *SliderPlugin::create(const QString &classname, QObject *object)
+{
+ QAccessibleInterface *interface = 0;
+
+ if (classname == "QSlider" && object && object->isWidgetType())
+ interface = new AccessibleSlider(classname, static_cast<QWidget *>(object));
+
+ return interface;
+}
+//! [1]
+
+//! [2]
+Q_EXPORT_STATIC_PLUGIN(SliderPlugin)
+Q_EXPORT_PLUGIN2(acc_sliderplugin, SliderPlugin)
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/accessibilityslidersnippet.cpp b/doc/codesnippets/doc/src/snippets/accessibilityslidersnippet.cpp
new file mode 100644
index 000000000..d14d40d53
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/accessibilityslidersnippet.cpp
@@ -0,0 +1,262 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+//! [0]
+QAccessibleSlider::QAccessibleSlider(QWidget *w)
+: QAccessibleAbstractSlider(w)
+{
+ Q_ASSERT(slider());
+ addControllingSignal(QLatin1String("valueChanged(int)"));
+}
+//! [0]
+
+QSlider *QAccessibleSlider::slider() const
+{
+ return qobject_cast<QSlider*>(object());
+}
+
+//! [1]
+QRect QAccessibleSlider::rect(int child) const
+{
+//! [1]
+ QRect rect;
+ if (!slider()->isVisible())
+ return rect;
+ const QStyleOptionSlider option = qt_qsliderStyleOption(slider());
+ QRect srect = slider()->style()->subControlRect(QStyle::CC_Slider, &option,
+ QStyle::SC_SliderHandle, slider());
+
+//! [2]
+ switch (child) {
+ case PageLeft:
+ if (slider()->orientation() == Qt::Vertical)
+ rect = QRect(0, 0, slider()->width(), srect.y());
+ else
+ rect = QRect(0, 0, srect.x(), slider()->height());
+ break;
+ case Position:
+ rect = srect;
+ break;
+ case PageRight:
+ if (slider()->orientation() == Qt::Vertical)
+ rect = QRect(0, srect.y() + srect.height(), slider()->width(), slider()->height()- srect.y() - srect.height());
+ else
+ rect = QRect(srect.x() + srect.width(), 0, slider()->width() - srect.x() - srect.width(), slider()->height());
+ break;
+ default:
+ return QAccessibleAbstractSlider::rect(child);
+ }
+//! [2] //! [3]
+
+ QPoint tp = slider()->mapToGlobal(QPoint(0,0));
+ return QRect(tp.x() + rect.x(), tp.y() + rect.y(), rect.width(), rect.height());
+}
+//! [3]
+
+int QAccessibleSlider::childCount() const
+{
+ if (!slider()->isVisible())
+ return 0;
+ return PageRight;
+}
+
+//! [4]
+QString QAccessibleSlider::text(Text t, int child) const
+{
+ if (!slider()->isVisible())
+ return QString();
+ switch (t) {
+ case Value:
+ if (!child || child == 2)
+ return QString::number(slider()->value());
+ return QString();
+ case Name:
+ switch (child) {
+ case PageLeft:
+ return slider()->orientation() == Qt::Horizontal ?
+ QSlider::tr("Page left") : QSlider::tr("Page up");
+ case Position:
+ return QSlider::tr("Position");
+ case PageRight:
+ return slider()->orientation() == Qt::Horizontal ?
+ QSlider::tr("Page right") : QSlider::tr("Page down");
+ }
+ break;
+ default:
+ break;
+ }
+ return QAccessibleAbstractSlider::text(t, child);
+}
+//! [4]
+
+//! [5]
+QAccessible::Role QAccessibleSlider::role(int child) const
+{
+ switch (child) {
+ case PageLeft:
+ case PageRight:
+ return PushButton;
+ case Position:
+ return Indicator;
+ default:
+ return Slider;
+ }
+}
+//! [5]
+
+//! [6]
+QAccessible::State QAccessibleSlider::state(int child) const
+{
+ const State parentState = QAccessibleAbstractSlider::state(0);
+//! [6]
+
+ if (child == 0)
+ return parentState;
+
+ // Inherit the Invisible state from parent.
+ State state = parentState & QAccessible::Invisible;
+
+ // Disable left/right if we are at the minimum/maximum.
+ const QSlider * const slider = QAccessibleSlider::slider();
+//! [7]
+ switch (child) {
+ case PageLeft:
+ if (slider->value() <= slider->minimum())
+ state |= Unavailable;
+ break;
+ case PageRight:
+ if (slider->value() >= slider->maximum())
+ state |= Unavailable;
+ break;
+ case Position:
+ default:
+ break;
+ }
+
+ return state;
+}
+//! [7]
+
+int QAccessibleSlider::defaultAction(int child) const
+{
+ switch (child) {
+ case SliderSelf:
+ return SetFocus;
+ case PageLeft:
+ return Press;
+ case PageRight:
+ return Press;
+ }
+
+ return 0;
+}
+
+// Name, Description, Value, Help, Accelerator
+static const char * const actionTexts[][5] =
+{
+ {"Press", "Decreases the value of the slider", "", "", "Ctrl+L"},
+ {"Press", "Increaces the value of the slider", "", "", "Ctrl+R"}
+};
+
+QString QAccessibleSlider::actionText(int action, Text text, int child) const
+{
+ if (action != Press || child < 1 || child > 2)
+ return QAccessibleAbstractSlider::actionText(action, text, child);
+
+ return actionTexts[child - 1][t];
+}
+
+bool QAccessibleSlider::doAction(int action, int child)
+{
+ if (action != Press || child < 1 || child > 2)
+ return false;
+
+ if (child == PageLeft)
+ slider()->setValue(slider()->value() - slider()->pageStep());
+ else
+ slider()->setValue(slider()->value() + slider()->pageStep());
+}
+
+QAccessibleAbstractSlider::QAccessibleAbstractSlider(QWidget *w, Role r)
+ : QAccessibleWidgetEx(w, r)
+{
+ Q_ASSERT(qobject_cast<QAbstractSlider *>(w));
+}
+
+QVariant QAccessibleAbstractSlider::invokeMethodEx(Method method, int child, const QVariantList &params)
+{
+ switch (method) {
+ case ListSupportedMethods: {
+ QSet<QAccessible::Method> set;
+ set << ListSupportedMethods;
+ return qVariantFromValue(set | qvariant_cast<QSet<QAccessible::Method> >(
+ QAccessibleWidgetEx::invokeMethodEx(method, child, params)));
+ }
+ default:
+ return QAccessibleWidgetEx::invokeMethodEx(method, child, params);
+ }
+}
+
+QVariant QAccessibleAbstractSlider::currentValue()
+{
+ return abstractSlider()->value();
+}
+
+void QAccessibleAbstractSlider::setCurrentValue(const QVariant &value)
+{
+ abstractSlider()->setValue(value.toInt());
+}
+
+QVariant QAccessibleAbstractSlider::maximumValue()
+{
+ return abstractSlider()->maximum();
+}
+
+QVariant QAccessibleAbstractSlider::minimumValue()
+{
+ return abstractSlider()->minimum();
+}
+
+QAbstractSlider *QAccessibleAbstractSlider::abstractSlider() const
+{
+ return static_cast<QAbstractSlider *>(object());
+}
diff --git a/doc/codesnippets/doc/src/snippets/alphachannel.cpp b/doc/codesnippets/doc/src/snippets/alphachannel.cpp
new file mode 100644
index 000000000..c4146848b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/alphachannel.cpp
@@ -0,0 +1,55 @@
+############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Nokia Corporation (qt-info@nokia.com)
+##
+## This file is part of the documentation of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at http://www.qtsoftware.com/contact.
+## $QT_END_LICENSE$
+##
+############################################################################
+
+//! [0]
+ pixmap = QPixmap(100, 100)
+ pixmap.fill(Qt.transparent)
+
+ gradient = QRadialGradient(50, 50, 50, 50, 50)
+ gradient.setColorAt(0, QColor.fromRgbF(1, 0, 0, 1))
+ gradient.setColorAt(1, QColor.fromRgbF(0, 0, 0, 0))
+ painter = QPainter(pixmap)
+ painter.fillRect(0, 0, 100, 100, gradient)
+
+ channelImage = pixmap.alphaChannel()
+ update()
+//! [0]
+
diff --git a/doc/codesnippets/doc/src/snippets/audioeffects.cpp b/doc/codesnippets/doc/src/snippets/audioeffects.cpp
new file mode 100644
index 000000000..febf34975
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/audioeffects.cpp
@@ -0,0 +1,42 @@
+#include <QtGui>
+
+#include <phonon/audiooutput.h>
+#include <phonon/mediaobject.h>
+#include <phonon/backendcapabilities.h>
+#include <phonon/effect.h>
+#include <phonon/effectwidget.h>
+
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+ app.setApplicationName("Audio effect tester");
+
+ Phonon::MediaObject *mediaObject = new Phonon::MediaObject;
+ mediaObject->setCurrentSource(QString("/home/gvatteka/Music/Lumme-Badloop.ogg"));
+
+ Phonon::AudioOutput *audioOutput =
+ new Phonon::AudioOutput(Phonon::MusicCategory);
+
+//! [0]
+ QList<Phonon::EffectDescription> effectDescriptions =
+ Phonon::BackendCapabilities::availableAudioEffects();
+ Phonon::EffectDescription effectDescription = effectDescriptions.at(4);
+
+ Phonon::Path path = Phonon::createPath(mediaObject, audioOutput);
+
+//! [1]
+ Phonon::Effect *effect = new Phonon::Effect(effectDescription);
+ path.insertEffect(effect);
+//! [0]
+
+ Phonon::EffectWidget *effectWidget = new Phonon::EffectWidget(effect);
+ effectWidget->show();
+//! [1]
+
+ mediaObject->play();
+
+ effectWidget->setWindowTitle("Effect Name: " + effectDescription.name());
+
+ app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/brush/brush.cpp b/doc/codesnippets/doc/src/snippets/brush/brush.cpp
new file mode 100644
index 000000000..e891af208
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/brush/brush.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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]
+ linearGrad = QLinearGradient(QPointF(100, 100), QPointF(200, 200))
+ linearGrad.setColorAt(0, Qt.black)
+ linearGrad.setColorAt(1, Qt.white)
+//! [0]
+
+ // RADIAL
+//! [1]
+ radialGrad = QRadialGradient(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/codesnippets/doc/src/snippets/brush/brush.pro b/doc/codesnippets/doc/src/snippets/brush/brush.pro
new file mode 100644
index 000000000..6a5f0dadb
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/brush/brush.pro
@@ -0,0 +1 @@
+SOURCES += brush.cpp
diff --git a/doc/codesnippets/doc/src/snippets/brush/gradientcreationsnippet.cpp b/doc/codesnippets/doc/src/snippets/brush/gradientcreationsnippet.cpp
new file mode 100644
index 000000000..8726a0126
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/brush/gradientcreationsnippet.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+
+//! [0]
+ gradient = 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))
+
+ brush = QBrush(gradient)
+//! [0]
+
+ QWidget widget;
+ QPalette palette;
+ palette.setBrush(widget.backgroundRole(), brush);
+ widget.setPalette(palette);
+ widget.show();
+
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/brushstyles/brushstyles.pro b/doc/codesnippets/doc/src/snippets/brushstyles/brushstyles.pro
new file mode 100644
index 000000000..80de531f0
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/brushstyles/brushstyles.pro
@@ -0,0 +1,12 @@
+######################################################################
+# Automatically generated by qmake (2.00a) Wed Dec 14 11:46:57 2005
+######################################################################
+
+TEMPLATE = app
+TARGET +=
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+HEADERS += renderarea.h stylewidget.h
+SOURCES += main.cpp renderarea.cpp stylewidget.cpp
diff --git a/doc/codesnippets/doc/src/snippets/brushstyles/main.cpp b/doc/codesnippets/doc/src/snippets/brushstyles/main.cpp
new file mode 100644
index 000000000..021c7adc8
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/brushstyles/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+
+#include "stylewidget.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ StyleWidget widget;
+ widget.show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/brushstyles/qt-logo.png b/doc/codesnippets/doc/src/snippets/brushstyles/qt-logo.png
new file mode 100644
index 000000000..2dc67161c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/brushstyles/qt-logo.png
Binary files differ
diff --git a/doc/codesnippets/doc/src/snippets/brushstyles/renderarea.cpp b/doc/codesnippets/doc/src/snippets/brushstyles/renderarea.cpp
new file mode 100644
index 000000000..408b09127
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/brushstyles/renderarea.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "renderarea.h"
+
+RenderArea::RenderArea(QBrush *brush, QWidget *parent)
+ : QWidget(parent)
+{
+ currentBrush = brush;
+}
+
+QSize RenderArea::minimumSizeHint() const
+{
+ return QSize(120, 60);
+}
+
+void RenderArea::paintEvent(QPaintEvent *)
+{
+ QPainter painter(this);
+ painter.setPen(Qt::NoPen);
+ painter.setRenderHint(QPainter::Antialiasing);
+
+
+ if(currentBrush->style() == Qt::LinearGradientPattern) {
+ currentBrush = new QBrush(QLinearGradient(0, 0, width(), 60));
+ } else if(currentBrush->style() == Qt::RadialGradientPattern) {
+ QRadialGradient radial(width() / 2, 30, width() / 2, width() / 2, 30);
+ radial.setColorAt(0, Qt::white);
+ radial.setColorAt(1, Qt::black);
+ currentBrush = new QBrush(radial);
+ } else if(currentBrush->style() == Qt::ConicalGradientPattern) {
+ currentBrush = new QBrush(QConicalGradient(width() / 2, 30, 90));
+ }
+ painter.setBrush(*currentBrush);
+
+ QPainterPath path;
+ path.addRect(0, 0, parentWidget()->width(), 60);
+ painter.drawPath(path);
+}
diff --git a/doc/codesnippets/doc/src/snippets/brushstyles/renderarea.h b/doc/codesnippets/doc/src/snippets/brushstyles/renderarea.h
new file mode 100644
index 000000000..4e2541300
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/brushstyles/renderarea.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef RENDERAREA_H
+#define RENDERAREA_H
+
+#include <QWidget>
+
+class RenderArea : public QWidget
+{
+ Q_OBJECT
+
+public:
+ RenderArea(QBrush *brush, QWidget *parent = 0);
+ QSize minimumSizeHint() const;
+
+protected:
+ void paintEvent(QPaintEvent *event);
+
+private:
+ QBrush *currentBrush;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/brushstyles/stylewidget.cpp b/doc/codesnippets/doc/src/snippets/brushstyles/stylewidget.cpp
new file mode 100644
index 000000000..54ed8c5f6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/brushstyles/stylewidget.cpp
@@ -0,0 +1,145 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "stylewidget.h"
+
+StyleWidget::StyleWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ solid = new RenderArea(new QBrush(Qt::SolidPattern));
+ dense1 = new RenderArea(new QBrush(Qt::Dense1Pattern));
+ dense2 = new RenderArea(new QBrush(Qt::Dense2Pattern));
+ dense3 = new RenderArea(new QBrush(Qt::Dense3Pattern));
+ dense4 = new RenderArea(new QBrush(Qt::Dense4Pattern));
+ dense5 = new RenderArea(new QBrush(Qt::Dense5Pattern));
+ dense6 = new RenderArea(new QBrush(Qt::Dense6Pattern));
+ dense7 = new RenderArea(new QBrush(Qt::Dense7Pattern));
+ no = new RenderArea(new QBrush(Qt::NoBrush));
+ hor = new RenderArea(new QBrush(Qt::HorPattern));
+ ver = new RenderArea(new QBrush(Qt::VerPattern));
+ cross = new RenderArea(new QBrush(Qt::CrossPattern));
+ bdiag = new RenderArea(new QBrush(Qt::BDiagPattern));
+ fdiag = new RenderArea(new QBrush(Qt::FDiagPattern));
+ diagCross = new RenderArea(new QBrush(Qt::DiagCrossPattern));
+ linear = new RenderArea(new QBrush(QLinearGradient()));
+ radial = new RenderArea(new QBrush(QRadialGradient()));
+ conical = new RenderArea(new QBrush(QConicalGradient()));
+ texture = new RenderArea(new QBrush(QPixmap("qt-logo.png")));
+
+ solidLabel = new QLabel("Qt::SolidPattern");
+ dense1Label = new QLabel("Qt::Dense1Pattern");
+ dense2Label = new QLabel("Qt::Dense2Pattern");
+ dense3Label = new QLabel("Qt::Dense3Pattern");
+ dense4Label = new QLabel("Qt::Dense4Pattern");
+ dense5Label = new QLabel("Qt::Dense5Pattern");
+ dense6Label = new QLabel("Qt::Dense6Pattern");
+ dense7Label = new QLabel("Qt::Dense7Pattern");
+ noLabel = new QLabel("Qt::NoPattern");
+ horLabel = new QLabel("Qt::HorPattern");
+ verLabel = new QLabel("Qt::VerPattern");
+ crossLabel = new QLabel("Qt::CrossPattern");
+ bdiagLabel = new QLabel("Qt::BDiagPattern");
+ fdiagLabel = new QLabel("Qt::FDiagPattern");
+ diagCrossLabel = new QLabel("Qt::DiagCrossPattern");
+ linearLabel = new QLabel("Qt::LinearGradientPattern");
+ radialLabel = new QLabel("Qt::RadialGradientPattern");
+ conicalLabel = new QLabel("Qt::ConicalGradientPattern");
+ textureLabel = new QLabel("Qt::TexturePattern");
+
+ QGridLayout *layout = new QGridLayout;
+ layout->addWidget(solid, 0, 0);
+ layout->addWidget(dense1, 0, 1);
+ layout->addWidget(dense2, 0, 2);
+ layout->addWidget(solidLabel, 1, 0);
+ layout->addWidget(dense1Label, 1, 1);
+ layout->addWidget(dense2Label, 1, 2);
+
+ layout->addWidget(dense3, 2, 0 );
+ layout->addWidget(dense4, 2, 1);
+ layout->addWidget(dense5, 2, 2);
+ layout->addWidget(dense3Label, 3, 0);
+ layout->addWidget(dense4Label, 3, 1);
+ layout->addWidget(dense5Label, 3, 2);
+
+ layout->addWidget(dense6, 4, 0);
+ layout->addWidget(dense7, 4, 1);
+ layout->addWidget(no, 4, 2);
+ layout->addWidget(dense6Label, 5, 0);
+ layout->addWidget(dense7Label, 5, 1);
+ layout->addWidget(noLabel, 5, 2);
+
+ layout->addWidget(hor, 6, 0);
+ layout->addWidget(ver, 6, 1);
+ layout->addWidget(cross, 6, 2);
+ layout->addWidget(horLabel, 7, 0);
+ layout->addWidget(verLabel, 7, 1);
+ layout->addWidget(crossLabel, 7, 2);
+
+ layout->addWidget(bdiag, 8, 0);
+ layout->addWidget(fdiag, 8, 1);
+ layout->addWidget(diagCross, 8, 2);
+ layout->addWidget(bdiagLabel, 9, 0);
+ layout->addWidget(fdiagLabel, 9, 1);
+ layout->addWidget(diagCrossLabel, 9, 2);
+
+ layout->addWidget(linear, 10, 0);
+ layout->addWidget(radial, 10, 1);
+ layout->addWidget(conical, 10, 2);
+ layout->addWidget(linearLabel, 11, 0);
+ layout->addWidget(radialLabel, 11, 1);
+ layout->addWidget(conicalLabel, 11, 2);
+
+ layout->addWidget(texture, 12, 0, 1, 3);
+ layout->addWidget(textureLabel, 13, 0, 1, 3);
+
+ setLayout(layout);
+
+ QPalette newPalette = palette();
+ newPalette.setColor(QPalette::Window, Qt::white);
+ setPalette(newPalette);
+
+ setWindowTitle(tr("Brush Styles"));
+ resize(430, 605);
+}
+
+
diff --git a/doc/codesnippets/doc/src/snippets/brushstyles/stylewidget.h b/doc/codesnippets/doc/src/snippets/brushstyles/stylewidget.h
new file mode 100644
index 000000000..18aa6ddfa
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/brushstyles/stylewidget.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef STYLEWIDGET_H
+#define STYLEWIDGET_H
+
+#include <QWidget>
+#include <QPainterPath>
+#include "renderarea.h"
+
+class QLabel;
+
+class StyleWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ StyleWidget(QWidget *parent = 0);
+
+private:
+ RenderArea *solid;
+ RenderArea *dense1;
+ RenderArea *dense2;
+ RenderArea *dense3;
+ RenderArea *dense4;
+ RenderArea *dense5;
+ RenderArea *dense6;
+ RenderArea *dense7;
+ RenderArea *no;
+ RenderArea *hor;
+ RenderArea *ver;
+ RenderArea *cross;
+ RenderArea *bdiag;
+ RenderArea *fdiag;
+ RenderArea *diagCross;
+ RenderArea *linear;
+ RenderArea *radial;
+ RenderArea *conical;
+ RenderArea *texture;
+
+ QLabel *solidLabel;
+ QLabel *dense1Label;
+ QLabel *dense2Label;
+ QLabel *dense3Label;
+ QLabel *dense4Label;
+ QLabel *dense5Label;
+ QLabel *dense6Label;
+ QLabel *dense7Label;
+ QLabel *noLabel;
+ QLabel *horLabel;
+ QLabel *verLabel;
+ QLabel *crossLabel;
+ QLabel *bdiagLabel;
+ QLabel *fdiagLabel;
+ QLabel *diagCrossLabel;
+ QLabel *linearLabel;
+ QLabel *radialLabel;
+ QLabel *conicalLabel;
+ QLabel *textureLabel;
+};
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/buffer/buffer.cpp b/doc/codesnippets/doc/src/snippets/buffer/buffer.cpp
new file mode 100644
index 000000000..dc3a0d58f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/buffer/buffer.cpp
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QBuffer>
+#include <QPalette>
+
+static void main_snippet()
+{
+//! [0]
+ buffer = QBuffer()
+
+ buffer.open(QBuffer.ReadWrite)
+ buffer.write("Qt rocks!")
+ buffer.seek(0)
+ ch = buffer.getChar() # ch == 'Q'
+ ch = buffer.getChar() # ch == 't'
+ ch = buffer.getChar() # ch == ' '
+ ch = buffer.getChar() # ch == 'r'
+//! [0]
+}
+
+static void write_datastream_snippets()
+{
+//! [1]
+ byteArray = QByteArray()
+ buffer = QBuffer(byteArray)
+ buffer.open(QIODevice.WriteOnly)
+
+ out = QDataStream(buffer)
+ out << QApplication.palette()
+//! [1]
+}
+
+static void read_datastream_snippets()
+{
+ QByteArray byteArray;
+
+//! [2]
+ palette = QPalette()
+ buffer = QBuffer(byteArray)
+ buffer.open(QIODevice.ReadOnly)
+
+ in = QDataStream(buffer)
+ in >> palette
+//! [2]
+}
+
+static void bytearray_ptr_ctor_snippet()
+{
+//! [3]
+ byteArray = QByteArray("abc")
+ buffer = QBuffer(byteArray)
+ buffer.open(QIODevice.WriteOnly)
+ buffer.seek(3)
+ buffer.write("def")
+ buffer.close()
+ # byteArray == "abcdef"
+//! [3]
+}
+
+static void setBuffer_snippet()
+{
+//! [4]
+ byteArray = QByteArray("abc")
+ buffer = QBuffer()
+ buffer.setBuffer(byteArray)
+ buffer.open(QIODevice.WriteOnly)
+ buffer.seek(3)
+ buffer.write("def")
+ 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/codesnippets/doc/src/snippets/buffer/buffer.pro b/doc/codesnippets/doc/src/snippets/buffer/buffer.pro
new file mode 100644
index 000000000..87eab9fb0
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/buffer/buffer.pro
@@ -0,0 +1,14 @@
+######################################################################
+# Automatically generated by qmake (1.08a) Tue Jan 4 13:19:41 2005
+######################################################################
+
+TEMPLATE = app
+CONFIG -= moc
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+SOURCES += buffer.cpp
+CONFIG += qt warn_on debug create_prl link_prl
+OBJECTS_DIR=.obj/debug-shared
+MOC_DIR=.moc/debug-shared
diff --git a/doc/codesnippets/doc/src/snippets/clipboard/clipboard.pro b/doc/codesnippets/doc/src/snippets/clipboard/clipboard.pro
new file mode 100644
index 000000000..a26fea6b5
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/clipboard/clipboard.pro
@@ -0,0 +1,3 @@
+HEADERS = clipwindow.h
+SOURCES = clipwindow.cpp \
+ main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/clipboard/clipwindow.cpp b/doc/codesnippets/doc/src/snippets/clipboard/clipwindow.cpp
new file mode 100644
index 000000000..5331818c8
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/clipboard/clipwindow.cpp
@@ -0,0 +1,97 @@
+############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Nokia Corporation (qt-info@nokia.com)
+##
+## This file is part of the documentation of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at http://www.qtsoftware.com/contact.
+## $QT_END_LICENSE$
+##
+############################################################################
+
+form PySide.QtGui import *
+
+
+def __init__(self, parent):
+ QMainWindow.__init__(self, parent)
+ clipboard = QApplication.clipboard()
+
+ centralWidget = QWidget(self)
+ currentItem = QWidget(centralWidget)
+ mimeTypeLabel = QLabel(tr("MIME types:"), currentItem)
+ mimeTypeCombo = QComboBox(currentItem)
+ dataLabel = QLabel(tr("Data:"), currentItem)
+ dataInfoLabel = QLabel("", currentItem)
+
+ previousItems = QListWidget(centralWidget)
+
+//! [0]
+ connect(clipboard, SIGNAL("dataChanged()"), self, SLOT("updateClipboard()"))
+//! [0]
+ connect(mimeTypeCombo, SIGNAL("activated(const QString &)"),
+ self, SLOT("updateData(const QString &))")
+
+ currentLayout = QVBoxLayout(currentItem)
+ currentLayout.addWidget(mimeTypeLabel)
+ currentLayout.addWidget(mimeTypeCombo)
+ currentLayout.addWidget(dataLabel)
+ currentLayout.addWidget(dataInfoLabel)
+ currentLayout.addStretch(1)
+
+ mainLayout = QHBoxLayout(centralWidget)
+ mainLayout.addWidget(currentItem, 1)
+ mainLayout.addWidget(previousItems)
+
+ setCentralWidget(centralWidget)
+ setWindowTitle(tr("Clipboard"))
+
+//! [1]
+def updateClipboard(self):
+ formats = clipboard.mimeData().formats()
+ data = clipboard.mimeData().data(format)
+//! [1]
+
+ mimeTypeCombo.clear()
+ mimeTypeCombo.insertStringList(formats)
+
+ size = clipboard.mimeData().data(formats[0]).size()
+ Item = QListWidgetItem(previousItems)
+ Item.setText(tr("%1 (%2 bytes)").arg(formats[0]).arg(size))
+
+ updateData(formats[0])
+//! [2]
+//! [2]
+
+def updateData(self, format)
+ data = clipboard.mimeData().data(format)
+ dataInfoLabel.setText(tr("%1 bytes").arg(data.size()))
diff --git a/doc/codesnippets/doc/src/snippets/clipboard/clipwindow.h b/doc/codesnippets/doc/src/snippets/clipboard/clipwindow.h
new file mode 100644
index 000000000..82de301ee
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/clipboard/clipwindow.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CLIPWINDOW_H
+#define CLIPWINDOW_H
+
+#include <QMainWindow>
+
+class QClipboard;
+class QComboBox;
+class QLabel;
+class QListWidget;
+class QMimeData;
+class QWidget;
+
+class ClipWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ ClipWindow(QWidget *parent = 0);
+
+public slots:
+ void updateClipboard();
+ void updateData(const QString &format);
+
+private:
+ int currentItem;
+ QClipboard *clipboard;
+ QComboBox *mimeTypeCombo;
+ QLabel *dataInfoLabel;
+ QListWidget *previousItems;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/clipboard/main.cpp b/doc/codesnippets/doc/src/snippets/clipboard/main.cpp
new file mode 100644
index 000000000..1139e79d4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/clipboard/main.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+
+#include "clipwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ ClipWindow *window = new ClipWindow;
+ window->resize(640, 480);
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/code/doc.src.qtscripttools.qdoc b/doc/codesnippets/doc/src/snippets/code/doc.src.qtscripttools.qdoc
new file mode 100644
index 000000000..c691f177e
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc.src.qtscripttools.qdoc
@@ -0,0 +1,8 @@
+//! [0]
+ #include <QtScriptTools>
+//! [0]
+
+
+//! [1]
+ QT += scripttools
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_activeqt-dumpcpp.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_activeqt-dumpcpp.qdoc
new file mode 100644
index 000000000..df1d5425a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_activeqt-dumpcpp.qdoc
@@ -0,0 +1,25 @@
+//! [0]
+Outlook::Application *outlook = new Outlook::Application;
+//! [0]
+
+
+//! [1]
+Outlook::_NameSpace *session = outlook->Session();
+//! [1]
+
+
+//! [2]
+Outlook::NameSpace *session = outlook->Session();
+//! [2]
+
+
+//! [3]
+Outlook::_NameSpace *tmp = outlook->Session();
+Outlook::NameSpace *session = new Outlook::NameSpace(tmp);
+delete tmp; // or any other use of tmp: segfault
+//! [3]
+
+
+//! [4]
+Outlook::NameSpace *session = new Outlook::NameSpace(outlook->Session());
+//! [4]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_appicon.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_appicon.qdoc
new file mode 100644
index 000000000..c8883fe38
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_appicon.qdoc
@@ -0,0 +1,23 @@
+//! [0]
+IDI_ICON1 ICON DISCARDABLE "myappico.ico"
+//! [0]
+
+
+//! [1]
+RC_FILE = myapp.rc
+//! [1]
+
+
+//! [2]
+ICON = myapp.icns
+//! [2]
+
+
+//! [3]
+kde-config --path icon
+//! [3]
+
+
+//! [4]
+gnome-config --datadir
+//! [4]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_assistant-manual.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_assistant-manual.qdoc
new file mode 100644
index 000000000..383bd618e
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_assistant-manual.qdoc
@@ -0,0 +1,110 @@
+//! [0]
+assistant -collectionFile file
+//! [0]
+
+
+//! [1]
+<?xml version="1.0" encoding="utf-8" ?>
+<QHelpCollectionProject version="1.0">
+ <assistant>
+ <title>My Application Help</title>
+ <startPage>qthelp://com.mycompany.1_0_0/doc/index.html</startPage>
+ <currentFilter>myfilter</currentFilter>
+ <applicationIcon>application.png</applicationIcon>
+ <enableFilterFunctionality>false</enableFilterFunctionality>
+ <enableDocumentationManager>false</enableDocumentationManager>
+ <enableAddressBar visible="true">true</enableAddressBar>
+ <cacheDirectory>mycompany/myapplication</cacheDirectory>
+ <aboutMenuText>
+ <text>About My Application</text>
+ <text language="de">Über meine Applikation...</text>
+ </aboutMenuText>
+ <aboutDialog>
+ <file>about.txt</file>
+ <file language="de">ueber.txt</file>
+ <icon>about.png</icon>
+ </aboutDialog>
+ </assistant>
+ <docFiles>
+ <generate>
+ <file>
+ <input>myapplication-manual.qhp</input>
+ <output>myapplication-manual.qch</output>
+ </file>
+ </generate>
+ <register>
+ <file>myapplication-manual.qch</file>
+ </register>
+ </docFiles>
+</QHelpCollectionProject>
+//! [1]
+
+
+//! [2]
+QProcess *process = new QProcess;
+QStringList args;
+args << QLatin1String("-collectionFile")
+ << QLatin1String("mycollection.qhc")
+ << QLatin1String("-enableRemoteControl");
+process->start(QLatin1String("assistant"), args);
+if (!process->waitForStarted())
+ return;
+//! [2]
+
+
+//! [3]
+QByteArray ba;
+ba.append("setSource qthelp://com.mycompany.1_0_0/doc/index.html");
+ba.append('\0');
+process->write(ba);
+//! [3]
+
+
+//! [4]
+QByteArray ba;
+ba.append("hide bookmarks;");
+ba.append("hide index;");
+ba.append("setSource qthelp://com.mycompany.1_0_0/doc/index.html");
+ba.append('\0');
+process->write(ba);
+//! [4]
+
+//! [5]
+<?xml version="1.0" encoding="utf-8" ?>
+<QHelpCollectionProject version="1.0">
+ ...
+ <docFiles>
+ <register>
+ <file>myapplication-manual.qch</file>
+ <file>another-manual.qch</file>
+ </register>
+ </docFiles>
+</QHelpCollectionProject>
+//! [5]
+
+//! [6]
+assistant -collectionFile mycollection.qhc -register myapplication-manual.qch
+//! [6]
+
+//! [7]
+<?xml version="1.0" encoding="utf-8" ?>
+<QHelpCollectionProject version="1.0">
+ <assistant>
+ <title>My Application Help</title>
+ <cacheDirectory>mycompany/myapplication</cacheDirectory>
+ ...
+ </assistant>
+</QHelpCollectionProject>
+//! [7]
+
+//! [8]
+assistant -collectionFile mycollection.qhc
+//! [8]
+
+//! [9]
+%QDesktopServices::DataLocation%/mycompany/myapplication/mycollection.qhc
+//! [9]
+
+//! [10]
+qcollectiongenerator mycollection.qhcp -o mycollection.qhc
+//! [10]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_atomic-operations.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_atomic-operations.qdoc
new file mode 100644
index 000000000..acda5e413
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_atomic-operations.qdoc
@@ -0,0 +1,71 @@
+//! [0]
+if (*ptr == expected) {
+ *ptr = newval;
+ return !0;
+}
+return 0;
+//! [0]
+
+
+//! [1]
+if (*ptr == expected) {
+ *ptr = newval;
+ return !0;
+}
+return 0;
+//! [1]
+
+
+//! [2]
+++(*ptr);
+return *ptr ? !0 : 0;
+//! [2]
+
+
+//! [3]
+return ++(*ptr);
+//! [3]
+
+
+//! [4]
+++(*ptr);
+return !(ControlRegister & ZeroFlag);
+//! [4]
+
+
+//! [5]
+--(*ptr);
+return *ptr ? : 0;
+//! [5]
+
+
+//! [6]
+return --(*ptr);
+//! [6]
+
+
+//! [7]
+--(*ptr);
+return !(ControlRegister & ZeroFlag);
+//! [7]
+
+
+//! [8]
+tmp = *ptr;
+*ptr = newval;
+return tmp;
+//! [8]
+
+
+//! [9]
+tmp = *ptr;
+*ptr = newval;
+return tmp;
+//! [9]
+
+
+//! [10]
+tmp = *ptr;
+*ptr += value;
+return tmp;
+//! [10]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_compiler-notes.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_compiler-notes.qdoc
new file mode 100644
index 000000000..12095d0c3
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_compiler-notes.qdoc
@@ -0,0 +1,8 @@
+//! [0]
+QTDIR=C:\Progra~1\Qt
+//! [0]
+
+
+//! [1]
+/usr/vacpp/bin/makeC++SharedLib -o shr1.o cplussource1.o
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_containers.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_containers.qdoc
new file mode 100644
index 000000000..9d6ba8dbb
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_containers.qdoc
@@ -0,0 +1,235 @@
+//! [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 (QString str, list)
+ qDebug() << str;
+//! [17]
+
+
+//! [18]
+QLinkedList<QString> list;
+...
+foreach (QString str, list) {
+ if (str.isEmpty())
+ break;
+ qDebug() << str;
+}
+//! [18]
+
+
+//! [19]
+QMap<QString, int> map;
+...
+foreach (QString str, map.keys())
+ qDebug() << str << ":" << map.value(str);
+//! [19]
+
+
+//! [20]
+QMultiMap<QString, int> map;
+...
+foreach (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/codesnippets/doc/src/snippets/code/doc_src_coordsys.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_coordsys.qdoc
new file mode 100644
index 000000000..4674e753b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_coordsys.qdoc
@@ -0,0 +1,47 @@
+//! [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/codesnippets/doc/src/snippets/code/doc_src_debug.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_debug.qdoc
new file mode 100644
index 000000000..0e8a1c52d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_debug.qdoc
@@ -0,0 +1,24 @@
+//! [0]
+qDebug() << "Widget" << widget << "at position" << widget->pos();
+//! [0]
+
+
+//! [1]
+char *alloc(int size)
+{
+ Q_ASSERT(size > 0);
+ char *ptr = new char[size];
+ Q_CHECK_PTR(ptr);
+ return ptr;
+}
+//! [1]
+
+
+//! [2]
+char *alloc(int size)
+{
+ char *ptr;
+ Q_CHECK_PTR(ptr = new char[size]); // WRONG
+ return ptr;
+}
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_deployment.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_deployment.qdoc
new file mode 100644
index 000000000..b8bf57106
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_deployment.qdoc
@@ -0,0 +1,414 @@
+//! [0]
+cd /path/to/Qt
+./configure -static -prefix /path/to/Qt <other parameters>
+make sub-src
+//! [0]
+
+
+//! [1]
+cd /path/to/Qt/examples/tools/plugandpaint
+//! [1]
+
+
+//! [2]
+make clean
+PATH=/path/to/Qt/bin:$PATH
+export PATH
+qmake -config release
+make
+//! [2]
+
+
+//! [3]
+ldd ./application
+//! [3]
+
+
+//! [4]
+cd /path/to/Qt/examples/tools/plugandpaint
+//! [4]
+
+
+//! [5]
+make clean
+qmake -config release
+make
+//! [5]
+
+
+//! [6]
+cd ../plugandpaintplugins
+make clean
+qmake -config release
+make
+//! [6]
+
+
+//! [7]
+#!/bin/sh
+appname=`basename $0 | sed s,\.sh$,,`
+
+dirname=`dirname $0`
+tmp="${dirname#?}"
+
+if [ "${dirname%$tmp}" != "/" ]; then
+dirname=$PWD/$dirname
+fi
+LD_LIBRARY_PATH=$dirname
+export LD_LIBRARY_PATH
+$dirname/$appname $*
+//! [7]
+
+
+//! [8]
+DESTDIR = /path/to/Qt/plugandpaint/plugins
+//! [8]
+
+
+//! [9]
+qApp->addLibraryPath("/some/other/path");
+//! [9]
+
+
+//! [10]
+ldd ./application
+//! [10]
+
+
+//! [11]
+cd C:\path\to\Qt
+configure -static <any other options you need>
+//! [11]
+
+
+//! [12]
+nmake sub-src
+//! [12]
+
+
+//! [13]
+cd examples\tools\plugandpaint
+//! [13]
+
+
+//! [14]
+nmake clean
+qmake -config release
+nmake
+//! [14]
+
+
+//! [15]
+cd examples\tools\plugandpaint
+//! [15]
+
+
+//! [16]
+nmake clean
+qmake -config release
+nmake
+//! [16]
+
+
+//! [17]
+cd ..\plugandpaintplugins
+nmake clean
+qmake -config release
+nmake
+//! [17]
+
+
+//! [18]
+plugins\pnp_basictools.dll
+plugins\pnp_extrafilters.dll
+//! [18]
+
+
+//! [19]
+qApp->addLibraryPath("C:\some\other\path");
+//! [19]
+
+
+//! [20]
+embed_manifest_dll
+embed_manifest_exe
+//! [20]
+
+
+//! [21]
+CONFIG += embed_manifest_exe
+//! [21]
+
+
+//! [22]
+<Visual Studio Install Path>\VC\redist\<Architecture>\Microsoft.VC80.CRT
+//! [22]
+
+
+//! [23]
+CONFIG-=embed_manifest_dll
+//! [23]
+
+
+//! [24]
+depends <application executable>
+//! [24]
+
+
+//! [25]
+C:<path to Qt>\plugins
+//! [25]
+
+
+//! [26]
+CONFIG-=app_bundle
+//! [26]
+
+
+//! [27]
+cd /path/to/Qt
+./configure -static <other parameters>
+make sub-src
+//! [27]
+
+
+//! [28]
+cd /path/to/Qt/examples/tools/plugandpaint
+//! [28]
+
+
+//! [29]
+make clean
+qmake -config release
+make
+//! [29]
+
+
+//! [30]
+otool -L plugandpaint.app/Contents/MacOs/plugandpaint
+//! [30]
+
+
+//! [31]
+plugandpaint.app/Contents/MacOS/plugandpaint:
+/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
+ (compatibility version 2.0.0, current version 128.0.0)
+/System/Library/Frameworks/QuickTime.framework/Versions/A/QuickTime
+ (compatibility version 1.0.0, current version 10.0.0)
+/usr/lib/libz.1.dylib
+ (compatibility version 1.0.0, current version 1.2.3)
+/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
+ (compatibility version 1.0.0, current version 22.0.0)
+/usr/lib/libstdc++.6.dylib
+ (compatibility version 7.0.0, current version 7.3.0)
+/usr/lib/libgcc_s.1.dylib
+ (compatibility version 1.0.0, current version 1.0.0)
+/usr/lib/libmx.A.dylib
+ (compatibility version 1.0.0, current version 92.0.0)
+/usr/lib/libSystem.B.dylib
+ (compatibility version 1.0.0, current version 88.0.0)
+//! [31]
+
+
+//! [32]
+-lQtGui
+//! [32]
+
+
+//! [33]
+/where/static/qt/lib/is/libQtGui.a
+//! [33]
+
+
+//! [34]
+cd /path/to/Qt/examples/tools/plugandpaint
+//! [34]
+
+
+//! [35]
+make clean
+qmake -config release
+make
+//! [35]
+
+
+//! [36]
+cd ../plugandpaintplugins
+make clean
+qmake -config release
+make
+//! [36]
+
+
+//! [37]
+otool -L QtGui.framework/QtGui
+//! [37]
+
+
+//! [38]
+QtGui.framework/QtGui:
+/path/to/Qt/lib/QtGui.framework/Versions/4.0/QtGui
+ (compatibility version 4.0.0, current version 4.0.1)
+/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
+ (compatibility version 2.0.0, current version 128.0.0)
+/System/Library/Frameworks/QuickTime.framework/Versions/A/QuickTime
+ (compatibility version 1.0.0, current version 10.0.0)
+/path/to/Qt/QtCore.framework/Versions/4.0/QtCore
+ (compatibility version 4.0.0, current version 4.0.1)
+/usr/lib/libz.1.dylib
+ (compatibility version 1.0.0, current version 1.2.3)
+/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
+ (compatibility version 1.0.0, current version 22.0.0)
+/usr/lib/libstdc++.6.dylib
+ (compatibility version 7.0.0, current version 7.3.0)
+/usr/lib/libgcc_s.1.dylib
+ (compatibility version 1.0.0, current version 1.0.0)
+/usr/lib/libmx.A.dylib
+ (compatibility version 1.0.0, current version 92.0.0)
+/usr/lib/libSystem.B.dylib
+ (compatibility version 1.0.0, current version 88.0.0)
+//! [38]
+
+
+//! [39]
+mkdir plugandpaint.app/Contents/Frameworks
+cp -R /path/to/Qt/lib/QtCore.framework
+ plugandpaint.app/Contents/Frameworks
+cp -R /path/to/Qt/lib/QtGui.framework
+ plugandpaint.app/Contents/Frameworks
+//! [39]
+
+
+//! [40]
+install_name_tool -id @executable_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore
+ plugandpaint.app/Contents/Frameworks/QtCore.framework/Versions/4.0/QtCore
+install_name_tool -id @executable_path/../Frameworks/QtGui.framework/Versions/4.0/QtGui
+ plugandpaint.app/Contents/Frameworks/QtGui.framework/Versions/4.0/QtGui
+//! [40]
+
+
+//! [41]
+install_name_tool -change path/to/Qt/lib/QtCore.framework/Versions/4.0/QtCore
+ @executable_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore
+ plugandpaint.app/Contents/MacOs/plugandpaint
+install_name_tool -change path/to/qt/lib/QtGui.framework/Versions/4.0/QtGui
+ @executable_path/../Frameworks/QtGui.framework/Versions/4.0/QtGui
+ plugandpaint.app/Contents/MacOs/plugandpaint
+//! [41]
+
+
+//! [42]
+install_name_tool -change path/to/Qt/lib/QtCore.framework/Versions/4.0/QtCore
+ @executable_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore
+ plugandpaint.app/Contents/Frameworks/QtGui.framework/Versions/4.0/QtGui
+//! [42]
+
+
+//! [43]
+mv plugins plugandpaint.app/Contents
+//! [43]
+
+
+//! [44]
+libpnp_basictools.dylib:
+libpnp_basictools.dylib
+ (compatibility version 0.0.0, current version 0.0.0)
+/path/to/Qt/lib/QtGui.framework/Versions/4.0/QtGui
+ (compatibility version 4.0.0, current version 4.0.1)
+/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
+ (compatibility version 2.0.0, current version 128.0.0)
+/System/Library/Frameworks/QuickTime.framework/Versions/A/QuickTime
+ (compatibility version 1.0.0, current version 10.0.0)
+/path/to/Qt/lib/QtCore.framework/Versions/4.0/QtCore
+ (compatibility version 4.0.0, current version 4.0.1)
+/usr/lib/libz.1.dylib
+ (compatibility version 1.0.0, current version 1.2.3)
+/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
+ (compatibility version 1.0.0, current version 22.0.0)
+/usr/lib/libstdc++.6.dylib
+ (compatibility version 7.0.0, current version 7.3.0)
+/usr/lib/libgcc_s.1.dylib
+ (compatibility version 1.0.0, current version 1.0.0)
+/usr/lib/libmx.A.dylib
+ (compatibility version 1.0.0, current version 92.0.0)
+/usr/lib/libSystem.B.dylib
+ (compatibility version 1.0.0, current version 88.0.0)
+//! [44]
+
+
+//! [45]
+install_name_tool -change /path/to/Qt/lib/QtCore.framework/Versions/4.0/QtCore
+ @executable_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore
+ plugandpaint.app/Contents/plugins/libpnp_basictools.dylib
+install_name_tool -change /path/to/Qt/lib/QtGui.framework/Versions/4.0/QtGui
+ @executable_path/../Frameworks/QtGui.framework/Versions/4.0/QtGui
+ plugandpaint.app/Contents/plugins/libpnp_basictools.dylib
+//! [45]
+
+
+//! [46]
+#elif defined(Q_OS_MAC)
+if (pluginsDir.dirName() == "MacOS") {
+ pluginsDir.cdUp();
+}
+#endif
+//! [46]
+
+
+//! [47]
+cp -R /path/to/Qt/plugins/imageformats
+ pluginandpaint.app/Contents/plugins
+//! [47]
+
+
+//! [48]
+install_name_tool -change /path/to/Qt/lib/QtGui.framework/Versions/4.0/QtGui
+ @executable_path/../Frameworks/QtGui.framework/Versions/4.0/QtGui
+ plugandpaint.app/Contents/plugins/imageformats/libqjpeg.dylib
+install_name_tool -change /path/to/Qt/lib/QtCore.framework/Versions/4.0/QtCore
+ @executable_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore
+ plugandpaint.app/Contents/plugins/imageformats/libqjpeg.dylib
+//! [48]
+
+
+//! [49]
+QDir dir(QApplication::applicationDirPath());
+dir.cdUp();
+dir.cd("plugins");
+QApplication::setLibraryPaths(QStringList(dir.absolutePath()));
+//! [49]
+
+
+//! [50]
+otool -L MyApp.app/Contents/MacOS/MyApp
+//! [50]
+
+
+//! [51]
+QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.3
+//! [51]
+
+//! [51a]
+install_name_tool -change /System/Library/Frameworks/CoreVideo.framework/
+Versions/A/CoreVideo /System/Library/Frameworks/QuartzCore.framework/
+Versions/A/QuartzCore libphonon_qt7.dylib
+//! [51a]
+
+//! [51b]
+./CONFIGURE - SDK MacOSX10.4u.sdk
+//! [51b]
+
+//! [52]
+./configure (other arguments) -universal -sdk /Developer/SDKs/MacOSX10.4u.sdk
+//! [52]
+
+
+//! [53]
+QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.4u.sdk
+CONFIG+=x86 ppc
+//! [53]
+
+
+//! [54]
+qApp->addLibraryPath("C:/customPath/plugins");
+//! [54]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_designer-manual.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_designer-manual.qdoc
new file mode 100644
index 000000000..673081534
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_designer-manual.qdoc
@@ -0,0 +1,98 @@
+//! [0]
+CONFIG += uitools
+//! [0]
+
+
+//! [1]
+#include <QtUiTools>
+//! [1]
+
+
+//! [2]
+void on_<object name>_<signal name>(<signal parameters>);
+//! [2]
+
+
+//! [3]
+CONFIG += release
+//! [3]
+
+
+//! [4]
+target.path = $$[QT_INSTALL_PLUGINS]/designer
+INSTALLS += target
+//! [4]
+
+
+//! [5]
+QT += script
+//! [5]
+
+
+//! [6]
+widget.text = 'Hi - I was built ' + new Date().toString();
+//! [6]
+
+
+//! [7]
+class MyExtension: public QObject,
+ public QdesignerContainerExtension
+{
+ Q_OBJECT
+ Q_INTERFACE(QDesignerContainerExtension)
+
+ ...
+}
+//! [7]
+
+
+//! [8]
+QObject *ANewExtensionFactory::createExtension(QObject *object,
+ const QString &iid, QObject *parent) const
+{
+ if (iid != Q_TYPEID(QDesignerContainerExtension))
+ return 0;
+
+ if (MyCustomWidget *widget = qobject_cast<MyCustomWidget*>
+ (object))
+ return new MyContainerExtension(widget, parent);
+
+ return 0;
+}
+//! [8]
+
+
+//! [9]
+QObject *AGeneralExtensionFactory::createExtension(QObject *object,
+ const QString &iid, QObject *parent) const
+{
+ MyCustomWidget *widget = qobject_cast<MyCustomWidget*>(object);
+
+ if (widget && (iid == Q_TYPEID(QDesignerTaskMenuExtension))) {
+ return new MyTaskMenuExtension(widget, parent);
+
+ } else if (widget && (iid == Q_TYPEID(QDesignerContainerExtension))) {
+ return new MyContainerExtension(widget, parent);
+
+ } else {
+ return 0;
+ }
+}
+//! [9]
+
+
+//! [10]
+void MyPlugin::initialize(QDesignerFormEditorInterface *formEditor)
+{
+ if (initialized)
+ return;
+
+ QExtensionManager *manager = formEditor->extensionManager();
+ Q_ASSERT(manager != 0);
+
+ manager->registerExtensions(new MyExtensionFactory(manager),
+ Q_TYPEID(QDesignerTaskMenuExtension));
+
+ initialized = true;
+}
+//! [10]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_dnd.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_dnd.qdoc
new file mode 100644
index 000000000..40df804a6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_dnd.qdoc
@@ -0,0 +1,34 @@
+//! [0]
+void MyQt3Widget::customStartDragFunction()
+{
+ QDragObject *d = new QTextDrag( myHighlightedText(), this );
+ d->dragCopy();
+ // do NOT delete d.
+}
+//! [0]
+
+
+//! [1]
+void MyQt3Widget::dragEnterEvent(QDragEnterEvent* event)
+{
+ event->accept(
+ QTextDrag::canDecode(event) ||
+ QImageDrag::canDecode(event)
+ );
+}
+//! [1]
+
+
+//! [2]
+void MyQt3Widget::dropEvent(QDropEvent* event)
+{
+ QImage image;
+ QString text;
+
+ if ( QImageDrag::decode(event, image) ) {
+ insertImageAt(image, event->pos());
+ } else if ( QTextDrag::decode(event, text) ) {
+ insertTextAt(text, event->pos());
+ }
+}
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_emb-charinput.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_emb-charinput.qdoc
new file mode 100644
index 000000000..2539e1367
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_emb-charinput.qdoc
@@ -0,0 +1,20 @@
+//! [0]
+./configure -help
+//! [0]
+
+
+//! [1]
+configure -qt-kbd-s15000
+//! [1]
+
+
+//! [2]
+export QWS_KEYBOARD=<driver>[:<driver specific options>]
+//! [2]
+
+
+//! [3]
+export QWS_KEYBOARD="<driver>[:<driver specific options>]
+ <driver>[:<driver specific options>]
+ <driver>[:<driver specific options>]"
+//! [3]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_emb-crosscompiling.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_emb-crosscompiling.qdoc
new file mode 100644
index 000000000..3791bfc26
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_emb-crosscompiling.qdoc
@@ -0,0 +1,36 @@
+//! [0]
+export PATH=path/to/cross/compiler:$PATH
+//! [0]
+
+
+//! [1]
+./configure -embedded arm -xplatform qws/linux-arm-g++ <other options>
+//! [1]
+
+
+//! [2]
+cp path/to/QtEmbedded/mkspecs/qws/linux-mips-g++/...
+ path/to/QtEmbedded/mkspecs/qws/linux-myarchitecture-g++/...
+//! [2]
+
+
+//! [3]
+cd path/to/QtEmbedded
+./configure -embedded <architecture> -qt-kbd-<keyboarddriver>
+ -qt-mouse-<mousedriver> -qt-gfx-<screendriver>
+//! [3]
+
+
+//! [4]
+cd path/to/QtEmbedded
+./configure <other options>
+ -L /path/to/libjpeg/libraries -I /path/to/libjpeg/headers
+//! [4]
+
+
+//! [5]
+cd path/to/myApplication
+qmake -project
+qmake
+make
+//! [5]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_emb-envvars.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_emb-envvars.qdoc
new file mode 100644
index 000000000..c242ff3ca
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_emb-envvars.qdoc
@@ -0,0 +1,38 @@
+//! [0]
+export QWS_DISPLAY=<driver>[:<driver specific options>]...
+ [:<display num>]
+//! [0]
+
+
+//! [1]
+export QWS_SIZE=<width>x<height>
+//! [1]
+
+
+//! [2]
+export QWS_MOUSE_PROTO=<driver>[:<driver specific options>]
+//! [2]
+
+
+//! [3]
+export QWS_MOUSE_PROTO="<driver>[:<driver specific options>]
+ <driver>[:<driver specific options>]
+ <driver>[:<driver specific options>]"
+//! [3]
+
+
+//! [4]
+export QWS_MOUSE_PROTO="Vr41xx:press=500:/dev/misc/ts"
+//! [4]
+
+
+//! [5]
+export QWS_KEYBOARD=<driver>[:<driver specific options>]
+//! [5]
+
+
+//! [6]
+export QWS_KEYBOARD="<driver>[:<driver specific options>]
+ <driver>[:<driver specific options>]
+ <driver>[:<driver specific options>]"
+//! [6]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_emb-features.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_emb-features.qdoc
new file mode 100644
index 000000000..e64a0ae42
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_emb-features.qdoc
@@ -0,0 +1,18 @@
+//! [0]
+configure.exe -D QT_NO_THREAD
+//! [0]
+
+
+//! [1]
+./configure -no-feature-thread
+//! [1]
+
+
+//! [2]
+configure.exe -qconfig myfile
+//! [2]
+
+
+//! [3]
+./configure -qconfig myfile
+//! [3]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_emb-fonts.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_emb-fonts.qdoc
new file mode 100644
index 000000000..b39cb6f19
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_emb-fonts.qdoc
@@ -0,0 +1,3 @@
+//! [0]
+name file renderer italic weight size flags
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_emb-install.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_emb-install.qdoc
new file mode 100644
index 000000000..11ff012a9
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_emb-install.qdoc
@@ -0,0 +1,37 @@
+//! [0]
+cd <anywhere>
+gunzip qt-embedded-linux-commercial-src-4.5.2.tar.gz
+tar xf qt-embedded-linux-commercial-src-4.5.2.tar
+//! [0]
+
+
+//! [1]
+~/qt-embedded-linux-commercial-src-4.5.2
+//! [1]
+
+
+//! [2]
+cd ~/qt-embedded-linux-commercial-src-4.5.2
+./configure -embedded [architecture]
+//! [2]
+
+
+//! [3]
+make
+//! [3]
+
+
+//! [4]
+su -c "make install"
+//! [4]
+
+
+//! [5]
+PATH=/usr/local/Trolltech/QtEmbedded-4.5.2/bin:$PATH
+export PATH
+//! [5]
+
+
+//! [6]
+setenv PATH /usr/local/Trolltech/QtEmbedded-4.5.2/bin:$PATH
+//! [6]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_emb-performance.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_emb-performance.qdoc
new file mode 100644
index 000000000..7dcba12aa
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_emb-performance.qdoc
@@ -0,0 +1,36 @@
+//! [0]
+./configure -static
+//! [0]
+
+
+//! [1]
+void *operator new[](size_t size)
+{
+ return malloc(size);
+}
+
+void *operator new(size_t size)
+{
+ return malloc(size);
+}
+
+void operator delete[](void *ptr)
+{
+ free(ptr);
+}
+
+void operator delete[](void *ptr, size_t)
+{
+ free(ptr);
+}
+
+void operator delete(void *ptr)
+{
+ free(ptr);
+}
+
+void operator delete(void *ptr, size_t)
+{
+ free(ptr);
+}
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_emb-pointer.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_emb-pointer.qdoc
new file mode 100644
index 000000000..37eb9c68f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_emb-pointer.qdoc
@@ -0,0 +1,68 @@
+//! [0]
+ <qtopia-root-dir>/qtopiacore/qt/configure -embedded -help |grep -a1 mouse
+//! [0]
+
+
+//! [1]
+ ./configure -extra-qtopiacore-config -qt-mouse-tslib
+//! [1]
+
+
+//! [2]
+ ./configure -help
+//! [2]
+
+
+//! [3]
+ configure -qt-mouse-tslib
+//! [3]
+
+
+//! [4]
+export QWS_MOUSE_PROTO=<driver>[:<driver specific options>]
+//! [4]
+
+
+//! [5]
+export QWS_MOUSE_PROTO="<driver>[:<driver specific options>]
+ <driver>[:<driver specific options>]
+ <driver>[:<driver specific options>]"
+//! [5]
+
+
+//! [6]
+export QWS_MOUSE_PROTO="Vr41xx:press=500:/dev/misc/ts"
+//! [6]
+
+
+//! [7]
+./configure -L <path to tslib library> -I <path to tslib headers>
+//! [7]
+
+
+//! [8]
+module_raw input
+module linear
+//! [8]
+
+
+//! [9]
+QWS_MOUSE_PROTO=IntelliMouse:/dev/input/mouse0
+//! [9]
+
+
+//! [10]
+cat /dev/input/mouse0 | hexdump
+//! [10]
+
+
+//! [11]
+QWS_MOUSE_PROTO=IntelliMouse:/dev/input/mouse0
+//! [11]
+
+
+//! [12]
+chmod a+rw /dev/input/mouse0
+//! [12]
+
+
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_emb-qvfb.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_emb-qvfb.qdoc
new file mode 100644
index 000000000..827c84a52
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_emb-qvfb.qdoc
@@ -0,0 +1,70 @@
+//! [0]
+cd path/to/QtEmbedded
+./configure -qvfb
+make
+//! [0]
+
+
+//! [1]
+cd path/to/Qt/tools/qvfb
+make
+./qvfb
+//! [1]
+
+
+//! [2]
+cd path/to/Qt/tools/qvfb/ClamshellPhone.skin/
+//! [2]
+
+
+//! [3]
+[SkinFile]
+Up=ClamshellPhone1-5.png
+Down=ClamshellPhone1-5-pressed.png
+Closed=ClamshellPhone1-5-closed.png
+Screen=72 84 176 208
+Areas=22
+
+"Power" 0x0100000a 205 563 249 586
+"1" 0x0031 62 414 119 438
+"2" 0x0032 130 414 189 438
+"3" 0x0033 198 413 257 438
+"4" 0x0034 54 444 117 470
+"5" 0x0035 128 444 189 471
+"6" 0x0036 202 444 264 471
+"7" 0x0037 47 477 113 507
+"8" 0x0038 126 477 190 507
+"9" 0x0039 205 478 270 509
+"*" 0x002a 39 515 110 552
+"0" 0x0030 122 515 195 553
+"#" 0x0023 207 516 280 553
+"Context1" 0x01100000 137 360 108 383 123 410 90 409 60 387 63 378
+ 100 362
+"Back" 0x01000061 184 361 206 376 213 387 197 410 226 410 256 392
+ 258 381 244 369
+"Backspace" 0x01000003 68 563 113 587
+"Select" 0x01010000 160 391 172 390 181 386 184 381 180 377 173
+ 373 165 372 155 372 145 375 138 378 136
+ 382 138 387 147 390
+"Left" 0x1000012 141 390 136 385 136 381 143 375 132 371 120
+ 380 121 393 129 401
+"Down" 0x1000015 143 389 130 402 162 412 191 404 175 390
+"Right" 0x1000014 186 370 176 375 184 382 182 387 175 390 190 404
+ 201 396 202 375
+"Up" 0x1000013 133 370 143 374 176 374 185 370 169 362 149 362
+"Flip" 0x01100006 98 325 225 353
+//! [3]
+
+
+//! [4]
+cd path/to/QtEmbedded/examples/widgets/analogclock
+make
+./analogclock -qws
+//! [4]
+
+
+//! [5]
+cd path/to/QtEmbedded/examples/widgets/analogclock
+make
+./analogclock -qws -display QVFb:0
+//! [5]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_emb-running.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_emb-running.qdoc
new file mode 100644
index 000000000..b15cfc1a1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_emb-running.qdoc
@@ -0,0 +1,61 @@
+//! [0]
+cd path/to/QtEmbedded/demos/textedit
+./textedit -qws
+//! [0]
+
+
+//! [1]
+./myfirstserverapplication -qws -display "transformed:rot90:1"
+./mysecondserverapplication -qws -display "QVFb:2"
+//! [1]
+
+
+//! [2]
+./myclientapplication -display "QVFb:2"
+//! [2]
+
+
+//! [3]
+./myserverapplication -qws -display "Multi: QVFb:0
+ QVFb:1:offset=0,0 VNC:offset=640,0 :2"
+//! [3]
+
+
+//! [4]
+./myapplication -fn helvetica
+//! [4]
+
+
+//! [5]
+./myapplication -bg blue
+//! [5]
+
+
+//! [6]
+./myapplication -btn green
+//! [6]
+
+
+//! [7]
+./myapplication -fg 'dark blue'
+//! [7]
+
+
+//! [8]
+./myapplication -name texteditapplication
+//! [8]
+
+
+//! [9]
+./myapplication -title 'Text Edit'
+//! [9]
+
+
+//! [10]
+./myapplication -geometry 300x200+50+50
+//! [10]
+
+
+//! [11]
+./myapplication -decoration windows
+//! [11]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_emb-vnc.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_emb-vnc.qdoc
new file mode 100644
index 000000000..c35274f3f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_emb-vnc.qdoc
@@ -0,0 +1,25 @@
+//! [0]
+cd path/to/QtEmbedded
+./configure -qt-gfx-vnc
+make
+//! [0]
+
+
+//! [1]
+cd path/to/QtEmbedded/examples/widgets/analogclock
+./analogclock -qws -display VNC:0
+//! [1]
+
+
+//! [2]
+vncviewer localhost:0
+//! [2]
+
+//! [Starting server]
+analogclock -qws -display VNC:0
+//! [Starting server]
+//! [Starting clients]
+calculator -display VNC:0
+scribble -display VNC:0
+imageviewer -display VNC:0
+//! [Starting clients]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_examples_activeqt_comapp.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_activeqt_comapp.qdoc
new file mode 100644
index 000000000..0414e5016
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_activeqt_comapp.qdoc
@@ -0,0 +1,39 @@
+//! [0]
+Private Application As comappLib.Application
+Private MyApp As Boolean
+
+Private Sub UpdateList()
+ DocumentList.Clear
+ DocumentsCount.Caption = Application.documents.Count
+ For Index = 0 To Application.documents.Count - 1
+ DocumentList.AddItem (Application.documents.Item(Index).Title)
+ Next
+End Sub
+
+Private Sub Form_Load()
+ On Error GoTo CreateNew
+ Set Application = GetObject(, "comapp.Application")
+ MyApp = False
+ GoTo Initialized
+CreateNew:
+ On Error GoTo InitializeFailed
+ Set Application = New Application
+ Application.Visible = True
+ MyApp = True
+Initialized:
+ Caption = Application.id
+ UpdateList
+InitializeFailed:
+End Sub
+
+Private Sub Form_Unload(Cancel As Integer)
+ If MyApp Then
+ Application.quit
+ End If
+End Sub
+
+Private Sub NewDocument_Click()
+ Application.documents.addDocument
+ UpdateList
+End Sub
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_examples_activeqt_dotnet.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_activeqt_dotnet.qdoc
new file mode 100644
index 000000000..3bdf9fa5f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_activeqt_dotnet.qdoc
@@ -0,0 +1,4 @@
+//! [0]
+' VB is case insensitive, but our C++ controls are not.
+' Me.resetButton.enabled = True
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_examples_activeqt_menus.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_activeqt_menus.qdoc
new file mode 100644
index 000000000..18849dde0
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_activeqt_menus.qdoc
@@ -0,0 +1,6 @@
+//! [0]
+<object ID="QMenus" CLASSID="CLSID:4dc3f340-a6f7-44e4-a79b-3e9217695fbd"
+CODEBASE="http://qtsoftware.com/demos/menusax.cab">
+[Object not available! Did you forget to build and register the server?]
+</object>
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_examples_ahigl.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_ahigl.qdoc
new file mode 100644
index 000000000..bf29cdaab
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_ahigl.qdoc
@@ -0,0 +1,8 @@
+//! [0]
+myApplication -qws -display ahigl
+//! [0]
+
+
+//! [1]
+myApplication -qws -display ahigl
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_examples_application.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_application.qdoc
new file mode 100644
index 000000000..85e04f71b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_application.qdoc
@@ -0,0 +1,5 @@
+//! [0]
+application -style=windows
+application -style=motif
+application -style=cde
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_examples_arrowpad.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_arrowpad.qdoc
new file mode 100644
index 000000000..ba7f8eb97
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_arrowpad.qdoc
@@ -0,0 +1,19 @@
+//! [0]
+qApp->translate("ArrowPad", x)
+//! [0]
+
+
+//! [1]
+lrelease arrowpad.pro
+//! [1]
+
+
+//! [2]
+export LANG=fr
+setenv LANG fr
+//! [2]
+
+
+//! [3]
+set LANG=fr
+//! [3]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_examples_containerextension.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_containerextension.qdoc
new file mode 100644
index 000000000..299c0dc74
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_containerextension.qdoc
@@ -0,0 +1,4 @@
+//! [0]
+target.path = $$[QT_INSTALL_PLUGINS]/designer
+INSTALLS += target
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_examples_customwidgetplugin.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_customwidgetplugin.qdoc
new file mode 100644
index 000000000..299c0dc74
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_customwidgetplugin.qdoc
@@ -0,0 +1,4 @@
+//! [0]
+target.path = $$[QT_INSTALL_PLUGINS]/designer
+INSTALLS += target
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_examples_dropsite.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_dropsite.qdoc
new file mode 100644
index 000000000..fd949ea15
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_dropsite.qdoc
@@ -0,0 +1,3 @@
+//! [0]
+foreach(variable, container)
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_examples_editabletreemodel.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_editabletreemodel.qdoc
new file mode 100644
index 000000000..2475842d5
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_editabletreemodel.qdoc
@@ -0,0 +1,8 @@
+//! [0]
+QVariant a = model->index(0, 0, QModelIndex()).data();
+//! [0]
+
+
+//! [1]
+QVariant b = model->index(1, 0, QModelIndex()).data();
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_examples_hellotr.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_hellotr.qdoc
new file mode 100644
index 000000000..4f31bc090
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_hellotr.qdoc
@@ -0,0 +1,31 @@
+//! [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/codesnippets/doc/src/snippets/code/doc_src_examples_icons.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_icons.qdoc
new file mode 100644
index 000000000..3d33dff14
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_icons.qdoc
@@ -0,0 +1,14 @@
+//! [0]
+if (!condition)
+ qFatal("ASSERT: "condition" in file ...");
+//! [0]
+
+
+//! [1]
+qmake "CONFIG += debug" icons.pro
+//! [1]
+
+
+//! [2]
+qmake "CONFIG += release" icons.pro
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_examples_imageviewer.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_imageviewer.qdoc
new file mode 100644
index 000000000..c1854ec00
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_imageviewer.qdoc
@@ -0,0 +1,24 @@
+//! [0]
+imageLabel->resize(imageLabel->pixmap()->size());
+//! [0]
+
+
+//! [1]
+if (!imageLabel->pixmap())
+ qFatal("ASSERT: "imageLabel->pixmap()" in file ...");
+//! [1]
+
+
+//! [2]
+qmake "CONFIG += debug" foo.pro
+//! [2]
+
+
+//! [3]
+qmake "CONFIG += release" foo.pro
+//! [3]
+
+
+//! [4]
+scrollBar->setValue(int(factor * scrollBar->value()));
+//! [4]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_examples_qtscriptcustomclass.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_qtscriptcustomclass.qdoc
new file mode 100644
index 000000000..f958cc9f8
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_qtscriptcustomclass.qdoc
@@ -0,0 +1,35 @@
+//! [0]
+var ba = new ByteArray(); // constructs an empty ByteArray
+var ba2 = new ByteArray(10); // constructs a ByteArray of length 10 (all bytes initialized to 0)
+//! [0]
+
+
+//! [1]
+for (var i = 0; i < ba.length; ++i)
+ ba[i] = 123;
+//! [1]
+
+
+//! [2]
+ba[0] = 257;
+print(ba[0]); // 1
+//! [2]
+
+
+//! [3]
+var ba3 = new ByteArray();
+print(ba3.length); // 0
+ba[0] = 64;
+print(ba3.length); // 1
+//! [3]
+
+
+//! [4]
+ba["foo"] = "Hello";
+//! [4]
+
+
+//! [5]
+var ba64 = ba.toBase64();
+print(ba64.toLatin1String());
+//! [5]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_examples_simpledommodel.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_simpledommodel.qdoc
new file mode 100644
index 000000000..c74a17668
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_simpledommodel.qdoc
@@ -0,0 +1,20 @@
+//! [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/codesnippets/doc/src/snippets/code/doc_src_examples_simpletreemodel.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_simpletreemodel.qdoc
new file mode 100644
index 000000000..907f3db28
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_simpletreemodel.qdoc
@@ -0,0 +1,12 @@
+//! [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/codesnippets/doc/src/snippets/code/doc_src_examples_svgalib.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_svgalib.qdoc
new file mode 100644
index 000000000..3b63146eb
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_svgalib.qdoc
@@ -0,0 +1,3 @@
+//! [0]
+myApplication -qws -display svgalib
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_examples_taskmenuextension.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_taskmenuextension.qdoc
new file mode 100644
index 000000000..299c0dc74
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_taskmenuextension.qdoc
@@ -0,0 +1,4 @@
+//! [0]
+target.path = $$[QT_INSTALL_PLUGINS]/designer
+INSTALLS += target
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_examples_textfinder.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_textfinder.qdoc
new file mode 100644
index 000000000..349becf88
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_textfinder.qdoc
@@ -0,0 +1,6 @@
+//! [0]
+CONFIG += uitools
+HEADERS = textfinder.h
+RESOURCES = textfinder.qrc
+SOURCES = textfinder.cpp main.cpp
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_examples_trollprint.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_trollprint.qdoc
new file mode 100644
index 000000000..7f51a1557
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_trollprint.qdoc
@@ -0,0 +1,35 @@
+//! [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/codesnippets/doc/src/snippets/code/doc_src_examples_tutorial.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_tutorial.qdoc
new file mode 100644
index 000000000..0b79563ef
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_tutorial.qdoc
@@ -0,0 +1,10 @@
+//! [0]
+qmake -project
+qmake
+//! [0]
+
+
+//! [1]
+qmake -project
+qmake
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_examples_worldtimeclockplugin.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_worldtimeclockplugin.qdoc
new file mode 100644
index 000000000..299c0dc74
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_examples_worldtimeclockplugin.qdoc
@@ -0,0 +1,4 @@
+//! [0]
+target.path = $$[QT_INSTALL_PLUGINS]/designer
+INSTALLS += target
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_exportedfunctions.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_exportedfunctions.qdoc
new file mode 100644
index 000000000..f0e5fb59f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_exportedfunctions.qdoc
@@ -0,0 +1,17 @@
+//! [0]
+#ifdef Q_WS_X11
+void qt_x11_wait_for_window_manager(QWidget *widget);
+#endif
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ ...
+ window.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&window);
+#endif
+ ...
+ return app.exec();
+}
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_gpl.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_gpl.qdoc
new file mode 100644
index 000000000..b6ef9540d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_gpl.qdoc
@@ -0,0 +1,679 @@
+//! [GPL v3]
+ You may use, distribute and copy the Qt GUI Toolkit under the terms of
+ GNU General Public License version 3, which is displayed below.
+
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+//! [GPL v3]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_graphicsview.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_graphicsview.qdoc
new file mode 100644
index 000000000..4c1978488
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_graphicsview.qdoc
@@ -0,0 +1,77 @@
+//! [0]
+QGraphicsScene scene;
+QGraphicsRectItem *rect = scene.addRect(QRectF(0, 0, 100, 100));
+
+QGraphicsItem *item = scene.itemAt(50, 50);
+// item == rect
+//! [0]
+
+
+//! [1]
+QGraphicsScene scene;
+myPopulateScene(&scene);
+
+QGraphicsView view(&scene);
+view.show();
+//! [1]
+
+
+//! [2]
+class View : public QGraphicsView
+{
+Q_OBJECT
+ ...
+public slots:
+ void zoomIn() { scale(1.2, 1.2); }
+ void zoomOut() { scale(1 / 1.2, 1 / 1.2); }
+ void rotateLeft() { rotate(-10); }
+ void rotateRight() { rotate(10); }
+ ...
+};
+//! [2]
+
+
+//! [3]
+QGraphicsScene scene;
+scene.addRect(QRectF(0, 0, 100, 200), QPen(Qt::black), QBrush(Qt::green));
+
+QPrinter printer;
+if (QPrintDialog(&printer).exec() == QDialog::Accepted) {
+ QPainter painter(&printer);
+ painter.setRenderHint(QPainter::Antialiasing);
+ scene.render(&painter);
+}
+//! [3]
+
+
+//! [4]
+QGraphicsScene scene;
+scene.addRect(QRectF(0, 0, 100, 200), QPen(Qt::black), QBrush(Qt::green));
+
+QPixmap pixmap;
+QPainter painter(&pixmap);
+painter.setRenderHint(QPainter::Antialiasing);
+scene.render(&painter);
+painter.end();
+
+pixmap.save("scene.png");
+//! [4]
+
+
+//! [5]
+void CustomItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ QMimeData *data = new QMimeData;
+ data->setColor(Qt::green);
+
+ QDrag *drag = new QDrag(event->widget());
+ drag->setMimeData(data);
+ drag->start();
+}
+//! [5]
+
+
+//! [6]
+QGraphicsView view(&scene);
+view.setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
+//! [6]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_groups.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_groups.qdoc
new file mode 100644
index 000000000..51c294464
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_groups.qdoc
@@ -0,0 +1,26 @@
+//! [0]
+void QPen::setStyle(Qt::PenStyle style)
+{
+ detach(); // detach from common data
+ d->style = style; // set the style member
+}
+
+void QPen::detach()
+{
+ if (d->ref != 1) {
+ ... // perform a deep copy
+ }
+}
+//! [0]
+
+
+//! [1]
+QPixmap p1, p2;
+p1.load("image.bmp");
+p2 = p1; // p1 and p2 share data
+
+QPainter paint;
+paint.begin(&p2); // cuts p2 loose from p1
+paint.drawText(0,50, "Hi");
+paint.end();
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_i18n.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_i18n.qdoc
new file mode 100644
index 000000000..857e70c8e
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_i18n.qdoc
@@ -0,0 +1,155 @@
+//! [0]
+LoginWidget::LoginWidget()
+{
+ QLabel *label = new QLabel(tr("Password:"));
+ ...
+}
+//! [0]
+
+
+//! [1]
+void some_global_function(LoginWidget *logwid)
+{
+ QLabel *label = new QLabel(
+ LoginWidget::tr("Password:"), logwid);
+}
+
+void same_global_function(LoginWidget *logwid)
+{
+ QLabel *label = new QLabel(
+ qApp->translate("LoginWidget", "Password:"), logwid);
+}
+//! [1]
+
+
+//! [2]
+QString FriendlyConversation::greeting(int type)
+{
+ static const char *greeting_strings[] = {
+ QT_TR_NOOP("Hello"),
+ QT_TR_NOOP("Goodbye")
+ };
+ return tr(greeting_strings[type]);
+}
+//! [2]
+
+
+//! [3]
+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]);
+}
+//! [3]
+
+
+//! [4]
+void FileCopier::showProgress(int done, int total,
+ const QString &currentFile)
+{
+ label.setText(tr("%1 of %2 files copied.\nCopying: %3")
+ .arg(done)
+ .arg(total)
+ .arg(currentFile));
+}
+//! [4]
+
+
+//! [5]
+QString s1 = "%1 of %2 files copied. Copying: %3";
+QString s2 = "Kopierer nu %3. Av totalt %2 filer er %1 kopiert.";
+
+qDebug() << s1.arg(5).arg(10).arg("somefile.txt");
+qDebug() << s2.arg(5).arg(10).arg("somefile.txt");
+//! [5]
+
+
+//! [6]
+5 of 10 files copied. Copying: somefile.txt
+Kopierer nu somefile.txt. Av totalt 10 filer er 5 kopiert.
+//! [6]
+
+
+//! [7]
+HEADERS = funnydialog.h \
+ wackywidget.h
+SOURCES = funnydialog.cpp \
+ main.cpp \
+ wackywidget.cpp
+FORMS = fancybox.ui
+TRANSLATIONS = superapp_dk.ts \
+ superapp_fi.ts \
+ superapp_no.ts \
+ superapp_se.ts
+//! [7]
+
+
+//! [8]
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QTranslator qtTranslator;
+ qtTranslator.load("qt_" + QLocale::system().name(),
+ QLibraryInfo::location(QLibraryInfo::TranslationsPath));
+ app.installTranslator(&qtTranslator);
+
+ QTranslator myappTranslator;
+ myappTranslator.load("myapp_" + QLocale::system().name());
+ app.installTranslator(&myappTranslator);
+
+ ...
+ return app.exec();
+}
+//! [8]
+
+
+//! [9]
+QString string = ...; // some Unicode text
+
+QTextCodec *codec = QTextCodec::codecForName("ISO 8859-5");
+QByteArray encodedString = codec->fromUnicode(string);
+//! [9]
+
+
+//! [10]
+QByteArray encodedString = ...; // some ISO 8859-5 encoded text
+
+QTextCodec *codec = QTextCodec::codecForName("ISO 8859-5");
+QString string = codec->toUnicode(encodedString);
+//! [10]
+
+
+//! [11]
+void Clock::setTime(const QTime &time)
+{
+ if (tr("AMPM") == "AMPM") {
+ // 12-hour clock
+ } else {
+ // 24-hour clock
+ }
+}
+//! [11]
+
+
+//! [12]
+void QWidget::changeEvent(QEvent *event)
+{
+ if (e->type() == QEvent::LanguageChange) {
+ titleLabel->setText(tr("Document Title"));
+ ...
+ okPushButton->setText(tr("&OK"));
+ } else
+ QWidget::changeEvent(event);
+}
+//! [12]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_installation.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_installation.qdoc
new file mode 100644
index 000000000..761df444b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_installation.qdoc
@@ -0,0 +1,127 @@
+//! [0]
+cd /tmp
+gunzip qt-x11-opensource-desktop-4.5.2.tar.gz # uncompress the archive
+tar xvf qt-x11-opensource-desktop-4.5.2.tar # unpack it
+//! [0]
+
+
+//! [1]
+cd /tmp/qt-x11-opensource-desktop-4.5.2
+./configure
+//! [1]
+
+
+//! [2]
+make
+//! [2]
+
+
+//! [3]
+make install
+//! [3]
+
+
+//! [4]
+PATH - to locate qmake, moc and other Qt tools
+//! [4]
+
+
+//! [5]
+PATH=/usr/local/Trolltech/Qt-4.5.2/bin:$PATH
+export PATH
+//! [5]
+
+
+//! [6]
+setenv PATH /usr/local/Trolltech/Qt-4.5.2/bin:$PATH
+//! [6]
+
+
+//! [7]
+PATH - to locate qmake, moc and other Qt tools
+//! [7]
+
+
+//! [8]
+C:
+cd /D C:\Qt\4.5.2
+configure
+//! [8]
+
+
+//! [9]
+configure -platform win32-msvc
+//! [9]
+
+
+//! [10]
+nmake
+//! [10]
+
+
+//! [11]
+cd /tmp
+gunzip qt-mac-opensource-desktop-4.5.2.tar.gz # uncompress the archive
+tar xvf qt-mac-opensource-desktop-4.5.2.tar # unpack it
+//! [11]
+
+
+//! [12]
+cd /tmp/qt-mac-opensource-desktop-4.5.2
+./configure
+//! [12]
+
+
+//! [13]
+make
+//! [13]
+
+
+//! [14]
+sudo make -j1 install
+//! [14]
+
+
+//! [15]
+PATH - to locate qmake, moc and other Qt tools
+//! [15]
+
+
+//! [16]
+PATH=/usr/local/Trolltech/Qt-4.5.2/bin:$PATH
+export PATH
+//! [16]
+
+
+//! [17]
+setenv PATH /usr/local/Trolltech/Qt-4.5.2/bin:$PATH
+//! [17]
+
+
+//! [18]
+PATH - to locate qmake, moc and other Qt tools
+//! [18]
+
+
+//! [19]
+C:
+cd \Qt\4.5.2
+configure -platform win32-msvc2005 -xplatform wincewm50pocket-msvc2005
+//! [19]
+
+
+//! [20]
+set INCLUDE=C:\Program Files\Microsoft Visual Studio 8\VC\ce\include;C:\Program Files\Windows CE Tools\wce500\Windows Mobile 5.0 Pocket PC SDK\Include\Armv4i
+set LIB=C:\Program Files\Microsoft Visual Studio 8\VC\ce\lib\armv4i;C:\Program Files\Windows CE Tools\wce500\Windows Mobile 5.0 Pocket PC SDK\Lib\ARMV4I
+set PATH=C:\Program Files\Microsoft Visual Studio 8\VC\ce\bin\x86_arm;%PATH%
+//! [20]
+
+
+//! [21]
+setcepaths wincewm50pocket-msvc2005
+//! [21]
+
+
+//! [22]
+nmake
+//! [22]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_introtodbus.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_introtodbus.qdoc
new file mode 100644
index 000000000..bedfe7ff0
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_introtodbus.qdoc
@@ -0,0 +1,3 @@
+//! [0]
+org.freedesktop.DBus
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_layout.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_layout.qdoc
new file mode 100644
index 000000000..60f36b0b9
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_layout.qdoc
@@ -0,0 +1,126 @@
+//! [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/codesnippets/doc/src/snippets/code/doc_src_lgpl.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_lgpl.qdoc
new file mode 100644
index 000000000..dc76d85f4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_lgpl.qdoc
@@ -0,0 +1,507 @@
+//! [LGPL v2.1]
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
+
+//! [LGPL v2.1]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_licenses.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_licenses.qdoc
new file mode 100644
index 000000000..4a95a5008
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_licenses.qdoc
@@ -0,0 +1,108 @@
+//! [1]
+ [utopiafonts] 1999 free font
+ ----------------------------------------------------
+
+ this font is provided free for personal or commercial use,
+ it can be redistributed however it may not be sold.
+ ----------------------------------------------------
+ (C) 1999 utopiafonts. dale_thorpe@bssc.edu.au
+//! [1]
+
+
+//! [2]
+ Bitstream Vera Fonts Copyright
+ ------------------------------
+
+ Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is
+ a trademark of Bitstream, Inc.
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of the fonts accompanying this license ("Fonts") and associated
+ documentation files (the "Font Software"), to reproduce and distribute the
+ Font Software, including without limitation the rights to use, copy, merge,
+ publish, distribute, and/or sell copies of the Font Software, and to permit
+ persons to whom the Font Software is furnished to do so, subject to the
+ following conditions:
+
+ The above copyright and trademark notices and this permission notice shall
+ be included in all copies of one or more of the Font Software typefaces.
+
+ The Font Software may be modified, altered, or added to, and in particular
+ the designs of glyphs or characters in the Fonts may be modified and
+ additional glyphs or characters may be added to the Fonts, only if the fonts
+ are renamed to names not containing either the words "Bitstream" or the word
+ "Vera".
+
+ This License becomes null and void to the extent applicable to Fonts or Font
+ Software that has been modified and is distributed under the "Bitstream
+ Vera" names.
+
+ The Font Software may be sold as part of a larger software package but no
+ copy of one or more of the Font Software typefaces may be sold by itself.
+
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
+ TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
+ FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
+ ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE
+ FONT SOFTWARE.
+
+ Except as contained in this notice, the names of Gnome, the Gnome
+ Foundation, and Bitstream Inc., shall not be used in advertising or
+ otherwise to promote the sale, use or other dealings in this Font Software
+ without prior written authorization from the Gnome Foundation or Bitstream
+ Inc., respectively. For further information, contact: fonts at gnome dot
+ org.
+
+ Arev Fonts Copyright
+ ------------------------------
+
+ Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of the fonts accompanying this license ("Fonts") and
+ associated documentation files (the "Font Software"), to reproduce
+ and distribute the modifications to the Bitstream Vera Font Software,
+ including without limitation the rights to use, copy, merge, publish,
+ distribute, and/or sell copies of the Font Software, and to permit
+ persons to whom the Font Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright and trademark notices and this permission notice
+ shall be included in all copies of one or more of the Font Software
+ typefaces.
+
+ The Font Software may be modified, altered, or added to, and in
+ particular the designs of glyphs or characters in the Fonts may be
+ modified and additional glyphs or characters may be added to the
+ Fonts, only if the fonts are renamed to names not containing either
+ the words "Tavmjong Bah" or the word "Arev".
+
+ This License becomes null and void to the extent applicable to Fonts
+ or Font Software that has been modified and is distributed under the
+ "Tavmjong Bah Arev" names.
+
+ The Font Software may be sold as part of a larger software package but
+ no copy of one or more of the Font Software typefaces may be sold by
+ itself.
+
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL
+ TAVMJONG BAH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+ OTHER DEALINGS IN THE FONT SOFTWARE.
+
+ Except as contained in this notice, the name of Tavmjong Bah shall not
+ be used in advertising or otherwise to promote the sale, use or other
+ dealings in this Font Software without prior written authorization
+ from Tavmjong Bah. For further information, contact: tavmjong @ free
+ . fr.
+
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_linguist-manual.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_linguist-manual.qdoc
new file mode 100644
index 000000000..ce3b99768
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_linguist-manual.qdoc
@@ -0,0 +1,183 @@
+//! [0]
+HEADERS = main-dlg.h \
+ options-dlg.h
+SOURCES = main-dlg.cpp \
+ options-dlg.cpp \
+ main.cpp
+FORMS = search-dlg.ui
+TRANSLATIONS = superapp_dk.ts \
+ superapp_fi.ts \
+ superapp_no.ts \
+ superapp_se.ts
+//! [0]
+
+
+//! [1]
+CODECFORTR = ISO-8859-5
+//! [1]
+
+
+//! [2]
+CODECFORSRC = UTF-8
+//! [2]
+
+
+//! [3]
+label->setText(tr("F\374r \310lise"));
+//! [3]
+
+
+//! [4]
+Usage:
+ lupdate [options] [project-file]
+ lupdate [options] [source-file|path]... -ts ts-files
+Options:
+ -help Display this information and exit.
+ -noobsolete
+ Drop all obsolete strings.
+ -extensions <ext>[,<ext>]...
+ Process files with the given extensions only.
+ The extension list must be separated with commas, not with whitespace.
+ Default: 'ui,c,c++,cc,cpp,cxx,ch,h,h++,hh,hpp,hxx'.
+ -pluralonly
+ Only include plural form messages.
+ -silent
+ Don't explain what is being done.
+ -version
+ Display the version of lupdate and exit.
+//! [4]
+
+
+//! [5]
+Usage:
+ lrelease [options] project-file
+ lrelease [options] ts-files [-qm qm-file]
+Options:
+ -help Display this information and exit
+ -compress
+ Compress the .qm files
+ -nounfinished
+ Do not include unfinished translations
+ -removeidentical
+ If the translated text is the same as
+ the source text, do not include the message
+ -silent
+ Don't explain what is being done
+ -version
+ Display the version of lrelease and exit
+//! [5]
+
+
+void wrapInFunction()
+{
+//! [6]
+button = new QPushButton("&Quit", this);
+//! [6]
+
+
+//! [7]
+button = new QPushButton(tr("&Quit"), this);
+//! [7]
+
+
+//! [8]
+QPushButton::tr("&Quit")
+//! [8]
+
+
+//! [9]
+QObject::tr("&Quit")
+//! [9]
+
+
+//! [10]
+rbc = new QRadioButton(tr("Enabled", "Color frame"), this);
+//! [10]
+
+
+//! [11]
+rbh = new QRadioButton(tr("Enabled", "Hue frame"), this);
+//! [11]
+}
+
+
+//! [12]
+/*
+ TRANSLATOR FindDialog
+
+ Choose Edit|Find from the menu bar or press Ctrl+F to pop up the
+ Find dialog.
+
+ ...
+*/
+//! [12]
+
+//! [13]
+/*
+ TRANSLATOR MyNamespace::MyClass
+
+ Necessary for lupdate.
+
+ ...
+*/
+//! [13]
+
+//! [14]
+void some_global_function(LoginWidget *logwid)
+{
+ QLabel *label = new QLabel(
+ LoginWidget::tr("Password:"), logwid);
+}
+
+void same_global_function(LoginWidget *logwid)
+{
+ QLabel *label = new QLabel(
+ qApp->translate("LoginWidget", "Password:"),
+ logwid);
+}
+//! [14]
+
+
+//! [15]
+QString FriendlyConversation::greeting(int greet_type)
+{
+ static const char* greeting_strings[] = {
+ QT_TR_NOOP("Hello"),
+ QT_TR_NOOP("Goodbye")
+ };
+ return tr(greeting_strings[greet_type]);
+}
+//! [15]
+
+
+//! [16]
+static const char* greeting_strings[] = {
+ QT_TRANSLATE_NOOP("FriendlyConversation", "Hello"),
+ QT_TRANSLATE_NOOP("FriendlyConversation", "Goodbye")
+};
+
+QString FriendlyConversation::greeting(int greet_type)
+{
+ return tr(greeting_strings[greet_type]);
+}
+
+QString global_greeting(int greet_type)
+{
+ return qApp->translate("FriendlyConversation",
+ greeting_strings[greet_type]);
+}
+//! [16]
+
+void wrapInFunction()
+{
+
+//! [17]
+QString tr(const char *text, const char *comment, int n);
+//! [17]
+
+//! [18]
+tr("%n item(s) replaced", "", count);
+//! [18]
+
+}
+
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_moc.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_moc.qdoc
new file mode 100644
index 000000000..59739e1a3
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_moc.qdoc
@@ -0,0 +1,124 @@
+//! [0]
+moc_%.cpp: %.h
+ moc $(DEFINES) $(INCPATH) $< -o $@
+//! [0]
+
+
+//! [1]
+moc_foo.cpp: foo.h
+ moc $(DEFINES) $(INCPATH) $< -o $@
+//! [1]
+
+
+//! [2]
+foo.o: foo.moc
+
+foo.moc: foo.cpp
+ moc $(DEFINES) $(INCPATH) -i $< -o $@
+//! [2]
+
+
+//! [3]
+#include "foo.moc"
+//! [3]
+
+
+//! [4]
+#ifndef Q_MOC_RUN
+ ...
+#endif
+//! [4]
+
+
+//! [5]
+class SomeTemplate<int> : public QFrame
+{
+ Q_OBJECT
+ ...
+
+signals:
+ void mySignal(int);
+};
+//! [5]
+
+
+//! [6]
+// correct
+class SomeClass : public QObject, public OtherClass
+{
+ ...
+};
+//! [6]
+
+
+//! [7]
+class SomeClass : public QObject
+{
+ Q_OBJECT
+
+public slots:
+ void apply(void (*apply)(List *, void *), char *); // WRONG
+};
+//! [7]
+
+
+//! [8]
+typedef void (*ApplyFunction)(List *, void *);
+
+class SomeClass : public QObject
+{
+ Q_OBJECT
+
+public slots:
+ void apply(ApplyFunction, char *);
+};
+//! [8]
+
+
+//! [9]
+class MyClass : public QObject
+{
+ Q_OBJECT
+
+ enum Error {
+ ConnectionRefused,
+ RemoteHostClosed,
+ UnknownError
+ };
+
+signals:
+ void stateChanged(MyClass::Error error);
+};
+//! [9]
+
+
+//! [10]
+#ifdef ultrix
+#define SIGNEDNESS(a) unsigned a
+#else
+#define SIGNEDNESS(a) a
+#endif
+
+class Whatever : public QObject
+{
+ Q_OBJECT
+
+signals:
+ void someSignal(SIGNEDNESS(int));
+};
+//! [10]
+
+
+//! [11]
+class A
+{
+public:
+ class B
+ {
+ Q_OBJECT
+
+ public slots: // WRONG
+ void b();
+ };
+};
+//! [11]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_model-view-programming.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_model-view-programming.qdoc
new file mode 100644
index 000000000..3501ce0bd
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_model-view-programming.qdoc
@@ -0,0 +1,36 @@
+//! [0]
+QAbstractItemModel *model = index.model();
+//! [0]
+
+
+//! [1]
+QModelIndex index = model->index(row, column, ...);
+//! [1]
+
+
+//! [2]
+QModelIndex indexA = model->index(0, 0, QModelIndex());
+QModelIndex indexB = model->index(1, 1, QModelIndex());
+QModelIndex indexC = model->index(2, 1, QModelIndex());
+//! [2]
+
+
+//! [3]
+QModelIndex index = model->index(row, column, parent);
+//! [3]
+
+
+//! [4]
+QModelIndex indexA = model->index(0, 0, QModelIndex());
+QModelIndex indexC = model->index(2, 1, QModelIndex());
+//! [4]
+
+
+//! [5]
+QModelIndex indexB = model->index(1, 0, indexA);
+//! [5]
+
+
+//! [6]
+QVariant value = model->data(index, role);
+//! [6]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_modules.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_modules.qdoc
new file mode 100644
index 000000000..e9006fd69
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_modules.qdoc
@@ -0,0 +1,3 @@
+//! [0]
+QT -= gui
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_objecttrees.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_objecttrees.qdoc
new file mode 100644
index 000000000..216027f27
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_objecttrees.qdoc
@@ -0,0 +1,20 @@
+//![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/codesnippets/doc/src/snippets/code/doc_src_phonon-api.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_phonon-api.qdoc
new file mode 100644
index 000000000..e2307929c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_phonon-api.qdoc
@@ -0,0 +1,224 @@
+//! [0]
+PushStream::PushStream(QObject *parent)
+ : AbstractMediaStream(parent), m_timer(new QTimer(this))
+{
+ setStreamSize(getMediaStreamSize());
+
+ connect(m_timer, SIGNAL(timeout()), SLOT(moreData()));
+ m_timer->setInterval(0);
+}
+
+void PushStream::moreData()
+{
+ const QByteArray data = getMediaData();
+ if (data.isEmpty()) {
+ endOfData();
+ } else {
+ writeData(data);
+ }
+}
+
+void PushStream::needData()
+{
+ m_timer->start();
+ moreData();
+}
+
+void PushStream::enoughData()
+{
+ m_timer->stop();
+}
+//! [0]
+
+
+//! [1]
+PullStream::PullStream(QObject *parent)
+ : AbstractMediaStream(parent)
+{
+ setStreamSize(getMediaStreamSize());
+}
+
+void PullStream::needData()
+{
+ const QByteArray data = getMediaData();
+ if (data.isEmpty()) {
+ endOfData();
+ } else {
+ writeData(data);
+ }
+}
+//! [1]
+
+
+//! [2]
+seekStream(0);
+//! [2]
+
+
+//! [3]
+MediaObject m;
+QString fileName("/home/foo/bar.ogg");
+QUrl url("http://www.example.com/stream.mp3");
+QBuffer *someBuffer;
+m.setCurrentSource(fileName);
+m.setCurrentSource(url);
+m.setCurrentSource(someBuffer);
+m.setCurrentSource(Phonon::Cd);
+//! [3]
+
+
+//! [4]
+VideoPlayer *player = new VideoPlayer(Phonon::VideoCategory, parentWidget);
+connect(player, SIGNAL(finished()), player, SLOT(deleteLater()));
+player->play(url);
+//! [4]
+
+
+//! [5]
+audioPlayer->load(url);
+audioPlayer->play();
+//! [5]
+
+
+//! [6]
+media = new MediaObject(this);
+connect(media, SIGNAL(finished()), SLOT(slotFinished());
+media->setCurrentSource("/home/username/music/filename.ogg");
+
+...
+
+media->play();
+//! [6]
+
+
+//! [7]
+media->setCurrentSource(":/sounds/startsound.ogg");
+media->enqueue("/home/username/music/song.mp3");
+media->enqueue(":/sounds/endsound.ogg");
+//! [7]
+
+
+//! [8]
+ media->setCurrentSource(":/sounds/startsound.ogg");
+ connect(media, SIGNAL(aboutToFinish()), SLOT(enqueueNextSource()));
+}
+
+void enqueueNextSource()
+{
+ media->enqueue("/home/username/music/song.mp3");
+}
+//! [8]
+
+
+//! [9]
+int x = 200;
+media->setTickInterval(x);
+Q_ASSERT(x == producer->tickInterval());
+//! [9]
+
+
+//! [10]
+int x = 200;
+media->setTickInterval(x);
+Q_ASSERT(x >= producer->tickInterval() &&
+ x <= 2producer->tickInterval());
+//! [10]
+
+
+//! [11]
+ connect(media, SIGNAL(hasVideoChanged(bool)), hasVideoChanged(bool));
+ media->setCurrentSource("somevideo.avi");
+ media->hasVideo(); // returns false;
+}
+
+void hasVideoChanged(bool b)
+{
+ // b == true
+ media->hasVideo(); // returns true;
+}
+//! [11]
+
+
+//! [12]
+ connect(media, SIGNAL(hasVideoChanged(bool)), hasVideoChanged(bool));
+ media->setCurrentSource("somevideo.avi");
+ media->hasVideo(); // returns false;
+}
+
+void hasVideoChanged(bool b)
+{
+ // b == true
+ media->hasVideo(); // returns true;
+}
+//! [12]
+
+
+//! [13]
+setMetaArtist(media->metaData("ARTIST"));
+setMetaAlbum(media->metaData("ALBUM"));
+setMetaTitle(media->metaData("TITLE"));
+setMetaDate(media->metaData("DATE"));
+setMetaGenre(media->metaData("GENRE"));
+setMetaTrack(media->metaData("TRACKNUMBER"));
+setMetaComment(media->metaData("DESCRIPTION"));
+//! [13]
+
+
+//! [14]
+QUrl url("http://www.example.com/music.ogg");
+media->setCurrentSource(url);
+//! [14]
+
+
+//! [15]
+progressBar->setRange(0, 100); // this is the default
+connect(media, SIGNAL(bufferStatus(int)), progressBar, SLOT(setValue(int)));
+//! [15]
+
+
+//! [16]
+QObject::connect(BackendCapabilities::notifier(), SIGNAL(capabilitiesChanged()), ...
+//! [16]
+
+
+//! [17]
+QComboBox *cb = new QComboBox(parentWidget);
+ObjectDescriptionModel *model = new ObjectDescriptionModel(cb);
+model->setModelData(BackendCapabilities::availableAudioOutputDevices());
+cb->setModel(model);
+cb->setCurrentIndex(0); // select first entry
+//! [17]
+
+
+//! [18]
+int cbIndex = cb->currentIndex();
+AudioOutputDevice selectedDevice = model->modelData(cbIndex);
+//! [18]
+
+
+//! [19]
+Path path = Phonon::createPath(...);
+Effect *effect = new Effect(this);
+path.insertEffect(effect);
+//! [19]
+
+
+//! [20]
+MediaObject *media = new MediaObject;
+AudioOutput *output = new AudioOutput(Phonon::MusicCategory);
+Path path = Phonon::createPath(media, output);
+Q_ASSERT(path.isValid()); // for this simple case the path should always be
+ //valid - there are unit tests to ensure it
+// insert an effect
+QList<EffectDescription> effectList = BackendCapabilities::availableAudioEffects();
+if (!effectList.isEmpty()) {
+ Effect *effect = path.insertEffect(effectList.first());
+}
+//! [20]
+
+
+//! [21]
+MediaObject *media = new MediaObject(parent);
+VideoWidget *vwidget = new VideoWidget(parent);
+Phonon::createPath(media, vwidget);
+//! [21]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_phonon.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_phonon.qdoc
new file mode 100644
index 000000000..3e4bce49f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_phonon.qdoc
@@ -0,0 +1,13 @@
+//! [0]
+QT += phonon
+//! [0]
+
+
+//! [1]
+QT += phonon
+//! [1]
+
+
+//! [2]
+#include <Phonon/MediaObject>
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_platform-notes.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_platform-notes.qdoc
new file mode 100644
index 000000000..ed56a0899
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_platform-notes.qdoc
@@ -0,0 +1,39 @@
+//! [0]
+undefined reference to `_vt.11QPushButton'
+//! [0]
+
+
+//! [1]
+ANSI C++ forbids declaration ... with no type
+//! [1]
+
+
+//! [2]
+c:\program.obj not found
+//! [2]
+
+
+//! [3]
+-universal -sdk /Developer/SDKs/MacOSX10.4u.sdk
+//! [3]
+
+
+//! [4]
+QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.4u.sdk
+CONFIG+=x86 ppc
+//! [4]
+
+
+//! [5]
+/usr/bin/ld: /System/Library/Frameworks/Carbon.framework/Carbon
+load command 20 unknown cmd field
+/usr/bin/ld: /usr/lib/libSystem.dylib
+load command 6 unknown cmd field
+//! [5]
+
+
+//! [6]
+ld: common symbols not allowed with MH_DYLIB output format with the -multi_module option
+/usr/local/mysql/lib/libmysqlclient.a(my_error.o) definition of common _errbuff (size 512)
+/usr/bin/libtool: internal link edit command failed
+//! [6]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_plugins-howto.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_plugins-howto.qdoc
new file mode 100644
index 000000000..45c869087
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_plugins-howto.qdoc
@@ -0,0 +1,67 @@
+//! [0]
+class MyStylePlugin : public QStylePlugin
+{
+public:
+ QStringList keys() const;
+ QStyle *create(const QString &key);
+};
+//! [0]
+
+
+//! [1]
+#include "mystyleplugin.h"
+
+QStringList MyStylePlugin::keys() const
+{
+ return QStringList() << "MyStyle";
+}
+
+QStyle *MyStylePlugin::create(const QString &key)
+{
+ if (key.toLower() == "mystyle")
+ return new MyStyle;
+ return 0;
+}
+
+Q_EXPORT_PLUGIN2(pnp_mystyleplugin, MyStylePlugin)
+//! [1]
+
+
+//! [2]
+QApplication::setStyle(QStyleFactory::create("MyStyle"));
+//! [2]
+
+
+//! [3]
+CONFIG += release
+//! [3]
+
+
+//! [4]
+#include <QApplication>
+#include <QtPlugin>
+
+Q_IMPORT_PLUGIN(qjpeg)
+Q_IMPORT_PLUGIN(qgif)
+Q_IMPORT_PLUGIN(qkrcodecs)
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ ...
+ return app.exec();
+}
+//! [4]
+
+
+//! [5]
+QTPLUGIN += qjpeg \
+ qgif \
+ qkrcodecs
+//! [5]
+
+
+//! [6]
+HKEY_CURRENT_USER\Software\Trolltech\OrganizationDefaults\Qt Plugin Cache 4.2.debug
+HKEY_CURRENT_USER\Software\Trolltech\OrganizationDefaults\Qt Plugin Cache 4.2.false
+//! [6]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_porting-qsa.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_porting-qsa.qdoc
new file mode 100644
index 000000000..0dc572cd9
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_porting-qsa.qdoc
@@ -0,0 +1,187 @@
+//! [0]
+point = new Object();
+point.x = 12;
+point.y = 35;
+//! [0]
+
+
+//! [1]
+function manhattanLength(point) {
+ return point.x + point.y;
+}
+//! [1]
+
+
+//! [2]
+manhattanLength = function(point) {
+ return point.x + point.y;
+}
+//! [2]
+
+
+//! [3]
+point.manhattanLength = function() {
+ return this.x + this.y;
+}
+print(point.manhattanLength()); // prints 47
+//! [3]
+
+
+//! [4]
+class Point() {
+ var x;
+ var y;
+ function manhattanLength() { return x + y; }
+}
+//! [4]
+
+
+//! [5]
+point.manhattanLength = function() {
+ return this.x + this.y;
+}
+print(point.manhattanLength()); // prints 47
+//! [5]
+
+
+//! [6]
+class Car {
+ var regNumber;
+ function Car(regnr) {
+ regNumber = regnr;
+ }
+}
+var car = new Car("ABC 123");
+//! [6]
+
+
+//! [7]
+function Car(regnr) {
+ this.regNumber = regnr;
+}
+var car = new Car("ABC 123");
+//! [7]
+
+
+//! [8]
+var car = new Object();
+car.constructor = function(regnr) { ... }
+car.constructor();
+//! [8]
+
+
+//! [9]
+class Car {
+ var regNumber;
+ function Car(regnr) {
+ regNumber = regnr;
+ }
+ function toString() {
+ return regNumber;
+ }
+}
+//! [9]
+
+
+//! [10]
+function Car(regnr) {
+ this.regNumber = regnr;
+ this.toString = function() { return this.regNumber; }
+}
+//! [10]
+
+
+//! [11]
+function Car(regnr) {
+ this.regNumber = regnr;
+}
+Car.prototype.toString = function() { return this.regNumber; }
+//! [11]
+
+
+//! [12]
+class GasolineCar extends Car {
+ function GasolineCar(regnr) {
+ Car(regnr);
+ }
+ function toString() {
+ return "GasolineCar(" + regNumber + ")";
+ }
+}
+//! [12]
+
+
+//! [13]
+function GasolineCar(regnr) {
+ Car(regnr);
+}
+GasolineCar.prototype = new Car();
+GasolineCar.prototype.toString = function() {
+ return "GasolineCar(" + this.regNumber + ")";
+}
+//! [13]
+
+
+//! [14]
+class Car {
+ static var globalCount = 0;
+}
+print(Car.globalCount);
+//! [14]
+
+
+//! [15]
+Car.globalCount = 0;
+print(Car.globalCount);
+//! [15]
+
+
+//! [16]
+QPushButton *button = new QPushButton();
+button->setObjectName("button");
+interpreter->addTransientObject(button);
+//! [16]
+
+
+//! [17]
+QPushButton *button = new QPushButton();
+QScriptValue scriptButton = engine.newQObject(button);
+engine.globalObject().setProperty("button", scriptButton);
+//! [17]
+
+
+//! [18]
+ModuleFactory::ModuleFactory()
+{
+ registerClass( "ImageSource", &ImgSource::staticMetaObject);
+ ...
+}
+
+QObject *ModuleFactory::create( const QString &type,
+ const QVariantList &,
+ QObject * )
+{
+ if ( type == "ImageSource" )
+ return new ImgSource();
+ ...
+}
+
+...
+
+interpreter.addObjectFactory(new ModuleFactory());
+//! [18]
+
+
+//! [19]
+QScriptValue construct_QPushButton(QScriptContext *, QScriptEngine *engine) {
+ return engine->newQObject(new QPushButton());
+}
+
+...
+
+QScriptValue constructor = engine.newFunction(construct_QPushButton);
+QScriptValue value =
+ engine.newQMetaObject(&QPushButton::staticMetaObject,
+ constructor);
+engine.globalObject().setProperty("QPushButton", value);
+//! [19]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_porting4-canvas.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_porting4-canvas.qdoc
new file mode 100644
index 000000000..e38660754
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_porting4-canvas.qdoc
@@ -0,0 +1,116 @@
+//! [0]
+item->scene().sceneRect().intersects(item->sceneBoundingRect());
+//! [0]
+
+
+//! [1]
+class TileScene : public QGraphicsScene
+{
+public:
+ ...
+
+ void setTiles(const QPixmap &pixmap, int h, int v,
+ int tileHeight, int tileWidth);
+ void setTile(int x, int y, int tilenum);
+
+private:
+ QRect tileRect(int x, int y) const;
+ QRect tileRect(int tileNum) const;
+
+ QVector<QVector<int> > tiles;
+ QPixmap tilePixmap;
+ int tileW, tileH;
+ int hTiles, vTiles;
+};
+//! [1]
+
+
+//! [2]
+void TileScene::setTiles(const QPixmap &pixmap, int h, int v,
+ int tileHeight, int tileWidth)
+{
+ tilePixmap = pixmap;
+ tileW = tileWidth;
+ tileH = tileHeight;
+ hTiles = h;
+ vTiles = v;
+
+ tiles.resize(v);
+ for (int y = 0; y < v; ++y)
+ tiles[y].resize(h);
+}
+//! [2]
+
+
+//! [3]
+void TileScene::setTile(int x, int y, int tilenum)
+{
+ tiles[y][x] = tilenum;
+ update(tileRect(x, y));
+}
+//! [3]
+
+
+//! [4]
+QRect TileScene::tileRect(int x, int y) const
+{
+ return QRect(x * tileW, y * tileH, tileW, tileH);
+}
+//! [4]
+
+
+//! [5]
+QRect TileScene::tileRect(int tileNum) const
+{
+ int numHTiles = tilePixmap.width() / tileW;
+ int numVTiles = tilePixmap.height() / tileH;
+ return tileRect(tileNum % numHTiles, tileNum / numHTiles);
+}
+//! [5]
+
+
+//! [6]
+void drawBackground(QPainter *painter, const QRectF &exposed)
+{
+ for (int y = 0; y < vTiles; ++y) {
+ for (int x = 0; x < hTiles; ++x) {
+ QRect destRect = tileRect(x, y);
+ if (exposed.intersects(destRect)) {
+ painter->drawPixmap(destRect, tilePixmap,
+ tileRect(tiles[y][x]));
+ }
+ }
+ }
+}
+//! [6]
+
+
+//! [7]
+ // Before
+ Q3CanvasEllipse ellipse(10, 10);
+
+ // After
+ QGraphicsEllipseItem ellipse(-5, -5, 10, 10);
+//! [7]
+
+
+//! [8]
+static QPainterPath fromControlPoints(const Q3PointArray &pa)
+{
+ QPainterPath path;
+ path.moveTo(pa[0]);
+ for (int i = 1; i < pa.size(); i += 3)
+ path.cubicTo(pa[i], pa[(i + 1) % pa.size()], pa[(i + 2) % pa.size()]);
+ return path;
+}
+//! [8]
+
+
+//! [9]
+wildcardPath.replace("%1", "*");
+QFileInfo fi(wildcardPath);
+
+QList<QPixmap> frames;
+foreach (QString entry, QDir(fi.path(), fi.fileName()).entryList())
+ frames << QPixmap(fi.path() + "/" + entry);
+//! [9]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_porting4-designer.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_porting4-designer.qdoc
new file mode 100644
index 000000000..d4abaa049
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_porting4-designer.qdoc
@@ -0,0 +1,159 @@
+//! [0]
+namespace Ui {
+
+class HelloWorld
+{
+public:
+ QVBoxLayout *vboxLayout;
+ QPushButton *pushButton;
+
+ void setupUi(QWidget *HelloWorld)
+ {
+ HelloWorld->setObjectName(QString::fromUtf8("HelloWorld"));
+
+ vboxLayout = new QVBoxLayout(HelloWorld);
+ vboxLayout->setObjectName(QString::fromUtf8("vboxLayout"));
+
+ pushButton = new QPushButton(HelloWorld);
+ pushButton->setObjectName(QString::fromUtf8("pushButton"));
+
+ vboxLayout->addWidget(pushButton);
+
+ retranslateUi(HelloWorld);
+ }
+};
+
+}
+//! [0]
+
+
+//! [1]
+#include <QApplication>
+#include <QWidget>
+
+#include "ui_helloworld.h" // defines Ui::HelloWorld
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QWidget w;
+ Ui::HelloWorld ui;
+ ui.setupUi(&w);
+
+ w.show();
+ return app.exec();
+}
+//! [1]
+
+
+//! [2]
+#include <QApplication>
+#include <QWidget>
+
+#include "ui_helloworld.h" // defines Ui::HelloWorld
+
+class HelloWorldWidget : public QWidget, public Ui::HelloWorld
+{
+ Q_OBJECT
+
+public:
+ HelloWorldWidget(QWidget *parent = 0)
+ : QWidget(parent)
+ { setupUi(this); }
+};
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ HelloWorldWidget w;
+ w.show();
+ return app.exec();
+}
+//! [2]
+
+
+//! [3]
+uic3 myform.ui > myform.h
+uic3 -impl myform.h myform.ui > myform.cpp
+//! [3]
+
+
+//! [4]
+uic3 -convert myform3.ui > myform4.ui
+//! [4]
+
+
+//! [5]
+class HelloWorldWidget : public QWidget, public Ui::HelloWorld
+{
+ Q_OBJECT
+
+public:
+ HelloWorldWidget(QWidget *parent = 0);
+
+public slots:
+ void mySlot();
+};
+
+HelloWorldWidget::HelloWorldWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ setupUi(this);
+
+ QObject::connect(pushButton, SIGNAL(clicked()),
+ this, SLOT(mySlot()));
+}
+
+void HelloWorldWidget::mySlot()
+{
+ ...
+}
+//! [5]
+
+
+//! [6]
+class HelloWorldWidget : public QWidget, public Ui::HelloWorld
+{
+ Q_OBJECT
+
+public:
+ HelloWorldWidget(QWidget *parent = 0);
+
+public slots:
+ void on_pushButton_clicked();
+};
+
+HelloWorldWidget::HelloWorldWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ setupUi(this);
+}
+
+void HelloWorldWidget::on_pushButton_clicked()
+{
+ ...
+}
+//! [6]
+
+
+//! [7]
+<RCC version="1.0">
+ <qresource prefix="/icons">
+ <file>yes.png</file>
+ <file>no.png</file>
+ </qresource>
+</RCC>
+//! [7]
+
+
+//! [8]
+RESOURCES += icons.qrc
+//! [8]
+
+
+//! [9]
+QFile file(":/icons/yes.png");
+QIcon icon(":/icons/no.png");
+QPixmap pixmap(":/icons/no.png");
+//! [9]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_porting4.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_porting4.qdoc
new file mode 100644
index 000000000..14fddf8e2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_porting4.qdoc
@@ -0,0 +1,473 @@
+//! [0]
+void MyButton::paintEvent(QPaintEvent *)
+{
+ QPainter painter(this);
+ drawButton(&painter);
+}
+//! [0]
+
+
+//! [1]
+ba.at(0) = 'X';
+//! [1]
+
+
+//! [2]
+ba[0] = 'X';
+//! [2]
+
+
+//! [3]
+if (!cache.insert(key, object))
+ delete object;
+//! [3]
+
+
+//! [4]
+cache.insert(key, object);
+//! [4]
+
+
+//! [5]
+Q3Cache<QWidget> cache;
+cache.insert(widget->name(), widget);
+...
+QWidget *foo = cache.take("foo");
+if (foo)
+ foo->show();
+//! [5]
+
+
+//! [6]
+typedef QWidget *QWidgetPtr;
+QCache<QString, QWidgetPtr> cache;
+cache.insert(widget->name(), new QWidgetPtr(widget));
+...
+QWidgetPtr *ptr = cache.take("foo");
+if (ptr) {
+ QWidget *foo = *ptr;
+ delete ptr;
+ foo->show();
+}
+//! [6]
+
+
+//! [7]
+painter.setBrush(palette().brush(QPalette::Text));
+//! [7]
+
+
+//! [8]
+QByteArray ba("Hello");
+ba.size(); // returns 5 (the '\0' is not counted)
+ba.length(); // returns 5
+ba.data()[5]; // returns '\0'
+//! [8]
+
+
+//! [9]
+dict.replace(key, value);
+//! [9]
+
+
+//! [10]
+delete hash.take(key);
+hash.insert(key, value);
+//! [10]
+
+
+//! [11]
+dict.remove(key, value);
+//! [11]
+
+
+//! [12]
+delete hash.take(key);
+//! [12]
+
+
+//! [13]
+dict.clear();
+//! [13]
+
+
+//! [14]
+while (!hash.isEmpty()) {
+ T *value = *hash.begin();
+ hash.erase(hash.begin());
+ delete value;
+}
+//! [14]
+
+
+//! [15]
+qDeleteAll(hash);
+hash.clear();
+//! [15]
+
+
+//! [16]
+Q3DictIterator<QWidget> i(dict);
+while (i.current() != 0) {
+ do_something(i.currentKey(), i.current());
+ ++i;
+}
+//! [16]
+
+
+//! [17]
+QHashIterator<QString, QWidget *> i(hash);
+while (i.hasNext()) {
+ i.next(); // must come first
+ do_something(i.key(), i.value());
+}
+//! [17]
+
+
+//! [18]
+QList<QWidget *> myWidgets = qFindChildren<QWidget *>(myParent);
+//! [18]
+
+
+//! [19]
+list.replace(index, value);
+//! [19]
+
+
+//! [20]
+delete list[index];
+list[index] = value;
+//! [20]
+
+
+//! [21]
+list.removeFirst();
+//! [21]
+
+
+//! [22]
+delete list.takeFirst();
+//! [22]
+
+
+//! [23]
+list.removeLast();
+//! [23]
+
+
+//! [24]
+delete list.takeLast();
+//! [24]
+
+
+//! [25]
+list.remove(index);
+//! [25]
+
+
+//! [26]
+delete list.takeAt(index);
+//! [26]
+
+
+//! [27]
+list.remove(value);
+//! [27]
+
+
+//! [28]
+int i = list.indexOf(value);
+if (i != -1)
+ delete list.takeAt(i);
+//! [28]
+
+
+//! [29]
+list.remove();
+//! [29]
+
+
+//! [30]
+QMutableListIterator<T *> i;
+...
+delete i.value();
+i.remove();
+//! [30]
+
+
+//! [31]
+list.clear();
+//! [31]
+
+
+//! [32]
+while (!list.isEmpty())
+ delete list.takeFirst();
+//! [32]
+
+
+//! [33]
+qDeleteAll(list);
+list.clear();
+//! [33]
+
+
+//! [34]
+QPtrList<QWidget> list;
+...
+while (list.current() != 0) {
+ do_something(list.current());
+ list.next();
+}
+//! [34]
+
+
+//! [35]
+QList<QWidget *> list;
+...
+QListIterator<QWidget *> i(list);
+while (i.hasNext())
+ do_something(i.next());
+//! [35]
+
+
+//! [36]
+QPtrList<QWidget> list;
+...
+QPtrListIterator<QWidget> i;
+while (i.current() != 0) {
+ do_something(i.current());
+ i.next();
+}
+//! [36]
+
+
+//! [37]
+QList<QWidget *> list;
+...
+QListIterator<QWidget *> i(list);
+while (i.hasNext())
+ do_something(i.next());
+//! [37]
+
+
+//! [38]
+queue.dequeue();
+//! [38]
+
+
+//! [39]
+delete queue.dequeue();
+//! [39]
+
+
+//! [40]
+queue.remove();
+//! [40]
+
+
+//! [41]
+delete queue.dequeue();
+//! [41]
+
+
+//! [42]
+queue.clear();
+//! [42]
+
+
+//! [43]
+while (!queue.isEmpty())
+ delete queue.dequeue();
+//! [43]
+
+
+//! [44]
+qDeleteAll(queue);
+queue.clear();
+//! [44]
+
+
+//! [45]
+stack.pop();
+//! [45]
+
+
+//! [46]
+delete stack.pop();
+//! [46]
+
+
+//! [47]
+stack.remove();
+//! [47]
+
+
+//! [48]
+delete stack.pop();
+//! [48]
+
+
+//! [49]
+stack.clear();
+//! [49]
+
+
+//! [50]
+while (!stack.isEmpty())
+ delete stack.pop();
+//! [50]
+
+
+//! [51]
+qDeleteAll(stack);
+stack.clear();
+//! [51]
+
+
+//! [52]
+vect.insert(i, ptr);
+//! [52]
+
+
+//! [53]
+delete vect[i];
+vect[i] = ptr;
+//! [53]
+
+
+//! [54]
+vect.remove(i);
+//! [54]
+
+
+//! [55]
+delete vect[i];
+vect[i] = 0;
+//! [55]
+
+
+//! [56]
+T *ptr = vect.take(i);
+//! [56]
+
+
+//! [57]
+T *ptr = vect[i];
+vect[i] = 0;
+//! [57]
+
+
+//! [58]
+vect.resize(n)
+//! [58]
+
+
+//! [59]
+while (n > vect.size())
+ vect.append(0);
+while (n < vect.size() {
+ T *ptr = vect.last();
+ vect.remove(vect.size() - 1);
+ delete ptr;
+}
+//! [59]
+
+
+//! [60]
+vect.clear();
+//! [60]
+
+
+//! [61]
+for (int i = 0; i < vect.size(); ++i)
+ T *ptr = vect[i];
+ vect[i] = 0;
+ delete ptr;
+}
+//! [61]
+
+
+//! [62]
+qDeleteAll(vect);
+vect.clear();
+//! [62]
+
+
+//! [63]
+struct Shared
+{
+ Shared() : count(1) {}
+ void ref() { ++count; }
+ bool deref() { return !--count; }
+ uint count;
+};
+//! [63]
+
+//! [63a]
+// Declare the object
+QSimpleRichText richText(text, font);
+
+// Set the width of the paragraph to w
+richText.setWidth(w);
+
+// Or set a resonable default size
+richText.adjustSize();
+
+// Query for its used size
+int width = richText.widthUsed();
+int height = richText.height();
+
+// Draw
+richText.draw(painter, x, y, clipRect, colorGroup);
+//! [63a]
+
+
+//! [63b]
+// Declare the object
+QTextDocument doc;
+
+// If text is rich text, use setHtml()
+doc.setHtml(text);
+
+// Otherwise, use setPlainText()
+doc.setPlainText(text);
+
+// Set the width of the paragraph of text to w
+doc.setTextWidth(w);
+
+// Query for the used size
+int width = doc.idealWidth();
+int height = doc.size().height();
+
+// Draw
+painter.translate(x, y);
+doc.drawContents(painter, clipRect);
+
+// If you have a palette/colorgroup you can draw using lower-level functions:
+QAbstractTextDocumentLayout::PaintContext context;
+context.palette = myPalette;
+doc.documentLayout()->draw(painter, context);
+//! [63b]
+
+//! [63c]
+QSlider *slider;
+slider->style()->subControlRect(CC_Slider, sliderOption, SC_SliderHandle, slider);
+//! [63c]
+
+//! [64]
+QString greeting = "Hello";
+const char *badData = greeting.toAscii().constData(); // data is invalid
+QByteArray asciiData = greeting.toAscii();
+const char *goodData = asciiData.constData();
+//! [64]
+
+
+//! [65]
+str.at(0) = 'X';
+//! [65]
+
+
+//! [66]
+str[0] = 'X';
+//! [66]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_properties.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_properties.qdoc
new file mode 100644
index 000000000..377cc9c14
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_properties.qdoc
@@ -0,0 +1,78 @@
+//! [0]
+Q_PROPERTY(type name
+ READ getFunction
+ [WRITE setFunction]
+ [RESET resetFunction]
+ [NOTIFY notifySignal]
+ [DESIGNABLE bool]
+ [SCRIPTABLE bool]
+ [STORED bool]
+ [USER bool])
+//! [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)
+ Q_ENUMS(Priority)
+
+public:
+ MyClass(QObject *parent = 0);
+ ~MyClass();
+
+ enum Priority { High, Low, VeryHigh, VeryLow };
+
+ void setPriority(Priority priority);
+ Priority priority() const;
+};
+//! [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/codesnippets/doc/src/snippets/code/doc_src_q3asciidict.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_q3asciidict.qdoc
new file mode 100644
index 000000000..e2c876afb
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_q3asciidict.qdoc
@@ -0,0 +1,52 @@
+//! [0]
+Q3AsciiDict<QLineEdit> fields; // char* keys, QLineEdit* values
+fields.insert( "forename", new QLineEdit( this ) );
+fields.insert( "surname", new QLineEdit( this ) );
+
+fields["forename"]->setText( "Homer" );
+fields["surname"]->setText( "Simpson" );
+
+Q3AsciiDictIterator<QLineEdit> it( fields ); // See Q3AsciiDictIterator
+for( ; it.current(); ++it )
+ cout << it.currentKey() << ": " << it.current()->text() << endl;
+cout << endl;
+
+if ( fields["forename"] && fields["surname"] )
+ cout << fields["forename"]->text() << " "
+ << fields["surname"]->text() << endl; // Prints "Homer Simpson"
+
+fields.remove( "forename" ); // Does not delete the line edit
+if ( ! fields["forename"] )
+ cout << "forename is not in the dictionary" << endl;
+//! [0]
+
+
+//! [1]
+Q3AsciiDict<char> dict;
+ ...
+if ( dict.find(key) )
+ dict.remove( key );
+dict.insert( key, item );
+//! [1]
+
+
+//! [2]
+Q3AsciiDict<QLineEdit> fields;
+fields.insert( "forename", new QLineEdit( this ) );
+fields.insert( "surname", new QLineEdit( this ) );
+fields.insert( "age", new QLineEdit( this ) );
+
+fields["forename"]->setText( "Homer" );
+fields["surname"]->setText( "Simpson" );
+fields["age"]->setText( "45" );
+
+Q3AsciiDictIterator<QLineEdit> it( fields );
+for( ; it.current(); ++it )
+ cout << it.currentKey() << ": " << it.current()->text() << endl;
+cout << endl;
+
+// Output (random order):
+// age: 45
+// surname: Simpson
+// forename: Homer
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_q3dict.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_q3dict.qdoc
new file mode 100644
index 000000000..f79d0f739
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_q3dict.qdoc
@@ -0,0 +1,29 @@
+//! [0]
+Q3Dict<char> dict;
+ ...
+if ( dict.find( key ) )
+ dict.remove( key );
+dict.insert( key, item );
+//! [0]
+
+
+//! [1]
+Q3Dict<QLineEdit> fields;
+fields.insert( "forename", new QLineEdit( this ) );
+fields.insert( "surname", new QLineEdit( this ) );
+fields.insert( "age", new QLineEdit( this ) );
+
+fields["forename"]->setText( "Homer" );
+fields["surname"]->setText( "Simpson" );
+fields["age"]->setText( "45" );
+
+Q3DictIterator<QLineEdit> it( fields );
+for( ; it.current(); ++it )
+ cout << it.currentKey() << ": " << it.current()->text() << endl;
+cout << endl;
+
+// Output (random order):
+// age: 45
+// surname: Simpson
+// forename: Homer
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_q3intdict.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_q3intdict.qdoc
new file mode 100644
index 000000000..0fae2c854
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_q3intdict.qdoc
@@ -0,0 +1,51 @@
+//! [0]
+Q3IntDict<QLineEdit> fields; // long int keys, QLineEdit* values
+for ( int i = 0; i < 3; i++ )
+ fields.insert( i, new QLineEdit( this ) );
+
+fields[0]->setText( "Homer" );
+fields[1]->setText( "Simpson" );
+fields[2]->setText( "45" );
+
+Q3IntDictIterator<QLineEdit> it( fields );
+for ( ; it.current(); ++it )
+ cout << it.currentKey() << ": " << it.current()->text() << endl;
+
+for ( int i = 0; i < 3; i++ )
+ cout << fields[i]->text() << " "; // Prints "Homer Simpson 45"
+cout << endl;
+
+fields.remove( 1 ); // Does not delete the line edit
+for ( int i = 0; i < 3; i++ )
+ if ( fields[i] )
+ cout << fields[i]->text() << " "; // Prints "Homer 45"
+//! [0]
+
+
+//! [1]
+Q3IntDict<char> dict;
+// ...
+if ( dict.find(key) )
+ dict.remove( key );
+dict.insert( key, item );
+//! [1]
+
+
+//! [2]
+Q3IntDict<QLineEdit> fields;
+for ( int i = 0; i < 3; i++ )
+ fields.insert( i, new QLineEdit( this ) );
+
+fields[0]->setText( "Homer" );
+fields[1]->setText( "Simpson" );
+fields[2]->setText( "45" );
+
+Q3IntDictIterator<QLineEdit> it( fields );
+for ( ; it.current(); ++it )
+ cout << it.currentKey() << ": " << it.current()->text() << endl;
+
+// Output (random order):
+// 0: Homer
+// 1: Simpson
+// 2: 45
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_q3memarray.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_q3memarray.qdoc
new file mode 100644
index 000000000..b56ef4e9b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_q3memarray.qdoc
@@ -0,0 +1,80 @@
+//! [0]
+#include <q3memarray.h>
+#include <stdio.h>
+
+Q3MemArray<int> fib( int num ) // returns fibonacci array
+{
+ Q_ASSERT( num > 2 );
+ Q3MemArray<int> f( num ); // array of ints
+
+ f[0] = f[1] = 1;
+ for ( int i = 2; i < num; i++ )
+ f[i] = f[i-1] + f[i-2];
+
+ return f;
+}
+
+int main()
+{
+ Q3MemArray<int> a = fib( 6 ); // get first 6 fibonaccis
+ for ( int i = 0; i < a.size(); i++ )
+ qDebug( "%d: %d", i, a[i] );
+
+ qDebug( "1 is found %d times", a.contains(1) );
+ qDebug( "5 is found at index %d", a.find(5) );
+
+ return 0;
+}
+//! [0]
+
+
+//! [1]
+0: 1
+1: 1
+2: 2
+3: 3
+4: 5
+5: 8
+1 is found 2 times
+5 is found at index 4
+//! [1]
+
+
+//! [2]
+// MyStruct may be padded to 4 or 8 bytes
+struct MyStruct
+{
+ short i; // 2 bytes
+ char c; // 1 byte
+};
+
+Q3MemArray<MyStruct> a(1);
+a[0].i = 5;
+a[0].c = 't';
+
+MyStruct x;
+x.i = '5';
+x.c = 't';
+int i = a.find( x ); // may return -1 if the pad bytes differ
+//! [2]
+
+
+//! [3]
+static char bindata[] = { 231, 1, 44, ... };
+QByteArray a;
+a.setRawData( bindata, sizeof(bindata) ); // a points to bindata
+QDataStream s( a, IO_ReadOnly ); // open on a's data
+s >> <something>; // read raw bindata
+a.resetRawData( bindata, sizeof(bindata) ); // finished
+//! [3]
+
+
+//! [4]
+static char bindata[] = { 231, 1, 44, ... };
+QByteArray a, b;
+a.setRawData( bindata, sizeof(bindata) ); // a points to bindata
+a.resize( 8 ); // will crash
+b = a; // will crash
+a[2] = 123; // might crash
+// forget to resetRawData: will crash
+//! [4]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_q3ptrdict.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_q3ptrdict.qdoc
new file mode 100644
index 000000000..d23824b19
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_q3ptrdict.qdoc
@@ -0,0 +1,66 @@
+//! [0]
+Q3PtrDict<char> fields; // void* keys, char* values
+
+QLineEdit *le1 = new QLineEdit( this );
+le1->setText( "Simpson" );
+QLineEdit *le2 = new QLineEdit( this );
+le2->setText( "Homer" );
+QLineEdit *le3 = new QLineEdit( this );
+le3->setText( "45" );
+
+fields.insert( le1, "Surname" );
+fields.insert( le2, "Forename" );
+fields.insert( le3, "Age" );
+
+Q3PtrDictIterator<char> it( fields );
+for( ; it.current(); ++it )
+ cout << it.current() << endl;
+cout << endl;
+
+if ( fields[le1] ) // Prints "Surname: Simpson"
+ cout << fields[le1] << ": " << le1->text() << endl;
+if ( fields[le2] ) // Prints "Forename: Homer"
+ cout << fields[le2] << ": " << le2->text() << endl;
+
+fields.remove( le1 ); // Removes le1 from the dictionary
+cout << le1->text() << endl; // Prints "Simpson"
+//! [0]
+
+
+//! [1]
+Q3PtrDict<ItemType> dict;
+ ...
+if ( dict.find( key ) )
+ dict.remove( key );
+dict.insert( key, item );
+//! [1]
+
+
+//! [2]
+Q3PtrDict<char> fields;
+
+QLineEdit *le1 = new QLineEdit( this );
+le1->setText( "Simpson" );
+QLineEdit *le2 = new QLineEdit( this );
+le2->setText( "Homer" );
+QLineEdit *le3 = new QLineEdit( this );
+le3->setText( "45" );
+
+fields.insert( le1, "Surname" );
+fields.insert( le2, "Forename" );
+fields.insert( le3, "Age" );
+
+Q3PtrDictIterator<char> it( fields );
+for( ; it.current(); ++it ) {
+ QLineEdit *le = (QLineEdit)it.currentKey();
+ cout << it.current() << ": " << le->text() << endl;
+}
+cout << endl;
+
+// Output (random order):
+// Forename: Homer
+// Age: 45
+// Surname: Simpson
+//! [2]
+
+
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_q3ptrlist.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_q3ptrlist.qdoc
new file mode 100644
index 000000000..f416784f7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_q3ptrlist.qdoc
@@ -0,0 +1,82 @@
+//! [0]
+class Employee
+{
+public:
+ Employee() : sn( 0 ) { }
+ Employee( const QString& forename, const QString& surname, int salary )
+ : fn( forename ), sn( surname ), sal( salary )
+ { }
+
+ void setSalary( int salary ) { sal = salary; }
+
+ QString forename() const { return fn; }
+ QString surname() const { return sn; }
+ int salary() const { return sal; }
+
+private:
+ QString fn;
+ QString sn;
+ int sal;
+};
+
+Q3PtrList<Employee> list;
+list.setAutoDelete( TRUE ); // the list owns the objects
+
+list.append( new Employee("John", "Doe", 50000) );
+list.append( new Employee("Jane", "Williams", 80000) );
+list.append( new Employee("Tom", "Jones", 60000) );
+
+Employee *employee;
+for ( employee = list.first(); employee; employee = list.next() )
+ cout << employee->surname().latin1() << ", " <<
+ employee->forename().latin1() << " earns " <<
+ employee->salary() << endl;
+cout << endl;
+
+// very inefficient for big lists
+for ( uint i = 0; i < list.count(); ++i )
+ if ( list.at(i) )
+ cout << list.at( i )->surname().latin1() << endl;
+//! [0]
+
+
+//! [1]
+Doe, John earns 50000
+Williams, Jane earns 80000
+Jones, Tom earns 60000
+
+Doe
+Williams
+Jones
+//! [1]
+
+
+//! [2]
+if ( list.findRef( item ) != -1 )
+ list.remove();
+//! [2]
+
+
+//! [3]
+Q3PtrList<Employee> list;
+
+list.append( new Employee("John", "Doe", 50000) );
+list.append( new Employee("Jane", "Williams", 80000) );
+list.append( new Employee("Tom", "Jones", 60000) );
+
+Q3PtrListIterator<Employee> it( list );
+Employee *employee;
+while ( (employee = it.current()) != 0 ) {
+ ++it;
+ cout << employee->surname().latin1() << ", " <<
+ employee->forename().latin1() << " earns " <<
+ employee->salary() << endl;
+}
+//! [3]
+
+
+//! [4]
+Doe, John earns 50000
+Williams, Jane earns 80000
+Jones, Tom earns 60000
+//! [4]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_q3valuelist.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_q3valuelist.qdoc
new file mode 100644
index 000000000..5a6d564ab
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_q3valuelist.qdoc
@@ -0,0 +1,95 @@
+//! [0]
+class Employee
+{
+public:
+ Employee(): sn(0) {}
+ Employee( const QString& forename, const QString& surname, int salary )
+ : fn(forename), sn(surname), sal(salary)
+ {}
+
+ QString forename() const { return fn; }
+ QString surname() const { return sn; }
+ int salary() const { return sal; }
+ void setSalary( int salary ) { sal = salary; }
+
+private:
+ QString fn;
+ QString sn;
+ int sal;
+};
+
+typedef Q3ValueList<Employee> EmployeeList;
+EmployeeList list;
+
+list.append( Employee("John", "Doe", 50000) );
+list.append( Employee("Jane", "Williams", 80000) );
+list.append( Employee("Tom", "Jones", 60000) );
+
+Employee mary( "Mary", "Hawthorne", 90000 );
+list.append( mary );
+mary.setSalary( 100000 );
+
+EmployeeList::iterator it;
+for ( it = list.begin(); it != list.end(); ++it )
+ cout << (*it).surname().latin1() << ", " <<
+ (*it).forename().latin1() << " earns " <<
+ (*it).salary() << endl;
+
+// Output:
+// Doe, John earns 50000
+// Williams, Jane earns 80000
+// Hawthorne, Mary earns 90000
+// Jones, Tom earns 60000
+//! [0]
+
+
+//! [1]
+Q3ValueList<int> list;
+list.append( 1 );
+list.append( 2 );
+list.append( 3 );
+...
+if ( !list.empty() ) {
+ // OK, modify the first item
+ int& i = list.first();
+ i = 18;
+}
+...
+Q3ValueList<double> dlist;
+double d = dlist.last(); // undefined
+//! [1]
+
+
+//! [2]
+Q3ValueList<int> l;
+...
+Q3ValueList<int>::iterator it = l.end();
+--it;
+if ( it != end() )
+ // ...
+//! [2]
+
+
+//! [3]
+Q3ValueList<int> l;
+...
+Q3ValueList<int>::iterator it = l.end();
+--it;
+if ( it != end() )
+ // ...
+//! [3]
+
+
+//! [4]
+EmployeeList::iterator it;
+for ( it = list.begin(); it != list.end(); ++it )
+ cout << (*it).surname().latin1() << ", " <<
+ (*it).forename().latin1() << " earns " <<
+ (*it).salary() << endl;
+
+// Output:
+// Doe, John earns 50000
+// Williams, Jane earns 80000
+// Hawthorne, Mary earns 90000
+// Jones, Tom earns 60000
+//! [4]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_q3valuestack.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_q3valuestack.qdoc
new file mode 100644
index 000000000..61d564b34
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_q3valuestack.qdoc
@@ -0,0 +1,13 @@
+//! [0]
+Q3ValueStack<int> stack;
+stack.push( 1 );
+stack.push( 2 );
+stack.push( 3 );
+while ( ! stack.isEmpty() )
+ cout << "Item: " << stack.pop() << endl;
+
+// Output:
+// Item: 3
+// Item: 2
+// Item: 1
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_q3valuevector.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_q3valuevector.qdoc
new file mode 100644
index 000000000..792bfacf2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_q3valuevector.qdoc
@@ -0,0 +1,85 @@
+//! [0]
+#include <qvaluevector.h>
+#include <qstring.h>
+#include <stdio.h>
+
+class Employee
+{
+public:
+ Employee(): s(0) {}
+ Employee( const QString& name, int salary )
+ : n( name ), s( salary )
+ { }
+
+ QString name() const { return n; }
+ int salary() const { return s; }
+ void setSalary( int salary ) { s = salary; }
+private:
+ QString n;
+ int s;
+};
+
+int main()
+{
+ typedef Q3ValueVector<Employee> EmployeeVector;
+ EmployeeVector vec( 3 ); // vector of 3 Employees
+
+ vec[0] = Employee( "Bill", 50000 );
+ vec[1] = Employee( "Steve", 80000 );
+ vec[2] = Employee( "Ron", 60000 );
+
+ Employee joe( "Joe", 50000 );
+ vec.push_back( joe ); // vector expands to accommodate 4 Employees
+ joe.setSalary( 70000 );
+
+ EmployeeVector::iterator it;
+ for( it = vec.begin(); it != vec.end(); ++it )
+ printf( "%s earns %d\n", (*it).name().latin1(), (*it).salary() );
+
+ return 0;
+}
+//! [0]
+
+
+//! [1]
+Bill earns 50000
+Steve earns 80000
+Ron earns 60000
+Joe earns 50000
+//! [1]
+
+
+//! [2]
+Q3ValueVector<int> vec1; // an empty vector
+vec1[10] = 4; // WARNING: undefined, probably a crash
+
+Q3ValueVector<QString> vec2(25); // initialize with 25 elements
+vec2[10] = "Dave"; // OK
+//! [2]
+
+
+//! [3]
+void func( Q3ValueVector<int>& vec )
+{
+ if ( vec.size() > 10 ) {
+ vec[9] = 99; // OK
+ }
+};
+//! [3]
+
+
+//! [4]
+Q3ValueVector<int> vec( 3 );
+vec.push_back( 1 );
+vec.push_back( 2 );
+vec.push_back( 3 );
+...
+if ( !vec.empty() ) {
+ // OK: modify the first element
+ int& i = vec.front();
+ i = 18;
+}
+...
+Q3ValueVector<double> dvec;
+double d = dvec.back(); // undefined behavior
+//! [4]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qalgorithms.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qalgorithms.qdoc
new file mode 100644
index 000000000..69d943c89
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qalgorithms.qdoc
@@ -0,0 +1,314 @@
+//! [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 (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: [ 68, 33, 12, 12, 6 ]
+//! [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/codesnippets/doc/src/snippets/code/doc_src_qaxcontainer.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qaxcontainer.qdoc
new file mode 100644
index 000000000..9edd87f05
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qaxcontainer.qdoc
@@ -0,0 +1,8 @@
+//! [0]
+CONFIG += qaxcontainer
+//! [0]
+
+
+//! [1]
+TYPELIBS = file.tlb
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qaxserver.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qaxserver.qdoc
new file mode 100644
index 000000000..9b51e668a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qaxserver.qdoc
@@ -0,0 +1,223 @@
+//! [0]
+TEMPLATE = app
+CONFIG += qaxserver
+
+RC_FILE = qaxserver.rc
+...
+//! [0]
+
+
+//! [1]
+TEMPLATE = lib
+CONFIG += qaxserver dll
+
+DEF_FILE = qaxserver.def
+RC_FILE = qaxserver.rc
+...
+//! [1]
+
+
+//! [2]
+TEMPLATE = lib
+VERSION = 2.5
+...
+//! [2]
+
+
+//! [3]
+#include <QWidget>
+
+class MyActiveX : public QWidget
+{
+ Q_OBJECT
+//! [3]
+
+
+//! [4]
+Q_CLASSINFO("ClassID", "{1D9928BD-4453-4bdd-903D-E525ED17FDE5}")
+Q_CLASSINFO("InterfaceID", "{99F6860E-2C5A-42ec-87F2-43396F4BE389}")
+Q_CLASSINFO("EventsID", "{0A3E9F27-E4F1-45bb-9E47-63099BCCD0E3}")
+//! [4]
+
+
+//! [5]
+Q_PROPERTY(int value READ value WRITE setValue)
+//! [5]
+
+
+//! [6]
+public:
+ MyActiveX(QWidget *parent = 0)
+ ...
+
+ int value() const;
+
+public slots:
+ void setValue(int v);
+ ...
+
+signals:
+ void valueChange(int v);
+ ...
+
+};
+//! [6]
+
+
+//! [7]
+#include <QAxBindable>
+#include <QWidget>
+
+class MyActiveX : public QWidget, public QAxBindable
+{
+ Q_OBJECT
+//! [7]
+
+
+//! [8]
+QAXFACTORY_BEGIN("{ad90301a-849e-4e8b-9a91-0a6dc5f6461f}",
+ "{a8f21901-7ff7-4f6a-b939-789620c03d83}")
+ QAXCLASS(MyWidget)
+ QAXCLASS(MyWidget2)
+ QAXTYPE(MySubType)
+QAXFACTORY_END()
+//! [8]
+
+
+//! [9]
+#include <QApplication>
+#include <QAxFactory>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ if (!QAxFactory::isServer()) {
+ // create and show main window
+ }
+ return app.exec();
+}
+//! [9]
+
+
+//! [10]
+MyFactory(const QUuid &, const QUuid &);
+//! [10]
+
+
+//! [11]
+HMODULE dll = LoadLibrary("myserver.dll");
+typedef HRESULT(__stdcall *DllRegisterServerProc)();
+DllRegisterServerProc DllRegisterServer =
+ (DllRegisterServerProc)GetProcAddress(dll, "DllRegisterServer");
+
+HRESULT res = E_FAIL;
+if (DllRegisterServer)
+ res = DllRegisterServer();
+if (res != S_OK)
+ // error handling
+//! [11]
+
+
+//! [12]
+cabarc N simpleax.cab simpleax.exe simple.inf
+//! [12]
+
+
+//! [13]
+<object ID="MyActiveX1" CLASSID="CLSID:ad90301a-849e-4e8b-9a91-0a6dc5f6461f">
+ ...
+<\object>
+//! [13]
+
+
+//! [14]
+<object ID=...>
+ <param name="name" value="value">
+<\object>
+//! [14]
+
+
+//! [15]
+class MyActiveX : public QWidget
+{
+ Q_OBJECT
+ Q_CLASSINFO("Version", "2.0")
+ Q_CLASSINFO("ClassID", "{7a4cffd8-cbcd-4ae9-ae7e-343e1e5710df}")
+ Q_CLASSINFO("InterfaceID", "{6fb035bf-8019-48d8-be51-ef05427d8994}")
+ Q_CLASSINFO("EventsID", "{c42fffdf-6557-47c9-817a-2da2228bc29c}")
+ Q_CLASSINFO("Insertable", "yes")
+ Q_CLASSINFO("ToSuperClass", "MyActiveX")
+ Q_PROPERTY(...)
+
+public:
+ MyActiveX(QWidget *parent = 0);
+
+ ...
+};
+//! [15]
+
+
+//! [16]
+class MyLicensedControl : public QWidget
+{
+ Q_OBJECT
+ Q_CLASSINFO("LicenseKey", "<key string>")
+ ...
+};
+//! [16]
+
+
+//! [17]
+class AxImpl : public QAxAggregated, public ISomeCOMInterface
+{
+public:
+ AxImpl() {}
+
+ long queryInterface(const QUuid &iid, void **iface);
+
+ // IUnknown
+ QAXAGG_IUNKNOWN
+
+ // ISomeCOMInterface
+ ...
+}
+//! [17]
+
+
+//! [18]
+long AxImpl::queryInterface(const QUuid &iid, void **iface)
+{
+ *iface = 0;
+ if (iid == IID_ISomeCOMInterface)
+ *iface = (ISomeCOMInterface *)this;
+ else
+ return E_NOINTERFACE;
+
+ AddRef();
+ return S_OK;
+}
+//! [18]
+
+
+//! [19]
+HRESULT AxImpl::QueryInterface(REFIID iid, void **iface)
+{
+ return controllingUnknown()->QueryInterface(iid, iface);
+}
+//! [19]
+
+
+//! [20]
+class MyActiveX : public QWidget, public QAxBindable
+{
+ Q_OBJECT
+
+public:
+ MyActiveX(QWidget *parent);
+
+ QAxAggregated *createAggregate()
+ {
+ return new AxImpl();
+ }
+};
+//! [20]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qcache.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qcache.qdoc
new file mode 100644
index 000000000..66bda6af9
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qcache.qdoc
@@ -0,0 +1,17 @@
+//! [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/codesnippets/doc/src/snippets/code/doc_src_qdbusadaptors.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qdbusadaptors.qdoc
new file mode 100644
index 000000000..7f69a907d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qdbusadaptors.qdoc
@@ -0,0 +1,253 @@
+//! [0]
+ class MainApplicationAdaptor: public QDBusAbstractAdaptor
+ {
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "org.kde.DBus.MainApplication")
+ Q_PROPERTY(QString caption READ caption WRITE setCaption)
+ Q_PROPERTY(QString organizationName READ organizationName)
+ Q_PROPERTY(QString organizationDomain READ organizationDomain)
+
+ private:
+ QApplication *app;
+
+ public:
+ MainApplicationAdaptor(QApplication *application)
+ : QDBusAbstractAdaptor(application), app(application)
+ {
+ connect(application, SIGNAL(aboutToQuit()), SIGNAL(aboutToQuit()));
+ connect(application, SIGNAL(focusChanged(QWidget*, QWidget*)),
+ SLOT(focusChangedSlot(QWidget*, QWidget*)));
+ }
+
+ QString caption()
+ {
+ if (app->hasMainWindow())
+ return app->mainWindow()->caption();
+ return QString(""); // must not return a null QString
+ }
+
+ void setCaption(const QString &newCaption)
+ {
+ if (app->hasMainWindow())
+ app->mainWindow()->setCaption(newCaption);
+ }
+
+ QString organizationName()
+ {
+ return app->organizationName();
+ }
+
+ QString organizationDomain()
+ {
+ return app->organizationDomain();
+ }
+
+ public slots:
+ Q_NOREPLY void quit()
+ { app->quit(); }
+
+ void reparseConfiguration()
+ { app->reparseConfiguration(); }
+
+ QString mainWindowObject()
+ {
+ if (app->hasMainWindow())
+ return QString("/%1/mainwindow").arg(app->applicationName());
+ return QString();
+ }
+
+ void setSessionManagement(bool enable)
+ {
+ if (enable)
+ app->enableSessionManagement();
+ else
+ app->disableSessionManagement();
+ }
+
+ private slots:
+ void focusChangedSlot(QWidget *, QWidget *now)
+ {
+ if (now == app->mainWindow())
+ emit mainWindowHasFocus();
+ }
+
+ signals:
+ void aboutToQuit();
+ void mainWindowHasFocus();
+ };
+//! [0]
+
+
+//! [1]
+interface org.kde.DBus.MainApplication
+{
+ property readwrite STRING caption
+ property read STRING organizationName
+ property read STRING organizationDomain
+
+ method quit() annotation("org.freedesktop.DBus.Method.NoReply", "true")
+ method reparseConfiguration()
+ method mainWindowObject(out STRING)
+ method disableSessionManagement(in BOOLEAN enable)
+
+ signal aboutToQuit()
+ signal mainWindowHasFocus()
+}
+//! [1]
+
+
+//! [2]
+int main(int argc, char **argv)
+{
+ // create the QApplication object
+ QApplication app(argc, argv);
+
+ // create the MainApplication adaptor:
+ new MainApplicationAdaptor(app);
+
+ // connect to D-Bus and register as an object:
+ QDBusConnection::sessionBus().registerObject("/MainApplication", app);
+
+ // add main window, etc.
+ [...]
+
+ app.exec();
+}
+//! [2]
+
+
+//! [3]
+class MainApplicationAdaptor: public QDBusAbstractAdaptor
+{
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "org.kde.DBus.MainApplication")
+//! [3]
+
+
+//! [4]
+ Q_PROPERTY(QString caption READ caption WRITE setCaption)
+ Q_PROPERTY(QString organizationName READ organizationName)
+ Q_PROPERTY(QString organizationDomain READ organizationDomain)
+//! [4]
+
+
+//! [5]
+QString caption()
+{
+ if (app->hasMainWindow())
+ return app->mainWindow()->caption();
+ return QString();
+}
+
+void setCaption(const QString &newCaption)
+{
+ if (app->hasMainWindow())
+ app->mainWindow()->setCaption(newCaption);
+}
+
+QString organizationName()
+{
+ return app->organizationName();
+}
+
+QString organizationDomain()
+{
+ return app->organizationDomain();
+}
+//! [5]
+
+
+//! [6]
+MyInterfaceAdaptor(QApplication *application)
+ : QDBusAbstractAdaptor(application), app(application)
+{
+ connect(application, SIGNAL(aboutToQuit()), SIGNAL(aboutToQuit());
+ connect(application, SIGNAL(focusChanged(QWidget*, QWidget*)),
+ SLOT(focusChangedSlot(QWidget*, QWidget*)));
+}
+//! [6]
+
+
+//! [7]
+public slots:
+ Q_NOREPLY void quit()
+ { app->quit(); }
+
+ void reparseConfiguration()
+ { app->reparseConfiguration(); }
+
+ QString mainWindowObject()
+ {
+ if (app->hasMainWindow())
+ return QString("/%1/mainwindow").arg(app->applicationName());
+ return QString();
+ }
+
+ void setSessionManagement(bool enable)
+ {
+ if (enable)
+ app->enableSessionManagement();
+ else
+ app->disableSessionManagement();
+ }
+//! [7]
+
+
+//! [8]
+signals:
+ void aboutToQuit();
+ void mainWindowHasFocus();
+//! [8]
+
+
+//! [9]
+private slots:
+ void focusChangedSlot(QWidget *, QWidget *now)
+ {
+ if (now == app->mainWindow())
+ emit mainWindowHasFocus();
+ }
+//! [9]
+
+
+//! [10]
+struct RequestData
+{
+ QString request;
+ QString processedData;
+ QDBusMessage reply;
+};
+
+QString processRequest(const QString &request, const QDBusMessage &message)
+{
+ RequestData *data = new RequestData;
+ data->request = request;
+ message.setDelayedReply(true);
+ data->reply = message.createReply();
+ QDBusConnection::sessionBus().send(data->reply);
+
+ appendRequest(data);
+ return QString();
+}
+//! [10]
+
+
+//! [11]
+void sendReply(RequestData *data)
+{
+ // data->processedData has been initialized with the request's reply
+ QDBusMessage &reply = &data->reply;
+
+ // send the reply over D-Bus:
+ reply << data->processedData;
+ QDBusConnection::sessionBus().send(reply);
+
+ // dispose of the transaction data
+ delete data;
+}
+//! [11]
+
+
+//! [12]
+Q_NOREPLY void myMethod();
+//! [12]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qiterator.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qiterator.qdoc
new file mode 100644
index 000000000..3dfa68a9c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qiterator.qdoc
@@ -0,0 +1,380 @@
+//! [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/codesnippets/doc/src/snippets/code/doc_src_qmake-manual.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qmake-manual.qdoc
new file mode 100644
index 000000000..edb66bcde
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qmake-manual.qdoc
@@ -0,0 +1,813 @@
+//! [0]
+make all
+//! [0]
+
+
+//! [1]
+CONFIG += qt thread debug
+//! [1]
+
+
+//! [2]
+CONFIG += qt
+QT += network xml
+//! [2]
+
+
+//! [3]
+QT = network xml # This will omit the core and gui modules.
+//! [3]
+
+
+//! [4]
+QT -= gui # Only the core module is used.
+//! [4]
+
+
+//! [5]
+CONFIG += link_pkgconfig
+PKGCONFIG += ogg dbus-1
+//! [5]
+
+
+//! [6]
+LIBS += -L/usr/local/lib -lmath
+//! [6]
+
+
+//! [7]
+INCLUDEPATH = c:/msdev/include d:/stl/include
+//! [7]
+
+
+//! [8]
+qmake [mode] [options] files
+//! [8]
+
+
+//! [9]
+qmake -makefile [options] files
+//! [9]
+
+
+//! [10]
+qmake -makefile -unix -o Makefile "CONFIG+=test" test.pro
+//! [10]
+
+
+//! [11]
+qmake "CONFIG+=test" test.pro
+//! [11]
+
+
+//! [12]
+qmake -project [options] files
+//! [12]
+
+
+//! [13]
+qmake -spec macx-g++
+//! [13]
+
+
+//! [14]
+QMAKE_LFLAGS += -F/path/to/framework/directory/
+//! [14]
+
+
+//! [15]
+LIBS += -framework TheFramework
+//! [15]
+
+
+//! [16]
+TEMPLATE = lib
+CONFIG += lib_bundle
+//! [16]
+
+
+//! [17]
+FRAMEWORK_HEADERS.version = Versions
+FRAMEWORK_HEADERS.files = path/to/header_one.h path/to/header_two.h
+FRAMEWORK_HEADERS.path = Headers
+QMAKE_BUNDLE_DATA += FRAMEWORK_HEADERS
+//! [17]
+
+
+//! [18]
+CONFIG += x86 ppc
+//! [18]
+
+
+//! [19]
+qmake -spec macx-xcode project.pro
+//! [19]
+
+
+//! [20]
+qmake -tp vc
+//! [20]
+
+
+//! [21]
+qmake -tp vc -r
+//! [21]
+
+
+//! [22]
+CONFIG -= embed_manifest_exe
+//! [22]
+
+
+//! [23]
+CONFIG -= embed_manifest_dll
+//! [23]
+
+
+//! [24]
+make all
+//! [24]
+
+
+//! [25]
+build_pass:CONFIG(debug, debug|release) {
+ unix: TARGET = $$join(TARGET,,,_debug)
+ else: TARGET = $$join(TARGET,,,d)
+}
+//! [25]
+
+
+//! [26]
+CONFIG += qt console newstuff
+...
+newstuff {
+ SOURCES += new.cpp
+ HEADERS += new.h
+}
+//! [26]
+
+
+//! [27]
+DEFINES += USE_MY_STUFF QT_DLL
+//! [27]
+
+
+//! [28]
+myFiles.sources = path\*.png
+DEPLOYMENT += myFiles
+//! [28]
+
+
+//! [29]
+myFiles.sources = path\file1.ext1 path2\file2.ext1 path3\*
+myFiles.path = \some\path\on\device
+someother.sources = C:\additional\files\*
+someother.path = \myFiles\path2
+DEPLOYMENT += myFiles someother
+//! [29]
+
+
+//! [30]
+DESTDIR = ../../lib
+//! [30]
+
+
+//! [31]
+DISTFILES += ../program.txt
+//! [31]
+
+
+//! [32]
+FORMS = mydialog.ui \
+ mywidget.ui \
+ myconfig.ui
+//! [32]
+
+
+//! [33]
+FORMS3 = my_uic3_dialog.ui \
+ my_uic3_widget.ui \
+ my_uic3_config.ui
+//! [33]
+
+
+//! [34]
+HEADERS = myclass.h \
+ login.h \
+ mainwindow.h
+//! [34]
+
+
+//! [35]
+INCLUDEPATH = c:/msdev/include d:/stl/include
+//! [35]
+
+
+//! [36]
+target.path += $$[QT_INSTALL_PLUGINS]/imageformats
+INSTALLS += target
+//! [36]
+
+
+//! [37]
+LEXSOURCES = lexer.l
+//! [37]
+
+
+//! [38]
+unix:LIBS += -L/usr/local/lib -lmath
+win32:LIBS += c:/mylibs/math.lib
+//! [38]
+
+
+//! [39]
+CONFIG += no_lflags_merge
+//! [39]
+
+
+//! [40]
+unix:MOC_DIR = ../myproject/tmp
+win32:MOC_DIR = c:/myproject/tmp
+//! [40]
+
+
+//! [41]
+unix:OBJECTS_DIR = ../myproject/tmp
+win32:OBJECTS_DIR = c:/myproject/tmp
+//! [41]
+
+
+//! [42]
+app {
+ # Conditional code for 'app' template here
+}
+//! [42]
+
+
+//! [43]
+FRAMEWORK_HEADERS.version = Versions
+FRAMEWORK_HEADERS.files = path/to/header_one.h path/to/header_two.h
+FRAMEWORK_HEADERS.path = Headers
+QMAKE_BUNDLE_DATA += FRAMEWORK_HEADERS
+//! [43]
+
+
+//! [44]
+QMAKE_BUNDLE_EXTENSION = .myframework
+//! [44]
+
+
+//! [45]
+QMAKE_RESOURCE_FLAGS += -threshold 0 -compress 9
+//! [45]
+
+
+//! [46]
+QMAKE_UIC = uic -L /path/to/plugin
+//! [46]
+
+
+//! [47]
+QT -= gui # Only the core module is used.
+//! [47]
+
+
+//! [48]
+unix:RCC_DIR = ../myproject/resources
+win32:RCC_DIR = c:/myproject/resources
+//! [48]
+
+
+//! [49]
+SOURCES = myclass.cpp \
+ login.cpp \
+ mainwindow.cpp
+//! [49]
+
+
+//! [50]
+SUBDIRS = kernel \
+ tools
+//! [50]
+
+
+//! [51]
+CONFIG += ordered
+//! [51]
+
+
+//! [52]
+TEMPLATE = app
+TARGET = myapp
+SOURCES = main.cpp
+//! [52]
+
+
+//! [53]
+TEMPLATE = lib
+SOURCES = main.cpp
+TARGET = mylib
+//! [53]
+
+
+//! [54]
+unix:UI_DIR = ../myproject/ui
+win32:UI_DIR = c:/myproject/ui
+//! [54]
+
+
+//! [55]
+unix:UI_HEADERS_DIR = ../myproject/ui/include
+win32:UI_HEADERS_DIR = c:/myproject/ui/include
+//! [55]
+
+
+//! [56]
+unix:UI_SOURCES_DIR = ../myproject/ui/src
+win32:UI_SOURCES_DIR = c:/myproject/ui/src
+//! [56]
+
+
+//! [57]
+VERSION = 1.2.3
+//! [57]
+
+
+//! [58]
+YACCSOURCES = moc.y
+//! [58]
+
+
+//! [59]
+FILE = /etc/passwd
+FILENAME = $$basename(FILE) #passwd
+//! [59]
+
+
+//! [60]
+CONFIG = debug
+CONFIG += release
+CONFIG(release, debug|release):message(Release build!) #will print
+CONFIG(debug, debug|release):message(Debug build!) #no print
+//! [60]
+
+
+//! [61]
+contains( drivers, network ) {
+ # drivers contains 'network'
+ message( "Configuring for network build..." )
+ HEADERS += network.h
+ SOURCES += network.cpp
+}
+//! [61]
+
+
+//! [62]
+error(An error has occurred in the configuration process.)
+//! [62]
+
+
+//! [63]
+exists( $(QTDIR)/lib/libqt-mt* ) {
+ message( "Configuring for multi-threaded Qt..." )
+ CONFIG += thread
+}
+//! [63]
+
+
+//! [64]
+MY_VAR = one two three four
+MY_VAR2 = $$join(MY_VAR, " -L", -L) -Lfive
+MY_VAR3 = $$member(MY_VAR, 2) $$find(MY_VAR, t.*)
+//! [64]
+
+
+//! [65]
+LIST = 1 2 3
+for(a, LIST):exists(file.$${a}):message(I see a file.$${a}!)
+//! [65]
+
+
+//! [66]
+include( shared.pri )
+OPTIONS = standard custom
+!include( options.pri ) {
+ message( "No custom build options specified" )
+OPTIONS -= custom
+}
+//! [66]
+
+
+//! [67]
+isEmpty( CONFIG ) {
+CONFIG += qt warn_on debug
+}
+//! [67]
+
+
+//! [68]
+message( "This is a message" )
+//! [68]
+
+
+//! [69]
+!build_pass:message( "This is a message" )
+//! [69]
+
+
+//! [70]
+This is a test.
+//! [70]
+
+
+//! [71]
+system(ls /bin):HAS_BIN=FALSE
+//! [71]
+
+
+//! [72]
+UNAME = $$system(uname -s)
+contains( UNAME, [lL]inux ):message( This looks like Linux ($$UNAME) to me )
+//! [72]
+
+
+//! [73]
+ARGS = 1 2 3 2 5 1
+ARGS = $$unique(ARGS) #1 2 3 5
+//! [73]
+
+
+//! [74]
+qmake -set VARIABLE VALUE
+//! [74]
+
+
+//! [75]
+qmake -query VARIABLE
+qmake -query #queries all current VARIABLE/VALUE pairs..
+//! [75]
+
+
+//! [76]
+qmake -query "1.06a/VARIABLE"
+//! [76]
+
+
+//! [77]
+qmake -query "QT_INSTALL_PREFIX"
+//! [77]
+
+
+//! [78]
+QMAKE_VERS = $$[QMAKE_VERSION]
+//! [78]
+
+
+//! [79]
+documentation.path = /usr/local/program/doc
+documentation.files = docs/*
+//! [79]
+
+
+//! [80]
+INSTALLS += documentation
+//! [80]
+
+
+//! [81]
+unix:documentation.extra = create_docs; mv master.doc toc.doc
+//! [81]
+
+
+//! [82]
+target.path = /usr/local/myprogram
+INSTALLS += target
+//! [82]
+
+
+//! [83]
+CONFIG += create_prl
+//! [83]
+
+
+//! [84]
+CONFIG += link_prl
+//! [84]
+
+
+//! [85]
+QMAKE_EXT_MOC = .mymoc
+//! [85]
+
+
+//! [86]
+mytarget.target = .buildfile
+mytarget.commands = touch $$mytarget.target
+mytarget.depends = mytarget2
+
+mytarget2.commands = @echo Building $$mytarget.target
+//! [86]
+
+
+//! [87]
+QMAKE_EXTRA_TARGETS += mytarget mytarget2
+//! [87]
+
+
+//! [88]
+new_moc.output = moc_${QMAKE_FILE_BASE}.cpp
+new_moc.commands = moc ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT}
+new_moc.depend_command = g++ -E -M ${QMAKE_FILE_NAME} | sed "s,^.*: ,,"
+new_moc.input = NEW_HEADERS
+QMAKE_EXTRA_COMPILERS += new_moc
+//! [88]
+
+
+//! [89]
+TARGET = myapp
+//! [89]
+
+
+//! [90]
+DEFINES += QT_DLL
+//! [90]
+
+
+//! [91]
+DEFINES -= QT_DLL
+//! [91]
+
+
+//! [92]
+DEFINES *= QT_DLL
+//! [92]
+
+
+//! [93]
+DEFINES ~= s/QT_[DT].+/QT
+//! [93]
+
+
+//! [94]
+EVERYTHING = $$SOURCES $$HEADERS
+message("The project contains the following files:")
+message($$EVERYTHING)
+//! [94]
+
+
+//! [95]
+win32:DEFINES += QT_DLL
+//! [95]
+
+
+//! [96]
+win32:xml {
+ message(Building for Windows)
+ SOURCES += xmlhandler_win.cpp
+} else:xml {
+ SOURCES += xmlhandler.cpp
+} else {
+ message("Unknown configuration")
+}
+//! [96]
+
+
+//! [97]
+MY_VARIABLE = value
+//! [97]
+
+
+//! [98]
+MY_DEFINES = $$DEFINES
+//! [98]
+
+
+//! [99]
+MY_DEFINES = $${DEFINES}
+//! [99]
+
+
+//! [100]
+TARGET = myproject_$${TEMPLATE}
+//! [100]
+
+
+//! [101]
+target.path = $$[QT_INSTALL_PLUGINS]/designer
+INSTALLS += target
+//! [101]
+
+
+//! [102]
+defineReplace(functionName){
+ #function code
+}
+//! [102]
+
+
+//! [103]
+CONFIG += myfeatures
+//! [103]
+
+
+//! [104]
+// Add C includes here
+
+#if defined __cplusplus
+// Add C++ includes here
+#include <stdlib>
+#include <iostream>
+#include <vector>
+#include <QApplication> // Qt includes
+#include <QPushButton>
+#include <QLabel>
+#include "thirdparty/include/libmain.h"
+#include "my_stable_class.h"
+...
+#endif
+//! [104]
+
+
+//! [105]
+PRECOMPILED_HEADER = stable.h
+//! [105]
+
+
+//! [106]
+precompile_header:!isEmpty(PRECOMPILED_HEADER) {
+DEFINES += USING_PCH
+}
+//! [106]
+
+
+//! [107]
+PRECOMPILED_HEADER = window.h
+SOURCES = window.cpp
+//! [107]
+
+
+//! [108]
+SOURCES += hello.cpp
+//! [108]
+
+
+//! [109]
+SOURCES += hello.cpp
+SOURCES += main.cpp
+//! [109]
+
+
+//! [110]
+SOURCES = hello.cpp \
+ main.cpp
+//! [110]
+
+
+//! [111]
+HEADERS += hello.h
+SOURCES += hello.cpp
+SOURCES += main.cpp
+//! [111]
+
+
+//! [112]
+TARGET = helloworld
+//! [112]
+
+
+//! [113]
+CONFIG += qt
+HEADERS += hello.h
+SOURCES += hello.cpp
+SOURCES += main.cpp
+//! [113]
+
+
+//! [114]
+qmake -o Makefile hello.pro
+//! [114]
+
+
+//! [115]
+qmake -tp vc -o hello.dsp hello.pro
+//! [115]
+
+
+//! [116]
+CONFIG += qt debug
+HEADERS += hello.h
+SOURCES += hello.cpp
+SOURCES += main.cpp
+//! [116]
+
+
+//! [117]
+win32 {
+ SOURCES += hellowin.cpp
+}
+//! [117]
+
+
+//! [118]
+CONFIG += qt debug
+HEADERS += hello.h
+SOURCES += hello.cpp
+SOURCES += main.cpp
+win32 {
+ SOURCES += hellowin.cpp
+}
+unix {
+ SOURCES += hellounix.cpp
+}
+//! [118]
+
+
+//! [119]
+!exists( main.cpp ) {
+ error( "No main.cpp file found" )
+}
+//! [119]
+
+
+//! [120]
+CONFIG += qt debug
+HEADERS += hello.h
+SOURCES += hello.cpp
+SOURCES += main.cpp
+win32 {
+ SOURCES += hellowin.cpp
+}
+unix {
+ SOURCES += hellounix.cpp
+}
+!exists( main.cpp ) {
+ error( "No main.cpp file found" )
+}
+//! [120]
+
+
+//! [121]
+win32 {
+ debug {
+ CONFIG += console
+ }
+}
+//! [121]
+
+
+//! [122]
+CONFIG += qt debug
+HEADERS += hello.h
+SOURCES += hello.cpp
+SOURCES += main.cpp
+win32 {
+ SOURCES += hellowin.cpp
+}
+unix {
+ SOURCES += hellounix.cpp
+}
+!exists( main.cpp ) {
+ error( "No main.cpp file found" )
+}
+win32:debug {
+ CONFIG += console
+}
+//! [122]
+
+
+//! [123]
+TEMPLATE = app
+DESTDIR = c:/helloapp
+HEADERS += hello.h
+SOURCES += hello.cpp
+SOURCES += main.cpp
+DEFINES += QT_DLL
+CONFIG += qt warn_on release
+//! [123]
+
+
+//! [124]
+make all
+//! [124]
+
+
+//! [125]
+make
+//! [125]
+
+
+//! [126]
+make install
+//! [126]
+
+
+//! [127]
+CONFIG(debug, debug|release) {
+ mac: TARGET = $$join(TARGET,,,_debug)
+ win32: TARGET = $$join(TARGET,,d)
+}
+//! [127]
+
+//! [128]
+DEPLOYMENT_PLUGIN += qjpeg
+//! [128]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qnamespace.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qnamespace.qdoc
new file mode 100644
index 000000000..250d62d23
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qnamespace.qdoc
@@ -0,0 +1,24 @@
+//! [0]
+QObject::connect: Cannot queue arguments of type 'MyType'
+//! [0]
+
+
+//! [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/codesnippets/doc/src/snippets/code/doc_src_qpair.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qpair.qdoc
new file mode 100644
index 000000000..74c7c8360
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qpair.qdoc
@@ -0,0 +1,15 @@
+//! [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/codesnippets/doc/src/snippets/code/doc_src_qplugin.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qplugin.qdoc
new file mode 100644
index 000000000..d9b627e6b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qplugin.qdoc
@@ -0,0 +1,24 @@
+//! [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/codesnippets/doc/src/snippets/code/doc_src_qset.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qset.qdoc
new file mode 100644
index 000000000..7469d2ac5
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qset.qdoc
@@ -0,0 +1,126 @@
+//! [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 (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/codesnippets/doc/src/snippets/code/doc_src_qsignalspy.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qsignalspy.qdoc
new file mode 100644
index 000000000..d6b65dcd6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qsignalspy.qdoc
@@ -0,0 +1,41 @@
+//! [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/codesnippets/doc/src/snippets/code/doc_src_qt-conf.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qt-conf.qdoc
new file mode 100644
index 000000000..d675795dd
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qt-conf.qdoc
@@ -0,0 +1,14 @@
+//! [0]
+[Paths]
+Prefix = /some/path
+Translations = i18n
+//! [0]
+
+
+//! [1]
+Paths
+Paths/4
+Paths/4.1
+Paths/4.2.5
+Paths/6
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qt-embedded-displaymanagement.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qt-embedded-displaymanagement.qdoc
new file mode 100644
index 000000000..a3ab4dd04
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qt-embedded-displaymanagement.qdoc
@@ -0,0 +1,51 @@
+//! [0]
+$QPEDIR/qtopiacore/qt/configure -help
+//! [0]
+
+
+//! [1]
+./configure -help
+//! [1]
+
+
+//! [2]
+./configure -extra-qt-embedded-config "-qt-gfx-transformed"
+//! [2]
+
+
+//! [3]
+./configure -qt-gfx-transformed
+//! [3]
+
+
+//! [4]
+export QWS_DISPLAY="<driver>[:<driver specific options>]...
+ [:<display num>]"
+//! [4]
+
+
+//! [5]
+myApplication -display "<driver>[:<driver specific options>]...
+ [:<display num>]"
+//! [5]
+
+
+//! [6]
+export QWS_DISPLAY="<driver>[:<subdriver>][:<subdriver options>]...
+ [ :<display num>]"
+//! [6]
+
+
+//! [7]
+export QWS_DISPLAY="Multi: QVFb:0 QVFb:offset=640,0:1 :2"
+//! [7]
+
+
+//! [8]
+export QWS_DISPLAY="VNC:size=720x480:depth=32"
+//! [8]
+
+
+//! [9]
+export QWS_DISPLAY="VNC:LinuxFb"
+//! [9]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qt3support.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qt3support.qdoc
new file mode 100644
index 000000000..e6f0272ac
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qt3support.qdoc
@@ -0,0 +1,8 @@
+//! [0]
+#include <Qt3Support>
+//! [0]
+
+
+//! [1]
+QT += qt3support
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qt3to4.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qt3to4.qdoc
new file mode 100644
index 000000000..da0832d3f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qt3to4.qdoc
@@ -0,0 +1,26 @@
+//! [0]
+qt3to4 myfile.cpp
+qt3to4 myapp.pro
+//! [0]
+
+
+//! [1]
+<Rules>
+ <Include>/path/to/q3porting.xml</Include>
+
+ <item Type="RenamedHeader" Disable="True" >
+ <Qt4>q3sqlselectcursor.h</Qt4>
+ <Qt3>qsqlselectcursor.h</Qt3>
+ </item>
+
+ <item Type="RenamedHeader" >
+ <Qt4>newclass.h</Qt4>
+ <Qt3>oldclass.h</Qt3>
+ </item>
+</Rules>
+//! [1]
+
+
+//! [2]
+using namespace Qt;
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qt4-accessibility.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qt4-accessibility.qdoc
new file mode 100644
index 000000000..8bed0a920
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qt4-accessibility.qdoc
@@ -0,0 +1,59 @@
+//! [environment]
+export QT_ACCESSIBILITY=1
+//! [environment]
+
+//! [0]
+class MyWidgetInterface : public QAccessibleWidget
+{
+public:
+ MyWidgetInterface(QWidget *widget, Role role);
+
+ QString text(Text text, int child) const;
+ State state(int child) const;
+ QString actionText(int action, Text text, int child) const;
+ bool doAction(int action, int child, const QVariantList &params);
+ ...
+};
+//! [0]
+
+
+//! [1]
+bool MyWidgetInterface::doAction(int action, int child,
+ const QVariantList &params)
+{
+ if (child || !widget()->isEnabled())
+ return false;
+
+ switch (action) {
+ case DefaultAction:
+ case Press:
+ {
+ MyWidget *widget = qobject_cast<MyWidget *>(object());
+ if (widget)
+ widget->click();
+ }
+ return true;
+ }
+ return QAccessibleWidget::doAction(action, child, params);
+}
+//! [1]
+
+
+//! [2]
+QStringList MyFactory::keys() const
+{
+ return QStringList() << "MyWidget" << "MyOtherWidget";
+}
+
+QAccessibleInterface *MyFactory::create(const QString &className,
+ QObject *object)
+{
+ if (classname == "MyWidget")
+ return new MyWidgetInterface(object);
+ if (classname == "MyOtherWidget")
+ return new MyOtherWidgetInterface(object);
+ return 0;
+}
+
+Q_EXPORT_PLUGIN2(myfactory, MyFactory)
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qt4-arthur.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qt4-arthur.qdoc
new file mode 100644
index 000000000..6ac30ae47
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qt4-arthur.qdoc
@@ -0,0 +1,104 @@
+//! [0]
+QLinearGradient gradient(0, 0, 100, 100);
+gradient.setColorAt(0, Qt::red);
+gradient.setColorAt(0.5, Qt::green);
+gradient.setColorAt(1, Qt::blue);
+painter.setBrush(gradient);
+painter.drawRect(0, 0, 100, 100);
+//! [0]
+
+
+//! [1]
+QRadialGradient gradient(50, 50, 50, 30, 30);
+gradient.setColorAt(0.2, Qt::white);
+gradient.setColorAt(0.8, Qt::green);
+gradient.setColorAt(1, Qt::black);
+painter.setBrush(gradient);
+painter.drawEllipse(0, 0, 100, 100);
+//! [1]
+
+
+//! [2]
+QConicalGradient gradient(60, 40, 0);
+gradient.setColorAt(0, Qt::black);
+gradient.setColorAt(0.4, Qt::green);
+gradient.setColorAt(0.6, Qt::white);
+gradient.setColorAt(1, Qt::black);
+painter.setBrush(gradient);
+painter.drawEllipse(0, 0, 100, 100);
+//! [2]
+
+
+//! [3]
+// Specfiy semi-transparent red
+painter.setBrush(QColor(255, 0, 0, 127));
+painter.drawRect(0, 0, width()/2, height());
+
+// Specify semi-transparend blue
+painter.setBrush(QColor(0, 0, 255, 127));
+painter.drawRect(0, 0, width(), height()/2);
+//! [3]
+
+
+//! [4]
+// One line without anti-aliasing
+painter.drawLine(0, 0, width()/2, height());
+
+// One line with anti-aliasing
+painter.setRenderHint(QPainter::Antialiasing);
+painter.drawLine(width()/2, 0, width()/2, height());
+//! [4]
+
+
+//! [5]
+QPainterPath path;
+path.addRect(20, 20, 60, 60);
+path.addBezier(0, 0, 99, 0, 50, 50, 99, 99);
+path.addBezier(99, 99, 0, 99, 50, 50, 0, 0);
+painter.drawPath(path);
+//! [5]
+
+
+//! [6]
+QPixmap buffer(size());
+QPainter painter(&buffer);
+
+// Paint code here
+
+painter.end();
+bitBlt(this, 0, 0, &buffer);
+//! [6]
+
+
+//! [7]
+QPainter painter(this);
+
+// Paint code here
+
+painter.end();
+//! [7]
+
+
+//! [8]
+unbufferedWidget->setAttribute(Qt::WA_PaintOnScreen);
+//! [8]
+
+
+//! [9]
+QLinearGradient gradient(0, 0, 100, 100);
+gradient.setColorAt(0, Qt::blue);
+gradient.setColorAt(1, Qt::red);
+painter.setPen(QPen(gradient, 0));
+for (int y=fontSize; y<100; y+=fontSize)
+ drawText(0, y, text);
+//! [9]
+
+
+//! [10]
+QImage image(100, 100, 32);
+QPainter painter(&image);
+
+// painter commands.
+
+painter.end();
+//! [10]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qt4-intro.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qt4-intro.qdoc
new file mode 100644
index 000000000..ced563e7d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qt4-intro.qdoc
@@ -0,0 +1,101 @@
+//! [0]
+QT -= gui
+//! [0]
+
+
+//! [1]
+QT += network opengl sql qt3support
+//! [1]
+
+
+//! [2]
+CONFIG += uic3
+//! [2]
+
+
+//! [3]
+#include <QClassName>
+//! [3]
+
+
+//! [4]
+#include <QString>
+#include <QApplication>
+#include <QSqlTableModel>
+//! [4]
+
+
+//! [5]
+#include <qclassname.h>
+//! [5]
+
+
+//! [6]
+#include <QtCore>
+//! [6]
+
+
+//! [7]
+using namespace Qt;
+//! [7]
+
+
+//! [8]
+QLabel *label1 = new QLabel("Hello", this);
+QLabel *label2 = new QLabel(this, "Hello");
+//! [8]
+
+
+//! [9]
+MyWidget::MyWidget(QWidget *parent, const char *name)
+ : QWidget(parent, name)
+{
+ ...
+}
+//! [9]
+
+
+//! [10]
+// DEPRECATED
+if (obj->inherits("QPushButton")) {
+ QPushButton *pushButton = (QPushButton *)obj;
+ ...
+}
+//! [10]
+
+
+//! [11]
+QPushButton *pushButton = qobject_cast<QPushButton *>(obj);
+if (pushButton) {
+ ...
+}
+//! [11]
+
+
+//! [12]
+QLabel *label = new QLabel;
+QPointer<QLabel> safeLabel = label;
+safeLabel->setText("Hello world!");
+delete label;
+// safeLabel is now 0, whereas label is a dangling pointer
+//! [12]
+
+
+//! [13]
+QT += qt3support
+//! [13]
+
+
+//! [14]
+DEFINES += QT3_SUPPORT
+//! [14]
+
+
+//! [15]
+DEFINES += QT3_SUPPORT_WARNINGS
+//! [15]
+
+
+//! [16]
+DEFINES += QT3_SUPPORT
+//! [16]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc
new file mode 100644
index 000000000..9e81fd15c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc
@@ -0,0 +1,70 @@
+//! [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/codesnippets/doc/src/snippets/code/doc_src_qt4-sql.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qt4-sql.qdoc
new file mode 100644
index 000000000..74b04eb95
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qt4-sql.qdoc
@@ -0,0 +1,19 @@
+//! [0]
+QSqlQueryModel model;
+model.setQuery("select * from person");
+
+QTableView view;
+view.setModel(&model);
+view.show();
+//! [0]
+
+
+//! [1]
+QSqlTableModel model;
+model.setTable("person");
+model.select();
+
+QTableView view;
+view.setModel(&model);
+view.show();
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qt4-styles.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qt4-styles.qdoc
new file mode 100644
index 000000000..b75c13556
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qt4-styles.qdoc
@@ -0,0 +1,42 @@
+//! [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/codesnippets/doc/src/snippets/code/doc_src_qt4-tulip.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qt4-tulip.qdoc
new file mode 100644
index 000000000..2bc5af182
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qt4-tulip.qdoc
@@ -0,0 +1,100 @@
+//! [0]
+foreach (variable, container)
+ statement;
+//! [0]
+
+
+//! [1]
+QList<QString> list;
+...
+foreach (QString str, list)
+ cout << str.ascii() << endl;
+//! [1]
+
+
+//! [2]
+QString str;
+foreach (str, list)
+ cout << str.ascii() << endl;
+//! [2]
+
+
+//! [3]
+// forward // backward
+QList<QString> list; QList<QString> list;
+... ...
+QListIterator<QString> i(list); QListIterator<QString> i(list);
+while (i.hasNext()) i.toBack();
+ cout << i.next().ascii() << endl; while (i.hasPrev())
+ cout << i.prev().ascii() << endl;
+//! [3]
+
+
+//! [4]
+// forward // backward
+QMutableListIterator<int> i(list); QMutableListIterator<int> i(list);
+while (i.hasNext()) i.toBack();
+ if (i.next() > 128) while (i.hasPrev())
+ i.setValue(128); if (i.prev() > 128)
+ i.setValue(128);
+//! [4]
+
+
+//! [5]
+// forward // backward
+QMutableListIterator<int> i(list); QMutableListIterator<int> i(list);
+while (i.hasNext()) i.toBack();
+ if (i.next() % 2 != 0) while (i.hasPrev())
+ i.remove(); if (i.prev() % 2 != 0)
+ i.remove();
+//! [5]
+
+
+//! [6]
+// STL-style // Java-style
+QMap<int, QWidget *>::const_iterator i; QMapIterator<int, QWidget *> i(map);
+for (i = map.begin(); i != map.end(); ++i) while (i.findNext(widget))
+ if (i.value() == widget) cout << "Found widget " << widget
+ cout << "Found widget " << widget << " under key "
+ << " under key " << i.key() << endl;
+ << i.key() << endl;
+//! [6]
+
+
+//! [7]
+// STL-style // Java-style
+QList<int>::iterator i = list.begin(); QMutableListIterator<int> i(list);
+while (i != list.end()) { while (i.hasNext()) {
+ if (*i == 0) { int val = i.next();
+ i = list.erase(i); if (val < 0)
+ } else { i.setValue(-val);
+ if (*i < 0) else if (val == 0)
+ *i = -*i; i.remove();
+ ++i; }
+ }
+}
+//! [7]
+
+
+//! [8]
+QList<double> list;
+...
+for (int i = 0; i < list.size(); ++i) {
+ if (list[i] < 0.0)
+ list[i] = 0.0;
+}
+//! [8]
+
+
+//! [9]
+QMap<QString, int> map;
+...
+map.value("TIMEOUT", 30); // returns 30 if "TIMEOUT" isn't in the map
+//! [9]
+
+
+//! [10]
+QMultiMap<QString, int> map;
+...
+QList<int> values = map.values("TIMEOUT");
+//! [10]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qtcore.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qtcore.qdoc
new file mode 100644
index 000000000..efa155f33
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qtcore.qdoc
@@ -0,0 +1,3 @@
+//! [0]
+#include <QtCore>
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qtdbus.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qtdbus.qdoc
new file mode 100644
index 000000000..4c8c4b0c5
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qtdbus.qdoc
@@ -0,0 +1,8 @@
+//! [0]
+#include <QtDBus>
+//! [0]
+
+
+//! [1]
+QT += dbus
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qtdesigner.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qtdesigner.qdoc
new file mode 100644
index 000000000..b19a7472a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qtdesigner.qdoc
@@ -0,0 +1,293 @@
+//! [0]
+#include <QtDesigner>
+//! [0]
+
+
+//! [1]
+CONFIG += designer
+//! [1]
+
+
+//! [2]
+QDesignerMemberSheetExtension *memberSheet = 0;
+QExtensionManager manager = formEditor->extensionManager();
+
+memberSheet = qt_extension<QDesignerMemberSheetExtension*>(manager, widget);
+int index = memberSheet->indexOf(setEchoMode);
+memberSheet->setVisible(index, false);
+
+delete memberSheet;
+//! [2]
+
+
+//! [3]
+class MyMemberSheetExtension : public QObject,
+ public QDesignerMemberSheetExtension
+{
+ Q_OBJECT
+ Q_INTERFACES(QDesignerMemberSheetExtension)
+
+public:
+ ...
+}
+//! [3]
+
+
+//! [4]
+QObject *ANewExtensionFactory::createExtension(QObject *object,
+ const QString &iid, QObject *parent) const
+{
+ if (iid != Q_TYPEID(QDesignerMemberSheetExtension))
+ return 0;
+
+ if (MyCustomWidget *widget = qobject_cast<MyCustomWidget*>
+ (object))
+ return new MyMemberSheetExtension(widget, parent);
+
+ return 0;
+}
+//! [4]
+
+
+//! [5]
+QObject *AGeneralExtensionFactory::createExtension(QObject *object,
+ const QString &iid, QObject *parent) const
+{
+ MyCustomWidget *widget = qobject_cast<MyCustomWidget*>(object);
+
+ if (widget && (iid == Q_TYPEID(QDesignerTaskMenuExtension))) {
+ return new MyTaskMenuExtension(widget, parent);
+
+ } else if (widget && (iid == Q_TYPEID(QDesignerMemberSheetExtension))) {
+ return new MyMemberSheetExtension(widget, parent);
+
+ } else {
+ return 0;
+ }
+}
+//! [5]
+
+
+//! [6]
+class MyContainerExtension : public QObject,
+ public QDesignerContainerExtension
+{
+ Q_OBJECT
+ Q_INTERFACES(QDesignerContainerExtension)
+
+public:
+ MyContainerExtension(MyCustomWidget *widget,
+ QObject *parent = 0);
+ int count() const;
+ QWidget *widget(int index) const;
+ int currentIndex() const;
+ void setCurrentIndex(int index);
+ void addWidget(QWidget *widget);
+ void insertWidget(int index, QWidget *widget);
+ void remove(int index);
+
+private:
+ MyCustomWidget *myWidget;
+};
+//! [6]
+
+
+//! [7]
+QObject *ANewExtensionFactory::createExtension(QObject *object,
+ const QString &iid, QObject *parent) const
+{
+ if (iid != Q_TYPEID(QDesignerContainerExtension))
+ return 0;
+
+ if (MyCustomWidget *widget = qobject_cast<MyCustomWidget*>
+ (object))
+ return new MyContainerExtension(widget, parent);
+
+ return 0;
+}
+//! [7]
+
+
+//! [8]
+QObject *AGeneralExtensionFactory::createExtension(QObject *object,
+ const QString &iid, QObject *parent) const
+{
+ MyCustomWidget *widget = qobject_cast<MyCustomWidget*>(object);
+
+ if (widget && (iid == Q_TYPEID(QDesignerTaskMenuExtension))) {
+ return new MyTaskMenuExtension(widget, parent);
+
+ } else if (widget && (iid == Q_TYPEID(QDesignerContainerExtension))) {
+ return new MyContainerExtension(widget, parent);
+
+ } else {
+ return 0;
+ }
+}
+//! [8]
+
+
+//! [9]
+class MyTaskMenuExtension : public QObject,
+ public QDesignerTaskMenuExtension
+{
+ Q_OBJECT
+ Q_INTERFACES(QDesignerTaskMenuExtension)
+
+public:
+ MyTaskMenuExtension(MyCustomWidget *widget, QObject *parent);
+
+ QAction *preferredEditAction() const;
+ QList<QAction *> taskActions() const;
+
+private slots:
+ void mySlot();
+
+private:
+ MyCustomWidget *widget;
+ QAction *myAction;
+};
+//! [9]
+
+
+//! [10]
+QObject *ANewExtensionFactory::createExtension(QObject *object,
+ const QString &iid, QObject *parent) const
+{
+ if (iid != Q_TYPEID(QDesignerTaskMenuExtension))
+ return 0;
+
+ if (MyCustomWidget *widget = qobject_cast<MyCustomWidget*>(object))
+ return new MyTaskMenuExtension(widget, parent);
+
+ return 0;
+}
+//! [10]
+
+
+//! [11]
+QObject *AGeneralExtensionFactory::createExtension(QObject *object,
+ const QString &iid, QObject *parent) const
+{
+ MyCustomWidget *widget = qobject_cast<MyCustomWidget*>(object);
+
+ if (widget && (iid == Q_TYPEID(QDesignerContainerExtension))) {
+ return new MyContainerExtension(widget, parent);
+
+ } else if (widget && (iid == Q_TYPEID(QDesignerTaskMenuExtension))) {
+ return new MyTaskMenuExtension(widget, parent);
+
+ } else {
+ return 0;
+ }
+}
+//! [11]
+
+
+//! [12]
+#include customwidgetoneinterface.h
+#include customwidgettwointerface.h
+#include customwidgetthreeinterface.h
+
+#include <QtDesigner/QtDesigner>
+#include <QtCore/qplugin.h>
+
+class MyCustomWidgets: public QObject, public QDesignerCustomWidgetCollectionInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(QDesignerCustomWidgetCollectionInterface)
+
+public:
+ MyCustomWidgets(QObject *parent = 0);
+
+ virtual QList<QDesignerCustomWidgetInterface*> customWidgets() const;
+
+private:
+ QList<QDesignerCustomWidgetInterface*> widgets;
+};
+//! [12]
+
+
+//! [13]
+MyCustomWidgets::MyCustomWidgets(QObject *parent)
+ : QObject(parent)
+{
+ widgets.append(new CustomWidgetOneInterface(this));
+ widgets.append(new CustomWidgetTwoInterface(this));
+ widgets.append(new CustomWidgetThreeInterface(this));
+}
+
+QList<QDesignerCustomWidgetInterface*> MyCustomWidgets::customWidgets() const
+{
+ return widgets;
+}
+
+Q_EXPORT_PLUGIN2(customwidgetsplugin, MyCustomWidgets)
+//! [13]
+
+
+//! [14]
+Q_EXPORT_PLUGIN2(customwidgetplugin, MyCustomWidget)
+//! [14]
+
+
+//! [15]
+QDesignerPropertySheetExtension *propertySheet = 0;
+QExtensionManager manager = formEditor->extensionManager();
+
+propertySheet = qt_extension<QDesignerPropertySheetExtension*>(manager, widget);
+int index = propertySheet->indexOf(QLatin1String("margin"));
+
+propertySheet->setProperty(index, 10);
+propertySheet->setChanged(index, true);
+
+delete propertySheet;
+//! [15]
+
+
+//! [16]
+class MyPropertySheetExtension : public QObject,
+ public QDesignerPropertySheetExtension
+{
+ Q_OBJECT
+ Q_INTERFACES(QDesignerPropertySheetExtension)
+
+public:
+ ...
+}
+//! [16]
+
+
+//! [17]
+QObject *ANewExtensionFactory::createExtension(QObject *object,
+ const QString &iid, QObject *parent) const
+{
+ if (iid != Q_TYPEID(QDesignerPropertySheetExtension))
+ return 0;
+
+ if (MyCustomWidget *widget = qobject_cast<MyCustomWidget*>
+ (object))
+ return new MyPropertySheetExtension(widget, parent);
+
+ return 0;
+}
+//! [17]
+
+
+//! [18]
+QObject *AGeneralExtensionFactory::createExtension(QObject *object,
+ const QString &iid, QObject *parent) const
+{
+ MyCustomWidget *widget = qobject_cast<MyCustomWidget*>(object);
+
+ if (widget && (iid == Q_TYPEID(QDesignerTaskMenuExtension))) {
+ return new MyTaskMenuExtension(widget, parent);
+
+ } else if (widget && (iid == Q_TYPEID(QDesignerPropertySheetExtension))) {
+ return new MyPropertySheetExtension(widget, parent);
+
+ } else {
+ return 0;
+ }
+}
+//! [18]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qtestevent.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qtestevent.qdoc
new file mode 100644
index 000000000..87591e047
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qtestevent.qdoc
@@ -0,0 +1,11 @@
+//! [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/codesnippets/doc/src/snippets/code/doc_src_qtestlib.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qtestlib.qdoc
new file mode 100644
index 000000000..5a7d0adcc
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qtestlib.qdoc
@@ -0,0 +1,102 @@
+//! [0]
+class MyFirstTest: public QObject
+{
+ Q_OBJECT
+private slots:
+ void initTestCase()
+ { qDebug("called before everything else"); }
+ void myFirstTest()
+ { QVERIFY(1 == 1); }
+ void mySecondTest()
+ { QVERIFY(1 != 2); }
+ void cleanupTestCase()
+ { qDebug("called after myFirstTest and mySecondTest"); }
+};
+//! [0]
+
+
+//! [1]
+QT += testlib
+//! [1]
+
+
+//! [2]
+testname [options] [testfunctions[:testdata]]...
+//! [2]
+
+
+//! [3]
+/myTestDirectory$ testQString toUpper
+//! [3]
+
+
+//! [4]
+/myTestDirectory$ testQString toUpper toInt:zero
+//! [4]
+
+
+//! [5]
+/myTestDirectory$ testMyWidget -vs -eventdelay 500
+//! [5]
+
+
+//! [6]
+cetest [options] ...
+//! [6]
+
+
+//! [7]
+set INCLUDE=C:\Program Files\Windows CE Tools\wce500\Windows Mobile 5.0 Pocket PC SDK\Activesync\Inc;%INCLUDE%
+set LIB=C:\Program Files\Windows CE Tools\wce500\Windows Mobile 5.0 Pocket PC SDK\Activesync\Lib;%LIB%
+//! [7]
+
+
+//! [8]
+void TestQString::toUpper()
+{
+ QString str = "Hello";
+ QVERIFY(str.toUpper() == "HELLO");
+}
+//! [8]
+
+
+//! [9]
+/myTestDirectory$ qmake -project "CONFIG += qtestlib"
+/myTestDirectory$ qmake
+/myTestDirectory$ make
+//! [9]
+
+
+//! [10]
+********* Start testing of TestQString *********
+Config: Using QTest library 4.5.2, Qt 4.5.2
+PASS : TestQString::initTestCase()
+PASS : TestQString::toUpper()
+PASS : TestQString::cleanupTestCase()
+Totals: 3 passed, 0 failed, 0 skipped
+********* Finished testing of TestQString *********
+//! [10]
+
+
+//! [11]
+QCOMPARE(QString("hello").toUpper(), QString("HELLO"));
+QCOMPARE(QString("Hello").toUpper(), QString("HELLO"));
+QCOMPARE(QString("HellO").toUpper(), QString("HELLO"));
+QCOMPARE(QString("HELLO").toUpper(), QString("HELLO"));
+//! [11]
+
+//! [12]
+class MyFirstBenchmark: public QObject
+{
+ Q_OBJECT
+private slots:
+ void myFirstBenchmark()
+ {
+ QString string1;
+ QString string2;
+ QBENCHMARK {
+ string1.localeAwareCompare(string2);
+ }
+ }
+};
+//! [12]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qtgui.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qtgui.qdoc
new file mode 100644
index 000000000..ff3afcf64
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qtgui.qdoc
@@ -0,0 +1,3 @@
+//! [0]
+#include <QtGui>
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qthelp.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qthelp.qdoc
new file mode 100644
index 000000000..11d231f5c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qthelp.qdoc
@@ -0,0 +1,161 @@
+//! [0]
+#include <QtHelp>
+//! [0]
+
+
+//! [1]
+CONFIG += help
+//! [1]
+
+
+//! [2]
+qhelpgenerator doc.qhp -o doc.qch
+//! [2]
+
+
+//! [3]
+<?xml version="1.0" encoding="utf-8" ?>
+<QHelpCollectionProject version="1.0">
+ <docFiles>
+ <register>
+ <file>doc.qch</file>
+ </register>
+ </docFiles>
+</QHelpCollectionProject>
+//! [3]
+
+
+//! [4]
+qcollectiongenerator mycollection.qhcp -o mycollection.qhc
+//! [4]
+
+
+//! [5]
+...
+<docFiles>
+ <generate>
+ <file>
+ <input>doc.qhp</input>
+ <output>doc.qch</output>
+ </file>
+ </generate>
+ <register>
+ <file>doc.qch</file>
+ </register>
+</docFiles>
+...
+//! [5]
+
+
+//! [6]
+QHelpEngineCore helpEngine("mycollection.qhc");
+...
+
+// get all file references for the identifier
+QMap<QString, QUrl> links =
+ helpEngine.linksForIdentifier(QLatin1String("MyDialog::ChangeButton"));
+
+// If help is available for this keyword, get the help data
+// of the first file reference.
+if (links.count()) {
+ QByteArray helpData = helpEngine->fileData(links.constBegin().value());
+ // show the documentation to the user
+ if (!helpData.isEmpty())
+ displayHelp(helpData);
+}
+//! [6]
+
+
+//! [7]
+<?xml version="1.0" encoding="UTF-8"?>
+<QtHelpProject version="1.0">
+ <namespace>mycompany.com.myapplication.1_0</namespace>
+ <virtualFolder>doc</virtualFolder>
+ <customFilter name="My Application 1.0">
+ <filterAttribute>myapp</filterAttribute>
+ <filterAttribute>1.0</filterAttribute>
+ </customFilter>
+ <filterSection>
+ <filterAttribute>myapp</filterAttribute>
+ <filterAttribute>1.0</filterAttribute>
+ <toc>
+ <section title="My Application Manual" ref="index.html">
+ <section title="Chapter 1" ref="doc.html#chapter1"/>
+ <section title="Chapter 2" ref="doc.html#chapter2"/>
+ <section title="Chapter 3" ref="doc.html#chapter3"/>
+ </section>
+ </toc>
+ <keywords>
+ <keyword name="foo" id="MyApplication::foo" ref="doc.html#foo"/>
+ <keyword name="bar" ref="doc.html#bar"/>
+ <keyword id="MyApplication::foobar" ref="doc.html#foobar"/>
+ </keywords>
+ <files>
+ <file>classic.css</file>
+ <file>index.html</file>
+ <file>doc.html</file>
+ </files>
+ </filterSection>
+</QtHelpProject>
+//! [7]
+
+
+//! [8]
+...
+<virtualFolder>doc</virtualFolder>
+...
+//! [8]
+
+
+//! [9]
+...
+<customFilter name="My Application 1.0">
+ <filterAttribute>myapp</filterAttribute>
+ <filterAttribute>1.0</filterAttribute>
+</customFilter>
+...
+//! [9]
+
+
+//! [10]
+...
+<filterSection>
+ <filterAttribute>myapp</filterAttribute>
+ <filterAttribute>1.0</filterAttribute>
+...
+//! [10]
+
+
+//! [11]
+...
+<toc>
+ <section title="My Application Manual" ref="index.html">
+ <section title="Chapter 1" ref="doc.html#chapter1"/>
+ <section title="Chapter 2" ref="doc.html#chapter2"/>
+ <section title="Chapter 3" ref="doc.html#chapter3"/>
+ </section>
+</toc>
+...
+//! [11]
+
+
+//! [12]
+...
+<keywords>
+ <keyword name="foo" id="MyApplication::foo" ref="doc.html#foo"/>
+ <keyword name="bar" ref="doc.html#bar"/>
+ <keyword id="MyApplication::foobar" ref="doc.html#foobar"/>
+</keywords>
+...
+//! [12]
+
+
+//! [13]
+...
+<files>
+ <file>classic.css</file>
+ <file>index.html</file>
+ <file>doc.html</file>
+</files>
+...
+//! [13]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qtmac-as-native.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qtmac-as-native.qdoc
new file mode 100644
index 000000000..6ad42b940
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qtmac-as-native.qdoc
@@ -0,0 +1,3 @@
+//! [0]
+qmake -spec macx-xcode project.pro
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qtnetwork.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qtnetwork.qdoc
new file mode 100644
index 000000000..48566869f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qtnetwork.qdoc
@@ -0,0 +1,8 @@
+//! [0]
+QT += network
+//! [0]
+
+
+//! [1]
+#include <QtNetwork>
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qtopengl.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qtopengl.qdoc
new file mode 100644
index 000000000..e13cdf055
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qtopengl.qdoc
@@ -0,0 +1,8 @@
+//! [0]
+#include <QtOpenGL>
+//! [0]
+
+
+//! [1]
+QT += opengl
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qtscript.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qtscript.qdoc
new file mode 100644
index 000000000..4031fef87
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qtscript.qdoc
@@ -0,0 +1,948 @@
+//! [0]
+#include <QtScript>
+//! [0]
+
+
+//! [1]
+QT += script
+//! [1]
+
+
+//! [2]
+function myInterestingScriptFunction() { ... }
+...
+myQObject.somethingChanged.connect(myInterestingScriptFunction);
+//! [2]
+
+
+//! [3]
+myQObject.somethingChanged.connect(myOtherQObject.doSomething);
+//! [3]
+
+
+//! [4]
+myQObject.somethingChanged.disconnect(myInterestingFunction);
+myQObject.somethingChanged.disconnect(myOtherQObject.doSomething);
+//! [4]
+
+
+//! [5]
+var obj = { x: 123 };
+var fun = function() { print(this.x); };
+myQObject.somethingChanged.connect(obj, fun);
+//! [5]
+
+
+//! [6]
+myQObject.somethingChanged.disconnect(obj, fun);
+//! [6]
+
+
+//! [7]
+var obj = { x: 123, fun: function() { print(this.x); } };
+myQObject.somethingChanged.connect(obj, "fun");
+//! [7]
+
+
+//! [8]
+myQObject.somethingChanged.disconnect(obj, "fun");
+//! [8]
+
+
+//! [9]
+try {
+ myQObject.somethingChanged.connect(myQObject, "slotThatDoesntExist");
+} catch (e) {
+ print(e);
+}
+//! [9]
+
+
+//! [10]
+myQObject.somethingChanged("hello");
+//! [10]
+
+
+//! [11]
+myQObject.myOverloadedSlot(10); // will call the int overload
+myQObject.myOverloadedSlot("10"); // will call the QString overload
+//! [11]
+
+
+//! [12]
+myQObject['myOverloadedSlot(int)']("10"); // call int overload; the argument is converted to an int
+myQObject['myOverloadedSlot(QString)'](10); // call QString overload; the argument is converted to a string
+//! [12]
+
+
+//! [13]
+Q_PROPERTY(bool enabled READ enabled WRITE setEnabled)
+//! [13]
+
+
+//! [14]
+myQObject.enabled = true;
+
+...
+
+myQObject.enabled = !myQObject.enabled;
+//! [14]
+
+
+//! [15]
+myDialog.okButton
+//! [15]
+
+
+//! [16]
+myDialog.okButton.objectName = "cancelButton";
+// from now on, myDialog.cancelButton references the button
+//! [16]
+
+
+//! [17]
+var okButton = myDialog.findChild("okButton");
+if (okButton != null) {
+ // do something with the OK button
+}
+
+var buttons = myDialog.findChildren(RegExp("button[0-9]+"));
+for (var i = 0; i < buttons.length; ++i) {
+ // do something with buttons[i]
+}
+//! [17]
+
+
+//! [18]
+QScriptValue myQObjectConstructor(QScriptContext *context, QScriptEngine *engine)
+{
+ // let the engine manage the new object's lifetime.
+ return engine->newQObject(new MyQObject(), QScriptEngine::ScriptOwnership);
+}
+//! [18]
+
+
+//! [19]
+class MyObject : public QObject
+{
+ Q_OBJECT
+
+public:
+ MyObject( ... );
+
+ void aNonScriptableFunction();
+
+public slots: // these functions (slots) will be available in QtScript
+ void calculate( ... );
+ void setEnabled( bool enabled );
+ bool isEnabled() const;
+
+private:
+ ....
+
+};
+//! [19]
+
+
+//! [20]
+class MyObject : public QObject
+{
+ Q_OBJECT
+
+ public:
+ Q_INVOKABLE void thisMethodIsInvokableInQtScript();
+ void thisMethodIsNotInvokableInQtScript();
+
+ ...
+};
+//! [20]
+
+
+//! [21]
+var obj = new MyObject;
+obj.setEnabled( true );
+print( "obj is enabled: " + obj.isEnabled() );
+//! [21]
+
+
+//! [22]
+var obj = new MyObject;
+obj.enabled = true;
+print( "obj is enabled: " + obj.enabled );
+//! [22]
+
+
+//! [23]
+class MyObject : public QObject
+{
+ Q_OBJECT
+ // define the enabled property
+ Q_PROPERTY( bool enabled WRITE setEnabled READ isEnabled )
+
+public:
+ MyObject( ... );
+
+ void aNonScriptableFunction();
+
+public slots: // these functions (slots) will be available in QtScript
+ void calculate( ... );
+ void setEnabled( bool enabled );
+ bool isEnabled() const;
+
+private:
+ ....
+
+};
+//! [23]
+
+
+//! [24]
+Q_PROPERTY(int nonScriptableProperty READ foo WRITE bar SCRIPTABLE false)
+//! [24]
+
+
+//! [25]
+class MyObject : public QObject
+{
+ Q_OBJECT
+ // define the enabled property
+ Q_PROPERTY( bool enabled WRITE setEnabled READ isEnabled )
+
+public:
+ MyObject( ... );
+
+ void aNonScriptableFunction();
+
+public slots: // these functions (slots) will be available in QtScript
+ void calculate( ... );
+ void setEnabled( bool enabled );
+ bool isEnabled() const;
+
+signals: // the signals
+ void enabledChanged( bool newState );
+
+private:
+ ....
+
+};
+//! [25]
+
+
+//! [26]
+function enabledChangedHandler( b )
+{
+ print( "state changed to: " + b );
+}
+
+function init()
+{
+ var obj = new MyObject();
+ // connect a script function to the signal
+ obj["enabledChanged(bool)"].connect(enabledChangedHandler);
+ obj.enabled = true;
+ print( "obj is enabled: " + obj.enabled );
+}
+//! [26]
+
+
+//! [27]
+var o = new Object();
+o.foo = 123;
+print(o.hasOwnProperty('foo')); // true
+print(o.hasOwnProperty('bar')); // false
+print(o); // calls o.toString(), which returns "[object Object]"
+//! [27]
+
+
+//! [28]
+function Person(name)
+{
+ this.name = name;
+}
+//! [28]
+
+
+//! [29]
+Person.prototype.toString = function() { return "Person(name: " + this.name + ")"; }
+//! [29]
+
+
+//! [30]
+var p1 = new Person("John Doe");
+var p2 = new Person("G.I. Jane");
+print(p1); // "Person(name: John Doe)"
+print(p2); // "Person(name: G.I. Jane)"
+//! [30]
+
+
+//! [31]
+print(p1.hasOwnProperty('name')); // 'name' is an instance variable, so this returns true
+print(p1.hasOwnProperty('toString')); // returns false; inherited from prototype
+print(p1 instanceof Person); // true
+print(p1 instanceof Object); // true
+//! [31]
+
+
+//! [32]
+function Employee(name, salary)
+{
+ Person.call(this, name); // call base constructor
+
+ this.salary = salary;
+}
+
+// set the prototype to be an instance of the base class
+Employee.prototype = new Person();
+
+// initialize prototype
+Employee.prototype.toString = function() { ... }
+//! [32]
+
+
+//! [33]
+var e = new Employee("Johnny Bravo", 5000000);
+print(e instanceof Employee); // true
+print(e instanceof Person); // true
+print(e instanceof Object); // true
+print(e instanceof Array); // false
+//! [33]
+
+
+//! [34]
+QScriptValue Person_ctor(QScriptContext *context, QScriptEngine *engine)
+{
+ QString name = context->argument(0).toString();
+ context->thisObject().setProperty("name", name);
+ return engine->undefinedValue();
+}
+//! [34]
+
+
+//! [35]
+QScriptValue Person_prototype_toString(QScriptContext *context, QScriptEngine *engine)
+{
+ QString name = context->thisObject().property("name").toString();
+ QString result = QString::fromLatin1("Person(name: %0)").arg(name);
+ return result;
+}
+//! [35]
+
+
+//! [36]
+QScriptEngine engine;
+QScriptValue ctor = engine.newFunction(Person_ctor);
+ctor.property("prototype").setProperty("toString", engine.newFunction(Person_prototype_toString));
+QScriptValue global = engine.globalObject();
+global.setProperty("Person", ctor);
+//! [36]
+
+
+//! [37]
+QScriptValue Employee_ctor(QScriptContext *context, QScriptEngine *engine)
+{
+ QScriptValue super = context->callee().property("prototype").property("constructor");
+ super.call(context->thisObject(), QScriptValueList() << context->argument(0));
+ context->thisObject().setProperty("salary", context->argument(1));
+ return engine->undefinedValue();
+}
+//! [37]
+
+
+//! [38]
+QScriptValue empCtor = engine.newFunction(Employee_ctor);
+empCtor.setProperty("prototype", global.property("Person").construct());
+global.setProperty("Employee", empCtor);
+//! [38]
+
+
+//! [39]
+Q_DECLARE_METATYPE(QPointF)
+Q_DECLARE_METATYPE(QPointF*)
+
+QScriptValue QPointF_prototype_x(QScriptContext *context, QScriptEngine *engine)
+{
+ // Since the point is not to be modified, it's OK to cast to a value here
+ QPointF point = qscriptvalue_cast<QPointF>(context->thisObject());
+ return point.x();
+}
+
+QScriptValue QPointF_prototype_setX(QScriptContext *context, QScriptEngine *engine)
+{
+ // Cast to a pointer to be able to modify the underlying C++ value
+ QPointF *point = qscriptvalue_cast<QPointF*>(context->thisObject());
+ if (!point)
+ return context->throwError(QScriptContext::TypeError, "QPointF.prototype.setX: this object is not a QPointF");
+ point->setX(context->argument(0).toNumber());
+ return engine->undefinedValue();
+}
+//! [39]
+
+
+//! [40]
+var o = new Object();
+(o.__proto__ === Object.prototype); // this evaluates to true
+//! [40]
+
+
+//! [41]
+var o = new Object();
+o.__defineGetter__("x", function() { return 123; });
+var y = o.x; // 123
+//! [41]
+
+
+//! [42]
+var o = new Object();
+o.__defineSetter__("x", function(v) { print("and the value is:", v); });
+o.x = 123; // will print "and the value is: 123"
+//! [42]
+
+
+//! [43]
+class MyObject : public QObject
+{
+ Q_OBJECT
+ ...
+};
+
+Q_DECLARE_METATYPE(MyObject*)
+
+QScriptValue myObjectToScriptValue(QScriptEngine *engine, MyObject* const &in)
+{ return engine->newQObject(in); }
+
+void myObjectFromScriptValue(const QScriptValue &object, MyObject* &out)
+{ out = qobject_cast<MyObject*>(object.toQObject()); }
+
+...
+
+qScriptRegisterMetaType(&engine, myObjectToScriptValue, myObjectFromScriptValue);
+//! [43]
+
+//! [44]
+QScriptValue QPoint_ctor(QScriptContext *context, QScriptEngine *engine)
+{
+ int x = context->argument(0).toInt32();
+ int y = context->argument(1).toInt32();
+ return engine->toScriptValue(QPoint(x, y));
+}
+
+...
+
+engine.globalObject().setProperty("QPoint", engine.newFunction(QPoint_ctor));
+//! [44]
+
+//! [45]
+QScriptValue myPrintFunction(QScriptContext *context, QScriptEngine *engine)
+{
+ QString result;
+ for (int i = 0; i < context->argumentCount(); ++i) {
+ if (i > 0)
+ result.append(" ");
+ result.append(context->argument(i).toString());
+ }
+
+ QScriptValue calleeData = context->callee().data();
+ QPlainTextEdit *edit = qobject_cast<QPlainTextEdit*>(calleeData.toQObject());
+ edit->appendPlainText(result);
+
+ return engine->undefinedValue();
+}
+//! [45]
+
+//! [46]
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ QScriptEngine eng;
+ QPlainTextEdit edit;
+
+ QScriptValue fun = eng.newFunction(myPrintFunction);
+ fun.setData(eng.newQObject(&edit));
+ eng.globalObject().setProperty("print", fun);
+
+ eng.evaluate("print('hello', 'world')");
+
+ edit.show();
+ return app.exec();
+}
+//! [46]
+
+
+//! [47]
+QScriptEngine eng;
+QLineEdit *edit = new QLineEdit(...);
+QScriptValue handler = eng.evaluate("function(text) { print('text was changed to', text); }");
+qScriptConnect(edit, SIGNAL(textChanged(const QString &)), QScriptValue(), handler);
+//! [47]
+
+//! [48]
+QLineEdit *edit1 = new QLineEdit(...);
+QLineEdit *edit2 = new QLineEdit(...);
+
+QScriptValue handler = eng.evaluate("function() { print('I am', this.name); }");
+QScriptValue obj1 = eng.newObject();
+obj1.setProperty("name", "the walrus");
+QScriptValue obj2 = eng.newObject();
+obj2.setProperty("name", "Sam");
+
+qScriptConnect(edit1, SIGNAL(returnPressed()), obj1, handler);
+qScriptConnect(edit2, SIGNAL(returnPressed()), obj2, handler);
+//! [48]
+
+//! [49]
+var getProperty = function(name) { return this[name]; };
+
+name = "Global Object"; // creates a global variable
+print(getProperty("name")); // "Global Object"
+
+var myObject = { name: 'My Object' };
+print(getProperty.call(myObject, "name")); // "My Object"
+
+myObject.getProperty = getProperty;
+print(myObject.getProperty("name")); // "My Object"
+
+getProperty.name = "The getProperty() function";
+getProperty.getProperty = getProperty;
+getProperty.getProperty("name"); // "The getProperty() function"
+//! [49]
+
+//! [50]
+var o = { a: 1, b: 2, sum: function() { return a + b; } };
+print(o.sum()); // reference error, or sum of global variables a and b!!
+//! [50]
+
+//! [51]
+var o = { a: 1, b: 2, sum: function() { return this.a + this.b; } };
+print(o.sum()); // 3
+//! [51]
+
+//! [52]
+QScriptValue getProperty(QScriptContext *ctx, QScriptEngine *eng)
+{
+ QString name = ctx->argument(0).toString();
+ return ctx->thisObject().property(name);
+}
+//! [52]
+
+//! [53]
+QScriptValue myCompare(QScriptContext *ctx, QScriptEngine *eng)
+{
+ double first = ctx->argument(0).toNumber();
+ double second = ctx->argument(1).toNumber();
+ int result;
+ if (first == second)
+ result = 0;
+ else if (first < second)
+ result = -1;
+ else
+ result = 1;
+ return result;
+}
+//! [53]
+
+//! [54]
+QScriptEngine eng;
+QScriptValue comparefn = eng.newFunction(myCompare);
+QScriptValue array = eng.evaluate("new Array(10, 5, 20, 15, 30)");
+array.property("sort").call(array, QScriptValueList() << comparefn);
+
+// prints "5,10,15,20,30"
+qDebug() << array.toString();
+//! [54]
+
+//! [55]
+QScriptValue rectifier(QScriptContext *ctx, QScriptEngine *eng)
+{
+ QRectF magicRect = qscriptvalue_cast<QRectF>(ctx->callee().data());
+ QRectF sourceRect = qscriptvalue_cast<QRectF>(ctx->argument(0));
+ return eng->toScriptValue(sourceRect.intersected(magicRect));
+}
+
+...
+
+QScriptValue fun = eng.newFunction(rectifier);
+QRectF magicRect = QRectF(10, 20, 30, 40);
+fun.setData(eng.toScriptValue(magicRect));
+eng.globalObject().setProperty("rectifier", fun);
+//! [55]
+
+//! [56]
+function add(a, b) {
+ return a + b;
+}
+//! [56]
+
+//! [57]
+function add() {
+ return arguments[0] + arguments[1];
+}
+//! [57]
+
+//! [58]
+QScriptValue add(QScriptContext *ctx, QScriptEngine *eng)
+{
+ double a = ctx->argument(0).toNumber();
+ double b = ctx->argument(1).toNumber();
+ return a + b;
+}
+//! [58]
+
+//! [59]
+function add() {
+ if (arguments.length != 2)
+ throw Error("add() takes exactly two arguments");
+ return arguments[0] + arguments[1];
+}
+//! [59]
+
+//! [60]
+function add() {
+ if (arguments.length != 2)
+ throw Error("add() takes exactly two arguments");
+ if (typeof arguments[0] != "number")
+ throw TypeError("add(): first argument is not a number");
+ if (typeof arguments[1] != "number")
+ throw TypeError("add(): second argument is not a number");
+ return arguments[0] + arguments[1];
+}
+//! [60]
+
+//! [61]
+function add() {
+ if (arguments.length != 2)
+ throw Error("add() takes exactly two arguments");
+ return Number(arguments[0]) + Number(arguments[1]);
+}
+//! [61]
+
+//! [62]
+QScriptValue add(QScriptContext *ctx, QScriptEngine *eng)
+{
+ if (ctx->argumentCount() != 2)
+ return ctx->throwError("add() takes exactly two arguments");
+ double a = ctx->argument(0).toNumber();
+ double b = ctx->argument(1).toNumber();
+ return a + b;
+}
+//! [62]
+
+//! [63]
+QScriptValue add(QScriptContext *ctx, QScriptEngine *eng)
+{
+ if (ctx->argumentCount() != 2)
+ return ctx->throwError("add() takes exactly two arguments");
+ if (!ctx->argument(0).isNumber())
+ return ctx->throwError(QScriptContext::TypeError, "add(): first argument is not a number");
+ if (!ctx->argument(1).isNumber())
+ return ctx->throwError(QScriptContext::TypeError, "add(): second argument is not a number");
+ double a = ctx->argument(0).toNumber();
+ double b = ctx->argument(1).toNumber();
+ return a + b;
+}
+//! [63]
+
+//! [64]
+function concat() {
+ var result = "";
+ for (var i = 0; i < arguments.length; ++i)
+ result += String(arguments[i]);
+ return result;
+}
+//! [64]
+
+//! [65]
+QScriptValue concat(QScriptContext *ctx, QScriptEngine *eng)
+{
+ QString result = "";
+ for (int i = 0; i < ctx->argumentCount(); ++i)
+ result += ctx->argument(i).toString();
+ return result;
+}
+//! [65]
+
+//! [66]
+function sort(comparefn) {
+ if (comparefn == undefined)
+ comparefn = /* the built-in comparison function */;
+ else if (typeof comparefn != "function")
+ throw TypeError("sort(): argument must be a function");
+ ...
+}
+//! [66]
+
+//! [67]
+QScriptValue sort(QScriptContext *ctx, QScriptEngine *eng)
+{
+ QScriptValue comparefn = ctx->argument(0);
+ if (comparefn.isUndefined())
+ comparefn = /* the built-in comparison function */;
+ else if (!comparefn.isFunction())
+ return ctx->throwError(QScriptContext::TypeError, "sort(): argument is not a function");
+ ...
+}
+//! [67]
+
+//! [68]
+function foo() {
+ // Let bar() take care of this.
+ print("calling bar() with " + arguments.length + "arguments");
+ var result = return bar.apply(this, arguments);
+ print("bar() returned" + result);
+ return result;
+}
+//! [68]
+
+//! [69]
+QScriptValue foo(QScriptContext *ctx, QScriptEngine *eng)
+{
+ QScriptValue bar = eng->globalObject().property("bar");
+ QScriptValue arguments = ctx->argumentsObject();
+ qDebug() << "calling bar() with" << arguments.property("length").toInt32() << "arguments";
+ QScriptValue result = bar.apply(ctx->thisObject(), arguments);
+ qDebug() << "bar() returned" << result.toString();
+ return result;
+}
+//! [69]
+
+//! [70]
+function counter() {
+ var count = 0;
+ return function() {
+ return count++;
+ }
+}
+//! [70]
+
+//! [71]
+var c1 = counter(); // create a new counter function
+var c2 = counter(); // create a new counter function
+print(c1()); // 0
+print(c1()); // 1
+print(c2()); // 0
+print(c2()); // 1
+//! [71]
+
+//! [72]
+QScriptValue counter(QScriptContext *ctx, QScriptEngine *eng)
+{
+ QScriptValue act = ctx->activationObject();
+ act.setProperty("count", 0);
+ QScriptValue result = eng->newFunction(counter_inner);
+ result.setScope(act);
+ return result;
+}
+//! [72]
+
+//! [73]
+QScriptValue counter_inner(QScriptContext *ctx, QScriptEngine *eng)
+{
+ QScriptValue outerAct = ctx->callee().scope();
+ double count = outerAct.property("count").toNumber();
+ outerAct.setProperty("count", count+1);
+ return count;
+}
+//! [73]
+
+//! [74]
+QScriptValue counter_hybrid(QScriptContext *ctx, QScriptEngine *eng)
+{
+ QScriptValue act = ctx->activationObject();
+ act.setProperty("count", 0);
+ return eng->evaluate("function() { return count++; }");
+}
+//! [74]
+
+//! [75]
+function Book(isbn) {
+ this.isbn = isbn;
+}
+
+var coolBook1 = new Book("978-0131872493");
+var coolBook2 = new Book("978-1593271473");
+//! [75]
+
+//! [76]
+QScriptValue Person_ctor(QScriptContext *ctx, QScriptEngine *eng)
+{
+ QScriptValue object;
+ if (ctx->isCalledAsConstructor()) {
+ object = ctx->thisObject();
+ } else {
+ object = eng->newObject();
+ object.setPrototype(ctx->callee().property("prototype"));
+ }
+ object.setProperty("name", ctx->argument(0));
+ return object;
+}
+//! [76]
+
+//! [77]
+QScriptContext *ctx = eng.pushContext();
+QScriptValue act = ctx->activationObject();
+act.setProperty("digit", 7);
+
+qDebug() << eng.evaluate("digit + 1").toNumber(); // 8
+
+eng.popContext();
+//! [77]
+
+//! [78]
+QScriptValue getSet(QScriptContext *ctx, QScriptEngine *eng)
+{
+ QScriptValue obj = ctx->thisObject();
+ QScriptValue data = obj.data();
+ if (!data.isValid()) {
+ data = eng->newObject();
+ obj.setData(data);
+ }
+ QScriptValue result;
+ if (ctx->argumentCount() == 1) {
+ QString str = ctx->argument(0).toString();
+ str.replace("Roberta", "Ken");
+ result = str;
+ data.setProperty("x", result);
+ } else {
+ result = data.property("x");
+ }
+ return result;
+}
+//! [78]
+
+//! [79]
+QScriptEngine eng;
+QScriptValue obj = eng.newObject();
+obj.setProperty("x", eng.newFunction(getSet),
+ QScriptValue::PropertyGetter|QScriptValue::PropertySetter);
+//! [79]
+
+//! [80]
+obj.x = "Roberta sent me";
+print(obj.x); // "Ken sent me"
+obj.x = "I sent the bill to Roberta";
+print(obj.x); // "I sent the bill to Ken"
+//! [80]
+
+//! [81]
+obj = {};
+obj.__defineGetter__("x", function() { return this._x; });
+obj.__defineSetter__("x", function(v) { print("setting x to", v); this._x = v; });
+obj.x = 123;
+//! [81]
+
+//! [82]
+myButton.text = qsTr("Hello world!");
+//! [82]
+
+//! [83]
+myButton.text = qsTranslate("MyAwesomeScript", "Hello world!");
+//! [83]
+
+//! [84]
+FriendlyConversation.prototype.greeting = function(type)
+{
+ if (FriendlyConversation['greeting_strings'] == undefined) {
+ FriendlyConversation['greeting_strings'] = [
+ QT_TR_NOOP("Hello"),
+ QT_TR_NOOP("Goodbye")
+ ];
+ }
+ return qsTr(FriendlyConversation.greeting_strings[type]);
+}
+//! [84]
+
+//! [85]
+FriendlyConversation.prototype.greeting = function(type)
+{
+ if (FriendlyConversation['greeting_strings'] == undefined) {
+ FriendlyConversation['greeting_strings'] = [
+ QT_TRANSLATE_NOOP("FriendlyConversation", "Hello"),
+ QT_TRANSLATE_NOOP("FriendlyConversation", "Goodbye")
+ ];
+ }
+ return qsTranslate("FriendlyConversation", FriendlyConversation.greeting_strings[type]);
+}
+//! [85]
+
+//! [86]
+FileCopier.prototype.showProgress = function(done, total, currentFileName)
+{
+ this.label.text = qsTr("%1 of %2 files copied.\nCopying: %3")
+ .arg(done)
+ .arg(total)
+ .arg(currentFileName));
+}
+//! [86]
+
+//! [87]
+lupdate myscript.qs -ts myscript_la.ts
+//! [87]
+
+//! [88]
+lupdate -extensions qs scripts/ -ts scripts_la.ts
+//! [88]
+
+//! [89]
+lrelease myscript_la.ts
+//! [89]
+
+//! [90]
+({ unitName: "Celsius",
+ toKelvin: function(x) { return x + 273; }
+ })
+//! [90]
+
+//! [91]
+QScriptValue object = engine.evaluate("({ unitName: 'Celsius', toKelvin: function(x) { return x + 273; } })");
+QScriptValue toKelvin = object.property("toKelvin");
+QScriptValue result = toKelvin.call(object, QScriptValueList() << 100);
+qDebug() << result.toNumber(); // 373
+//! [91]
+
+//! [92]
+QScriptValue add = engine.globalObject().property("add");
+qDebug() << add.call(QScriptValue(), QScriptValueList() << 1 << 2).toNumber(); // 3
+//! [92]
+
+//! [93]
+typedef QSharedPointer<QXmlStreamReader> XmlStreamReaderPointer;
+
+Q_DECLARE_METATYPE(XmlStreamReaderPointer)
+
+QScriptValue constructXmlStreamReader(QScriptContext *context, QScriptEngine *engine)
+{
+ if (!context->isCalledAsConstructor())
+ return context->throwError(QScriptContext::SyntaxError, "please use the 'new' operator");
+
+ QIODevice *device = qobject_cast<QIODevice*>(context->argument(0).toQObject());
+ if (!device)
+ return context->throwError(QScriptContext::TypeError, "please supply a QIODevice as first argument");
+
+ // Create the C++ object
+ QXmlStreamReader *reader = new QXmlStreamReader(device);
+
+ XmlStreamReaderPointer pointer(reader);
+
+ // store the shared pointer in the script object that we are constructing
+ return engine->newVariant(context->thisObject(), qVariantFromValue(pointer));
+}
+//! [93]
+
+//! [94]
+QScriptValue xmlStreamReader_atEnd(QScriptContext *context, QScriptEngine *)
+{
+ XmlStreamReaderPointer reader = qscriptvalue_cast<XmlStreamReaderPointer>(context->thisObject());
+ if (!reader)
+ return context->throwError(QScriptContext::TypeError, "this object is not an XmlStreamReader");
+ return reader->atEnd();
+}
+//! [94]
+
+//! [95]
+ QScriptEngine engine;
+ QScriptValue xmlStreamReaderProto = engine.newObject();
+ xmlStreamReaderProto.setProperty("atEnd", engine.newFunction(xmlStreamReader_atEnd));
+
+ QScriptValue xmlStreamReaderCtor = engine.newFunction(constructXmlStreamReader, xmlStreamReaderProto);
+ engine.globalObject().setProperty("XmlStreamReader", xmlStreamReaderCtor);
+//! [95]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qtscriptextensions.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qtscriptextensions.qdoc
new file mode 100644
index 000000000..24fb25481
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qtscriptextensions.qdoc
@@ -0,0 +1,7 @@
+//! [0]
+print("importing " + __extension__);
+__setupPackage__("cool.stuff");
+
+cool.stuff.add = function(a, b) { return a + b; }
+cool.stuff.subtract = function(a, b) { return a - b; }
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qtsql.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qtsql.qdoc
new file mode 100644
index 000000000..1a687dbf7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qtsql.qdoc
@@ -0,0 +1,8 @@
+//! [0]
+#include <QtSql>
+//! [0]
+
+
+//! [1]
+QT += sql
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qtsvg.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qtsvg.qdoc
new file mode 100644
index 000000000..c99ea4137
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qtsvg.qdoc
@@ -0,0 +1,8 @@
+//! [0]
+#include <QtSvg>
+//! [0]
+
+
+//! [1]
+QT += svg
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qttest.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qttest.qdoc
new file mode 100644
index 000000000..c2aa27bf6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qttest.qdoc
@@ -0,0 +1,8 @@
+//! [0]
+#include <QtTest>
+//! [0]
+
+
+//! [1]
+CONFIG += qtestlib
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qtuiloader.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qtuiloader.qdoc
new file mode 100644
index 000000000..64f3eac32
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qtuiloader.qdoc
@@ -0,0 +1,8 @@
+//! [0]
+CONFIG += uitools
+//! [0]
+
+
+//! [1]
+#include <QtUiTools>
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qtxml.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qtxml.qdoc
new file mode 100644
index 000000000..f5dc5a533
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qtxml.qdoc
@@ -0,0 +1,77 @@
+//! [0]
+#include <QtXml>
+//! [0]
+
+
+//! [1]
+QT += xml
+//! [1]
+
+
+//! [2]
+QT += xml
+//! [2]
+
+
+//! [3]
+<quote>A quotation.</quote>
+//! [3]
+
+
+//! [4]
+<document xmlns:book = 'http://qtsoftware.com/fnord/book/'
+ xmlns = 'http://qtsoftware.com/fnord/' >
+//! [4]
+
+
+//! [5]
+<author xmlns:fnord = 'http://qtsoftware.com/fnord/'
+ title="Ms"
+ fnord:title="Goddess"
+ name="Eris Kallisti"/>
+//! [5]
+
+
+//! [6]
+<document>
+<book>
+ <title>Practical XML</title>
+ <author title="Ms" name="Eris Kallisti"/>
+ <chapter>
+ <title>A Namespace Called fnord</title>
+ </chapter>
+</book>
+</document>
+//! [6]
+
+
+//! [7]
+<book:title>Practical XML</book:title>
+//! [7]
+
+
+//! [8]
+xmlns="http://qtsoftware.com/fnord/"
+//! [8]
+
+
+//! [9]
+xmlns:book="http://qtsoftware.com/fnord/book/"
+//! [9]
+
+
+//! [10]
+<document xmlns:book = 'http://qtsoftware.com/fnord/book/'
+ xmlns = 'http://qtsoftware.com/fnord/' >
+<book>
+ <book:title>Practical XML</book:title>
+ <book:author xmlns:fnord = 'http://qtsoftware.com/fnord/'
+ title="Ms"
+ fnord:title="Goddess"
+ name="Eris Kallisti"/>
+ <chapter>
+ <title>A Namespace Called fnord</title>
+ </chapter>
+</book>
+</document>
+//! [10]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qtxmlpatterns.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qtxmlpatterns.qdoc
new file mode 100644
index 000000000..638bf93bf
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qtxmlpatterns.qdoc
@@ -0,0 +1,349 @@
+
+void wrapInFunction()
+{
+
+//! [0]
+#include <QtXmlPatterns>
+//! [0]
+
+
+//! [1]
+QT += xmlpatterns
+//! [1]
+
+//! [2]
+xmlpatterns myQuery.xq
+//! [2]
+
+//! [3]
+declare namespace c = "http://cookbook/namespace";
+doc('cookbook.xml')//c:recipe/c:title
+//! [3]
+
+//! [4]
+declare default element namespace "http://cookbook/namespace";
+doc('cookbook.xml')//recipe/title
+//! [4]
+
+//! [5]
+<title xmlns="http://cookbook/namespace">Quick and Easy Mushroom Soup</title>
+<title xmlns="http://cookbook/namespace">Cheese on Toast</title>
+<title xmlns="http://cookbook/namespace">Hard-Boiled Eggs</title>
+//! [5]
+
+//! [6]
+xmlpatterns file.xq
+//! [6]
+
+//! [7]
+doc('cookbook.xml')//@xml:*
+//! [7]
+
+//! [8]
+doc('cookbook.xml')//@*:name
+//! [8]
+
+//! [9]
+declare default element namespace "http://cookbook/namespace";
+doc('cookbook.xml')/cookbook/@*
+//! [9]
+
+//! [10]
+declare default element namespace "http://cookbook/namespace";
+doc("cookbook.xml")/cookbook/recipe[title = "Hard-Boiled Eggs"]
+//! [10]
+
+//! [11]
+declare default element namespace "http://cookbook/namespace";
+doc('cookbook.xml')//method[string-length(.) = 0]
+//! [11]
+
+//! [12]
+declare default element namespace "http://cookbook/namespace";
+doc('cookbook.xml')//method[string-length() = 0]
+//! [12]
+
+//! [13]
+declare default element namespace "http://cookbook/namespace";
+doc('cookbook.xml')/cookbook/recipe[2]
+//! [13]
+
+//! [14]
+declare default element namespace "http://cookbook/namespace";
+doc('cookbook.xml')/cookbook/recipe[position() = 2]
+//! [14]
+
+//! [15]
+declare default element namespace "http://cookbook/namespace";
+doc('cookbook.xml')/cookbook/recipe[position() > 1]
+//! [15]
+
+//! [16]
+declare default element namespace "http://cookbook/namespace";
+doc('cookbook.xml')/cookbook/recipe[last()]
+//! [16]
+
+//! [17]
+declare default element namespace "http://cookbook/namespace";
+doc('cookbook.xml')/cookbook/recipe[last() - 1]
+//! [17]
+
+//! [18]
+doc('cookbook.xml')//recipe
+//! [18]
+
+//! [19]
+doc('cookbook.xml')//recipe/title
+//! [19]
+
+//! [20]
+<recipe/>
+//! [20]
+
+//! [21]
+ <html xmlns="http://www.w3.org/1999/xhtml/"
+ xml:id="{doc("other.html")/html/@xml:id}"/>
+//! [21]
+
+//! [22]
+doc('cookbook.xml')/descendant-or-self::element(recipe)/child::element(title)
+//! [22]
+
+//! [23]
+<cookbook>
+//! [23]
+
+//! [24]
+<cookbook xmlns="http://cookbook/namespace">
+//! [24]
+
+//! [25]
+for $i in doc("cookbook.xml")//@xml:*
+return <p>{$i}</p>
+//! [25]
+
+//! [26]
+for $i in doc("cookbook.xml")//@*:name
+return <p>{$i}</p>
+//! [26]
+
+//! [27]
+declare default element namespace "http://cookbook/namespace";
+for $i in doc("cookbook.xml")/cookbook/@*
+return <p>{$i}</p>
+//! [27]
+
+//! [28]
+<p xml:id="MushroomSoup"/>
+<p xml:id="CheeseOnToast"/>
+<p xml:id="HardBoiledEggs"/>
+//! [28]
+
+//! [29]
+<p name="Fresh mushrooms"/>
+<p name="Garlic"/>
+<p name="Olive oil"/>
+<p name="Milk"/>
+<p name="Water"/>
+<p name="Cream"/>
+<p name="Vegetable soup cube"/>
+<p name="Ground black pepper"/>
+<p name="Dried parsley"/>
+<p name="Bread"/>
+<p name="Cheese"/>
+<p name="Eggs"/>
+//! [29]
+
+//! [30]
+<p xmlns="http://cookbook/namespace" count="3"/>
+//! [30]
+
+//! [31]
+<method xmlns="http://cookbook/namespace"/>
+//! [31]
+
+//! [32]
+declare default element namespace "http://cookbook/namespace";
+doc('cookbook.xml')//recipe[string-length(method) = 0]
+//! [32]
+
+//! [33]
+<recipe xmlns="http://cookbook/namespace" xml:id="HardBoiledEggs">
+ <title>Hard-Boiled Eggs</title>
+ <ingredient name="Eggs" quantity="3" unit="eggs"/>
+ <time quantity="3" unit="minutes"/>
+ <method/>
+</recipe>
+//! [33]
+
+//! [34]
+declare default element namespace "http://cookbook/namespace";
+doc('cookbook.xml')/cookbook/recipe[method[empty(step)]]
+//! [34]
+
+//! [35]
+declare default element namespace "http://cookbook/namespace";
+doc('cookbook.xml')/cookbook/recipe[not(normalize-space(method))]
+//! [35]
+
+//! [36]
+<e>{sum((1, 2, 3))}</e>
+//! [36]
+
+//! [37]
+<e>6</e>
+//! [37]
+
+//![38]
+declare variable $insertion := "example";
+<p class="important {$insertion} obsolete"/>
+//![38]
+
+//! [39]
+<p class="important example obsolete"/>
+//! [39]
+
+//! [40]
+declare default element namespace "http://cookbook/namespace";
+let $docURI := 'cookbook.xml'
+return if(doc-available($docURI))
+ then doc($docURI)//recipe/<resept>{./node()}</resept>
+ else <resept>Failed to load {$docURI}</resept>
+//! [40]
+
+//! [41]
+<span>1</span>
+<span>3</span>
+<span>5</span>
+<span>7</span>
+<span>9</span>
+<span>b</span>
+<span>d</span>
+<span>f</span>
+//! [41]
+
+//! [42]
+<span>1</span>
+//! [42]
+
+//! [43]
+let $doc := doc('doc.txt')
+return $doc/doc/p[1]/span[1]
+//! [43]
+
+//! [44]
+for $a in doc('doc.txt')/doc/p/span[1]
+return $a
+//! [44]
+
+//! [45]
+doc('doc.txt')/doc/p/span[1]
+//! [45]
+
+//! [46]
+doc('doc.txt')//p/<p>{span/node()}</p>
+//! [46]
+
+//! [47]
+<p>78</p>
+<p>9a</p>
+<p>12</p>
+<p>bc</p>
+<p>de</p>
+<p>34</p>
+<p>56</p>
+<p>f0</p>
+//! [47]
+
+//! [48]
+for $a in doc('doc.txt')//p
+ return <p>{$a/span/node()}</p>
+//! [48]
+
+//! [49]
+<p>12</p>
+<p>34</p>
+<p>56</p>
+<p>78</p>
+<p>9a</p>
+<p>bc</p>
+<p>de</p>
+<p>f0</p>
+//! [49]
+
+//! [100]
+<?xml version="1.0" encoding="UTF-8"?>
+<cookbook>
+ <recipe xml:id="MushroomSoup">
+ <title>Quick and Easy Mushroom Soup</title>
+ <ingredient name="Fresh mushrooms"
+ quantity="7"
+ unit="pieces"/>
+ <ingredient name="Garlic"
+ quantity="1"
+ unit="cloves"/>
+ <ingredient name="Olive oil"
+ quantity="2"
+ unit="tablespoons"/>
+ <ingredient name="Milk"
+ quantity="200"
+ unit="milliliters"/>
+ <ingredient name="Water"
+ quantity="200"
+ unit="milliliters"/>
+ <ingredient name="Cream"
+ quantity="100"
+ unit="milliliters"/>
+ <ingredient name="Vegetable soup cube"
+ quantity="1/2"
+ unit="cubes"/>
+ <ingredient name="Ground black pepper"
+ quantity="1/2"
+ unit="teaspoons"/>
+ <ingredient name="Dried parsley"
+ quantity="1"
+ unit="teaspoons"/>
+ <time quantity="20"
+ unit="minutes"/>
+ <method>
+ <step>1. Slice mushrooms and garlic.</step>
+ <step>2. Fry mushroom slices and garlic with olive oil.</step>
+ <step>3. Once mushrooms are cooked, add milk, cream water. Stir.</step>
+ <step>4. Add vegetable soup cube.</step>
+ <step>5. Reduce heat, add pepper and parsley.</step>
+ <step>6. Turn off the stove before the mixture boils.</step>
+ <step>7. Blend the mixture.</step>
+ </method>
+ </recipe>
+ <recipe xml:id="CheeseOnToast">
+ <title>Cheese on Toast</title>
+ <ingredient name="Bread"
+ quantity="2"
+ unit="slices"/>
+ <ingredient name="Cheese"
+ quantity="2"
+ unit="slices"/>
+ <time quantity="3"
+ unit="minutes"/>
+ <method>
+ <step>1. Slice the bread and cheese.</step>
+ <step>2. Grill one side of each slice of bread.</step>
+ <step>3. Turn over the bread and place a slice of cheese on each piece.</step>
+ <step>4. Grill until the cheese has started to melt.</step>
+ <step>5. Serve and enjoy!</step>
+ </method>
+ </recipe>
+ <recipe xml:id="HardBoiledEggs">
+ <title>Hard-Boiled Eggs</title>
+ <ingredient name="Eggs"
+ quantity="3"
+ unit="eggs"/>
+ <time quantity="3"
+ unit="minutes"/>
+ <method/>
+ </recipe>
+</cookbook>
+//! [100]
+
+}
+
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_qvarlengtharray.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_qvarlengtharray.qdoc
new file mode 100644
index 000000000..95db9d349
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_qvarlengtharray.qdoc
@@ -0,0 +1,38 @@
+//! [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/codesnippets/doc/src/snippets/code/doc_src_rcc.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_rcc.qdoc
new file mode 100644
index 000000000..423f8e622
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_rcc.qdoc
@@ -0,0 +1,3 @@
+//! [0]
+rcc [options] <inputs>
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_resources.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_resources.qdoc
new file mode 100644
index 000000000..bc85341b1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_resources.qdoc
@@ -0,0 +1,41 @@
+//! [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]
+
+
+//! [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/codesnippets/doc/src/snippets/code/doc_src_richtext.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_richtext.qdoc
new file mode 100644
index 000000000..d6f54c29c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_richtext.qdoc
@@ -0,0 +1,50 @@
+//! [0]
+QTextDocument *newDocument = new QTextDocument;
+//! [0]
+
+
+//! [1]
+QTextEdit *editor = new QTextEdit;
+QTextDocument *editorDocument = editor->document();
+//! [1]
+
+
+//! [2]
+QTextEdit *editor = new QTextEdit(parent);
+editor->setHtml(aStringContainingHTMLtext);
+editor->show();
+//! [2]
+
+
+//! [3]
+QTextDocument *document = editor->document();
+//! [3]
+
+
+//! [4]
+QTextCursor cursor = editor->textCursor();
+//! [4]
+
+
+//! [5]
+editor->setTextCursor(cursor);
+//! [5]
+
+
+//! [6]
+textEdit.show();
+
+textCursor.beginEditBlock();
+
+for (int i = 0; i < 1000; ++i) {
+ textCursor.insertBlock();
+ textCursor.insertText(paragraphText.at(i));
+}
+
+textCursor.endEditBlock();
+//! [6]
+
+
+//! [7]
+<meta http-equiv="Content-Type" content="text/html; charset=EUC-JP" />
+//! [7]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_session.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_session.qdoc
new file mode 100644
index 000000000..6a3286313
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_session.qdoc
@@ -0,0 +1,3 @@
+//! [0]
+xterm
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_sql-driver.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_sql-driver.qdoc
new file mode 100644
index 000000000..74cd8dc45
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_sql-driver.qdoc
@@ -0,0 +1,239 @@
+//! [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]
+
+
+//! [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]
+
+
+//! [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" 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]
+
+
+//! [10]
+\\ STORED_PROC uses the return statement or returns multiple result sets
+QSqlQuery query;
+query.setForwardOnly(true);
+query.exec("{call STORED_PROC}");
+//! [10]
+
+
+//! [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]
+
+
+//! [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]
+
+
+//! [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]
+
+
+//! [31]
+QSqlDatabase: QMYSQL driver not loaded
+QSqlDatabase: available drivers: QMYSQL
+//! [31]
+
+//! [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/codesnippets/doc/src/snippets/code/doc_src_styles.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_styles.qdoc
new file mode 100644
index 000000000..e11dc0523
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_styles.qdoc
@@ -0,0 +1,94 @@
+//! [0]
+ opt.init(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/codesnippets/doc/src/snippets/code/doc_src_stylesheet.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_stylesheet.qdoc
new file mode 100644
index 000000000..60622d322
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_stylesheet.qdoc
@@ -0,0 +1,1911 @@
+//! [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]
+
+
+//! [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->setSytleSheet("ns--MyPushButton { background: yellow; }");
+//! [27]
+
+
+//! [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]
+
+
+//! [32]
+void CustomWidget::paintEvent(QPaintEvent *)
+{
+ QStyleOption opt;
+ opt.init(this);
+ QPainter p(this);
+ style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
+}
+//! [32]
+
+
+//! [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) }
+
+QTextEdit { image: url(x1.png) url(x2.png) }
+QTextEdit { image: url(pic1.svg) }
+//! [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]
+
+
+//! [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]
+
+
+//! [94]
+*[mandatoryField="true"] { background-color: yellow }
+//! [94]
+
+
+//! [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]
+
+
+//! [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;
+}
+
+/* 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;
+}
+//! [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]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_uic.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_uic.qdoc
new file mode 100644
index 000000000..310e839c8
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_uic.qdoc
@@ -0,0 +1,15 @@
+//! [0]
+uic [options] <uifile>
+//! [0]
+
+
+//! [1]
+ui_%.h: %.ui
+ uic $< -o $@
+//! [1]
+
+
+//! [2]
+ui_foo.h: foo.ui
+ uic $< -o $@
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_unicode.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_unicode.qdoc
new file mode 100644
index 000000000..30a37108d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_unicode.qdoc
@@ -0,0 +1,18 @@
+//! [0]
+label->setText("Password:");
+//! [0]
+
+
+//! [1]
+label->setText(tr("Password:"));
+//! [1]
+
+
+//! [2]
+QFile file(QString::fromLatin1("appicon.png"));
+//! [2]
+
+
+//! [3]
+QFile file(QLatin1String("appicon.png"));
+//! [3]
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_unix-signal-handlers.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_unix-signal-handlers.qdoc
new file mode 100644
index 000000000..8abcba69a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/doc_src_unix-signal-handlers.qdoc
@@ -0,0 +1,110 @@
+//! [0]
+class MyDaemon : public QObject
+{
+ Q_OBJECT
+
+ public:
+ MyDaemon(QObject *parent = 0, const char *name = 0);
+ ~MyDaemon();
+
+ // Unix signal handlers.
+ static void hupSignalHandler(int unused);
+ static void termSignalHandler(int unused);
+
+ public slots:
+ // Qt signal handlers.
+ void handleSigHup();
+ void handleSigTerm();
+
+ private:
+ static int sighupFd[2];
+ static int sigtermFd[2];
+
+ QSocketNotifier *snHup;
+ QSocketNotifier *snTerm;
+};
+//! [0]
+
+
+//! [1]
+MyDaemon::MyDaemon(QObject *parent, const char *name)
+ : QObject(parent,name)
+{
+ if (::socketpair(AF_UNIX, SOCK_STREAM, 0, sighupFd))
+ qFatal("Couldn't create HUP socketpair");
+
+ if (::socketpair(AF_UNIX, SOCK_STREAM, 0, sigtermFd))
+ qFatal("Couldn't create TERM socketpair");
+ snHup = new QSocketNotifier(sighupFd[1], QSocketNotifier::Read, this);
+ connect(snHup, SIGNAL(activated(int)), this, SLOT(handleSigHup()));
+ snTerm = new QSocketNotifier(sigtermFd[1], QSocketNotifier::Read, this);
+ connect(snTerm, SIGNAL(activated(int)), this, SLOT(handleSigTerm()));
+
+ ...
+}
+//! [1]
+
+
+//! [2]
+static int setup_unix_signal_handlers()
+{
+ struct sigaction hup, term;
+
+ hup.sa_handler = MyDaemon::hupSignalHandler;
+ sigemptyset(&hup.sa_mask);
+ hup.sa_flags = 0;
+ hup.sa_flags |= SA_RESTART;
+
+ if (sigaction(SIGHUP, &hup, 0) > 0)
+ return 1;
+
+ term.sa_handler = MyDaemon::termSignalHandler;
+ sigemptyset(&term.sa_mask);
+ term.sa_flags |= SA_RESTART;
+
+ if (sigaction(SIGTERM, &term, 0) > 0)
+ return 2;
+
+ return 0;
+}
+//! [2]
+
+
+//! [3]
+void MyDaemon::hupSignalHandler(int)
+{
+ char a = 1;
+ ::write(sighupFd[0], &a, sizeof(a));
+}
+
+void MyDaemon::termSignalHandler(int)
+{
+ char a = 1;
+ ::write(sigtermFd[0], &a, sizeof(a));
+}
+//! [3]
+
+
+//! [4]
+void MyDaemon::handleSigTerm()
+{
+ snTerm->setEnabled(false);
+ char tmp;
+ ::read(sigtermFd[1], &tmp, sizeof(tmp));
+
+ // do Qt stuff
+
+ snTerm->setEnabled(true);
+}
+
+void MyDaemon::handleSigHup()
+{
+ snHup->setEnabled(false);
+ char tmp;
+ ::read(sighupFd[1], &tmp, sizeof(tmp));
+
+ // do Qt stuff
+
+ snHup->setEnabled(true);
+}
+//! [4]
diff --git a/doc/codesnippets/doc/src/snippets/code/src.gui.text.qtextdocumentwriter.cpp b/doc/codesnippets/doc/src/snippets/code/src.gui.text.qtextdocumentwriter.cpp
new file mode 100644
index 000000000..aa6e51bed
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src.gui.text.qtextdocumentwriter.cpp
@@ -0,0 +1,5 @@
+//! [0]
+ writer = QTextDocumentWriter()
+ writer.setFormat("odf") # same as writer.setFormat("ODF");
+//! [0]
+
diff --git a/doc/codesnippets/doc/src/snippets/code/src.qdbus.qdbuspendingcall.cpp b/doc/codesnippets/doc/src/snippets/code/src.qdbus.qdbuspendingcall.cpp
new file mode 100644
index 000000000..c9b3b7c98
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src.qdbus.qdbuspendingcall.cpp
@@ -0,0 +1,24 @@
+{
+//! [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);
+ }
+}
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src.qdbus.qdbuspendingreply.cpp b/doc/codesnippets/doc/src/snippets/code/src.qdbus.qdbuspendingreply.cpp
new file mode 100644
index 000000000..49363a813
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src.qdbus.qdbuspendingreply.cpp
@@ -0,0 +1,23 @@
+{
+//! [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/codesnippets/doc/src/snippets/code/src.scripttools.qscriptenginedebugger.cpp b/doc/codesnippets/doc/src/snippets/code/src.scripttools.qscriptenginedebugger.cpp
new file mode 100644
index 000000000..44849c9aa
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src.scripttools.qscriptenginedebugger.cpp
@@ -0,0 +1,9 @@
+//! [0]
+ engine = QScriptEngine()
+ debugger = QScriptEngineDebugger()
+ debugger.attachTo(engine)
+//! [0]
+
+//! [1]
+ engine.evaluate("debugger")
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_activeqt_container_qaxbase.cpp b/doc/codesnippets/doc/src/snippets/code/src_activeqt_container_qaxbase.cpp
new file mode 100644
index 000000000..94b0da83f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_activeqt_container_qaxbase.cpp
@@ -0,0 +1,159 @@
+//! [0]
+connect(buttonBack, SIGNAL(clicked()), webBrowser, SLOT(GoBack()));
+//! [0]
+
+
+//! [1]
+activeX->setProperty("text", "some text");
+int value = activeX->property("value");
+//! [1]
+
+
+//! [2]
+webBrowser->dynamicCall("GoHome()");
+//! [2]
+
+
+//! [3]
+connect(webBrowser, SIGNAL(TitleChanged(QString)),
+ this, SLOT(setCaption(QString)));
+//! [3]
+
+
+//! [4]
+dispinterface IControl
+{
+properties:
+ [id(1)] BSTR text;
+ [id(2)] IFontDisp *font;
+
+methods:
+ [id(6)] void showColumn([in] int i);
+ [id(3)] bool addColumn([in] BSTR t);
+ [id(4)] int fillList([in, out] SAFEARRAY(VARIANT) *list);
+ [id(5)] IDispatch *item([in] int i);
+};
+//! [4]
+
+
+//! [5]
+QAxObject object("<CLSID>");
+
+QString text = object.property("text").toString();
+object.setProperty("font", QFont("Times New Roman", 12));
+
+connect(this, SIGNAL(clicked(int)), &object, SLOT(showColumn(int)));
+bool ok = object.dynamicCall("addColumn(const QString&)", "Column 1").toBool();
+
+QList<QVariant> varlist;
+QList<QVariant> parameters;
+parameters << QVariant(varlist);
+int n = object.dynamicCall("fillList(QList<QVariant>&)", parameters).toInt();
+
+QAxObject *item = object.querySubItem("item(int)", 5);
+//! [5]
+
+
+//! [6]
+IUnknown *iface = 0;
+activeX->queryInterface(IID_IUnknown, (void**)&iface);
+if (iface) {
+ // use the interface
+ iface->Release();
+}
+//! [6]
+
+
+//! [7]
+ctrl->setControl("{8E27C92B-1264-101C-8A2F-040224009C02}");
+//! [7]
+
+
+//! [8]
+ctrl->setControl("MSCal.Calendar");
+//! [8]
+
+
+//! [9]
+ctrl->setControl("Calendar Control 9.0");
+//! [9]
+
+
+//! [10]
+ctrl->setControl("c:/files/file.doc");
+//! [10]
+
+
+//! [11]
+<domain/username>:<password>@server/{8E27C92B-1264-101C-8A2F-040224009C02}
+//! [11]
+
+
+//! [12]
+{8E27C92B-1264-101C-8A2F-040224009C02}:<LicenseKey>
+//! [12]
+
+
+//! [13]
+{8E27C92B-1264-101C-8A2F-040224009C02}&
+//! [13]
+
+
+//! [14]
+ctrl->setControl("DOMAIN/user:password@server/{8E27C92B-1264-101C-8A2F-040224009C02}:LicenseKey");
+//! [14]
+
+
+//! [15]
+activeX->dynamicCall("Navigate(const QString&)", "qtsoftware.com");
+//! [15]
+
+
+//! [16]
+activeX->dynamicCall("Navigate(\"qtsoftware.com\")");
+//! [16]
+
+
+//! [17]
+activeX->dynamicCall("Value", 5);
+QString text = activeX->dynamicCall("Text").toString();
+//! [17]
+
+
+//! [18]
+IWebBrowser2 *webBrowser = 0;
+activeX->queryInterface(IID_IWebBrowser2, (void **)&webBrowser);
+if (webBrowser) {
+ webBrowser->Navigate2(pvarURL);
+ webBrowser->Release();
+}
+//! [18]
+
+
+//! [19]
+QAxWidget outlook("Outlook.Application");
+QAxObject *session = outlook.querySubObject("Session");
+if (session) {
+ QAxObject *defFolder = session->querySubObject(
+ "GetDefaultFolder(OlDefaultFolders)",
+ "olFolderContacts");
+ //...
+}
+//! [19]
+
+
+//! [20]
+void Receiver::slot(const QString &name, int argc, void *argv)
+{
+ VARIANTARG *params = (VARIANTARG*)argv;
+ if (name.startsWith("BeforeNavigate2(")) {
+ IDispatch *pDisp = params[argc-1].pdispVal;
+ VARIANTARG URL = *params[argc-2].pvarVal;
+ VARIANTARG Flags = *params[argc-3].pvarVal;
+ VARIANTARG TargetFrameName = *params[argc-4].pvarVal;
+ VARIANTARG PostData = *params[argc-5].pvarVal;
+ VARIANTARG Headers = *params[argc-6].pvarVal;
+ bool *Cancel = params[argc-7].pboolVal;
+ }
+}
+//! [20]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_activeqt_container_qaxscript.cpp b/doc/codesnippets/doc/src/snippets/code/src_activeqt_container_qaxscript.cpp
new file mode 100644
index 000000000..07fca1ec7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_activeqt_container_qaxscript.cpp
@@ -0,0 +1,18 @@
+//! [0]
+function setNumber(number)
+{
+ n = number;
+}
+//! [0]
+
+
+//! [1]
+QValueList args;
+args << 5;
+script->call("setNumber(const QVariant&)", args);
+//! [1]
+
+
+//! [2]
+script->call("setNumber(5)");
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_activeqt_control_qaxbindable.cpp b/doc/codesnippets/doc/src/snippets/code/src_activeqt_control_qaxbindable.cpp
new file mode 100644
index 000000000..c296789b6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_activeqt_control_qaxbindable.cpp
@@ -0,0 +1,60 @@
+//! [0]
+class MyActiveX : public QWidget, public QAxBindable
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue)
+
+public:
+ MyActiveX(QWidget *parent = 0);
+ ...
+
+ int value() const;
+ void setValue(int);
+};
+//! [0]
+
+
+//! [1]
+void MyActiveQt::setText(const QString &text)
+{
+ if (!requestPropertyChange("text"))
+ return;
+
+ // update property
+
+ propertyChanged("text");
+}
+//! [1]
+
+
+//! [2]
+long AxImpl::queryInterface(const QUuid &iid, void **iface)
+{
+ *iface = 0;
+ if (iid == IID_ISomeCOMInterface)
+ *iface = (ISomeCOMInterface*)this;
+ else
+ return E_NOINTERFACE;
+
+ AddRef();
+ return S_OK;
+}
+//! [2]
+
+
+//! [3]
+HRESULT AxImpl::QueryInterface(REFIID iid, void **iface)
+{
+ return controllingUnknown()->QueryInterface(iid, iface);
+}
+
+ulong AxImpl::AddRef()
+{
+ return controllingUnknown()->AddRef();
+}
+
+ulong AxImpl::Release()
+{
+ return controllingUnknown()->Release();
+}
+//! [3]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_activeqt_control_qaxfactory.cpp b/doc/codesnippets/doc/src/snippets/code/src_activeqt_control_qaxfactory.cpp
new file mode 100644
index 000000000..6eca43402
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_activeqt_control_qaxfactory.cpp
@@ -0,0 +1,155 @@
+//! [0]
+QStringList ActiveQtFactory::featureList() const
+{
+ QStringList list;
+ list << "ActiveX1";
+ list << "ActiveX2";
+ return list;
+}
+
+QObject *ActiveQtFactory::createObject(const QString &key)
+{
+ if (key == "ActiveX1")
+ return new ActiveX1(parent);
+ if (key == "ActiveX2")
+ return new ActiveX2(parent);
+ return 0;
+}
+
+const QMetaObject *ActiveQtFactory::metaObject(const QString &key) const
+{
+ if (key == "ActiveX1")
+ return &ActiveX1::staticMetaObject;
+ if (key == "ActiveX2")
+ return &ActiveX2::staticMetaObject;
+}
+
+QUuid ActiveQtFactory::classID(const QString &key) const
+{
+ if (key == "ActiveX1")
+ return "{01234567-89AB-CDEF-0123-456789ABCDEF}";
+ ...
+ return QUuid();
+}
+
+QUuid ActiveQtFactory::interfaceID(const QString &key) const
+{
+ if (key == "ActiveX1")
+ return "{01234567-89AB-CDEF-0123-456789ABCDEF}";
+ ...
+ return QUuid();
+}
+
+QUuid ActiveQtFactory::eventsID(const QString &key) const
+{
+ if (key == "ActiveX1")
+ return "{01234567-89AB-CDEF-0123-456789ABCDEF}";
+ ...
+ return QUuid();
+}
+
+QAXFACTORY_EXPORT(
+ ActiveQtFactory, // factory class
+ "{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID
+ "{01234567-89AB-CDEF-0123-456789ABCDEF}" // application ID
+)
+//! [0]
+
+
+//! [1]
+QAXFACTORY_BEGIN(
+ "{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID
+ "{01234567-89AB-CDEF-0123-456789ABCDEF}" // application ID
+)
+ QAXCLASS(Class1)
+ QAXCLASS(Class2)
+QAXFACTORY_END()
+//! [1]
+
+
+//! [2]
+#include <qapplication.h>
+#include <qaxfactory.h>
+
+#include "theactivex.h"
+
+QAXFACTORY_DEFAULT(
+ TheActiveX, // widget class
+ "{01234567-89AB-CDEF-0123-456789ABCDEF}", // class ID
+ "{01234567-89AB-CDEF-0123-456789ABCDEF}", // interface ID
+ "{01234567-89AB-CDEF-0123-456789ABCDEF}", // event interface ID
+ "{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID
+ "{01234567-89AB-CDEF-0123-456789ABCDEF}" // application ID
+)
+//! [2]
+
+
+//! [3]
+settings->setValue("/CLSID/" + classID(key)
+ + "/Implemented Categories/"
+ + "/{00000000-0000-0000-000000000000}/.",
+ QString());
+//! [3]
+
+
+//! [4]
+settings->remove("/CLSID/" + classID(key)
+ + "/Implemented Categories"
+ + "/{00000000-0000-0000-000000000000}/.");
+//! [4]
+
+
+//! [5]
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ if (!QAxFactory::isServer()) {
+ // initialize for stand-alone execution
+ }
+ return app.exec();
+}
+//! [5]
+
+
+//! [6]
+if (QAxFactory::isServer()) {
+ QAxFactory::stopServer();
+ QAxFactory::startServer(QAxFactory::SingleInstance);
+}
+//! [6]
+
+
+//! [7]
+#include <qaxfactory.h>
+
+#include "theactivex.h"
+
+QAXFACTORY_DEFAULT(
+ TheActiveX, // widget class
+ "{01234567-89AB-CDEF-0123-456789ABCDEF}", // class ID
+ "{01234567-89AB-CDEF-0123-456789ABCDEF}", // interface ID
+ "{01234567-89AB-CDEF-0123-456789ABCDEF}", // event interface ID
+ "{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID
+ "{01234567-89AB-CDEF-0123-456789ABCDEF}" // application ID
+)
+//! [7]
+
+
+//! [8]
+QAXFACTORY_EXPORT(
+ MyFactory, // factory class
+ "{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID
+ "{01234567-89AB-CDEF-0123-456789ABCDEF}" // application ID
+)
+//! [8]
+
+
+//! [9]
+QAXFACTORY_BEGIN(
+ "{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID
+ "{01234567-89AB-CDEF-0123-456789ABCDEF}" // application ID
+)
+ QAXCLASS(Class1)
+ QAXCLASS(Class2)
+QAXFACTORY_END()
+//! [9]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_codecs_qtextcodec.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_codecs_qtextcodec.cpp
new file mode 100644
index 000000000..f1c839d79
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_codecs_qtextcodec.cpp
@@ -0,0 +1,32 @@
+//! [0]
+encodedString = QByteArray("...")
+codec = QTextCodec::codecForName("KOI8-R")
+string = codec->toUnicode(encodedString)
+//! [0]
+
+
+//! [1]
+string = QString("...")
+codec = QTextCodec::codecForName("KOI8-R")
+encodedString = codec->fromUnicode(string)
+//! [1]
+
+
+//! [2]
+codec = QTextCodec::codecForName("Shift-JIS")
+decoder = codec->makeDecoder()
+
+string = QString()
+while new_data_available():
+ chunk = get_new_data();
+ string += decoder->toUnicode(chunk)
+
+//! [2]
+
+
+//! [3]
+def main():
+ app = QApplication([])
+ QTextCodec::setCodecForTr(QTextCodec::codecForName("eucKR"))
+ ...
+//! [3]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_codecs_qtextcodecplugin.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_codecs_qtextcodecplugin.cpp
new file mode 100644
index 000000000..15ae48865
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_codecs_qtextcodecplugin.cpp
@@ -0,0 +1,12 @@
+//! [0]
+
+def names(self):
+ return list = ["IBM01140", "hp15-tw"]
+
+def createForName(name):
+ if (name == "IBM01140"):
+ return Ibm01140Codec()
+ else if (name == "hp15-tw"):
+ return Hp15TwCodec()
+ return None
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qfuture.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qfuture.cpp
new file mode 100644
index 000000000..24fc791cb
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qfuture.cpp
@@ -0,0 +1,24 @@
+//! [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/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qfuturesynchronizer.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qfuturesynchronizer.cpp
new file mode 100644
index 000000000..a50a99e86
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qfuturesynchronizer.cpp
@@ -0,0 +1,13 @@
+//! [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/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qfuturewatcher.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qfuturewatcher.cpp
new file mode 100644
index 000000000..e1f06ccc2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qfuturewatcher.cpp
@@ -0,0 +1,10 @@
+//! [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/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentexception.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentexception.cpp
new file mode 100644
index 000000000..8b4d10acb
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentexception.cpp
@@ -0,0 +1,35 @@
+//! [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/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentfilter.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentfilter.cpp
new file mode 100644
index 000000000..d284d0245
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentfilter.cpp
@@ -0,0 +1,131 @@
+//! [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/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp
new file mode 100644
index 000000000..cbff31892
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp
@@ -0,0 +1,144 @@
+//! [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/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentrun.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentrun.cpp
new file mode 100644
index 000000000..99583ba25
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentrun.cpp
@@ -0,0 +1,60 @@
+//! [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 'QStringList QString::split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const' in a separate thread
+QString string = ...;
+QFuture<QStringList> future = QtConcurrent::run(string, &QString::split, QString(", "), QString::KeepEmptyParts, Qt::CaseSensitive);
+...
+QStringList 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/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qthreadpool.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qthreadpool.cpp
new file mode 100644
index 000000000..174b8788f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qthreadpool.cpp
@@ -0,0 +1,9 @@
+//! [0]
+class HelloWorldTask(QRunnable):
+ def run(self):
+ print "Hello world from thread", QThread.currentThread()
+
+hello = HelloWorldTask()
+# QThreadPool takes ownership and deletes 'hello' automatically
+QThreadPool.globalInstance()->start(hello)
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_global_qglobal.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_global_qglobal.cpp
new file mode 100644
index 000000000..287181a3a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_global_qglobal.cpp
@@ -0,0 +1,466 @@
+//! [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]
+
+
+//! [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]
+
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qabstractfileengine.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qabstractfileengine.cpp
new file mode 100644
index 000000000..5984b62f1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qabstractfileengine.cpp
@@ -0,0 +1,62 @@
+//! [0]
+class ZipEngineHandler(QAbstractFileEngineHandler)
+ def create(fileName):
+ # ZipEngineHandler returns a ZipEngine for all .zip files
+ if fileName.toLower().endsWith(".zip"):
+ return ZipEngine(fileName)
+ else
+ return None
+
+def main():
+ app = QApplication(sys.argv)
+
+ engine = ZipEngineHandler()
+
+ window = MainWindow()
+ window.show()
+
+ return app.exec()
+//! [0]
+
+
+//! [1]
+def create(fileName):
+ # ZipEngineHandler returns a ZipEngine for all .zip files
+ if fileName.toLower().endsWith(".zip"):
+ return ZipEngine(fileName)
+ else
+ return None
+//! [1]
+
+
+//! [2]
+# @arg filters QDir.Filters
+# @arg filterNames QStringList
+# @return QAbstractFileEngineIterator
+def beginEntryList(filters, filterNames):
+ return CustomFileEngineIterator(filters, filterNames)
+//! [2]
+
+
+//! [3]
+class CustomIterator(QAbstractFileEngineIterator):
+ def __init__(self, nameFilters, filters):
+ QAbstractFileEngineIterator.__init__(self, nameFilters, filters)
+
+ self.index = 0
+ # In a real iterator, these entries are fetched from the
+ # file system based on the value of path().
+ self.entries << "entry1" << "entry2" << "entry3"
+
+ def hasNext(self):
+ return self.index < self.entries.size() - 1
+
+ def next(self):
+ if !self.hasNext():
+ return QString()
+ index++
+ return currentFilePath()
+
+ def currentFileName(self):
+ return self.entries.at(index)
+//! [3]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdatastream.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdatastream.cpp
new file mode 100644
index 000000000..6b66276b7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdatastream.cpp
@@ -0,0 +1,85 @@
+void wrapInFunction()
+{
+
+//! [0]
+file = QFile("file.dat")
+file.open(QIODevice.WriteOnly)
+# we will serialize the data into the file
+out = QDataStream(file)
+# serialize a string
+out << "the answer is"
+# serialize an integer
+out.writeInt32(42)
+//! [0]
+
+
+//! [1]
+file = QFile("file.dat")
+file.open(QIODevice.ReadOnly)
+# read the data serialized from the file
+i = QDataStream(file)
+str = QString()
+a = 0
+# extract "the answer is" and 42
+i >> str
+a = i.readInt32()
+//! [1]
+
+
+//! [2]
+stream.setVersion(QDataStream.Qt_4_0)
+//! [2]
+
+
+//! [3]
+file = QFile("file.xxx")
+file.open(QIODevice.WriteOnly)
+out = QDataStream(file)
+
+# Write a header with a "magic number" and a version
+out.writeInt32(0xA0B0C0D0)
+out.writeInt32(123)
+
+out.setVersion(QDataStream.Qt_4_0);
+
+// Write the data
+out << lots_of_interesting_data
+//! [3]
+
+
+//! [4]
+file = QFile("file.xxx")
+file.open(QIODevice.ReadOnly)
+i = QDataStream(file)
+
+// Read and check the header
+magic = i.readInt32()
+if magic != 0xA0B0C0D0:
+ return XXX_BAD_FILE_FORMAT
+
+// Read the version
+version = i.readInt32()
+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]
+out = QDataStream(file)
+out.setVersion(QDataStream.Qt_4_0)
+//! [5]
+
+}
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdir.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdir.cpp
new file mode 100644
index 000000000..5bb0b07d8
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdir.cpp
@@ -0,0 +1,130 @@
+
+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]
+directory = QDir("Documents/Letters")
+path = directory.filePath("contents.txt")
+absolutePath = directory.absoluteFilePath("contents.txt")
+//! [3]
+
+
+//! [4]
+dir = QDir("example")
+if !dir.exists():
+ print "Cannot find the example directory"
+//! [4]
+
+
+//! [5]
+dir = QDir.root() # "/"
+if !dir.cd("tmp"): # "/tmp"
+ print "Cannot find the \"/tmp\" directory"
+else:
+ file = QFile(dir.filePath("ex1.txt")) # "/tmp/ex1.txt"
+ if !file.open(QIODevice.ReadWrite):
+ print "Cannot create the file %s" % (file.name())
+//! [5]
+
+
+//! [6]
+bin = "/local/bin" # where /local/bin is a symlink to /usr/bin
+binDir = QDir(bin)
+canonicalBin = binDir.canonicalPath()
+# canonicalBin now equals "/usr/bin"
+
+ls = "/local/bin/ls" # where ls is the executable "ls"
+lsDir = QDir(ls)
+canonicalLs = lsDir.canonicalPath()
+# canonicalLS now equals "/usr/bin/ls".
+//! [6]
+
+
+//! [7]
+dir = QDir("/home/bob")
+
+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"))
+...
+pixmap = QPixmap("icons:undo.png") # will look for undo.png in QDir::homePath() + "/images"
+file = QFile("docs:design.odf") # will look in the :/embeddedDocuments resource path
+//! [8]
+
+
+//! [9]
+dir = QDir("/tmp/root_link")
+dir = dir.canonicalPath()
+if dir.isRoot():
+ print "It is a root link"
+//! [9]
+
+
+//! [10]
+// The current directory is "/usr/local"
+d1 = QDir("/usr/local/bin")
+d2 = QDir("bin")
+if d1 == d2:
+ print "They're the same"
+//! [10]
+
+
+//! [11]
+// The current directory is "/usr/local"
+d1 = QDir("/usr/local/bin")
+d1.setFilter(QDir.Executable)
+d2 = QDir("bin")
+if d1 != d2:
+ print "They differ"
+//! [11]
+
+
+//! [12]
+C:/Documents and Settings/Username
+//! [12]
+
+
+//! [13]
+Q_INIT_RESOURCE(myapp);
+//! [13]
+
+
+//! [14]
+def initMyResource():
+ Q_INIT_RESOURCE(myapp)
+
+class MyNamespace
+ ...
+
+ def myFunction(self):
+ initMyResource()
+//! [14]
+
+
+//! [15]
+Q_CLEANUP_RESOURCE(myapp);
+//! [15]
+
+}
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdiriterator.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdiriterator.cpp
new file mode 100644
index 000000000..8da40f94f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdiriterator.cpp
@@ -0,0 +1,12 @@
+//! [0]
+it = QDirIterator("/etc", QDirIterator.Subdirectories)
+while it.hasNext():
+ print it.next()
+
+ # /etc/.
+ # /etc/..
+ # /etc/X11
+ # /etc/X11/fs
+ # ...
+
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qfile.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qfile.cpp
new file mode 100644
index 000000000..c700154c2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qfile.cpp
@@ -0,0 +1,32 @@
+//! [0]
+file = QFile()
+QDir.setCurrent("/tmp")
+file.setFileName("readme.txt")
+QDir.setCurrent("/home")
+file.open(QIODevice.ReadOnly) # opens "/home/readme.txt" under Unix
+//! [0]
+
+
+//! [1]
+def myEncoderFunc(fileName):
+//! [1]
+
+
+//! [2]
+def myDecoderFunc(localFileName):
+//! [2]
+
+
+//! [3]
+
+def printError(msg):
+ file = QFile()
+ file.open(sys.stderr.fileno(), QIODevice.WriteOnly)
+ file.write(msg, size(msg)) # write to stderr
+ file.close()
+//! [3]
+
+
+//! [4]
+CONFIG += console
+//! [4]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp
new file mode 100644
index 000000000..fb0e1c8fc
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp
@@ -0,0 +1,99 @@
+
+//![newstuff]
+ fi = QFileInfo("c:/temp/foo") => fi.absoluteFilePath() => "C:/temp/foo"
+//![newstuff]
+
+//! [0]
+info1 = QFileInfo("/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"
+
+info2 = QFileInfo(info1.symLinkTarget())
+info1.isSymLink() # returns false
+info1.absoluteFilePath() # returns "/opt/pretty++/bin/untabify"
+info1.size() # returns 56201
+
+//! [0]
+
+
+//! [1]
+info1 = QFileInfo("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"
+
+info2 = QFileInfo(info1.symLinkTarget())
+info1.isSymLink() # returns false
+info1.absoluteFilePath() # returns "C:/Pretty++/untabify"
+info1.size() # returns 63942
+//! [1]
+
+
+//! [2]
+absolute = QString("/local/bin")
+relative = QString("local/bin")
+absFile = QFileInfo(absolute)
+relFile = QFileInfo(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]
+fi = QFileInfo("/tmp/archive.tar.gz")
+name = fi.fileName() # name = "archive.tar.gz"
+//! [3]
+
+
+//! [4]
+fi = QFileInfo("/Applications/Safari.app")
+bundle = fi.bundleName() # name = "Safari"
+//! [4]
+
+
+//! [5]
+fi = QFileInfo("/tmp/archive.tar.gz")
+base = fi.baseName() # base = "archive"
+//! [5]
+
+
+//! [6]
+fi = QFileInfo("/tmp/archive.tar.gz")
+base = fi.completeBaseName() # base = "archive.tar"
+//! [6]
+
+
+//! [7]
+fi = QFileInfo("/tmp/archive.tar.gz")
+ext = fi.completeSuffix() # ext = "tar.gz"
+//! [7]
+
+
+//! [8]
+fi = QFileInfo("/tmp/archive.tar.gz")
+ext = fi.suffix(); # ext = "gz"
+//! [8]
+
+
+//! [9]
+info = QFileInfo(fileName)
+if info.isSymLink():
+ fileName = info.symLinkTarget()
+//! [9]
+
+
+//! [10]
+fi = QFileInfo("/tmp/archive.tar.gz")
+if fi.permission(QFile.WriteUser | QFile.ReadGroup):
+ print "I can change the file; my group can read the file"
+if fi.permission(QFile.WriteGroup | QFile.WriteOther):
+ print "The group or others can change the file"
+//! [10]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qiodevice.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qiodevice.cpp
new file mode 100644
index 000000000..44bd19795
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qiodevice.cpp
@@ -0,0 +1,48 @@
+//! [0]
+gzip = QProcess()
+gzip.start("gzip", QStringList() << "-c")
+if !gzip.waitForStarted():
+ return false
+
+gzip.write("uncompressed data");
+
+compressed = QByteArray()
+while gzip.waitForReadyRead():
+ compressed += gzip.readAll()
+//! [0]
+
+
+//! [1]
+def bytesAvailable(self):
+ return buffer.size() + QIODevice.bytesAvailable()
+//! [1]
+
+
+//! [2]
+file = QFile("box.txt")
+if file.open(QFile.ReadOnly):
+ buf = file.readLine(1024);
+ if buf.size():
+ # the line is available in buf
+//! [2]
+
+
+//! [3]
+def canReadLine(self):
+ return buffer.contains('\n') || QIODevice.canReadLine()
+//! [3]
+
+
+//! [4]
+def isExeFile(file):
+ buf = file->peek(2);
+ if buf.size() == 2:
+ return (buf[0] == 'M' && buf[1] == 'Z')
+ return false
+//! [4]
+
+
+//! [5]
+def isExeFile(file):
+ return file->peek(2) == "MZ"
+//! [5]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qprocess.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qprocess.cpp
new file mode 100644
index 000000000..7f4bd7a69
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qprocess.cpp
@@ -0,0 +1,82 @@
+
+def wrapInFunction():
+
+//! [0]
+builder = QProcess()
+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]
+more = QProcess()
+more.start("more")
+more.write("Text to display")
+more.closeWriteChannel()
+#QProcess will emit readyRead() once "more" starts printing
+//! [1]
+
+
+//! [2]
+command1 | command2
+//! [2]
+
+
+//! [3]
+process1 = QProcess()
+process2 = QProcess()
+
+process1.setStandardOutputProcess(process2)
+
+process1.start("command1")
+process2.start("command2")
+//! [3]
+
+
+//! [4]
+class SandboxProcess(QProcess):
+ def setupChildProcess(self)
+ # Drop all privileges in the child process, and enter
+ # a chroot jail.
+ os.setgroups(0, 0)
+ os.chroot("/etc/safe")
+ os.chdir("/")
+ os.setgid(safeGid)
+ os.setuid(safeUid)
+ os.umask(0)
+
+//! [4]
+
+
+//! [5]
+process = QProcess()
+process.start("del /s *.txt")
+# same as process.start("del", QStringList() << "/s" << "*.txt")
+...
+//! [5]
+
+
+//! [6]
+process = QProcess()
+process.start("dir \"My Documents\"")
+//! [6]
+
+
+//! [7]
+process = QProcess()
+process.start("dir \"\"\"My Documents\"\"\"")
+//! [7]
+
+
+//! [8]
+environment = QProcess.systemEnvironment()
+# environment = {"PATH=/usr/bin:/usr/local/bin",
+# "USER=greg", "HOME=/home/greg"}
+//! [8]
+
+
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qsettings.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qsettings.cpp
new file mode 100644
index 000000000..71745fa06
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qsettings.cpp
@@ -0,0 +1,280 @@
+//! [0]
+settings = QSettings("MySoft", "Star Runner")
+color = QColor(settings.value("DataPump/bgcolor"))
+//! [0]
+
+
+//! [1]
+settings = QSettings("MySoft", "Star Runner")
+color = palette().background().color()
+settings.setValue("DataPump/bgcolor", color)
+//! [1]
+
+
+//! [2]
+settings = QSettings("/home/petra/misc/myapp.ini",
+ QSettings.IniFormat)
+//! [2]
+
+
+//! [3]
+settings = QSettings("/Users/petra/misc/myapp.plist",
+ QSettings.NativeFormat)
+//! [3]
+
+
+//! [4]
+settings = QSettings("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
+ settings = QSettings("grenoullelogique.fr", "Squash")
+#else
+ settings = QSettings("Grenoulle Logique", "Squash")
+#endif
+//! [7]
+
+
+//! [8]
+pos = @Point(100 100)
+//! [8]
+
+
+//! [9]
+windir = C:\Windows
+//! [9]
+
+
+//! [10]
+settings = QSettings("Moose Tech", "Facturo-Pro")
+//! [10]
+
+
+//! [11]
+settings = QSettings("Moose Soft", "Facturo-Pro")
+//! [11]
+
+
+//! [12]
+QCoreApplication.setOrganizationName("Moose Soft")
+QCoreApplication.setApplicationName("Facturo-Pro")
+settings = QSettings()
+//! [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]
+class Login:
+ userName = QString()
+ password = QString()
+
+ logins = []
+ ...
+
+ settings = QSettings()
+ size = settings.beginReadArray("logins")
+ for i in range(size):
+ settings.setArrayIndex(i)
+ login = Login()
+ login.userName = settings.value("userName").toString()
+ login.password = settings.value("password").toString()
+ logins.append(login)
+
+ settings.endArray()
+//! [15]
+
+
+//! [16]
+class Login:
+ userName = QString()
+ password = QString()
+
+ logins = []
+ ...
+
+ settings = QSettings()
+ settings.beginWriteArray("logins")
+ for i in range(logins.size()):
+ settings.setArrayIndex(i)
+ settings.setValue("userName", list.at(i).userName)
+ settings.setValue("password", list.at(i).password)
+
+ settings.endArray()
+//! [16]
+
+
+//! [17]
+settings = QSettings()
+settings.setValue("fridge/color", Qt.white)
+settings.setValue("fridge/size", QSize(32, 96))
+settings.setValue("sofa", true)
+settings.setValue("tv", false)
+
+keys = settings.allKeys();
+# keys: ["fridge/color", "fridge/size", "sofa", "tv"]
+//! [17]
+
+
+//! [18]
+settings.beginGroup("fridge")
+keys = settings.allKeys()
+# keys: ["color", "size"]
+//! [18]
+
+
+//! [19]
+settings = QSettings()
+settings.setValue("fridge/color", Qt.white)
+settings.setValue("fridge/size", QSize(32, 96))
+settings.setValue("sofa", true)
+settings.setValue("tv", false)
+
+keys = settings.childKeys()
+# keys: ["sofa", "tv"]
+//! [19]
+
+
+//! [20]
+settings.beginGroup("fridge")
+keys = settings.childKeys()
+# keys: ["color", "size"]
+//! [20]
+
+
+//! [21]
+settings = QSettings()
+settings.setValue("fridge/color", Qt.white)
+settings.setValue("fridge/size", QSize(32, 96));
+settings.setValue("sofa", true)
+settings.setValue("tv", false)
+
+groups = settings.childGroups()
+# group: ["fridge"]
+//! [21]
+
+
+//! [22]
+settings.beginGroup("fridge")
+groups = settings.childGroups()
+# groups: []
+//! [22]
+
+
+//! [23]
+settings = QSettings()
+settings.setValue("interval", 30)
+settings.value("interval").toInt() # returns 30
+
+settings.setValue("interval", 6.55)
+settings.value("interval").toDouble() # returns 6.55
+//! [23]
+
+
+//! [24]
+settings = QSettings()
+settings.setValue("ape")
+settings.setValue("monkey", 1)
+settings.setValue("monkey/sea", 2)
+settings.setValue("monkey/doe", 4)
+
+settings.remove("monkey")
+keys = settings.allKeys()
+# keys: ["ape"]
+//! [24]
+
+
+//! [25]
+settings = QSettings()
+settings.setValue("ape")
+settings.setValue("monkey", 1)
+settings.setValue("monkey/sea", 2)
+settings.setValue("monkey/doe", 4)
+
+settings.beginGroup("monkey")
+settings.remove("")
+settings.endGroup()
+
+keys = settings.allKeys()
+# keys: ["ape"]
+//! [25]
+
+
+//! [26]
+settings = QSettings()
+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]
+# @arg device QIODevice
+# @arg map QSettings.SettingsMap
+# @return bool
+def myReadFunc(device, map):
+//! [27]
+
+
+//! [28]
+# @arg device QIODevice
+# @arg map QSettings.SettingsMap
+# @return bool
+def myWriteFunc(device, map)
+//! [28]
+
+
+//! [29]
+# @arg device QIODevice
+# @arg map QSettings.SettingsMap
+# @return bool
+def readXmlFile(device, map):
+def writeXmlFile(device, map):
+
+def main():
+ XmlFormat = QSettings::registerFormat("xml", readXmlFile, writeXmlFile)
+ settings = QSettings(XmlFormat, QSettings.UserSettings,
+ "MySoft", "Star Runner")
+ ...
+//! [29]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qtemporaryfile.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qtemporaryfile.cpp
new file mode 100644
index 000000000..8ebbd9e3d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qtemporaryfile.cpp
@@ -0,0 +1,12 @@
+{
+//! [0]
+ # Within a function/method...
+
+ file = QTemporaryFile()
+ 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/codesnippets/doc/src/snippets/code/src_corelib_io_qtextstream.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qtextstream.cpp
new file mode 100644
index 000000000..6988af4d3
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qtextstream.cpp
@@ -0,0 +1,90 @@
+//! [0]
+data = QFile("output.txt")
+if data.open(QFile.WriteOnly | QFile::Truncate):
+ out = QTextStream(&data)
+ out << "Result: " << qSetFieldWidth(10) << left << 3.14 << 2.7
+ # writes "Result: 3.14 2.7 "
+
+//! [0]
+
+
+//! [1]
+stream = QTextStream(sys.stdin.fileno())
+
+while(True):
+ line = stream.readLine()
+ if line.isNull():
+ break;
+//! [1]
+
+
+//! [2]
+in = QTextStream("0x50 0x20")
+firstNumber = 0
+secondNumber = 0
+
+in >> firstNumber # firstNumber == 80
+in >> dec >> secondNumber # secondNumber == 0
+
+ch = None
+in >> ch # ch == 'x'
+//! [2]
+
+
+//! [3]
+def main():
+ # read numeric arguments (123, 0x20, 4.5...)
+ for i in sys.argv():
+ number = None
+ QTextStream in(i)
+ in >> number
+ ...
+//! [3]
+
+
+//! [4]
+str = QString()
+in = QTextStream(sys.stdin.fileno())
+in >> str
+//! [4]
+
+
+//! [5]
+s = QString()
+out = QTextStream(s)
+out.setFieldWidth(10)
+out.setFieldAlignment(QTextStream::AlignCenter)
+out.setPadChar('-')
+out << "Qt" << "rocks!"
+//! [5]
+
+
+//! [6]
+----Qt------rocks!--
+//! [6]
+
+
+//! [7]
+in = QTextStream(file)
+ch1 = QChar()
+ch2 = QChar()
+ch3 = QChar()
+in >> ch1 >> ch2 >> ch3;
+//! [7]
+
+
+//! [8]
+out = QTextStream(sys.stdout.fileno())
+out << "Qt rocks!" << endl
+//! [8]
+
+
+//! [9]
+stream << '\n' << flush
+//! [9]
+
+
+//! [10]
+out = QTextStream(file)
+out.setCodec("UTF-8")
+//! [10]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qurl.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qurl.cpp
new file mode 100644
index 000000000..a56843816
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qurl.cpp
@@ -0,0 +1,46 @@
+//! [0]
+url = QUrl("http://www.example.com/List of holidays.xml")
+# url.toEncoded() == "http://www.example.com/List%20of%20holidays.xml"
+//! [0]
+
+
+//! [1]
+url = QUrl.fromEncoded("http://qtsoftware.com/List%20of%20holidays.xml")
+//! [1]
+
+
+//! [2]
+def checkUrl(url):
+ if !url.isValid():
+ print QString("Invalid URL: %1").arg(url.toString())
+ return false
+
+ return true
+
+//! [2]
+
+
+//! [3]
+ftp = QFtp()
+ftp.connectToHost(url.host(), url.port(21))
+//! [3]
+
+
+//! [4]
+http://www.example.com/cgi-bin/drawgraph.cgi?type-pie/color-green
+//! [4]
+
+
+//! [5]
+baseUrl = QUrl("http://qtsoftware.com/support")
+relativeUrl = QUrl("../products/solutions")
+print baseUrl.resolved(relativeUrl).toString()
+# prints "http://qtsoftware.com/products/solutions"
+//! [5]
+
+
+//! [6]
+ba = QUrl.toPercentEncoding("{a fishy string?}", "{}", "s")
+print ba.constData()
+# prints "{a fi%73hy %73tring%3F}"
+//! [6]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qabstracteventdispatcher.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qabstracteventdispatcher.cpp
new file mode 100644
index 000000000..a531f22fc
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qabstracteventdispatcher.cpp
@@ -0,0 +1,3 @@
+//! [0]
+bool myEventFilter(void *message);
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp
new file mode 100644
index 000000000..61ea36233
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp
@@ -0,0 +1,28 @@
+//! [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]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp
new file mode 100644
index 000000000..f9cc0015f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp
@@ -0,0 +1,86 @@
+//! [0]
+event = QMouseEvent(QEvent.MouseButtonPress, pos, 0, 0, 0)
+QApplication.sendEvent(mainWindow, event)
+//! [0]
+
+
+//! [1]
+quitButton = QPushButton("Quit")
+QObject.connect(quitButton, SIGNAL("clicked()"), app, SLOT("quit()"))
+//! [1]
+
+
+//! [2]
+for path in app.libraryPaths():
+ do_something(path)
+//! [2]
+
+
+//! [3]
+myEventFilter(message, 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/codesnippets/doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp
new file mode 100644
index 000000000..5676f1318
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp
@@ -0,0 +1,87 @@
+
+void wrapInFunction()
+{
+
+//! [0]
+class MyClass:
+
+ Q_CLASSINFO("author", "Sabrina Schweinsteiger")
+ Q_CLASSINFO("url", "http://doc.moosesoft.co.uk/1.0/")
+
+ ...
+//! [0]
+
+
+//! [1]
+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]
+retVal = QString()
+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_CLASSINFO("author", "Sabrina Schweinsteiger")
+ Q_CLASSINFO("url", "http://doc.moosesoft.co.uk/1.0/")
+//! [5]
+
+
+//! [propertyCount]
+metaObject = obj.metaObject()
+properties = QStringList()
+for i in range(metaObject.propertyOffset(), metaObject.propertyCount()):
+ properties << QString.fromLatin1(metaObject.property(i).name())
+//! [propertyCount]
+
+
+//! [methodCount]
+metaObject = obj.metaObject()
+methods = QStringList()
+for i in rang(metaObject.methodOffset(), metaObject->methodCount()):
+ methods << QString.fromLatin1(metaObject.method(i).signature())
+//! [methodCount]
+
+//! [6]
+methodIndex = pushButton.metaObject().indexOfMethod("animateClick()")
+method = metaObject.method(methodIndex)
+method.invoke(pushButton, Qt.QueuedConnection)
+//! [6]
+
+//! [7]
+QMetaMethod.invoke: Unable to handle unregistered datatype 'MyType'
+//! [7]
+
+//! [8]
+retVal = QString()
+normalizedSignature = QMetaObject.normalizedSignature("compute(QString, int, double)")
+methodIndex = obj.metaObject().indexOfMethod(normalizedSignature)
+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/codesnippets/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp
new file mode 100644
index 000000000..783852bbb
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp
@@ -0,0 +1,69 @@
+//! [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]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qmimedata.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qmimedata.cpp
new file mode 100644
index 000000000..f074b427a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qmimedata.cpp
@@ -0,0 +1,57 @@
+//! [0]
+def dragEnterEvent(self, event):
+ if event.mimeData().hasUrls():
+ event.acceptProposedAction()
+
+def dropEvent(self, event):
+ if event->mimeData().hasUrls():
+ for url in event.mimeData().urls():
+ ...
+//! [0]
+
+
+//! [1]
+csvData = QByteArray(...)
+
+mimeData = QMimeData()
+mimeData.setData("text/csv", csvData)
+//! [1]
+
+
+//! [2]
+def dropEvent(self, event):
+ myData = 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():
+ image = QImage(event.mimeData().imageData())
+ ...
+//! [5]
+
+
+//! [6]
+mimeData.setImageData(QImage("beautifulfjord.png"))
+//! [6]
+
+
+//! [7]
+if event.mimeData().hasColor():
+ color = QColor(event.mimeData().colorData())
+ ...
+//! [7]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qobject.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qobject.cpp
new file mode 100644
index 000000000..81e7edc8a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qobject.cpp
@@ -0,0 +1,319 @@
+//! [0]
+lineEdit = qt_find_obj_child(myWidget, "QLineEdit", "my line edit")
+if lineEdit:
+ lineEdit.setText("Default")
+//! [0]
+
+
+//! [1]
+obj = QPushButton()
+obj.metaObject().className() # returns "QPushButton"
+
+QPushButton.staticMetaObject.className() # returns "QPushButton"
+//! [1]
+
+
+//! [2]
+QPushButton.staticMetaObject.className() # returns "QPushButton"
+
+obj = QPushButton()
+obj.metaObject().className() # returns "QPushButton"
+//! [2]
+
+
+//! [3]
+obj = QTimer() # QTimer inherits QObject
+
+timer = obj
+# timer == (QObject *)obj
+
+button = obj
+# button == 0
+//! [3]
+
+
+//! [4]
+timer = QTimer() # QTimer inherits QObject
+timer.inherits("QTimer") # returns true
+timer.inherits("QObject") # returns true
+timer.inherits("QAbstractButton") # returns false
+
+# QLayout inherits QObject and QLayoutItem
+layout = QLayout()
+layout.inherits("QObject") # returns true
+layout.inherits("QLayoutItem") # returns false
+//! [4]
+
+
+//! [5]
+print "MyClass::setPrecision(): (%s) invalid precision %f" % \
+ (qPrintable(objectName()), newPrecision)
+//! [5]
+
+
+//! [6]
+class MainWindow(QMainWindow):
+ def __init__(self):
+ self.textEdit = QTextEdit()
+ setCentralWidget(self.textEdit)
+ textEdit.installEventFilter(self)
+
+ def eventFilter(self, obj, event):
+ if obj == textEdit:
+ if event.type() == QEvent.KeyPress:
+ keyEvent = event
+ print "Ate key press", keyEvent.key()
+ return true
+ else:
+ return false
+ else:
+ # pass the event on to the parent class
+ return QMainWindow.eventFilter(self, obj, event)
+//! [6]
+
+
+//! [7]
+myObject.moveToThread(QApplication.instance().thread())
+//! [7]
+
+
+//! [8]
+class MyObject(QObject):
+ def __init__(self, parent):
+ QObject.__init__(self, parent)
+
+ self.startTimer(50) # 50-millisecond timer
+ self.startTimer(1000) # 1-second timer
+ self.startTimer(60000) # 1-minute timer
+
+
+ def timerEvent(self, event):
+ print "Timer ID:", event.timerId()
+
+//! [8]
+
+
+//! [9]
+list = window().queryList("QAbstractButton")
+for obj in list:
+ obj.setEnabled(false)
+//! [9]
+
+
+//! [10]
+button = parentWidget.findChild(QPushButton, "button1")
+//! [10]
+
+
+//! [11]
+list = parentWidget.findChild(QListWidget)
+//! [11]
+
+
+//! [12]
+widgets = parentWidget.findChildren(QWidget, "widgetname")
+//! [12]
+
+
+//! [13]
+allPButtons = parentWidget.findChildren(QPushButton)
+//! [13]
+
+
+//! [14]
+monitoredObj.installEventFilter(filterObj)
+//! [14]
+
+
+//! [15]
+class KeyPressEater(QObject):
+ def eventFilter(self, obj, event):
+ if event.type() == QEvent.KeyPress:
+ print "Ate key press", event.key()
+ return True
+ else:
+ # standard event processing
+ return QObject.eventFilter(self, obj, event)
+//! [15]
+
+
+//! [16]
+keyPressEater = KeyPressEater(self)
+pushButton = QPushButton(self)
+listView = QListView(self)
+
+pushButton.installEventFilter(keyPressEater)
+listView.installEventFilter(keyPressEater)
+//! [16]
+
+
+//! [17]
+def __init__(self):
+ senderLabel = QLabel(self.tr("Name:"))
+ recipientLabel = QLabel(self.tr("Name:", "recipient"))
+ # ...
+//! [17]
+
+
+//! [18]
+n = messages.count();
+showMessage(self.tr("%n message(s) saved", "", n));
+//! [18]
+
+
+//! [19]
+if n == 1:
+ self.tr("%n message saved")
+else:
+ self.tr("%n messages saved")
+//! [19]
+
+
+//! [20]
+label.setText(self.tr("F\374r \310lise"))
+//! [20]
+
+
+//! [21]
+if receivers(SIGNAL('valueChanged()')) > 0:
+ data = get_the_value() # expensive operation
+ self.valueChanged(data)
+//! [21]
+
+
+//! [22]
+label = QLabel()
+scrollBar = QScrollBar()
+QObject.connect(scrollBar, SIGNAL('valueChanged()'),
+ label, SLOT('setNum()'))
+//! [22]
+
+
+//! [23]
+// WRONG
+QObject.connect(scrollBar, SIGNAL('valueChanged()'),
+ label, SLOT('setNum()'));
+//! [23]
+
+
+//! [24]
+class MyWidget(QWidget):
+ def __init__(self):
+ myButton = QPushButton(self)
+ connect(myButton, SIGNAL('clicked()'),
+ self, 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()'):
+ # signal is valueChanged()
+//! [32]
+
+
+//! [33]
+def on_<object name>_<signal name>(<signal parameters>)
+//! [33]
+
+
+//! [34]
+def on_button1_clicked()
+//! [34]
+
+
+//! [35]
+class MyClass(QObject):
+ Q_CLASSINFO("Author", "Pierre Gendron")
+ Q_CLASSINFO("URL", "http://www.my-organization.qc.ca")
+
+//! [35]
+
+
+//! [36]
+Q_PROPERTY(type name
+ READ getFunction
+ [WRITE setFunction]
+ [RESET resetFunction]
+ [DESIGNABLE bool]
+ [SCRIPTABLE bool]
+ [STORED bool]
+ [USER bool])
+//! [36]
+
+
+//! [37]
+Q_PROPERTY(QString title READ title WRITE setTitle USER true)
+//! [37]
+
+
+//! [38]
+#this not apply for Python
+class MyClass(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]
+
+
+//! [39]
+#this not apply for Python
+Q_FLAGS(Options Alignment)
+//! [39]
+
+
+//! [40]
+//: This name refers to a host name.
+hostNameLabel.setText(self.tr("Name:"))
+
+#: This text refers to a C++ code example.
+example = self.tr("Example")
+//! [40]
+
+//! [explicit tr context]
+text = QScrollBar.tr("Page up")
+//! [explicit tr context]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp
new file mode 100644
index 000000000..40bcf7049
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp
@@ -0,0 +1,21 @@
+//! [0]
+sem = QSystemSemaphore("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]
+sem = QSystemSemaphore("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/codesnippets/doc/src/snippets/code/src_corelib_kernel_qtimer.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qtimer.cpp
new file mode 100644
index 000000000..1b7ea4ee2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qtimer.cpp
@@ -0,0 +1,10 @@
+//! [0]
+from PySide.QtCore import QApplication, QTimer
+
+def main():
+
+ app = QApplication([])
+ QTimer.singleShot(600000, app, SLOT('quit()'))
+ ...
+ return app.exec()
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qvariant.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qvariant.cpp
new file mode 100644
index 000000000..d03b83e80
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qvariant.cpp
@@ -0,0 +1,99 @@
+//! [0]
+out = QDataStream(...)
+v = QVariant(123) // The variant now contains an 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
+y = v.toInt() // y = 0 since v cannot be converted to an int
+s = v.toString() // s = tr("hello") (see QObject::tr())
+out << v // Writes a type tag and a QString to out
+...
+in = QDataStream(...) // (opening the previously written stream)
+in >> v // Reads an Int variant
+z = v.toInt() // z = 123
+print ("Type is %s", a v.typeName()) // prints "Type is int"
+v = v.toInt() + 100 // The variant now hold the value 223
+v = QVariant(QStringList())
+//! [0]
+
+
+//! [1]
+x = QVariant()
+y = QVariant(QString())
+z = QVariant(QString(""))
+x.convert(QVariant.Int)
+// x.isNull() == true
+// y.isNull() == true, z.isNull() == false
+// y.isEmpty() == true, z.isEmpty() == true
+//! [1]
+
+
+//! [2]
+variant = QVariant(some_qcolor)
+...
+color = QColor(variant)
+//! [2]
+
+
+//! [3]
+color = palette().background().color()
+variant = QVariant(color)
+//! [3]
+
+
+//! [4]
+v = QVariant()
+
+v.setValue(5) // Not supported by PySide
+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 // canConvert not supported by PySide
+if (v.canConvert<MyCustomStruct>())
+ c = v.value<MyCustomStruct>(v)
+
+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
+
+// canConvert not supported by PySide
+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 // fromValue not supported by PySide
+return QVariant::fromValue(s)
+//! [7]
+
+
+//! [8]
+QObject *object = getObjectFromSomewhere()
+QVariant data = qVariantFromValue(object) // not supported by PySide.
+//! [8]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp
new file mode 100644
index 000000000..06590610c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp
@@ -0,0 +1,44 @@
+//! [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/codesnippets/doc/src/snippets/code/src_corelib_plugin_quuid.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_plugin_quuid.cpp
new file mode 100644
index 000000000..c173a679f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_plugin_quuid.cpp
@@ -0,0 +1,4 @@
+//! [0]
+# {67C8770B-44F1-410A-AB9A-F9B5446F13EE}
+IID_MyInterface = QUuid(0x67c8770b, 0x44f1, 0x410a, 0xab, 0x9a, 0xf9, 0xb5, 0x44, 0x6f, 0x13, 0xee)
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qatomic.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qatomic.cpp
new file mode 100644
index 000000000..3f67ddf8e
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qatomic.cpp
@@ -0,0 +1,58 @@
+//! [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/codesnippets/doc/src/snippets/code/src_corelib_thread_qmutex.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qmutex.cpp
new file mode 100644
index 000000000..25068b801
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qmutex.cpp
@@ -0,0 +1,115 @@
+//! [0]
+number = 6
+
+def method1():
+ number *= 5
+ number /= 4
+
+def 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]
+mutex = QMutex()
+number = 6
+
+def method1():
+ mutex.lock()
+ number *= 5
+ number /= 4
+ mutex.unlock()
+
+def method2():
+ mutex.lock()
+ number *= 3
+ number /= 2
+ mutex.unlock()
+//! [3]
+
+
+//! [4]
+def complexFunction(flag):
+ mutex.lock()
+
+ retVal = 0
+
+ if flag == 0 or flag == 1:
+ mutex.unlock()
+ return moreComplexFunction(flag)
+ elif flag == 2:
+ status = anotherFunction()
+ if status < 0:
+ mutex.unlock()
+ return -2
+ retVal = status + flag
+ else:
+ if flag > 10:
+ mutex.unlock()
+ return -1
+
+ mutex.unlock()
+ return retVal
+//! [4]
+
+
+//! [5]
+def complexFunction(flag):
+ locker = QMutexLocker(mutex)
+
+ retVal = 0
+
+ if flag == 0 or flag == 1:
+ return moreComplexFunction(flag)
+ elif flag == 2:
+ status = anotherFunction()
+ if status < 0:
+ return -2
+ retVal = status + flag
+ else:
+ if flag > 10:
+ return -1
+
+ return retVal
+//! [5]
+
+
+//! [6]
+class SignalWaiter:
+ def __init__(mutex):
+ self.locker = mutex
+
+ def waitForSignal():
+ # ...
+ while not signalled:
+ waitCondition.wait(self.locker.mutex())
+ # ...
+//! [6]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qmutexpool.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qmutexpool.cpp
new file mode 100644
index 000000000..740d96a9d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qmutexpool.cpp
@@ -0,0 +1,12 @@
+//! [0]
+class Number:
+ def __init__(n):
+ self.num = n
+//! [0]
+
+
+//! [1]
+def calcSquare(number):
+ locker = QMutexLocker(mutexpool.get(number))
+ number.num = number.num * number.num
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qreadwritelock.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qreadwritelock.cpp
new file mode 100644
index 000000000..d8c088d69
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qreadwritelock.cpp
@@ -0,0 +1,61 @@
+//! [0]
+lock = QReadWriteLock()
+
+class ReaderThread:
+ # ...
+ def run():
+ # ...
+ lock.lockForRead()
+ read_file()
+ lock.unlock()
+ # ...
+
+class WriterThread:
+ #...
+ def run():
+ # ...
+ lock.lockForWrite()
+ write_file()
+ lock.unlock()
+ # ...
+//! [0]
+
+
+//! [1]
+lock = QReadWriteLock()
+
+def readData():
+ locker = QReadLocker(lock)
+ # ...
+ return data
+//! [1]
+
+
+//! [2]
+lock = QReadWriteLock()
+
+def readData():
+ locker.lockForRead()
+ # ...
+ locker.unlock()
+ return data
+//! [2]
+
+
+//! [3]
+lock = QReadWriteLock()
+
+def writeData(data):
+ locker = QWriteLocker(lock)
+ # ...
+//! [3]
+
+
+//! [4]
+lock = QReadWriteLock()
+
+def writeData(data):
+ locker.lockForWrite()
+ # ...
+ locker.unlock()
+//! [4]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qsemaphore.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qsemaphore.cpp
new file mode 100644
index 000000000..da809ec12
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qsemaphore.cpp
@@ -0,0 +1,33 @@
+//! [0]
+sem = QSemaphore(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]
+sem = QSemaphore(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]
+sem = QSemaphore(5) # sem.available() == 5
+sem.tryAcquire(250) # sem.available() == 5, returns false
+sem.tryAcquire(3) # sem.available() == 2, returns true
+//! [2]
+
+
+//! [3]
+sem = QSemaphore(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/codesnippets/doc/src/snippets/code/src_corelib_thread_qthread.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qthread.cpp
new file mode 100644
index 000000000..a10012725
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qthread.cpp
@@ -0,0 +1,9 @@
+//! [0]
+class MyThread (QThread):
+ def run():
+ socket = QTcpSocket()
+ # connect QTcpSocket's signals somewhere meaningful
+ # ...
+ socket.connectToHost(hostName, portNumber)
+ exec_()
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp
new file mode 100644
index 000000000..6737e9df9
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp
@@ -0,0 +1,45 @@
+//! [0]
+while True:
+ mutex.lock()
+ keyPressed.wait(mutex)
+ do_something()
+ mutex.unlock()
+//! [0]
+
+
+//! [1]
+while True:
+ getchar()
+ keyPressed.wakeAll()
+
+//! [1]
+
+
+//! [2]
+while True:
+ mutex.lock()
+ keyPressed.wait(&mutex)
+ count += 1
+ mutex.unlock()
+
+ do_something()
+
+ mutex.lock()
+ count -= 1
+ mutex.unlock()
+//! [2]
+
+
+//! [3]
+while True:
+ 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/codesnippets/doc/src/snippets/code/src_corelib_tools_qbitarray.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qbitarray.cpp
new file mode 100644
index 000000000..19be88f99
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qbitarray.cpp
@@ -0,0 +1,189 @@
+//! [0]
+ba = QBitArray(200)
+//! [0]
+
+
+//! [1]
+ba = QBitArray()
+ba.resize(3)
+ba[0] = True
+ba[1] = False
+ba[2] = True
+//! [1]
+
+
+//! [2]
+ba = QBitArray(3)
+ba.setBit(0, True)
+ba.setBit(1, False)
+ba.setBit(2, True)
+//! [2]
+
+
+//! [3]
+x = QBitArray(5)
+x.setBit(3, True)
+# x: [ 0, 0, 0, 1, 0 ]
+
+y = QBitArray(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]
+ba = QBitArray(8)
+ba.fill(True)
+# ba: [ 1, 1, 1, 1, 1, 1, 1, 1 ]
+
+ba.fill(False, 2)
+# ba: [ 0, 0 ]
+//! [6]
+
+
+//! [7]
+a = QBitArray(3)
+a[0] = False
+a[1] = True
+a[2] = a[0] ^ a[1]
+//! [7]
+
+
+//! [8]
+a = QBitArray(3)
+b = QBitArray(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]
+a = QBitArray(3)
+b = QBitArray(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]
+a = QBitArray(3)
+b = QBitArray(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]
+a = QBitArray(3)
+b = QBitArray()
+a[0] = 1
+a[1] = 0
+a[2] = 1
+# a: [ 1, 0, 1 ]
+
+b = ~a
+# b: [ 0, 1, 0 ]
+//! [11]
+
+
+//! [12]
+a = QBitArray(3)
+b = QBitArray(2)
+c = QBitArray()
+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]
+a = QBitArray(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]
+a = QBitArray(3)
+QBitArray b(2)
+c = QBitArray()
+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/codesnippets/doc/src/snippets/code/src_corelib_tools_qbytearray.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qbytearray.cpp
new file mode 100644
index 000000000..c097a260d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qbytearray.cpp
@@ -0,0 +1,355 @@
+
+void wrapInFunction()
+{
+
+//! [0]
+ba = QByteArray("Hello")
+//! [0]
+
+
+//! [1]
+ba = QByteArray()
+ba.resize(5)
+ba[0] = 'H'
+ba[1] = 'e'
+ba[2] = 'l'
+ba[3] = 'l'
+ba[4] = 'o'
+//! [1]
+
+
+//! [2]
+for i in range(0, ba.size()):
+ if ba.at(i) >= 'a' and ba.at(i) <= 'f':
+ print "Found character in range [a-f]"
+//! [2]
+
+
+//! [3]
+x = QByteArray("and")
+x.prepend("rock ") # x == "rock and"
+x.append(" roll") # x == "rock and roll"
+x.replace(5, 3, "&") # x == "rock & roll"
+//! [3]
+
+
+//! [4]
+ba = QByteArray("We must be <b>bold</b>, very <b>bold</b>")
+j = 0
+while (j = ba.indexOf("<b>", j)) != -1:
+ print "Found <b> tag at index position %d" % j
+ ++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]
+ba = QByteArray("Hello")
+n = ba.size() # n == 5
+ba.data()[0] # returns 'H'
+ba.data()[4] # returns 'o'
+//! [6]
+
+
+//! [7]
+QByteArray().isEmpty() # returns true
+QByteArray("").isEmpty() # returns true
+QByteArray("abc").isEmpty() # returns false
+//! [7]
+
+
+//! [8]
+ba = QByteArray("Hello world");
+print ba.data();
+//! [8]
+
+
+//! [9]
+ba = QByteArray()
+for i in range(0, 10):
+ ba[i] = 'A' + str(i)
+# ba == "ABCDEFGHIJ"
+//! [9]
+
+
+//! [10]
+ba = QByteArray("Stockholm")
+ba.truncate(5) # ba == "Stock"
+//! [10]
+
+
+//! [11]
+ba = QByteArray("STARTTLS\r\n")
+ba.chop(2) # ba == "STARTTLS"
+//! [11]
+
+
+//! [12]
+x = QByteArray("free")
+y = QByteArray("dom");
+x += y
+# x == "freedom"
+//! [12]
+
+
+//! [13]
+QByteArray().isNull() # returns true
+QByteArray("").isNull() # returns false
+QByteArray("abc").isNull() # returns false
+//! [13]
+
+
+//! [14]
+ba = QByteArray("Istambul")
+ba.fill('o')
+# ba == "oooooooo"
+
+ba.fill('X', 2)
+# ba == "XX"
+//! [14]
+
+
+//! [15]
+x = QByteArray("ship")
+y = QByteArray("air")
+x.prepend(y)
+# x == "airship"
+//! [15]
+
+
+//! [16]
+x = QByteArray("free")
+y = QByteArray("dom")
+x.append(y)
+# x == "freedom"
+//! [16]
+
+
+//! [17]
+ba = QByteArray("Meal")
+ba.insert(1, QByteArray("ontr"))
+# ba == "Montreal"
+//! [17]
+
+
+//! [18]
+ba = QByteArray("Montreal")
+ba.remove(1, 4)
+# ba == "Meal"
+//! [18]
+
+
+//! [19]
+x = QByteArray("Say yes!")
+y = QByteArray("no")
+x.replace(4, 3, y)
+# x == "Say no!"
+//! [19]
+
+
+//! [20]
+ba = QByteArray("colour behaviour flavour neighbour")
+ba.replace(QByteArray("ou"), QByteArray("o"))
+# ba == "color behavior flavor neighbor"
+//! [20]
+
+
+//! [21]
+x = QByteArray("sticky question")
+y = QByteArray("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]
+ba = QByteArray("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]
+x = QByteArray("crazy azimuths")
+y = QByteArray("azy")
+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]
+ba = QByteArray("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]
+url = QByteArray("ftp://ftp.trolltech.com/")
+if url.startsWith("ftp:"):
+ ...
+//! [25]
+
+
+//! [26]
+url = QByteArray("http://qtsoftware.com/index.html")
+if url.endsWith(".html"):
+ ...
+//! [26]
+
+
+//! [27]
+x = QByteArray("Pineapple")
+y = x.left(4)
+# y == "Pine"
+//! [27]
+
+
+//! [28]
+x = QByteArray("Pineapple")
+y = x.right(5)
+# y == "apple"
+//! [28]
+
+
+//! [29]
+x = QByteArray("Five pineapples")
+y = x.mid(5, 4) # y == "pine"
+z = x.mid(5) # z == "pineapples"
+//! [29]
+
+
+//! [30]
+x = QByteArray("TROlltECH")
+y = x.toLower()
+# y == "trolltech"
+//! [30]
+
+
+//! [31]
+x = QByteArray("TROlltECH")
+y = x.toUpper()
+# y == "TROLLTECH"
+//! [31]
+
+
+//! [32]
+ba = QByteArray(" lots\t of\nwhitespace\r\n ")
+ba = ba.simplified()
+# ba == "lots of whitespace";
+//! [32]
+
+
+//! [33]
+ba = QByteArray(" lots\t of\nwhitespace\r\n ");
+ba = ba.trimmed();
+# ba == "lots\t of\nwhitespace";
+//! [33]
+
+
+//! [34]
+x = QByteArray("apple")
+y = x.leftJustified(8, '.') # y == "apple..."
+//! [34]
+
+
+//! [35]
+x = QByteArray("apple")
+y = x.rightJustified(8, '.') # y == "...apple"
+//! [35]
+
+
+//! [36]
+string = QByteArray("FF")
+(hex, ok) = string.toInt(16) # hex == 255, ok == true
+(dec, ok) = string.toInt(10) # dec == 0, ok == false
+//! [36]
+
+
+//! [37]
+string = QByteArray("FF")
+(hex, ok) = str.toLong(16); # hex == 255, ok == true
+(dec, ok) = str.toLong(10); # dec == 0, ok == false
+//! [37]
+
+
+//! [38]
+string = QByteArray("1234.56")
+(a, ok) = string.toDouble() # a == 1234.56, ok == true
+//! [38]
+
+
+//! [39]
+text = QByteArray("Qt is great!")
+text.toBase64() # returns "UXQgaXMgZ3JlYXQh"
+//! [39]
+
+
+//! [40]
+ba = QByteArray()
+n = 63
+ba.setNum(n) # ba == "63"
+ba.setNum(n, 16) # ba == "3f"
+//! [40]
+
+
+//! [41]
+n = 63;
+QByteArray.number(n) # returns "63"
+QByteArray.number(n, 16) # returns "3f"
+QByteArray.number(n, 16).toUpper() # returns "3F"
+//! [41]
+
+
+//! [42]
+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]
+text = QByteArray.fromBase64("UXQgaXMgZ3JlYXQh")
+text.data() # returns "Qt is great!"
+//! [44]
+
+
+//! [45]
+text = QByteArray.fromHex("517420697320677265617421")
+text.data() # returns "Qt is great!"
+//! [45]
+
+}
+
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qdatetime.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qdatetime.cpp
new file mode 100644
index 000000000..b935e34a6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qdatetime.cpp
@@ -0,0 +1,106 @@
+//! [0]
+d1 = QDate(1995, 5, 17) # May 17, 1995
+d2 = QDate(1995, 5, 20) # May 20, 1995
+d1.daysTo(d2) # returns 3
+d2.daysTo(d1) # returns -3
+//! [0]
+
+
+//! [1]
+date = QDate.fromString("1MM12car2003", "d'MM'MMcaryyyy")
+# date is 1 December 2003
+//! [1]
+
+
+//! [2]
+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]
+n = QTime(14, 0, 0) # n == 14:00:00
+t = QTime()
+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]
+time = QTime.fromString("1mm12car00", "m'mm'hcarss")
+# time is 12:01.00
+//! [6]
+
+
+//! [7]
+time = QTime.fromString("00:710", "hh:ms") # invalid
+//! [7]
+
+
+//! [8]
+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]
+t = QTime()
+t.start()
+some_lengthy_task()
+print ("Time elapsed: %d ms" % t.elapsed())
+//! [10]
+
+
+//! [11]
+now = QDateTime.currentDateTime()
+xmas(QDate(now.date().year(), 12, 25), QTime(0, 0))
+print("There are %d seconds to Christmas" % now.secsTo(xmas))
+//! [11]
+
+
+//! [12]
+time1 = QTime.fromString("131", "HHh")
+# time1 is 13:00:00
+time1 = QTime.fromString("1apA", "1amAM")
+# time1 is 01:00:00
+
+dateTime2 = QDateTime.fromString("M1d1y9800:01:02",
+ "'M'M'd'd'y'yyhh:mm:ss")
+# dateTime is 1 January 1998 00:01:02
+//! [12]
+
+
+//! [13]
+dateTime = QDateTime.fromString("130", "Mm") # invalid
+//! [13]
+
+
+//! [14]
+dateTime = QDateTime.fromString("1.30.1", "M.d.s")
+# dateTime is January 30 in 1900 at 00:00:01.
+//! [14]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qhash.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qhash.cpp
new file mode 100644
index 000000000..05f6eb306
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qhash.cpp
@@ -0,0 +1,259 @@
+//! [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/codesnippets/doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp
new file mode 100644
index 000000000..3d63b2cb0
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp
@@ -0,0 +1,164 @@
+//! [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/codesnippets/doc/src/snippets/code/src_corelib_tools_qlistdata.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qlistdata.cpp
new file mode 100644
index 000000000..7d75e1be2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qlistdata.cpp
@@ -0,0 +1,227 @@
+//! [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<double> set;
+set << 20.0 << 30.0 << 40.0 << ... << 70.0;
+
+QList<double> list = QList<double>::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/codesnippets/doc/src/snippets/code/src_corelib_tools_qlocale.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qlocale.cpp
new file mode 100644
index 000000000..6fedb1f67
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qlocale.cpp
@@ -0,0 +1,48 @@
+//! [0]
+egyptian = QLocale(QLocale.Arabic, QLocale.Egypt)
+s1 = egyptian.toString(1.571429E+07, 'e')
+s2 = egyptian.toString(10)
+
+(d, ok) = egyptian.toDouble(s1)
+(i, ok) = egyptian.toInt(s2)
+//! [0]
+
+
+//! [1]
+QLocale.setDefault(QLocale(QLocale.Hebrew, QLocale.Israel))
+hebrew = QLocale() # Constructs a default QLocale
+s1 = hebrew.toString(15714.3, 'e')
+
+QLocale.setDefault(QLocale(QLocale.C))
+(d, ok) = QString("1234,56").toDouble() # ok == false
+(d, ok) = QString("1234.56").toDouble() # ok == true, d == 1234.56
+
+QLocale.setDefault(QLocale(QLocale.German))
+(d, ok) = QString("1234,56").toDouble() # ok == true, d == 1234.56
+(d, ok) = QString("1234.56").toDouble() # ok == true, d == 1234.56
+
+QLocale.setDefault(QLocale(QLocale.English, QLocale.UnitedStates))
+string = QString("%1 %L2 %L3").arg(12345).arg(12345).arg(12345, 0, 16)
+# string == "12345 12,345 3039"
+//! [1]
+
+
+//! [2]
+korean = QLocale("ko")
+swiss = QLocale("de_CH")
+//! [2]
+
+
+//! [3]
+c = QLocale(QLocale.C)
+(d, ok) = c.toDouble( "1234.56" ) # ok == true, d == 1234.56
+(d, ok) = c.toDouble( "1,234.56" ) # ok == true, d == 1234.56
+(d, ok) = c.toDouble( "1234,56" ) # ok == false
+
+german = QLocale(QLocale.German)
+(d, ok) = german.toDouble( "1234,56" ) # ok == true, d == 1234.56
+(d, ok) = german.toDouble( "1.234,56" ) # ok == true, d == 1234.56
+(d, ok) = german.toDouble( "1234.56" ) # ok == false
+
+(d, ok) = german.toDouble( "1.234" ) # ok == true, d == 1234.0
+//! [3]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qmap.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qmap.cpp
new file mode 100644
index 000000000..924ed2288
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qmap.cpp
@@ -0,0 +1,273 @@
+//! [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/codesnippets/doc/src/snippets/code/src_corelib_tools_qpoint.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qpoint.cpp
new file mode 100644
index 000000000..9921f16c4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qpoint.cpp
@@ -0,0 +1,111 @@
+//! [0]
+p = QPoint()
+
+p.setX(p.x() + 1)
+p += QPoint(1, 0)
+//! [0]
+
+
+//! [1]
+p = QPoint(1, 2)
+#p.rx()--; // p becomes (0, 2)
+//! [1]
+
+
+//! [2]
+p = QPoint(1, 2)
+#p.ry()++; // p becomes (1, 3)
+//! [2]
+
+
+//! [3]
+p = QPoint( 3, 7)
+q = QPoint(-1, 4)
+p += q # p becomes (2, 11)
+//! [3]
+
+
+//! [4]
+p = QPoint( 3, 7)
+q = QPoint(-1, 4)
+p -= q # p becomes (4, 3)
+//! [4]
+
+
+//! [5]
+p = QPoint(-1, 4)
+p *= 2.5 # p becomes (-3, 10)
+//! [5]
+
+
+//! [6]
+p = QPoint(-3, 10)
+p /= 2.5 # p becomes (-1, 4)
+//! [6]
+
+
+//! [7]
+
+class MyWidget(QWidget):
+
+ self.oldPosition = QPointer()
+
+ # event : QMouseEvent
+ def mouseMoveEvent(QMouseEvent event):
+ point = event.pos() - self.oldPosition
+ if (point.manhattanLength() > 3):
+ # the mouse has moved more than 3 pixels since the oldPosition
+ pass
+//! [7]
+
+
+//! [8]
+trueLength = sqrt(pow(x(), 2) + pow(y(), 2))
+//! [8]
+
+
+//! [9]
+p = QPointF()
+
+p.setX(p.x() + 1.0)
+p += QPointF(1.0, 0.0)
+#p.rx()++;
+//! [9]
+
+
+//! [10]
+ p = QPointF(1.1, 2.5)
+ #p.rx()--; // p becomes (0.1, 2.5)
+//! [10]
+
+
+//! [11]
+p = QPointF(1.1, 2.5)
+#p.ry()++; // p becomes (1.1, 3.5)
+//! [11]
+
+
+//! [12]
+p = QPointF( 3.1, 7.1)
+q = QPointF(-1.0, 4.1)
+p += q # p becomes (2.1, 11.2)
+//! [12]
+
+
+//! [13]
+p = QPointF( 3.1, 7.1)
+q = QPointF(-1.0, 4.1)
+p -= q # p becomes (4.1, 3.0)
+//! [13]
+
+
+//! [14]
+p = QPointF(-1.1, 4.1)
+p *= 2.5 # p becomes (-2.75, 10.25)
+//! [14]
+
+
+//! [15]
+p = QPointF(-2.75, 10.25)
+p /= 2.5 # p becomes (-1.1, 4.1)
+//! [15]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qqueue.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qqueue.cpp
new file mode 100644
index 000000000..da4c4a644
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qqueue.cpp
@@ -0,0 +1,8 @@
+//! [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/codesnippets/doc/src/snippets/code/src_corelib_tools_qrect.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qrect.cpp
new file mode 100644
index 000000000..1dced9f67
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qrect.cpp
@@ -0,0 +1,10 @@
+//! [0]
+r1 = QRect(100, 200, 11, 16)
+r2 = QRect(QPoint(100, 200), QSize(11, 16))
+//! [0]
+
+
+//! [1]
+r1 = QRectF(100, 200, 11, 16)
+r2 = QRectF(QPoint(100, 200), QSize(11, 16))
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qregexp.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qregexp.cpp
new file mode 100644
index 000000000..c6f9a9dbc
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qregexp.cpp
@@ -0,0 +1,175 @@
+//! [0]
+rx = QRegExp("(\\d+)")
+txt = "Offsets: 12 14 99 231 7"
+lst = []
+
+pos = rx.indexIn(txt, 0)
+
+while pos != -1:
+ lst.append(rx.cap(1))
+ pos += rx.matchedLength()
+ pos = rx.indexIn(txt, pos)
+
+# lst: ["12", "14", "99", "231", "7"]
+//! [0]
+
+
+//! [1]
+rx = QRegExp("*.txt")
+rx.setPatternSyntax(QRegExp.Wildcard)
+rx.exactMatch("README.txt") # returns True
+rx.exactMatch("welcome.txt.bak") # returns False
+//! [1]
+
+
+//! [2]
+rx = QRegExp("ro+m")
+rx.setMinimal(True)
+//! [2]
+
+
+//! [3]
+mark = QRegExp("\\b" # word boundary
+ "[Mm]ark" # the word we want to match
+ )
+//! [3]
+
+
+//! [4]
+rx = QRegExp("^\\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]
+rx = QRegExp("^\\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]
+rx = QRegExp("\\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]
+captured = rx.cap(1) # captured == "letter"
+//! [7]
+
+
+//! [8]
+rx = QRegExp("&(?!amp;)") # match ampersands but not &amp;
+line1 = QString("This & that")
+line1.replace(rx, "&amp;") # line1 == "This &amp; that"
+line2 = QString("His &amp; hers & theirs")
+line2.replace(rx, "&amp;") # line2 == "His &amp; hers &amp; theirs"
+//! [8]
+
+
+//! [9]
+txt = QString("One Eric another Eirik, and an Ericsson. How many Eiriks, Eric?")
+rx = QRegExp("\\b(Eric|Eirik)\\b") # match Eric or Eirik
+pos = 0 # where we are in the string
+count = 0 # how many Eric and Eirik's we've counted
+
+while pos >= 0:
+ pos = rx.indexIn(txt, pos)
+ if pos >= 0:
+ pos += 1 # move along in str
+ count += 1 # count our Eric or Eirik
+//! [9]
+
+
+//! [10]
+txt = "Nokia Corporation and/or its subsidiary(-ies)\tqtsoftware.com\tNorway"
+rx.setPattern("^([^\t]+)\t([^\t]+)\t([^\t]+)$");
+if rx.indexIn(txt) != -1:
+ company = rx.cap(1)
+ web = rx.cap(2)
+ country = rx.cap(3)
+//! [10]
+
+
+//! [11]
+field = txt.split("\t")
+//! [11]
+
+
+//! [12]
+rx = QRegExp("*.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]
+txt = QString("offsets: 1.23 .50 71.00 6.00")
+rx = QRegExp("\\d*\\.\\d+") # primitive floating point matching
+count = 0
+pos = rx.indexIn(txt, 0)
+while pos != -1:
+ count += 1
+ pos += rx.matchedLength()
+ pos = rx.indexIn(txt, pos)
+
+# pos will be 9, 14, 18 and finally 24; count will end up as 4
+//! [13]
+
+
+//! [14]
+rx = QRegExp("(\\d+)(\\s*)(cm|inch(es)?)")
+pos = rx.indexIn("Length: 36 inches")
+lst = rx.capturedTexts()
+# lst is now ("36 inches", "36", " ", "inches", "es")
+//! [14]
+
+
+//! [15]
+rx = QRegExp("(\\d+)(?:\\s*)(cm|inch(?:es)?)")
+pos = rx.indexIn("Length: 36 inches")
+lst = rx.capturedTexts()
+# lst is now ("36 inches", "36", "inches")
+//! [15]
+
+
+//! [16]
+for a in rx.capturedTexts():
+ myProcessing(a)
+//! [16]
+
+
+//! [17]
+rxlen = QRegExp("(\\d+)(?:\\s*)(cm|inch)")
+pos = rxlen.indexIn("Length: 189cm")
+if pos > -1:
+ value = rxlen.cap(1) # "189"
+ unit = rxlen.cap(2) # "cm"
+//! [17]
+
+
+//! [18]
+rx = QRegExp("/([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]
+rx = QRegExp("(" + QRegExp.escape(name) + "|" + QRegExp.escape(alias) + ")")
+//! [20]
+
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qsize.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qsize.cpp
new file mode 100644
index 000000000..e75e7b15f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qsize.cpp
@@ -0,0 +1,96 @@
+//! [0]
+t1 = QSize(10, 12)
+t1.scale(60, 60, Qt.IgnoreAspectRatio)
+# t1 is (60, 60)
+
+t2 = QSize(10, 12)
+t2.scale(60, 60, Qt.KeepAspectRatio)
+# t2 is (50, 60)
+
+t3 = QSize(10, 12)
+t3.scale(60, 60, Qt.KeepAspectRatioByExpanding)
+# t3 is (60, 72)
+//! [0]
+
+
+//! [1]
+size = QSize(100, 10)
+size.rwidth() += 20
+
+#size becomes (120,10)
+//! [1]
+
+
+//! [2]
+size = QSize(100, 10)
+size.rheight() += 5
+
+# size becomes (100,15)
+//! [2]
+
+
+//! [3]
+s = QSize( 3, 7)
+r = QSize(-1, 4)
+s += r
+
+# s becomes (2,11)
+//! [3]
+
+
+//! [4]
+s = QSize( 3, 7)
+r = QSize(-1, 4)
+s -= r
+
+# s becomes (4,3)
+//! [4]
+
+
+//! [5]
+t1 = QSizeF(10, 12)
+t1.scale(60, 60, Qt.IgnoreAspectRatio)
+# t1 is (60, 60)
+
+t2 = QSizeF(10, 12)
+t2.scale(60, 60, Qt.KeepAspectRatio)
+# t2 is (50, 60)
+
+t3 = QSizeF(10, 12)
+t3.scale(60, 60, Qt.KeepAspectRatioByExpanding)
+# t3 is (60, 72)
+//! [5]
+
+
+//! [6]
+size = QSizeF(100.3, 10)
+size.rwidth() += 20.5
+
+# size becomes (120.8,10)
+//! [6]
+
+
+//! [7]
+size = QSizeF(100, 10.2)
+size.rheight() += 5.5
+
+# size becomes (100,15.7)
+//! [7]
+
+
+//! [8]
+s = QSizeF( 3, 7)
+r = QSizeF(-1, 4)
+s += r
+
+# s becomes (2,11)
+//! [8]
+
+
+//! [9]
+s = QSizeF( 3, 7)
+r = QSizeF(-1, 4)
+s -= r
+
+# s becomes (4,3)
+//! [9]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qstring.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qstring.cpp
new file mode 100644
index 000000000..6637290de
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qstring.cpp
@@ -0,0 +1,45 @@
+//! [0]
+DEFINES += QT_NO_CAST_FROM_ASCII \
+ QT_NO_CAST_TO_ASCII
+//! [0]
+
+
+//! [1]
+url = QLatin1String("http://www.unicode.org/")
+//! [1]
+
+
+//! [2]
+d = 12.34;
+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]
+label = QLabel(QLatin1String("MOD"), self)
+//! [6]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qtimeline.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qtimeline.cpp
new file mode 100644
index 000000000..5f2e97853
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qtimeline.cpp
@@ -0,0 +1,15 @@
+//! [0]
+...
+progressBar = QProgressBar(self)
+progressBar.setRange(0, 100)
+
+# Construct a 1-second timeline with a frame range of 0 - 100
+timeLine = QTimeLine(1000, self)
+timeLine.setFrameRange(0, 100)
+QObject.connect(timeLine, SIGNAL("frameChanged(int)"), progressBar, SLOT("setValue(int)"))
+
+# Clicking the push button will start the progress bar animation
+pushButton = QPushButton(QObject.tr("Start animation"), self)
+QObject.connect(pushButton, SIGNAL("clicked()"), timeLine, SLOT("start()"))
+...
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qvector.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qvector.cpp
new file mode 100644
index 000000000..bbe7ca288
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qvector.cpp
@@ -0,0 +1,143 @@
+//! [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/codesnippets/doc/src/snippets/code/src_corelib_xml_qxmlstream.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_xml_qxmlstream.cpp
new file mode 100644
index 000000000..59223dc44
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_xml_qxmlstream.cpp
@@ -0,0 +1,27 @@
+//! [0]
+xml = QXmlStreamReader()
+...
+while not 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/codesnippets/doc/src/snippets/code/src_gui_accessible_qaccessible.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_accessible_qaccessible.cpp
new file mode 100644
index 000000000..1c57954cd
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_accessible_qaccessible.cpp
@@ -0,0 +1,7 @@
+//! [0]
+child = QAccessibleInterface()
+targetChild = object.navigate(Accessible.Child, 1, child)
+if child:
+ # ...
+ del child
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qabstractprintdialog.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qabstractprintdialog.cpp
new file mode 100644
index 000000000..02e21f1e6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qabstractprintdialog.cpp
@@ -0,0 +1,5 @@
+//! [0]
+printDialog = QPrintDialog(printer, parent)
+if printDialog.exec_() == QDialog.Accepted:
+ # print ...
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp
new file mode 100644
index 000000000..51c03c59a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp
@@ -0,0 +1,86 @@
+//! [0]
+fileName = QFileDialog.getOpenFileName(self,
+ 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]
+dialog = QFileDialog(self)
+dialog.setFileMode(QFileDialog.AnyFile)
+//! [2]
+
+
+//! [3]
+dialog.setNameFilter(tr("Images (*.png *.xpm *.jpg)"))
+//! [3]
+
+
+//! [4]
+dialog.setViewMode(QFileDialog.Detail)
+//! [4]
+
+
+//! [5]
+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]
+filters = QStringList()
+filters << "Image files (*.png *.xpm *.jpg)"
+ << "Text files (*.txt)"
+ << "Any files (*)"
+
+dialog = QFileDialog(this)
+dialog.setNameFilters(filters)
+dialog.exec_()
+//! [7]
+
+
+//! [8]
+fileName = QFileDialog.getOpenFileName(self, tr("Open File"),
+ "/home",
+ tr("Images (*.png *.xpm *.jpg)"))
+//! [8]
+
+
+//! [9]
+files = QFileDialog.getOpenFileNames(self,
+ "Select one or more files to open",
+ "/home",
+ "Images (*.png *.xpm *.jpg)")
+//! [9]
+
+
+//! [10]
+for it in list:
+ myProcessing(it)
+ it++
+//! [10]
+
+
+//! [11]
+fileName = QFileDialog.getSaveFileName(self, tr("Save F:xile"),
+ "/home/jana/untitled.png",
+ tr("Images (*.png *.xpm *.jpg)"))
+//! [11]
+
+
+//! [12]
+dir = QFileDialog.getExistingDirectory(self, tr("Open Directory"),
+ "/home",
+ QFileDialog.ShowDirsOnly
+ | QFileDialog.DontResolveSymlinks)
+//! [12]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp
new file mode 100644
index 000000000..1516988d4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp
@@ -0,0 +1,40 @@
+//! [0]
+
+(ok, font) = QFontDialog.getFont(QFont("Helvetica [Cronyx]", 10), self)
+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]
+(ok, font) = QFontDialog.getFont(QFont("Times", 12), self)
+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]
+
+(ok, font) = QFontDialog.getFont(self)
+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/codesnippets/doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp
new file mode 100644
index 000000000..8bc2f347b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp
@@ -0,0 +1,102 @@
+//! [0]
+ret = QMessageBox.warning(self, self.tr("My Application"),
+ self.tr("The document has been modified.\n" + \
+ "Do you want to save your changes?"),
+ QMessageBox.Save | QMessageBox.Discard
+ | QMessageBox.Cancel,
+ QMessageBox.Save)
+//! [0]
+
+
+//! [1]
+msgBox = QMessageBox()
+msgBox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
+result = msgBox.exec_()
+
+if result == QMessageBox.Yes:
+ # yes was clicked
+elif result == QMessageBox.No:
+ # no was clicked
+else:
+ # should never be reached
+//! [1]
+
+
+//! [2]
+msgBox = QMessageBox()
+connectButton = msgBox.addButton(self.tr("Connect"), QMessageBox.ActionRole)
+abortButton = msgBox.addButton(QMessageBox.Abort)
+
+msgBox.exec_()
+
+if msgBox.clickedButton() == connectButton:
+ # connect
+elif msgBox.clickedButton() == abortButton:
+ # abort
+}
+//! [2]
+
+
+//! [3]
+messageBox = QMessageBox(self)
+disconnectButton = messageBox.addButton(self.tr("Disconnect"),
+ QMessageBox.ActionRole)
+...
+messageBox.exec_()
+if messageBox.clickedButton() == disconnectButton:
+ ...
+
+//! [3]
+
+
+//! [4]
+#include <QApplication>
+#include <QMessageBox>
+
+int main(int argc, char *argv[])
+{
+# Not Supported by PySide
+ QT_REQUIRE_VERSION(argc, argv, "4.0.2")
+
+ QApplication app(argc, argv);
+ ...
+ return app.exec();
+}
+//! [4]
+
+//! [5]
+msgBox = QMessageBox()
+msgBox.setText("The document has been modified.")
+msgBox.exec_()
+//! [5]
+
+//! [6]
+msgBox = QMessageBox()
+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)
+ret = msgBox.exec_()
+//! [6]
+
+//! [7]
+
+if ret == QMessageBox.Save:
+ # Save was clicked
+elif ret == QMessageBox.Discard:
+ # Don't save was clicked
+elif ret == QMessageBox.Cancel:
+ # cancel was clicked
+else:
+ # should never be reached
+
+//! [7]
+
+//! [9]
+msgBox = QMessageBox(self)
+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/codesnippets/doc/src/snippets/code/src_gui_dialogs_qwizard.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qwizard.cpp
new file mode 100644
index 000000000..0d46ee55c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qwizard.cpp
@@ -0,0 +1,31 @@
+//! [0]
+def nextId(self):
+ id = self.currentId()
+ if id == Page_Intro:
+ if field("intro.evaluate").toBool():
+ return Page_Evaluate
+ else:
+ return Page_Register
+ elif id == Page_Evaluate:
+ return Page_Conclusion
+ elif id == Page_Register:
+ if field("register.upgradeKey").toString().isEmpty():
+ return Page_Details
+ else:
+ return Page_Conclusion
+ elif id == Page_Details:
+ return Page_Conclusion
+ else:
+ return -1
+//! [0]
+
+
+//! [1]
+class MyWizard(QWizard):
+ def __init__(self, parent):
+ QWizard.__ini__(self, parent)
+ ...
+ layout = [QWizard.Stretch, QWizard.BackButton, QWizard.CancelButton, QWizard.NextButton, QWizard.FinishButton]
+ setButtonLayout(layout);
+ ...
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsgridlayout.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsgridlayout.cpp
new file mode 100644
index 000000000..829b9bec5
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsgridlayout.cpp
@@ -0,0 +1,13 @@
+//! [0]
+scene = QGraphicsScene()
+textEdit = scene.addWidget(QTextEdit())
+pushButton = scene.addWidget(QPushButton())
+
+layout = QGraphicsGridLayout()
+layout.addItem(textEdit, 0, 0)
+layout.addItem(pushButton, 0, 1)
+
+form = QGraphicsWidget()
+form.setLayout(layout)
+scene.addItem(form)
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp
new file mode 100644
index 000000000..1f1ff39ae
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp
@@ -0,0 +1,185 @@
+//! [0]
+class SimpleItem(QGraphicsItem):
+
+ def boundingRect(self):
+ penWidth = 1.0
+ return QRectF(-10 - penWidth / 2, -10 - penWidth / 2,
+ 20 + penWidth, 20 + penWidth)
+
+ def paint(self, painter, option, widget):
+ painter.drawRoundedRect(-10, -10, 20, 20, 5, 5)
+//! [0]
+
+
+//! [1]
+class CustomItem(QGraphicsItem):
+ ...
+ self.Type = QGraphicsItem.UserType + 1
+
+ def type(self):
+ # Enable the use of qgraphicsitem_cast with this item.
+ return self.Type
+ ...
+
+//! [1]
+
+
+//! [2]
+item.setCursor(Qt.IBeamCursor)
+//! [2]
+
+
+//! [3]
+item.setCursor(Qt.IBeamCursor)
+//! [3]
+
+
+//! [4]
+rect = QGraphicsRectItem()
+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]
+rect = QGraphicsRectItem()
+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]
+def boundingRect(self):
+ penWidth = 1.0
+ return QRectF(-radius - penWidth / 2, -radius - penWidth / 2,
+ diameter + penWidth, diameter + penWidth)
+//! [8]
+
+
+//! [9]
+def shape(self):
+ path = QPainterPath()
+ path.addEllipse(boundingRect())
+ return path
+//! [9]
+
+
+//! [10]
+def paint(self, painter, option, widget):
+ painter.drawRoundedRect(-10, -10, 20, 20, 5, 5)
+//! [10]
+
+
+//! [11]
+ObjectName = 0;
+
+item = scene.itemAt(100, 50)
+if item.data(ObjectName).toString().isEmpty():
+ if isinstance(ButtonItem, item):
+ item.setData(ObjectName, "Button")
+//! [11]
+
+
+//! [12]
+scene = QGraphicsScene()
+ellipse = scene.addEllipse(QRectF(-10, -10, 20, 20))
+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]
+def contextMenuEvent(self, event):
+ menu = QMenu()
+ removeAction = menu.addAction("Remove")
+ markAction = menu.addAction("Mark")
+ selectedAction = menu.exec(event.screenPos())
+ // ...
+//! [13]
+
+
+//! [14]
+def __init__(self):
+ self.setAcceptDrops(true)
+ ...
+
+def dragEnterEvent(self, event):
+ event.setAccepted(event.mimeData().hasFormat("text/plain"))
+//! [14]
+
+
+//! [15]
+def itemChange(self, change, value):
+ if change == ItemPositionChange && scene():
+ # value is the new position.
+ newPos = value.toPointF()
+ 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(self, change, value)
+//! [15]
+
+
+//! [16]
+def setRadius(self, newRadius):
+ if radius != newRadius:
+ prepareGeometryChange()
+ radius = newRadius
+//! [16]
+
+
+//! [17]
+# Group all selected items together
+group = scene.createItemGroup(scene.selecteditems())
+
+# Destroy the group, and delete the group item
+scene.destroyItemGroup(group)
+//! [17]
+
+
+//! [QGraphicsItem type]
+class CustomItem(QGraphicsItem):
+ ...
+ self.Type = QGraphicsItem.UserType + 1
+
+ def type(self):
+ # Enable the use of qgraphicsitem_cast with this item.
+ return self.Type
+ ...
+//! [QGraphicsItem type]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicslinearlayout.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicslinearlayout.cpp
new file mode 100644
index 000000000..b8356ab23
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicslinearlayout.cpp
@@ -0,0 +1,13 @@
+//! [0]
+scene = QGraphicsScene()
+textEdit = scene.addWidget(QTextEdit())
+pushButton = scene.addWidget(QPushButton())
+
+layout = QGraphicsLinearLayout()
+layout.addItem(textEdit)
+layout.addItem(pushButton)
+
+form = QGraphicsWidget()
+form.setLayout(layout)
+scene.addItem(form)
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp
new file mode 100644
index 000000000..e66031094
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp
@@ -0,0 +1,46 @@
+//! [0]
+import sys
+
+QApplication app(sys.argv)
+
+tabWidget = QTabWidget()
+
+scene = QGraphicsScene()
+proxy = scene.addWidget(tabWidget)
+
+view = QGraphicsView(scene)
+view.show()
+
+return app.exec_()
+//! [0]
+
+//! [1]
+groupBox = QGroupBox("Contact Details")
+numberLabel = QLabel("Telephone number")
+numberEdit = QLineEdit()
+
+layout = QFormLayout()
+layout.addRow(numberLabel, numberEdit)
+groupBox.setLayout(layout)
+
+scene = QGraphicsScene()
+proxy = scene.addWidget(groupBox)
+
+view = QGraphicsView(scene)
+view.show()
+//! [1]
+
+//! [2]
+scene = QGraphicsScene()
+
+edit = QLineEdit()
+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/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp
new file mode 100644
index 000000000..6f251779b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp
@@ -0,0 +1,75 @@
+//! [0]
+scene = QGraphicsScene()
+scene.addText("Hello, world!")
+
+view = QGraphicsView(&scene)
+view.show()
+//! [0]
+
+
+//! [1]
+scene = QGraphicsScene
+scene.addItem(...
+...
+printer = QPrinter(QPrinter.HighResolution)
+printer.setPaperSize(QPrinter.A4)
+
+painter = QPainter(printer)
+scene.render(&painter)
+//! [1]
+
+
+//! [2]
+segmentSize = sceneRect().size() / math.pow(2, depth - 1)
+//! [2]
+
+
+//! [3]
+scene = QGraphicsScene()
+view = QGraphicsView(scene)
+view.show()
+
+# a blue background
+scene.setBackgroundBrush(Qt.blue)
+
+# a gradient background
+gradient = QRadialGradient(0, 0, 10)
+gradient.setSpread(QGradient.RepeatSpread)
+scene.setBackgroundBrush(gradient)
+//! [3]
+
+
+//! [4]
+scene = QGraphicsScene()
+view = QGraphicsView(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]
+class TileScene (QGraphicsScene):
+ # ...
+ def rectForTile(x, y):
+ # Return the rectangle for the tile at position (x, y).
+ return QRectF(x * self.tileWidth, y * self.tileHeight, self.tileWidth, self.tileHeight)
+
+ def setTile(x, y, pixmap):
+ # Sets or replaces the tile at position (x, y) with pixmap.
+ if x >= 0 && x < self.numTilesH && y >= 0 && y < self.numTilesV:
+ self.tiles[y][x] = pixmap
+ invalidate(rectForTile(x, y), BackgroundLayer)
+
+ def drawBackground(painter, exposed):
+ # Draws all tiles that intersect the exposed area.
+ for y in range(0, self.numTilesV:
+ for x in range(0, self.numTilesH:
+ rect = rectForTile(x, y)
+ if exposed.intersects(rect):
+ painter.drawPixmap(rect.topLeft(), tiles[y][x])
+//! [5]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicssceneevent.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicssceneevent.cpp
new file mode 100644
index 000000000..f60c12c98
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicssceneevent.cpp
@@ -0,0 +1,5 @@
+//! [0]
+
+setDropAction(proposedAction())
+
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp
new file mode 100644
index 000000000..e753462f1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp
@@ -0,0 +1,86 @@
+//! [0]
+scene = QGraphicsScene()
+scene.addText("Hello, world!")
+
+view = QGraphicsView(scene)
+view.show()
+//! [0]
+
+
+//! [1]
+scene = QGraphicsScene()
+scene.addRect(QRectF(-10, -10, 20, 20))
+
+view = QGraphicsView(scene)
+view.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform)
+view.show()
+//! [1]
+
+
+//! [2]
+view = QGraphicsView()
+view.setBackgroundBrush(QImage(":/images/backgroundtile.png"))
+view.setCacheMode(QGraphicsView.CacheBackground)
+//! [2]
+
+
+//! [3]
+scene = QGraphicsScene()
+scene.addText("GraphicsView rotated clockwise")
+
+view = QGraphicsView(scene)
+view.rotate(90) # the text is rendered with a 90 degree clockwise rotation
+view.show()
+//! [3]
+
+
+//! [4]
+scene = QGraphicsScene()
+scene.addItem(...
+...
+
+view = QGraphicsView(scene)
+view.show()
+...
+
+printer = QPrinter(QPrinter.HighResolution)
+printer.setPageSize(QPrinter.A4)
+painter = QPainter(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.
+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]
+def mousePressEvent(self, event):
+ print "There are", items(event->pos()).size(), "items at position", mapToScene(event->pos())
+//! [5]
+
+
+//! [6]
+def mousePressEvent(self, event):
+ if (item = itemAt(event.pos()):
+ print "You clicked on item", item
+ else:
+ print "You didn't click on an item."
+//! [6]
+
+
+//! [7]
+scene = QGraphicsScene()
+scene.addText("GraphicsView rotated clockwise")
+
+view = QGraphicsView(scene)
+view.rotate(90) # the text is rendered with a 90 degree clockwise rotation
+view.show()
+//! [7]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp
new file mode 100644
index 000000000..11caa467f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp
@@ -0,0 +1,25 @@
+//! [0]
+class MyGroupBoxWidget (QStyleOptionGroupBox):
+ # ...
+ def initStyleOption(option):
+ QGraphicsWidget.initStyleOption(self, option)
+ if isinstance(option, QStyleOptionGroupBox):
+ # 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/codesnippets/doc/src/snippets/code/src_gui_image_qbitmap.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_image_qbitmap.cpp
new file mode 100644
index 000000000..fa8317a1a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_image_qbitmap.cpp
@@ -0,0 +1,4 @@
+//! [0]
+uchar arrow_bits[] = { 0x3f, 0x1f, 0x0f, 0x1f, 0x3b, 0x71, 0xe0, 0xc0 };
+QBitmap bm(8, 8, arrow_bits, true);
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_image_qicon.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_image_qicon.cpp
new file mode 100644
index 000000000..5e8f1da4b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_image_qicon.cpp
@@ -0,0 +1,26 @@
+//! [0]
+button = QToolButton()
+button.setIcon(QIcon("open.xpm"))
+//! [0]
+
+
+//! [1]
+button.setIcon(QIcon())
+//! [1]
+
+
+//! [2]
+def drawIcon(self, painter, pos):
+ enabledStatus = QIcon.Normal
+ if !isEnabled():
+ enabledStatus = QIcon::Disabled
+
+ onOff = QIcon.On
+ if !isOn():
+ onOff = QIcon.Off
+
+ pixmap = icon.pixmap(QSize(22, 22),
+ enabledStatus,
+ onOff)
+ painter.drawPixmap(pos, pixmap)
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_image_qimage.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_image_qimage.cpp
new file mode 100644
index 000000000..8592a2d7e
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_image_qimage.cpp
@@ -0,0 +1,36 @@
+//! [0]
+image = QImage(3, 3, QImage.Format_RGB32)
+
+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]
+image = QImage(3, 3, QImage.Format_Indexed8)
+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]
+start_xpm = ["16 15 8 1", "a c #cec6bd", ....
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_image_qimagereader.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_image_qimagereader.cpp
new file mode 100644
index 000000000..01cd537d9
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_image_qimagereader.cpp
@@ -0,0 +1,25 @@
+//! [0]
+reader = QImageReader()
+reader.setFormat("png") # same as reader.setFormat("PNG")
+//! [0]
+
+
+//! [1]
+reader = QImageReader("image.png")
+# reader.format() == "png"
+//! [1]
+
+
+//! [2]
+icon = QImage(64, 64, QImage.Format_RGB32)
+reader = QImageReader("icon_64x64.bmp")
+if reader.read(icon):
+ # Display icon
+//! [2]
+
+
+//! [3]
+reader = QImageReader(":/image.png")
+if reader.supportsOption(QImageIOHandler.Size):
+ print "Size:", str(reader.size())
+//! [3]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_image_qimagewriter.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_image_qimagewriter.cpp
new file mode 100644
index 000000000..613b51e54
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_image_qimagewriter.cpp
@@ -0,0 +1,19 @@
+//! [0]
+writer = QImageWriter()
+writer.setFormat("png") # same as writer.setFormat("PNG")
+//! [0]
+
+
+//! [1]
+image = QImage("some/image.jpeg")
+writer = QImageWriter("images/outimage.png", "png")
+writer.setText("Author", "John Smith")
+writer.write(image)
+//! [1]
+
+
+//! [2]
+writer = QImageWriter(fileName)
+if writer.supportsOption(QImageIOHandler.Description):
+ writer.setText("Author", "John Smith")
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_image_qmovie.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_image_qmovie.cpp
new file mode 100644
index 000000000..e187add4b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_image_qmovie.cpp
@@ -0,0 +1,13 @@
+//! [0]
+label = QLabel()
+movie = QMovie("animations/fire.gif")
+
+label.setMovie(movie)
+movie.start()
+//! [0]
+
+
+//! [1]
+movie = QMovie("racecar.gif")
+movie.setSpeed(200) // 2x speed
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_image_qpixmap.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_image_qpixmap.cpp
new file mode 100644
index 000000000..baa533794
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_image_qpixmap.cpp
@@ -0,0 +1,12 @@
+//! [0]
+static const char * const start_xpm[]={
+ "16 15 8 1",
+ "a c #cec6bd",
+....
+//! [0]
+
+
+//! [1]
+myPixmap = QPixmap()
+myPixmap.setMask(myPixmap.createHeuristicMask())
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_image_qpixmapcache.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_image_qpixmapcache.cpp
new file mode 100644
index 000000000..fd9f42a31
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_image_qpixmapcache.cpp
@@ -0,0 +1,16 @@
+//! [0]
+pm = QPixmapCache.find("my_big_image")
+if not pm.isNull():
+ pm.load("bigimage.png")
+ QPixmapCache.insert("my_big_image", pm)
+painter.drawPixmap(0, 0, pm)
+//! [0]
+
+
+//! [1]
+pm = QPixmapCache.find("my_big_image")
+if not pm.isNull():
+ pm.load("bigimage.png")
+ QPixmapCache.insert("my_big_image", pm)
+painter.drawPixmap(0, 0, pm)
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_image_qpixmapfilter.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_image_qpixmapfilter.cpp
new file mode 100644
index 000000000..96a4752a0
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_image_qpixmapfilter.cpp
@@ -0,0 +1,22 @@
+//! [0]
+myFilter = QPixmapColorFilter()
+myFilter.setColor(QColor(128, 0, 0))
+myFilter.draw(painter, QPoint(0, 0), originalPixmap)
+//! [0]
+
+//! [1]
+myFilter = QPixmapConvolutionFilter()
+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.sdraw(painter, QPoint(0, 0), originalPixmap)
+//! [1]
+
+//! [2]
+myFilter = QPixmapDropShadowFilter()
+myFilter.draw(painter, QPoint(0, 0), originalPixmap)
+//! [2]
+
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qabstractitemview.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qabstractitemview.cpp
new file mode 100644
index 000000000..3d8bb660c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qabstractitemview.cpp
@@ -0,0 +1,17 @@
+//! [0]
+def resizeEvent(self, event):
+ horizontalScrollBar().setRange(0, realWidth - width())
+ ...
+//! [0]
+
+//! [1]
+setIndexWidget(index, QLineEdit())
+...
+setIndexWidget(index, QTextEdit())
+//! [1]
+
+//! [2]
+m = view->selectionModel()
+view->setModel(model())
+del m
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp
new file mode 100644
index 000000000..cfcb99a58
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp
@@ -0,0 +1,23 @@
+//! [0]
+mapper = QDataWidgetMapper
+mapper.setModel(model)
+mapper.addMapping(mySpinBox, 0)
+mapper.addMapping(myLineEdit, 1)
+mapper.addMapping(myCountryChooser, 2)
+mapper.toFirst()
+//! [0]
+
+
+//! [1]
+mapper = QDataWidgetMapper()
+mapper.setModel(myModel)
+mapper.addMapping(nameLineEdit, 0)
+mapper.addMapping(ageSpinBox, 1)
+//! [1]
+
+
+//! [2]
+mapper = QDataWidgetMapper()
+connect(myTableView.selectionModel(), SIGNAL("currentRowChanged(QModelIndex,QModelIndex)"),
+ mapper, SLOT(setCurrentModelIndex(QModelIndex)))
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qitemeditorfactory.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qitemeditorfactory.cpp
new file mode 100644
index 000000000..29601bfe3
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qitemeditorfactory.cpp
@@ -0,0 +1,23 @@
+//! [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/codesnippets/doc/src/snippets/code/src_gui_itemviews_qitemselectionmodel.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qitemselectionmodel.cpp
new file mode 100644
index 000000000..c245026ca
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qitemselectionmodel.cpp
@@ -0,0 +1,10 @@
+//! [0]
+selection = QItemSelection(topLeft, bottomRight)
+//! [0]
+
+
+//! [1]
+selection = QItemSelection()
+...
+selection.select(topLeft, bottomRight)
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp
new file mode 100644
index 000000000..8086919dc
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp
@@ -0,0 +1,37 @@
+//! [0]
+model = QStandardItemModel (4, 4)
+for row in range(4):
+ for column in range(4):
+ item = QStandardItem(QString("row %0, column %1").arg(row).arg(column))
+ model.setItem(row, column, item)
+//! [0]
+
+
+//! [1]
+model = QStandardItemModel()
+parentItem = model.invisibleRootItem()
+for i in range(4):
+ item = QStandardItem(QString("item %0").arg(i))
+ parentItem.appendRow(item)
+ parentItem = item
+//! [1]
+
+
+//! [2]
+treeView = QTreeView(self)
+treeView.setModel(myStandardItemModel)
+connect(treeView, SIGNAL('clicked(QModelIndex)')
+ this, SLOT('clicked(QModelIndex)'))
+//! [2]
+
+
+//! [3]
+def clicked(self, index):
+ item = myStandardItemModel.itemFromIndex(index)
+ # Do stuff with the item ...
+//! [3]
+
+
+//! [4]
+treeView.scrollTo(item.index())
+//! [4]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qtablewidget.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qtablewidget.cpp
new file mode 100644
index 000000000..2c89a5fed
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qtablewidget.cpp
@@ -0,0 +1,5 @@
+//! [0]
+setCellWidget(index, QLineEdit())
+...
+setCellWidget(index, QTextEdit())
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qtreewidget.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qtreewidget.cpp
new file mode 100644
index 000000000..c3311d060
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qtreewidget.cpp
@@ -0,0 +1,8 @@
+//! [0]
+treeWidget = QTreeWidget()
+treeWidget.setColumnCount(1)
+items = []
+for i in range(10):
+ items.append(QTreeWidgetItem(None, QStringList(QString("item: %1").arg(i))))
+treeWidget.insertTopLevelItems(None, items)
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qaction.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qaction.cpp
new file mode 100644
index 000000000..7594ee33e
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qaction.cpp
@@ -0,0 +1,9 @@
+//! [0]
+app = QApplication(argv)
+app.setAttribute(Qt.AA_DontShowIconsInMenus) # Icons are *no longer shown* in menus
+// ...
+myAction = QAction()
+// ...
+myAction.setIcon(SomeIcon)
+myAction.setIconVisibleInMenu(True) # Icon *will* be shown in menus for *this* action.
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qapplication.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qapplication.cpp
new file mode 100644
index 000000000..21cfdea77
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qapplication.cpp
@@ -0,0 +1,127 @@
+//! [0]
+def main():
+ if Qt.Q_WS_X11
+ useGUI = getenv("DISPLAY") != 0
+ else:
+ useGUI = True
+
+ app = QApplication(sys.argv, useGUI)
+
+ if useGUI:
+ # start GUI version
+ ...
+ else:
+ # start non-GUI version
+ ...
+ return app.exec_()
+//! [0]
+
+
+//! [1]
+QApplication.setStyle(QWindowsStyle())
+//! [1]
+
+
+//! [2]
+def main():
+ QApplication.setColorSpec(QApplication.ManyColor)
+ QApplication app(sys.argv)
+ ...
+ return app.exec_()
+
+//! [2]
+
+
+//! [3]
+class MyWidget (QWidget):
+ # ...
+ def sizeHint(self):
+ return QSize(80, 25).expandedTo(QApplication.globalStrut())
+//! [3]
+
+
+//! [4]
+def showAllHiddenTopLevelWidgets():
+ for widget in QApplication.topLevelWidgets():
+ if widget.isHidden():
+ widget.show()
+//! [4]
+
+
+//! [5]
+def updateAllWidgets():
+ for widget in QApplication.allWidgets()
+ widget.update()
+//! [5]
+
+
+//! [6]
+if __name__ == '__main__':
+ QApplication.setDesktopSettingsAware(False)
+ app = QApplication(sys.argv)
+ # ...
+ return app.exec_()
+//! [6]
+
+
+//! [7]
+if (startPos - currentPos).manhattanLength() >= QApplication.startDragDistance():
+ startTheDrag()
+//! [7]
+
+
+//! [8]
+class MyApplication (QApplication):
+# ...
+ def commitData(QSessionManager& manager)
+ if manager.allowsInteraction():
+ ret = QMessageBox.warning(
+ mainWindow,
+ QObject.tr("My Application"),
+ QObject.tr("Save changes to document?"),
+ QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel)
+
+ if ret == QMessageBox.Save:
+ manager.release()
+ if not saveDocument():
+ manager.cancel()
+ elif ret == QMessageBox.Discard:
+ pass
+ else:
+ manager.cancel()
+ else:
+ # we did not get permission to interact, then
+ # do something reasonable instead
+ pass
+//! [8]
+
+
+//! [9]
+appname -session id
+//! [9]
+
+
+//! [10]
+for command in mySession.restartCommand():
+ do_something(command)
+//! [10]
+
+
+//! [11]
+for command in mySession.discardCommand():
+ do_something(command)
+//! [11]
+
+
+//! [12]
+widget = qApp.widgetAt(x, y)
+if widget:
+ widget = widget.window()
+//! [12]
+
+
+//! [13]
+widget = qApp.widgetAt(point)
+if widget:
+ widget = widget.window()
+//! [13]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qapplication_x11.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qapplication_x11.cpp
new file mode 100644
index 000000000..98d404338
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qapplication_x11.cpp
@@ -0,0 +1,5 @@
+//! [0]
+QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
+calculateHugeMandelbrot() # lunch time...
+QApplication.restoreOverrideCursor()
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qclipboard.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qclipboard.cpp
new file mode 100644
index 000000000..f06074db4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qclipboard.cpp
@@ -0,0 +1,13 @@
+//! [0]
+clipboard = QApplication.clipboard()
+originalText = clipboard.text()
+...
+clipboard.setText(newText)
+//! [0]
+
+
+//! [1]
+data = QMimeData()
+data.setImageData(image)
+clipboard.setMimeData(data, mode)
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qevent.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qevent.cpp
new file mode 100644
index 000000000..331765015
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qevent.cpp
@@ -0,0 +1,11 @@
+//! [0]
+def wheelEvent(self, event):
+ numDegrees = event.delta() / 8
+ numSteps = numDegrees / 15
+
+ if event->orientation() == Qt.Horizontal:
+ scrollHorizontally(numSteps)
+ else:
+ scrollVertically(numSteps)
+ event.accept()
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qformlayout.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qformlayout.cpp
new file mode 100644
index 000000000..e5f5c18cc
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qformlayout.cpp
@@ -0,0 +1,36 @@
+//! [0]
+formLayout = QFormLayout()
+formLayout.addRow(self.tr("&Name:"), nameLineEdit)
+formLayout.addRow(self.tr("&Email:"), emailLineEdit)
+formLayout.addRow(self.tr("&Age:"), ageSpinBox)
+setLayout(formLayout)
+//! [0]
+
+
+//! [1]
+nameLabel = QLabel(self.tr("&Name:"))
+nameLabel.setBuddy(nameLineEdit)
+
+emailLabel = QLabel(self.tr("&Name:"))
+emailLabel.setBuddy(emailLineEdit)
+
+ageLabel = QLabel(self.tr("&Name:"))
+ageLabel.setBuddy(ageSpinBox)
+
+gridLayout = 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.trowWrapPolicy(QFormLayout.DontWrapRows)
+formLayout.setFieldGrowthPolicy(QFormLayout.FieldsStayAtSizeHint)
+formLayout.setFormAlignment(Qt.AlignHCenter | Qt.AlignTop)
+formLayout.setLabelAlignment(Qt.AlignLeft)
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qkeysequence.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qkeysequence.cpp
new file mode 100644
index 000000000..538ee8807
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qkeysequence.cpp
@@ -0,0 +1,19 @@
+//! [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]
+file = QMenu(self)
+file.addAction(tr("&Open..."), self, SLOT("open()"),
+ QKeySequence(tr("Ctrl+O", "File|Open")))
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qlayout.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qlayout.cpp
new file mode 100644
index 000000000..12f123913
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qlayout.cpp
@@ -0,0 +1,25 @@
+//! [0]
+
+def paintLayout(self, painter, item):
+ layout = item.layout()
+
+ if layout:
+ for layout_item in layout:
+ self.paintLayout(painter, layout_item)
+
+ painter.drawRect(item.geometry())
+
+def paintEvent(self, event):
+ painter = QPainter(self)
+ if self.layout():
+ self.paintLayout(painter, self.layout())
+
+//! [0]
+
+
+//! [1]
+child = layout.takeAt(0)
+while child:
+ ...
+ del child
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qlayoutitem.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qlayoutitem.cpp
new file mode 100644
index 000000000..a2ce8843d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qlayoutitem.cpp
@@ -0,0 +1,8 @@
+//! [0]
+def heightForWidth(self, w):
+ if cache_dirty or cached_width != w:
+ h = calculateHeightForWidth(w)
+ self.cached_hfw = h
+ return h
+ return cached_hfw
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qshortcut.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qshortcut.cpp
new file mode 100644
index 000000000..b0df58f59
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qshortcut.cpp
@@ -0,0 +1,15 @@
+//! [0]
+shortcut = QShortcut(QKeySequence(self.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/codesnippets/doc/src/snippets/code/src_gui_kernel_qshortcutmap.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qshortcutmap.cpp
new file mode 100644
index 000000000..48f63f6e9
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qshortcutmap.cpp
@@ -0,0 +1,3 @@
+//! [0]
+key = QKeySequence()
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qsound.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qsound.cpp
new file mode 100644
index 000000000..20cc1af98
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qsound.cpp
@@ -0,0 +1,9 @@
+//! [0]
+QSound.play("mysounds/bells.wav")
+//! [0]
+
+
+//! [1]
+bells = QSound("mysounds/bells.wav")
+bells.play()
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qwidget.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qwidget.cpp
new file mode 100644
index 000000000..482dbd6b9
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qwidget.cpp
@@ -0,0 +1,100 @@
+//! [0]
+w.setWindowState(w.windowState() ^ Qt.WindowFullScreen)
+//! [0]
+
+
+//! [1]
+w.setWindowState(w.windowState() & ~Qt.WindowMinimized | Qt.WindowActive)
+//! [1]
+
+
+//! [2]
+width = widget.baseSize().width() + i * widget.sizeIncrement().width()
+height = widget.baseSize().height() + j * widget.sizeIncrement().height()
+//! [2]
+
+
+//! [3]
+aWidget.window().setWindowTitle("New Window Title")
+//! [3]
+
+
+//! [4]
+font = QFont("Helvetica", 12, QFont.Bold)
+widget.setFont(font)
+//! [4]
+
+
+//! [5]
+font = QFont()
+font.setBold(false)
+widget.setFont(font)
+//! [5]
+
+
+//! [6]
+widget.setCursor(Qt.IBeamCursor)
+//! [6]
+
+
+//! [7]
+pixmap = QPixmap(widget.size())
+widget.render(&pixmap)
+//! [7]
+
+
+//! [8]
+painter = QPainter(self)
+...
+painter.end()
+myWidget.render(self)
+//! [8]
+
+
+//! [9]
+widget.setTabOrder(a, b) # a to b
+widget.setTabOrder(b, c) # a to b to c
+widge.tsetTabOrder(c, d) # a to b to c to d
+//! [9]
+
+
+//! [10]
+# WRONG
+widget.setTabOrder(c, d) # c to d
+widget.setTabOrder(a, b) # a to b AND c to d
+widget.setTabOrder(b, c) # a to b to c, but not c to d
+//! [10]
+
+
+//! [11]
+class MyWidget(QWidget):
+
+ self.settings = None
+
+ def closeEvent(event):
+ # event is a QCloseEvent
+ self.settings = QSettings("MyCompany", "MyApp")
+ self.settings.setValue("geometry", self.saveGeometry())
+ QWidget.closeEvent(self, event)
+//! [11]
+
+
+//! [12]
+settings = QSettings("MyCompany", "MyApp")
+myWidget.restoreGeometry(settings.value("myWidget/geometry").toByteArray())
+//! [12]
+
+
+//! [13]
+widget.setUpdatesEnabled(False)
+widget.bigVisualChanges()
+widget.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/codesnippets/doc/src/snippets/code/src_gui_painting_qbrush.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qbrush.cpp
new file mode 100644
index 000000000..0e7c17d76
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qbrush.cpp
@@ -0,0 +1,11 @@
+//! [0]
+painter = QPainter(self)
+
+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/codesnippets/doc/src/snippets/code/src_gui_painting_qcolor.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qcolor.cpp
new file mode 100644
index 000000000..f97ef61a5
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qcolor.cpp
@@ -0,0 +1,9 @@
+//! [0]
+# Specify semi-transparent red
+painter.setBrush(QColor(255, 0, 0, 127))
+painter.drawRect(0, 0, self.width()/2, self.height())
+
+# Specify semi-transparent blue
+painter.setBrush(QColor(0, 0, 255, 127))
+painter.drawRect(0, 0, self.width(), self.height()/2)
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qdrawutil.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qdrawutil.cpp
new file mode 100644
index 000000000..61fec38e1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qdrawutil.cpp
@@ -0,0 +1,58 @@
+//! [0]
+frame = QFrame()
+frame.setFrameStyle(QFrame.HLine | QFrame.Sunken)
+//! [0]
+
+
+//! [1]
+frame = QFrame()
+frame.setFrameStyle(QFrame.Box | QFrame.Raised)
+//! [1]
+
+
+//! [2]
+frame = QFrame()
+frame.setFrameStyle( QFrame.Panel | QFrame.Sunken)
+//! [2]
+
+
+//! [3]
+frame = QFrame()
+frame.setFrameStyle(QFrame.WinPanel | QFrame.Raised)
+//! [3]
+
+
+//! [4]
+frame = QFrame()
+frame.setFrameStyle(QFrame.Box | QFrame.Plain)
+//! [4]
+
+
+//! [5]
+frame = QFrame()
+frame.setFrameStyle(QFrame.HLine | QFrame.Sunken)
+//! [5]
+
+
+//! [6]
+frame = QFrame()
+frame.setFrameStyle(QFrame.Box | QFrame.Raised)
+//! [6]
+
+
+//! [7]
+frame = QFrame()
+frame.setFrameStyle( QFrame.Panel | QFrame.Sunken)
+//! [7]
+
+
+//! [8]
+frame = QFrame()
+frame.setFrameStyle(QFrame.WinPanel | QFrame.Raised)
+//! [8]
+
+
+//! [9]
+frame = QFrame()
+frame.setFrameStyle(QFrame.Box | QFrame.Plain)
+//! [9]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qmatrix.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qmatrix.cpp
new file mode 100644
index 000000000..4a8a427be
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qmatrix.cpp
@@ -0,0 +1,22 @@
+//! [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/codesnippets/doc/src/snippets/code/src_gui_painting_qpainter.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qpainter.cpp
new file mode 100644
index 000000000..dca129280
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qpainter.cpp
@@ -0,0 +1,195 @@
+//! [0]
+def paintEvent(self, paintEvent):
+ painter = QPainter(self)
+ painter.setPen(Qt.blue)
+ painter.setFont(QFont("Arial", 30))
+ painter.drawText(rect(), Qt.AlignCenter, "Qt")
+//! [0]
+
+
+//! [1]
+def paintEvent(self, paintEvent):
+ p = QPainter()
+ p.begin(self)
+ p.drawLine(...) # drawing code
+ p.end()
+//! [1]
+
+
+//! [2]
+self paintEvent(self, paintEvent):
+ p = QPainter(self)
+ p.drawLine(...) # drawing code
+
+//! [2]
+
+
+//! [3]
+painter.begin(0) # impossible - paint device cannot be 0
+
+image = QPixmap(0, 0)
+painter.begin(&image) # impossible - image.isNull() == true
+
+painter.begin(myWidget)
+painter2.begin(myWidget) # impossible - only one painter at a time
+//! [3]
+
+
+//! [4]
+def rotate(self, angle):
+ matrix = QMatrix()
+ matrix.rotate(angle)
+ setWorldMatrix(matrix, true)
+//! [4]
+
+
+//! [5]
+path = QPainterPath()
+path.moveTo(20, 80)
+path.lineTo(20, 30)
+path.cubicTo(80, 0, 50, 50, 80, 80)
+
+painter = QPainter(self)
+painter.drawPath(path)
+//! [5]
+
+
+//! [6]
+line = QLineF(10.0, 80.0, 90.0, 20.0)
+
+painter = QPainter(self)
+painter.drawLine(line)
+//! [6]
+
+
+//! [7]
+rectangle = QRectF(10.0, 20.0, 80.0, 60.0)
+
+painter = QPainter(self)
+painter.drawRect(rectangle)
+//! [7]
+
+
+//! [8]
+rectangle = QRectF(10.0, 20.0, 80.0, 60.0)
+
+painter = QPainter(self)
+painter.drawRoundedRect(rectangle, 20.0, 15.0)
+//! [8]
+
+
+//! [9]
+rectangle = QRectF(10.0, 20.0, 80.0, 60.0)
+
+painter = QPainter(self)
+painter.drawEllipse(rectangle)
+//! [9]
+
+
+//! [10]
+rectangle = QRectF(10.0, 20.0, 80.0, 60.0)
+startAngle = 30 * 16
+spanAngle = 120 * 16
+
+painter = QPainter(self)
+painter.drawArc(rectangle, startAngle, spanAngle)
+//! [10]
+
+
+//! [11]
+rectangle = QRectF(10.0, 20.0, 80.0, 60.0)
+startAngle = 30 * 16
+spanAngle = 120 * 16
+
+painter = QPainter(self)
+painter.drawPie(rectangle, startAngle, spanAngle)
+//! [11]
+
+
+//! [12]
+rectangle = QRectF(10.0, 20.0, 80.0, 60.0)
+startAngle = 30 * 16
+spanAngle = 120 * 16
+
+painter = QPainter(self)
+painter.drawChord(rect, startAngle, spanAngle)
+//! [12]
+
+
+//! [13]
+points = [
+ QPointF(10.0, 80.0),
+ QPointF(20.0, 10.0),
+ QPointF(80.0, 30.0),
+]
+
+painter = QPainter(self)
+painter.drawPolyline(points, 3)
+//! [13]
+
+
+//! [14]
+points = [
+ QPointF(10.0, 80.0),
+ QPointF(20.0, 10.0),
+ QPointF(80.0, 30.0),
+ QPointF(90.0, 70.0)
+]
+
+painter = QPainter(self)
+painter.drawPolygon(points, 4)
+//! [14]
+
+
+//! [15]
+points = [
+ QPointF(10.0, 80.0),
+ QPointF(20.0, 10.0),
+ QPointF(80.0, 30.0),
+ QPointF(90.0, 70.0)
+]
+
+painter = QPainter(self)
+painter.drawConvexPolygon(points, 4)
+//! [15]
+
+
+//! [16]
+target = QRectF(10.0, 20.0, 80.0, 60.0)
+source = QRectF(0.0, 0.0, 70.0, 40.0)
+pixmap = QPixmap(":myPixmap.png")
+
+painter = QPainter(self)
+painter.drawPixmap(target, image, source)
+//! [16]
+
+
+//! [17]
+painter = QPainter(self)
+painter.drawText(rect, Qt.AlignCenter, tr("Qt by\nTrolltech"))
+//! [17]
+
+
+//! [18]
+picture = QPicture()
+point = QPointF(10.0, 20.0)
+picture.load("drawing.pic")
+
+painter = QPainter(self)
+painter.drawPicture(0, 0, picture)
+//! [18]
+
+
+//! [19]
+fillRect(rectangle, background())
+//! [19]
+
+
+//! [20]
+target = QRectF(10.0, 20.0, 80.0, 60.0)
+source = QRectF(0.0, 0.0, 70.0, 40.0)
+image = QImage(":/images/myImage.png")
+
+painter = QPainter(self)
+painter.drawImage(target, image, source)
+//! [20]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qpainterpath.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qpainterpath.cpp
new file mode 100644
index 000000000..08b8f69d2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qpainterpath.cpp
@@ -0,0 +1,110 @@
+//! [0]
+path = QPainterPath()
+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(self)
+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]
+myGradient = QLinearGradient()
+myPen = QPen()
+
+myPath = QPainterPath()
+myPath.cubicTo(c1, c2, endPoint)
+
+painter = QPainter(self)
+painter.setBrush(myGradient)
+painter.setPen(myPen)
+painter.drawPath(myPath)
+//! [1]
+
+
+//! [2]
+myGradient = QLinearGradient()
+myPen = QPen()
+
+startPoint = QPointF()
+center = QPointF()
+
+myPath = QPainterPath()
+myPath.moveTo(center)
+myPath.arcTo(boundingRect, startAngle,
+ sweepLength)
+
+painter = QPainter(self)
+painter.setBrush(myGradient)
+painter.setPen(myPen)
+painter.drawPath(myPath)
+//! [2]
+
+
+//! [3]
+myGradient = QLinearGradient()
+myPen = QPen()
+myRectangle = QRectF()
+
+myPath = QPainterPath()
+myPath.addRect(myRectangle)
+
+painter = QPainter(self)
+painter.setBrush(myGradient)
+painter.setPen(myPen)
+painter.drawPath(myPath)
+//! [3]
+
+
+//! [4]
+myGradient = QLinearGradient()
+myPen = QPen()
+myPolygon = QPolygonF()
+
+myPath = QPainterPath()
+myPath.addPolygon(myPolygon)
+
+QPainter painter(self)
+painter.setBrush(myGradient)
+painter.setPen(myPen)
+painter.drawPath(myPath)
+//! [4]
+
+
+//! [5]
+myGradient = QLinearGradient()
+myPen = QPen()
+boundingRectangle = QRectF()
+
+myPath = QPainterPath()
+myPath.addEllipse(boundingRectangle)
+
+QPainter painter(self)
+painter.setBrush(myGradient)
+painter.setPen(myPen)
+painter.drawPath(myPath)
+//! [5]
+
+
+//! [6]
+myGradient = QLinearGradient()
+myPen = QPen()
+myFont = QFont()
+QPointF baseline(x, y)
+
+myPath = QPainterPath()
+myPath.addText(baseline, myFont, tr("Qt"))
+
+painter QPainter(self)
+painter.setBrush(myGradient)
+painter.setPen(myPen)
+painter.drawPath(myPath)
+//! [6]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qpen.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qpen.cpp
new file mode 100644
index 000000000..b1584629a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qpen.cpp
@@ -0,0 +1,35 @@
+//! [0]
+painter = QPainter(self)
+pen = QPen(Qt.green, 3, Qt.DashDotLine, Qt.RoundCap, Qt.RoundJoin)
+painter.setPen(pen)
+//! [0]
+
+
+//! [1]
+painter = QPainter(self)
+pen = QPen() # 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]
+pen = QPen()
+space = 4;
+dashes = [1, space, 3, space, 9, space, 27, space, 9, space]
+pen.setDashPattern(dashes)
+//! [2]
+
+
+//! [3]
+pen = QPen()
+space = 4;
+dashes = [1, space, 3, space, 9, space, 27, space, 9, space]
+pen.setDashPattern(dashes)
+//! [3]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qregion.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qregion.cpp
new file mode 100644
index 000000000..b97cc2e4c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qregion.cpp
@@ -0,0 +1,13 @@
+//! [0]
+class MyWidget (QWidget):
+ # ...
+ def paintEvent(self):
+ r1 = QRegion(QRect(100, 100, 200, 80), QRegion.Ellipse) # r1: elliptic region
+ )
+ r2 = QRect(100, 120, 90, 30) # r2: rectangular region
+ r3 = r1.intersected(r2) # r3: intersection
+
+ painter = QPainter(self)
+ painter.setClipRegion(r3)
+ ... # paint clipped graphics
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qregion_unix.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qregion_unix.cpp
new file mode 100644
index 000000000..9b6e31805
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qregion_unix.cpp
@@ -0,0 +1,18 @@
+//! [0]
+r1 = QRegion(10, 10, 20, 20)
+r1.isNull() // false
+r1.isEmpty() // false
+
+r2 = QRegion(40, 40, 20, 20)
+r3 = QRegion()
+r3.isNull() // true
+r3.isEmpty() // true
+
+r3 = r1.intersected(r2) // r3: intersection of r1 and r2
+r3.isNull() // false
+r3.isEmpty() // true
+
+r3 = r1.united(r2) // r3: union of r1 and r2
+r3.isNull() // false
+r3.isEmpty() // false
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qtransform.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qtransform.cpp
new file mode 100644
index 000000000..0d049bb38
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qtransform.cpp
@@ -0,0 +1,38 @@
+//! [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/codesnippets/doc/src/snippets/code/src_gui_styles_qstyle.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_styles_qstyle.cpp
new file mode 100644
index 000000000..49452ffe0
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_styles_qstyle.cpp
@@ -0,0 +1,8 @@
+//! [0]
+python myapplication.py -style motif
+//! [0]
+
+
+//! [1]
+python myapplication.py -style custom
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_styles_qstyleoption.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_styles_qstyleoption.cpp
new file mode 100644
index 000000000..87e13a988
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_styles_qstyleoption.cpp
@@ -0,0 +1,7 @@
+//! [0]
+def styleHint(self, stylehint, opt, widget, returnData):
+ if stylehint == SH_RubberBand_Mask:
+ if isinstance(QStyleHintReturnMask, hint):
+ ...
+ ...
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_text_qfont.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_text_qfont.cpp
new file mode 100644
index 000000000..0df078e9a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_text_qfont.cpp
@@ -0,0 +1,27 @@
+//! [0]
+serifFont = QFont("Times", 10, QFont.Bold)
+sansFont = QFont("Helvetica [Cronyx]", 12)
+//! [0]
+
+
+//! [1]
+f = QFont("Helvetica")
+//! [1]
+
+
+//! [2]
+f = QFont("Helvetica [Cronyx]")
+//! [2]
+
+
+//! [3]
+info = QFontInfo(f1)
+family = info.family()
+//! [3]
+
+
+//! [4]
+fm = QFontMetrics(f1)
+textWidthInPixels = fm.width("How many pixels wide is this text?")
+textHeightInPixels = fm.height()
+//! [4]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_text_qfontmetrics.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_text_qfontmetrics.cpp
new file mode 100644
index 000000000..18a4a7491
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_text_qfontmetrics.cpp
@@ -0,0 +1,14 @@
+//! [0]
+font = QFont("times", 24)
+fm = QFontMetrics(font)
+pixelsWide = fm.width("What's the width of this text?")
+pixelsHigh = fm.height()
+//! [0]
+
+
+//! [1]
+font = QFont("times", 24)
+fm = QFontMetricsF(font)
+pixelsWide = fm.width("What's the width of this text?")
+pixelsHigh = fm.height()
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_text_qsyntaxhighlighter.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_text_qsyntaxhighlighter.cpp
new file mode 100644
index 000000000..bb00cac38
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_text_qsyntaxhighlighter.cpp
@@ -0,0 +1,74 @@
+//! [0]
+editor = QTextEdit()
+highlighter = MyHighlighter(editor.document())
+//! [0]
+
+
+//! [1]
+class MyHighlighter(QSyntaxHighlighter):
+ def highlightBlock(self, text):
+ myClassFormat = QTextCharFormat()
+ myClassFormat.setFontWeight(QFont.Bold)
+ myClassFormat.setForeground(Qt.darkMagenta)
+ pattern = QString("\\bMy[A-Za-z]+\\b")
+
+ expression = QRegExp(pattern)
+ index = text.indexOf(expression)
+ while index >= 0:
+ length = expression.matchedLength()
+ setFormat(index, length, myClassFormat)
+ index = text.indexOf(expression, index + length)
+//! [1]
+
+
+//! [2]
+multiLineCommentFormat = QTextCharFormat()
+multiLineCommentFormat.setForeground(Qt.red)
+
+startExpression = QRegExp("/\\*")
+endExpression = QRegExp("\\*/")
+
+setCurrentBlockState(0)
+
+startIndex = 0
+if previousBlockState() != 1:
+ startIndex = text.indexOf(startExpression)
+
+while startIndex >= 0:
+ endIndex = text.indexOf(endExpression, startIndex)
+ 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]
+class MyHighlighter(QSyntaxHighlighter):
+ def highlightBlock(self, text):
+ myClassFormat = QTextCharFormat()
+ myClassFormat.setFontWeight(QFont.Bold)
+ myClassFormat.setForeground(Qt.darkMagenta)
+ pattern = QString("\\bMy[A-Za-z]+\\b")
+
+ expression = QRegExp(pattern)
+ index = text.indexOf(expression)
+ while index >= 0:
+ length = expression.matchedLength()
+ setFormat(index, length, myClassFormat)
+ index = text.indexOf(expression, index + length)
+//! [3]
+
+
+//! [4]
+class BlockData(QTextBlockUserData):
+ def __init__(self):
+ # ...
+ self.parentheses = []
+//! [4]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_text_qtextcursor.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_text_qtextcursor.cpp
new file mode 100644
index 000000000..a70c6dc5d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_text_qtextcursor.cpp
@@ -0,0 +1,40 @@
+//! [0]
+cursor.clearSelection()
+cursor.movePosition(QTextCursor.NextWord, QTextCursor.KeepAnchor)
+cursor.insertText("Hello World")
+//! [0]
+
+
+//! [1]
+img = ... # A QImage
+textDocument.addResource(QTextDocument.ImageResource, QUrl("myimage"), img)
+cursor.insertImage("myimage")
+//! [1]
+
+
+//! [2]
+cursor = QTextCursor(textDocument)
+cursor.beginEditBlock()
+cursor.insertText("Hello")
+cursor.insertText("World")
+cursor.endEditBlock()
+
+textDocument.undo()
+//! [2]
+
+
+//! [3]
+cursor = QTextCursor(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/codesnippets/doc/src/snippets/code/src_gui_text_qtextdocument.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_text_qtextdocument.cpp
new file mode 100644
index 000000000..2fd8b9435
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_text_qtextdocument.cpp
@@ -0,0 +1,10 @@
+//! [0]
+plain = QString("#include <QtCore>")
+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/codesnippets/doc/src/snippets/code/src_gui_text_qtextlayout.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_text_qtextlayout.cpp
new file mode 100644
index 000000000..267f195b9
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_text_qtextlayout.cpp
@@ -0,0 +1,23 @@
+//! [0]
+leading = fontMetrics.leading()
+height = 0
+widthUsed = 0
+textLayout.beginLayout()
+while True:
+ line = textLayout.createLine()
+ if not line.isValid():
+ break
+
+ line.setLineWidth(lineWidth)
+ height += leading
+ line.setPosition(QPointF(0, height))
+ height += line.height()
+ widthUsed = qMax(widthUsed, line.naturalTextWidth())
+textLayout.endLayout()
+//! [0]
+
+
+//! [1]
+painter = QPainter(self)
+textLayout.draw(painter, QPoint(0, 0))
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_util_qcompleter.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_util_qcompleter.cpp
new file mode 100644
index 000000000..a2339ae89
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_util_qcompleter.cpp
@@ -0,0 +1,25 @@
+
+//! [0]
+wordList = ["alpha", "omega", "omicron", "zeta"]
+
+lineEdit = QLineEdit(self)
+
+completer = QCompleter(wordList, self)
+completer.setCaseSensitivity(Qt.CaseInsensitive)
+lineEdit.setCompleter(completer)
+//! [0]
+
+
+//! [1]
+completer = QCompleter(self)
+completer.setModel(QDirModel(completer))
+lineEdit.setCompleter(completer)
+//! [1]
+
+
+//! [2]
+i = 0
+while completer.setCurrentRow(i):
+ print "%s is match number %d" % (completer.currentCompletion(), i)
+ i += 1
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_util_qdesktopservices.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_util_qdesktopservices.cpp
new file mode 100644
index 000000000..82c3c3094
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_util_qdesktopservices.cpp
@@ -0,0 +1,15 @@
+//! [0]
+def showHelp(url):
+ # ...
+ pass
+
+QDesktopServices.setUrlHandler("help", 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/codesnippets/doc/src/snippets/code/src_gui_util_qundostack.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_util_qundostack.cpp
new file mode 100644
index 000000000..283392bbd
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_util_qundostack.cpp
@@ -0,0 +1,70 @@
+//! [0]
+class AppendText(QUndoCommand):
+ self.m_document = ''
+ self.m_text = ''
+
+ def AppendText(self, doc, text):
+ self.m_document = doc
+ self.m_text = text
+ self.setText("append text")
+
+ def undo(self):
+ self.m_document.chop(self.m_text.length())
+
+ def redo(self):
+ self.m_document->append(self.m_text)
+//! [0]
+
+
+//! [1]
+command1 = MyCommand()
+stack.push(command1)
+command2 = MyCommand()
+stack.push(command2)
+
+stack.undo()
+
+command3 = MyCommand()
+stack.push(command3) # command2 gets deleted
+//! [1]
+
+
+//! [2]
+insertRed = QUndoCommand() # an empty command
+insertRed.setText("insert red text")
+
+InsertText(document, idx, text, insertRed) # becomes child of insertRed
+SetColor(document, idx, text.length(), Qt.red, insertRed)
+
+stack.push(insertRed)
+//! [2]
+
+
+//! [3]
+class AppendText(QUndoCommand):
+ ...
+ def mergeWith(self, other):
+ if other.id() != self.id(): # make sure other is also an AppendText command
+ return False
+ m_text += other.m_text
+ return True
+//! [3]
+
+
+//! [4]
+stack.beginMacro("insert red text")
+stack.push(InsertText(document, idx, text))
+stack.push(SetColor(document, idx, text.length(), Qt.red))
+stack.endMacro() # indexChanged() is emitted
+//! [4]
+
+
+//! [5]
+insertRed = QUndoCommand() # an empty command
+insertRed.setText("insert red text")
+
+InsertText(document, idx, text, insertRed) # becomes child of insertRed
+SetColor(document, idx, text.length(), Qt.red, insertRed)
+
+stack.push(insertRed)
+//! [5]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qabstractbutton.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qabstractbutton.cpp
new file mode 100644
index 000000000..3539a80e0
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qabstractbutton.cpp
@@ -0,0 +1,19 @@
+//! [0]
+button = QPushButton(QObject.tr("Ro&ck && Roll"), self)
+//! [0]
+
+
+//! [1]
+button.setIcon(QIcon(":/images/print.png"))
+button.setShortcut(tr("Alt+F7"))
+//! [1]
+
+
+//! [2]
+class MyWidget (QWidget):
+ #...
+ def reactToToggle(checked):
+ if checked:
+ // Examine the button states.
+ ...
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qabstractspinbox.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qabstractspinbox.cpp
new file mode 100644
index 000000000..ba9686798
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qabstractspinbox.cpp
@@ -0,0 +1,8 @@
+//! [0]
+spinBox = QSpinBox(self)
+spinBox.setRange(0, 100)
+spinBox.setWrapping(True)
+spinBox.setValue(100)
+spinBox.stepBy(1)
+// value is 0
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qcalendarwidget.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qcalendarwidget.cpp
new file mode 100644
index 000000000..9323ce4c5
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qcalendarwidget.cpp
@@ -0,0 +1,33 @@
+//! [0]
+calendar.setGridVisible(True)
+//! [0]
+
+
+//! [1]
+calendar.setGridVisible(True)
+calendar.setMinimumDate(QDate(2006, 6, 19))
+//! [1]
+
+
+//! [2]
+calendar.setGridVisible(True)
+calendar.setMaximumDate(QDate(2006, 7, 3))
+//! [2]
+
+
+//! [3]
+
+calendar.setDateRange(min, max)
+//! [3]
+
+
+//! [4]
+
+calendar.setMinimumDate(min)
+calendar.setMaximumDate(max)
+//! [4]
+
+
+//! [5]
+calendar.setGridVisible(True)
+//! [5]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qcheckbox.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qcheckbox.cpp
new file mode 100644
index 000000000..c8aa50aa2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qcheckbox.cpp
@@ -0,0 +1,3 @@
+//! [0]
+checkbox = QCheckBox("C&ase sensitive", self)
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qdatetimeedit.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qdatetimeedit.cpp
new file mode 100644
index 000000000..7561475dd
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qdatetimeedit.cpp
@@ -0,0 +1,39 @@
+//! [0]
+dateEdit = 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/codesnippets/doc/src/snippets/code/src_gui_widgets_qdockwidget.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qdockwidget.cpp
new file mode 100644
index 000000000..3c6741a6f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qdockwidget.cpp
@@ -0,0 +1,7 @@
+//! [0]
+dockWidget = parentWidget()
+if dockWidget.features() & QDockWidget.DockWidgetVerticalTitleBar:
+ # I need to be vertical
+else:
+ # I need to be horizontal
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qframe.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qframe.cpp
new file mode 100644
index 000000000..0edbf4ea2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qframe.cpp
@@ -0,0 +1,8 @@
+//! [0]
+label = QLabel()
+label.setFrameStyle(QFrame.Panel | QFrame.Raised)
+label.setLineWidth(2)
+
+pbar = QProgressBar()
+label.setFrameStyle(QFrame.NoFrame)
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qgroupbox.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qgroupbox.cpp
new file mode 100644
index 000000000..d236d91dd
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qgroupbox.cpp
@@ -0,0 +1,3 @@
+//! [0]
+g.setTitle("&User information")
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qlabel.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qlabel.cpp
new file mode 100644
index 000000000..f32c5b2f1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qlabel.cpp
@@ -0,0 +1,24 @@
+//! [0]
+label = QLabel(self)
+label.setFrameStyle(QFrame.Panel | QFrame.Sunken)
+label.setText("first line\nsecond line")
+label.setAlignment(Qt.AlignBottom | Qt.AlignRight)
+//! [0]
+
+
+//! [1]
+phoneEdit = QLineEdit(self)
+phoneLabel = QLabel("&Phone:", self)
+phoneLabel.setBuddy(phoneEdit)
+//! [1]
+
+
+//! [2]
+nameEd = QLineEdit(self)
+nameLb = QLabel("&Name:", self)
+nameLb.setBuddy(nameEd)
+phoneEd = QLineEdit(self)
+phoneLb = QLabel("&Phone:", self)
+phoneLb.setBuddy(phoneEd)
+# (layout setup not shown)
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qlineedit.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qlineedit.cpp
new file mode 100644
index 000000000..cc929a114
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qlineedit.cpp
@@ -0,0 +1,7 @@
+//! [0]
+def contextMenuEvent(event):
+ menu = createStandardContextMenu()
+ menu.addAction(QObject.tr("My Menu Item"))
+ #...
+ menu.exec_(event.globalPos())
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qmenu.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qmenu.cpp
new file mode 100644
index 000000000..e2d13a45b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qmenu.cpp
@@ -0,0 +1,37 @@
+//! [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]
+menu = QMenu()
+at = actions[0] // Assumes actions is not empty
+for a in actions:
+ menu.addAction(a)
+menu.exec_(pos, at)
+//! [6]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qmenubar.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qmenubar.cpp
new file mode 100644
index 000000000..871137d30
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qmenubar.cpp
@@ -0,0 +1,8 @@
+//! [0]
+menubar.addMenu(fileMenu)
+//! [0]
+
+
+//! [1]
+menuBar = QMenuBar()
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qplaintextedit.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qplaintextedit.cpp
new file mode 100644
index 000000000..c39041857
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qplaintextedit.cpp
@@ -0,0 +1,14 @@
+//! [0]
+class MyQPlainTextEdit(QPlainTextEdit):
+ def contextMenuEvent(self, event):
+ menu = createStandardContextMenu()
+ menu.addAction(tr("My Menu Item"))
+ # ...
+ menu.exec_(event.globalPos())
+ del menu
+//! [0]
+
+
+//! [1]
+edit.textCursor().insertText(text)
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qpushbutton.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qpushbutton.cpp
new file mode 100644
index 000000000..74b4cf884
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qpushbutton.cpp
@@ -0,0 +1,3 @@
+//! [0]
+button = QPushButton("&Download", self)
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qradiobutton.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qradiobutton.cpp
new file mode 100644
index 000000000..dbee86850
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qradiobutton.cpp
@@ -0,0 +1,3 @@
+//! [0]
+button = QRadioButton("Search from the &cursor", self)
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qrubberband.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qrubberband.cpp
new file mode 100644
index 000000000..df56def60
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qrubberband.cpp
@@ -0,0 +1,17 @@
+//! [0]
+class Widget:
+ def mousePressEvent(self, event):
+ origin = event.pos()
+ if not self.rubberBand:
+ self.rubberBand = QRubberBand(QRubberBand.Rectangle, self)
+ rubberBand.setGeometry(QRect(origin, QSize()))
+ rubberBand.show()
+
+ def mouseMoveEvent(self, event):
+ rubberBand.setGeometry(QRect(origin, event.pos()).normalized())
+
+ def mouseReleaseEvent(self, event):
+ rubberBand.hide()
+ # determine selection, for example using QRect.intersects()
+ # and QRect.contains().
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qscrollarea.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qscrollarea.cpp
new file mode 100644
index 000000000..bfc650420
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qscrollarea.cpp
@@ -0,0 +1,9 @@
+//! [0]
+imageLabel = QLabel()
+image = QImage("happyguy.png")
+imageLabel.setPixmap(QPixmap.fromImage(image))
+
+scrollArea = QScrollArea()
+scrollArea.setBackgroundRole(QPalette.Dark)
+scrollArea.setWidget(imageLabel)
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qspinbox.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qspinbox.cpp
new file mode 100644
index 000000000..936af3023
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qspinbox.cpp
@@ -0,0 +1,40 @@
+//! [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/codesnippets/doc/src/snippets/code/src_gui_widgets_qsplashscreen.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qsplashscreen.cpp
new file mode 100644
index 000000000..87d4bd81c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qsplashscreen.cpp
@@ -0,0 +1,15 @@
+//! [0]
+pixmap = QPixmap(":/splash.png")
+splash = 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/codesnippets/doc/src/snippets/code/src_gui_widgets_qsplitter.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qsplitter.cpp
new file mode 100644
index 000000000..3f6d3b89f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qsplitter.cpp
@@ -0,0 +1,7 @@
+//! [0]
+widget = splitter.widget(index)
+policy = widget.sizePolicy()
+policy.setHorizontalStretch(stretch)
+policy.setVerticalStretch(stretch)
+widget.setSizePolicy(policy)
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qstatusbar.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qstatusbar.cpp
new file mode 100644
index 000000000..8b972b6f2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qstatusbar.cpp
@@ -0,0 +1,3 @@
+//! [0]
+statusBar().addWidget(MyReadWriteIndication())
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qtextbrowser.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qtextbrowser.cpp
new file mode 100644
index 000000000..e554c1af0
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qtextbrowser.cpp
@@ -0,0 +1,4 @@
+//! [0]
+backaction.setToolTip(browser.historyTitle(-1))
+forwardaction.setToolTip(browser.historyTitle(+1))
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qtextedit.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qtextedit.cpp
new file mode 100644
index 000000000..1336f6eaa
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qtextedit.cpp
@@ -0,0 +1,19 @@
+//! [0]
+class MyTextEdit(QTextEdit):
+ def contextMenuEvent(self, event):
+ menu = createStandardContextMenu()
+ menu.addAction(tr("My Menu Item"))
+ #...
+ menu.exec_(event->globalPos())
+ del menu
+//! [0]
+
+
+//! [1]
+edit.textCursor().insertText(text)
+//! [1]
+
+
+//! [2]
+edit.textCursor().insertHtml(fragment)
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qvalidator.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qvalidator.cpp
new file mode 100644
index 000000000..71e2fe146
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qvalidator.cpp
@@ -0,0 +1,105 @@
+//! [0]
+validator = QIntValidator(100, 999, self)
+edit = QLineEdit(self)
+
+# the edit lineedit will only accept integers between 100 and 999
+edit.setValidator(validator)
+//! [0]
+
+
+//! [1]
+pos = 0
+v = QIntValidator(100, 900, self)
+
+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]
+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
+rx = QRegExp("-?\\d{1,3}")
+validator = QRegExpValidator(rx, self)
+
+edit = QLineEdit(self)
+edit.setValidator(validator)
+//! [3]
+
+
+//! [4]
+# integers 1 to 9999
+rx = QRegExp("[1-9]\\d{0,3}")
+# the validator treats the regexp as "^[1-9]\\d{0,3}$"
+v = QRegExpValidator(rx, 0)
+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/codesnippets/doc/src/snippets/code/src_gui_widgets_qworkspace.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qworkspace.cpp
new file mode 100644
index 000000000..678db44b5
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qworkspace.cpp
@@ -0,0 +1,7 @@
+//! [0]
+class MainWindow(...):
+ def __init__(self):
+ self.workspace = QWorkspace()
+ self.setCentralWidget(workspace)
+ ...
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_network_access_qftp.cpp b/doc/codesnippets/doc/src/snippets/code/src_network_access_qftp.cpp
new file mode 100644
index 000000000..63e17aa97
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_network_access_qftp.cpp
@@ -0,0 +1,59 @@
+//! [0]
+ftp = QFtp(parent)
+ftp.connectToHost("ftp.trolltech.com")
+ftp.login()
+//! [0]
+
+
+//! [1]
+ftp.connectToHost("ftp.trolltech.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/codesnippets/doc/src/snippets/code/src_network_access_qhttp.cpp b/doc/codesnippets/doc/src/snippets/code/src_network_access_qhttp.cpp
new file mode 100644
index 000000000..a3b4c26ed
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_network_access_qhttp.cpp
@@ -0,0 +1,82 @@
+//! [0]
+content-type: text/html
+//! [0]
+
+
+//! [1]
+header.setValue("content-type", "text/html")
+contentType = header.value("content-type")
+//! [1]
+
+
+//! [2]
+header = QHttpRequestHeader("GET", QUrl.toPercentEncoding("/index.html"))
+header.setValue("Host", "qtsoftware.com")
+http.setHost("qtsoftware.com")
+http.request(header)
+//! [2]
+
+
+//! [3]
+http.setHost("qtsoftware.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]
+def getTicks(self):
+ http = QHttp(self)
+ self.connect(http, SIGNAL('done(bool)'), self, SLOT('showPage()'))
+ http.setProxy("proxy.example.com", 3128)
+ http.setHost("ticker.example.com")
+ http.get("/ticks.asp")
+
+def showPage(self):
+ self.display(http.readAll())
+
+//! [7]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp b/doc/codesnippets/doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp
new file mode 100644
index 000000000..73b58c1fd
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp
@@ -0,0 +1,21 @@
+//! [0]
+manager = QNetworkAccessManager(self)
+connect(manager, SIGNAL(finished("QNetworkReply*")),
+ self, SLOT(replyFinished("QNetworkReply*")))
+
+manager.get(QNetworkRequest(QUrl("http://qtsoftware.com")))
+//! [0]
+
+
+//! [1]
+QNetworkRequest request
+request.setUrl(QUrl("http://qtsoftware.com"))
+request.setRawHeader("User-Agent", "MyOwnBrowser 1.0")
+
+reply = manager.get(request)
+connect(reply, SIGNAL("readyRead()"), self, SLOT("slotReadyRead()"))
+connect(reply, SIGNAL(error("QNetworkReply.NetworkError")),
+ self, SLOT(slotError("QNetworkReply.NetworkError")))
+connect(reply, SIGNAL(sslErrors("QList<QSslError>")),
+ self, SLOT(slotSslErrors("QList<QSslError>")))
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_network_access_qnetworkrequest.cpp b/doc/codesnippets/doc/src/snippets/code/src_network_access_qnetworkrequest.cpp
new file mode 100644
index 000000000..9156597b1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_network_access_qnetworkrequest.cpp
@@ -0,0 +1,3 @@
+//! [0]
+request.setRawHeader("Last-Modified", "Sun, 06 Nov 1994 08:49:37 GMT")
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_network_kernel_qhostaddress.cpp b/doc/codesnippets/doc/src/snippets/code/src_network_kernel_qhostaddress.cpp
new file mode 100644
index 000000000..adbe02188
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_network_kernel_qhostaddress.cpp
@@ -0,0 +1,7 @@
+//! [0]
+addr = hostAddr.toIPv6Address()
+# addr contains 16 unsigned characters
+
+for i in range(0, 16):
+ # process addr[i]
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_network_kernel_qhostinfo.cpp b/doc/codesnippets/doc/src/snippets/code/src_network_kernel_qhostinfo.cpp
new file mode 100644
index 000000000..1602b105b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_network_kernel_qhostinfo.cpp
@@ -0,0 +1,42 @@
+//! [0]
+# To find the IP address of qtsoftware.com
+QHostInfo.lookupHost("qtsoftware.com", self, SLOT("printResults(QHostInfo)"))
+
+# To find the host name for 4.2.2.1
+QHostInfo.lookupHost("4.2.2.1", self, SLOT("printResults(QHostInfo)"))
+//! [0]
+
+
+//! [1]
+info = QHostInfo.fromName("qtsoftware.com")
+//! [1]
+
+
+//! [2]
+QHostInfo.lookupHost("www.kde.org", self.lookedUp)
+//! [2]
+
+
+//! [3]
+def lookedUp(host):
+ if host.error() != QHostInfo.NoError:
+ print "Lookup failed: %s" % host.errorString()
+ return
+
+ for address in host.addresses():
+ print "Found address: %s" % address.toString()
+//! [3]
+
+
+//! [4]
+QHostInfo.lookupHost("4.2.2.1", self.lookedUp)
+//! [4]
+
+
+//! [5]
+info = QHostInfo()
+...
+if not info.addresses().isEmpty():
+ address = info.addresses().first()
+ # use the first IP address
+//! [5]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_network_kernel_qnetworkproxy.cpp b/doc/codesnippets/doc/src/snippets/code/src_network_kernel_qnetworkproxy.cpp
new file mode 100644
index 000000000..4ad72ef1a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_network_kernel_qnetworkproxy.cpp
@@ -0,0 +1,14 @@
+//! [0]
+proxy = QNetworkProxy()
+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/codesnippets/doc/src/snippets/code/src_network_socket_qabstractsocket.cpp b/doc/codesnippets/doc/src/snippets/code/src_network_socket_qabstractsocket.cpp
new file mode 100644
index 000000000..aefead248
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_network_socket_qabstractsocket.cpp
@@ -0,0 +1,28 @@
+//! [0]
+socket.connectToHost("imap", 143)
+if socket.waitForConnected(1000):
+ print "Connected!"
+//! [0]
+
+
+//! [1]
+socket.disconnectFromHost()
+ if socket.state() == QAbstractSocket.UnconnectedState or \
+ socket.waitForDisconnected(1000):
+ print "Disconnected!"
+//! [1]
+
+
+//! [2]
+class SocketClass(...):
+ def readyReadSlot(self):
+ # This slot is connected to QAbstractSocket::readyRead()
+ while not socket.atEnd():
+ data = socket.read(100)
+ ...
+//! [2]
+
+
+//! [3]
+socket.setProxy(QNetworkProxy.NoProxy)
+//! [3]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_network_socket_qlocalsocket_unix.cpp b/doc/codesnippets/doc/src/snippets/code/src_network_socket_qlocalsocket_unix.cpp
new file mode 100644
index 000000000..04458fb92
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_network_socket_qlocalsocket_unix.cpp
@@ -0,0 +1,12 @@
+//! [0]
+socket.connectToServer("market")
+if (socket.waitForConnected(1000))
+ print("Connected!")
+//! [0]
+
+
+//! [1]
+socket.disconnectFromServer()
+if (socket.waitForDisconnected(1000))
+ print("Disconnected!")
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_network_socket_qnativesocketengine.cpp b/doc/codesnippets/doc/src/snippets/code/src_network_socket_qnativesocketengine.cpp
new file mode 100644
index 000000000..1bceff272
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_network_socket_qnativesocketengine.cpp
@@ -0,0 +1,21 @@
+//! [0]
+socketLayer = QNativeSocketEngine()
+socketLayer.initialize(QAbstractSocket.TcpSocket, QAbstractSocket.IPv4Protocol)
+socketLayer.connectToHost(QHostAddress.LocalHost, 22)
+# returns False
+
+socketLayer.waitForWrite()
+socketLayer.connectToHost(QHostAddress.LocalHost, 22)
+# returns True
+//! [0]
+
+
+//! [1]
+socketLayer = QNativeSocketEngine()
+socketLayer.bind(QHostAddress.Any, 4000)
+socketLayer.listen()
+if socketLayer.waitForRead():
+ clientSocket = socketLayer.accept()
+ # a client is connected
+
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_network_socket_qtcpserver.cpp b/doc/codesnippets/doc/src/snippets/code/src_network_socket_qtcpserver.cpp
new file mode 100644
index 000000000..b685462bc
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_network_socket_qtcpserver.cpp
@@ -0,0 +1,3 @@
+//! [0]
+server.setProxy(QNetworkProxy.NoProxy)
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_network_socket_qudpsocket.cpp b/doc/codesnippets/doc/src/snippets/code/src_network_socket_qudpsocket.cpp
new file mode 100644
index 000000000..bc39440c6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_network_socket_qudpsocket.cpp
@@ -0,0 +1,17 @@
+//! [0]
+def initSocket(self):
+ udpSocket = QUdpSocket(self)
+ udpSocket.bind(QHostAddress.LocalHost, 7755)
+
+ self.connect(udpSocket, SIGNAL('readyRead()'),
+ self, SLOT('readPendingDatagrams()'))
+
+def readPendingDatagrams(self):
+ while udpSocket.hasPendingDatagrams():
+ datagram = QByteArray()
+ datagram.resize(udpSocket.pendingDatagramSize())
+
+ (sender, senderPort) = udpSocket.readDatagram(datagram.data(), datagram.size())
+
+ processTheDatagram(datagram)
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_network_ssl_qsslcertificate.cpp b/doc/codesnippets/doc/src/snippets/code/src_network_ssl_qsslcertificate.cpp
new file mode 100644
index 000000000..953ddbddc
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_network_ssl_qsslcertificate.cpp
@@ -0,0 +1,4 @@
+//! [0]
+for cert in QSslCertificate.fromPath('C:/ssl/certificate.*.pem', QSsL.Pem, QRegExp.Wildcard):
+ print cert.issuerInfo(QSslCertificate.Organization)
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_network_ssl_qsslconfiguration.cpp b/doc/codesnippets/doc/src/snippets/code/src_network_ssl_qsslconfiguration.cpp
new file mode 100644
index 000000000..5a64a087e
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_network_ssl_qsslconfiguration.cpp
@@ -0,0 +1,5 @@
+//! [0]
+config = sslSocket.sslConfiguration()
+config.setProtocol(QSsl.TlsV1)
+sslSocket.setSslConfiguration(config)
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_network_ssl_qsslsocket.cpp b/doc/codesnippets/doc/src/snippets/code/src_network_ssl_qsslsocket.cpp
new file mode 100644
index 000000000..21e2d078f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_network_ssl_qsslsocket.cpp
@@ -0,0 +1,50 @@
+//! [0]
+socket = QSslSocket(self)
+QObject.connect(socket, SIGNAL("encrypted()"), self, SLOT("ready()"))
+
+socket.connectToHostEncrypted("imap.example.com", 993)
+//! [0]
+
+
+//! [1]
+def incomingConnection(socketDescriptor):
+ serverSocket = QSslSocket()
+ if serverSocket.setSocketDescriptor(socketDescriptor):
+ QObject.connect(serverSocket, SIGNAL("encrypted()"), self, SLOT("ready()"))
+ serverSocket.startServerEncryption()
+//! [1]
+
+
+//! [2]
+socket = QSslSocket()
+socket.connectToHostEncrypted("http.example.com", 443)
+if not socket.waitForEncrypted():
+ print socket.errorString()
+ return false
+
+socket.write("GET / HTTP/1.0\r\n\r\n")
+while socket.waitForReadyRead():
+ print socket.readAll().data()
+//! [2]
+
+
+//! [3]
+socket = QSslSocket()
+QObject.connect(socket, SIGNAL("encrypted()"), receiver, SLOT("socketEncrypted()"))
+
+socket.connectToHostEncrypted("imap", 993)
+socket.write("1 CAPABILITY\r\n")
+//! [3]
+
+
+//! [4]
+socket = QSslSocket()
+socket.setCiphers("DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:AES256-SHA")
+//! [4]
+
+
+//! [5]
+socket.connectToHostEncrypted("imap", 993)
+if socket.waitForEncrypted(1000):
+ print "Encrypted!"
+//! [5]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_opengl_qgl.cpp b/doc/codesnippets/doc/src/snippets/code/src_opengl_qgl.cpp
new file mode 100644
index 000000000..80ef99c95
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_opengl_qgl.cpp
@@ -0,0 +1,118 @@
+//! [0]
+fmt = QGLFormat()
+fmt.setAlpha(True)
+fmt.setStereo(True)
+QGLFormat.setDefaultFormat(fmt)
+//! [0]
+
+
+//! [1]
+fmt = QGLFormat()
+fmt.setDoubleBuffer(False) # single buffer
+fmt.setDirectRendering(False) # software rendering
+myWidget = MyGLWidget(fmt, ...)
+//! [1]
+
+
+//! [2]
+fmt = QGLFormat()
+fmt.setOverlay(True)
+fmt.setStereo(True)
+myWidget = MyGLWidget(fmt, ...)
+if !myWidget.format().stereo():
+ # ok, goggles off
+ if !myWidget.format().hasOverlay():
+ print "Cool hardware required"
+//! [2]
+
+
+//! [3]
+# The rendering in MyGLWidget depends on using
+# stencil buffer and alpha channel
+
+class MyGLWidget(QGLWidget):
+ def __init__(self, parent):
+ QGLWidget.__init__(self, QGLFormat(QGL.StencilBuffer | QGL.AlphaChannel), parent)
+
+ if !format().stencil():
+ print "Could not get stencil buffer results will be suboptimal"
+ if !format().alpha():
+ print "Could not get alpha channel results will be suboptimal"
+ ...
+//! [3]
+
+
+//! [4]
+a = QApplication([])
+f = QGLFormat()
+f.setDoubleBuffer(False)
+QGLFormat.setDefaultFormat(f)
+//! [4]
+
+
+//! [5]
+f = QGLFormat.defaultOverlayFormat()
+f.setDoubleBuffer(True)
+QGLFormat.setDefaultOverlayFormat(f)
+//! [5]
+
+
+//! [6]
+# ...continued from above
+myWidget = MyGLWidget(QGLFormat(QGL.HasOverlay), ...)
+if myWidget.format().hasOverlay():
+ # Yes, we got an overlay, let's check _its_ format:
+ olContext = myWidget.overlayContext()
+ if olContext.format().doubleBuffer():
+ # yes, we got a double buffered overlay
+ else:
+ # no, only single buffered overlays are available
+//! [6]
+
+
+//! [7]
+cx = QGLContext()
+# ...
+f = QGLFormat()
+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(QGLWidget):
+
+ def __init__(self, parent):
+ QGLWidget.__init__(self, parent)
+ pass
+
+ def initializeGL(self):
+ # Set up the rendering context, define display lists etc.:
+ ...
+ glClearColor(0.0, 0.0, 0.0, 0.0)
+ glEnable(GL_DEPTH_TEST)
+ ...
+
+ def resizeGL(self, w, h):
+ # setup viewport, projection etc.:
+ glViewport(0, 0, w, h)
+ ...
+ glFrustum(...)
+ ...
+
+ def paintGL(self):
+ # draw the scene:
+ ...
+ glRotatef(...)
+ glMaterialfv(...)
+ glBegin(GL_QUADS)
+ glVertex3f(...)
+ glVertex3f(...)
+ ...
+ glEnd()
+ ...
+//! [8]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_opengl_qglcolormap.cpp b/doc/codesnippets/doc/src/snippets/code/src_opengl_qglcolormap.cpp
new file mode 100644
index 000000000..804741221
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_opengl_qglcolormap.cpp
@@ -0,0 +1,24 @@
+//! [0]
+import sys
+
+from PySide.QtGui import QApplication, qRgb
+from PySide.QtOpenGL import QGLColormap
+
+def main(argv):
+ app = QApplication(argv)
+
+ widget = MySuperGLWidget() # a QGLWidget in color-index mode
+ colormap = QGLColormap()
+
+ # This will fill the colormap with colors ranging from
+ # black to white.
+ for i in range(0, colormap.size()):
+ colormap.setEntry(i, qRgb(i, i, i))
+
+ widget.setColormap(colormap)
+ widget.show()
+ return app.exec_()
+
+if __name__ == "__main__":
+ main(sys.argv)
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_opengl_qglpixelbuffer.cpp b/doc/codesnippets/doc/src/snippets/code/src_opengl_qglpixelbuffer.cpp
new file mode 100644
index 000000000..5c63b3e75
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_opengl_qglpixelbuffer.cpp
@@ -0,0 +1,19 @@
+//! [0]
+pbuffer QGLPixelBuffer(...)
+...
+pbuffer.makeCurrent()
+dynamicTexture = pbuffer.generateDynamicTexture()
+pbuffer.bindToDynamicTexture(dynamicTexture)
+...
+pbuffer.releaseFromDynamicTexture()
+//! [0]
+
+
+//! [1]
+pbuffer QGLPixelBuffer(...)
+...
+pbuffer.makeCurrent()
+dynamicTexture = pbuffer.generateDynamicTexture()
+...
+pbuffer.updateDynamicTexture(dynamicTexture)
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qdbus_qdbusabstractinterface.cpp b/doc/codesnippets/doc/src/snippets/code/src_qdbus_qdbusabstractinterface.cpp
new file mode 100644
index 000000000..cc5b86deb
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qdbus_qdbusabstractinterface.cpp
@@ -0,0 +1,20 @@
+//! [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/codesnippets/doc/src/snippets/code/src_qdbus_qdbusargument.cpp b/doc/codesnippets/doc/src/snippets/code/src_qdbus_qdbusargument.cpp
new file mode 100644
index 000000000..efd54ac1b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qdbus_qdbusargument.cpp
@@ -0,0 +1,151 @@
+//! [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/codesnippets/doc/src/snippets/code/src_qdbus_qdbuscontext.cpp b/doc/codesnippets/doc/src/snippets/code/src_qdbus_qdbuscontext.cpp
new file mode 100644
index 000000000..2a8c868ad
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qdbus_qdbuscontext.cpp
@@ -0,0 +1,32 @@
+//! [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/codesnippets/doc/src/snippets/code/src_qdbus_qdbusinterface.cpp b/doc/codesnippets/doc/src/snippets/code/src_qdbus_qdbusinterface.cpp
new file mode 100644
index 000000000..df883e7d7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qdbus_qdbusinterface.cpp
@@ -0,0 +1,11 @@
+//! [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/codesnippets/doc/src/snippets/code/src_qdbus_qdbusmetatype.cpp b/doc/codesnippets/doc/src/snippets/code/src_qdbus_qdbusmetatype.cpp
new file mode 100644
index 000000000..99fd6e4f7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qdbus_qdbusmetatype.cpp
@@ -0,0 +1,3 @@
+//! [0]
+qDBusRegisterMetaType<MyClass>();
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qdbus_qdbusreply.cpp b/doc/codesnippets/doc/src/snippets/code/src_qdbus_qdbusreply.cpp
new file mode 100644
index 000000000..4dc896f9e
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qdbus_qdbusreply.cpp
@@ -0,0 +1,14 @@
+//! [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/codesnippets/doc/src/snippets/code/src_qt3support_canvas_q3canvas.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_canvas_q3canvas.cpp
new file mode 100644
index 000000000..bca056c9d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_canvas_q3canvas.cpp
@@ -0,0 +1,51 @@
+//! [0]
+QPrinter pr;
+if (pr.setup()) {
+ QPainter p(&pr);
+ canvas.drawArea(canvas.rect(), &p);
+}
+//! [0]
+
+
+//! [1]
+void MyCanvasView::contentsMousePressEvent(QMouseEvent* e)
+{
+ Q3CanvasItemList l = canvas()->collisions(e->pos());
+ for (Q3CanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) {
+ if ((*it)->rtti() == Q3CanvasRectangle::RTTI)
+ qDebug("A Q3CanvasRectangle lies somewhere at this point");
+ }
+}
+//! [1]
+
+
+//! [2]
+QMatrix wm;
+wm.scale(2, 2); // Zooms in by 2 times
+wm.rotate(90); // Rotates 90 degrees counter clockwise
+ // around the origin.
+wm.translate(0, -canvas->height());
+ // moves the canvas down so what was visible
+ // before is still visible.
+myCanvasView->setWorldMatrix(wm);
+//! [2]
+
+
+//! [3]
+QRect rc = QRect(myCanvasView->contentsX(), myCanvasView->contentsY(),
+ myCanvasView->visibleWidth(), myCanvasView->visibleHeight());
+QRect canvasRect = myCanvasView->inverseWorldMatrix().mapRect(rc);
+//! [3]
+
+
+//! [4]
+Q3CanvasItem* item;
+// Find an item, e.g. with Q3CanvasItem::collisions().
+...
+if (item->rtti() == MySprite::RTTI) {
+ MySprite* s = (MySprite*)item;
+ if (s->isDamagable()) s->loseHitPoints(1000);
+ if (s->isHot()) myself->loseHitPoints(1000);
+ ...
+}
+//! [4]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_dialogs_q3filedialog.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_dialogs_q3filedialog.cpp
new file mode 100644
index 000000000..ea669857d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_dialogs_q3filedialog.cpp
@@ -0,0 +1,229 @@
+//! [0]
+QString s = Q3FileDialog::getOpenFileName(
+ "/home",
+ "Images (*.png *.xpm *.jpg)",
+ this,
+ "open file dialog",
+ "Choose a file");
+//! [0]
+
+
+//! [1]
+"Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"
+//! [1]
+
+
+//! [2]
+Q3FileDialog* fd = new Q3FileDialog(this, "file dialog", true);
+fd->setMode(Q3FileDialog::AnyFile);
+//! [2]
+
+
+//! [3]
+fd->setFilter("Images (*.png *.xpm *.jpg)");
+//! [3]
+
+
+//! [4]
+fd->setViewMode(Q3FileDialog::Detail);
+//! [4]
+
+
+//! [5]
+QString fileName;
+if (fd->exec() == QDialog::Accepted)
+ fileName = fd->selectedFile();
+//! [5]
+
+
+//! [6]
+class Preview : public QLabel, public Q3FilePreview
+{
+public:
+ Preview(QWidget *parent=0) : QLabel(parent) {}
+
+ void previewUrl(const Q3Url &u)
+ {
+ QString path = u.path();
+ QPixmap pix(path);
+ if (pix.isNull())
+ setText("This is not a pixmap");
+ else
+ setPixmap(pix);
+ }
+};
+//! [6]
+
+
+//! [7]
+Preview* p = new Preview;
+
+Q3FileDialog* fd = new Q3FileDialog(this);
+fd->setContentsPreviewEnabled(true);
+fd->setContentsPreview(p, p);
+fd->setPreviewMode(Q3FileDialog::Contents);
+fd->show();
+//! [7]
+
+
+//! [8]
+QStringList list = myFileDialog.selectedFiles();
+QStringList::Iterator it = list.begin();
+while(it != list.end()) {
+ myProcessing(*it);
+ ++it;
+}
+//! [8]
+
+
+//! [9]
+fd->setFilter("All C++ files (*.cpp *.cc *.C *.cxx *.c++)");
+fd->setFilter("*.cpp *.cc *.C *.cxx *.c++");
+fd->setFilter("All C++ files (*.cpp;*.cc;*.C;*.cxx;*.c++)");
+fd->setFilter("*.cpp;*.cc;*.C;*.cxx;*.c++");
+//! [9]
+
+
+//! [10]
+QString s = Q3FileDialog::getOpenFileName(
+ "/home",
+ "Images (*.png *.xpm *.jpg)",
+ this,
+ "open file dialog",
+ "Choose a file to open");
+//! [10]
+
+
+//! [11]
+QString s = Q3FileDialog::getSaveFileName(
+ "/home",
+ "Images (*.png *.xpm *.jpg)",
+ this,
+ "save file dialog",
+ "Choose a filename to save under");
+//! [11]
+
+
+//! [12]
+QString s = Q3FileDialog::getExistingDirectory(
+ "/home",
+ this,
+ "get existing directory",
+ "Choose a directory",
+ true);
+//! [12]
+
+
+//! [13]
+MyFileDialog::MyFileDialog(QWidget* parent, const char* name) :
+ Q3FileDialog(parent, name)
+{
+ QLabel* label = new QLabel("Added widgets", this);
+ QLineEdit* lineedit = new QLineEdit(this);
+ QPushButton* pushbutton = new QPushButton(this);
+
+ addWidgets(label, lineedit, pushbutton);
+}
+//! [13]
+
+
+//! [14]
+QString types("Image files (*.png *.xpm *.jpg);;"
+ "Text files (*.txt);;"
+ "Any files (*)");
+Q3FileDialog fd = new Q3FileDialog(this);
+fd->setFilters(types);
+fd->show();
+//! [14]
+
+
+//! [15]
+Q3FileDialog* fd = new Q3FileDialog(this);
+fd->addFilter("Images (*.png *.jpg *.xpm)");
+fd->show();
+//! [15]
+
+
+//! [16]
+QStringList files = Q3FileDialog::getOpenFileNames(
+ "Images (*.png *.xpm *.jpg)",
+ "/home",
+ this,
+ "open files dialog",
+ "Select one or more files to open");
+//! [16]
+
+
+//! [17]
+QStringList list = files;
+QStringList::Iterator it = list.begin();
+while(it != list.end()) {
+ myProcessing(*it);
+ ++it;
+}
+//! [17]
+
+
+//! [18]
+class Preview : public QLabel, public Q3FilePreview
+{
+public:
+ Preview(QWidget *parent=0) : QLabel(parent) {}
+
+ void previewUrl(const Q3Url &u)
+ {
+ QString path = u.path();
+ QPixmap pix(path);
+ if (pix.isNull())
+ setText("This is not a pixmap");
+ else
+ setText("This is a pixmap");
+ }
+};
+
+//...
+
+int main(int argc, char** argv)
+{
+ Preview* p = new Preview;
+
+ Q3FileDialog* fd = new Q3FileDialog(this);
+ fd->setInfoPreviewEnabled(true);
+ fd->setInfoPreview(p, p);
+ fd->setPreviewMode(Q3FileDialog::Info);
+ fd->show();
+}
+
+//! [18]
+
+
+//! [19]
+class Preview : public QLabel, public Q3FilePreview
+{
+public:
+ Preview(QWidget *parent=0) : QLabel(parent) {}
+
+ void previewUrl(const Q3Url &u)
+ {
+ QString path = u.path();
+ QPixmap pix(path);
+ if (pix.isNull())
+ setText("This is not a pixmap");
+ else
+ setPixmap(pix);
+ }
+};
+
+//...
+
+int main(int argc, char** argv)
+{
+ Preview* p = new Preview;
+
+ Q3FileDialog* fd = new Q3FileDialog(this);
+ fd->setContentsPreviewEnabled(true);
+ fd->setContentsPreview(p, p);
+ fd->setPreviewMode(Q3FileDialog::Contents);
+ fd->show();
+}
+//! [19]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_dialogs_q3progressdialog.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_dialogs_q3progressdialog.cpp
new file mode 100644
index 000000000..8aeafe8ab
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_dialogs_q3progressdialog.cpp
@@ -0,0 +1,41 @@
+//! [0]
+Q3ProgressDialog progress("Copying files...", "Abort Copy", numFiles,
+ this, "progress", true);
+for (int i = 0; i < numFiles; i++) {
+ progress.setProgress(i);
+ qApp->processEvents();
+
+ if (progress.wasCanceled())
+ break;
+ //... copy one file
+}
+progress.setProgress(numFiles);
+//! [0]
+
+
+//! [1]
+Operation::Operation(QObject *parent = 0)
+ : QObject(parent), steps(0)
+{
+ pd = new Q3ProgressDialog("Operation in progress.", "Cancel", 100);
+ connect(pd, SIGNAL(canceled()), this, SLOT(cancel()));
+ t = new QTimer(this);
+ connect(t, SIGNAL(timeout()), this, SLOT(perform()));
+ t->start(0);
+}
+
+void Operation::perform()
+{
+ pd->setProgress(steps);
+ //... perform one percent of the operation
+ steps++;
+ if (steps > pd->totalSteps())
+ t->stop();
+}
+
+void Operation::cancel()
+{
+ t->stop();
+ //... cleanup
+}
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_itemviews_q3iconview.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_itemviews_q3iconview.cpp
new file mode 100644
index 000000000..8c303891e
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_itemviews_q3iconview.cpp
@@ -0,0 +1,75 @@
+//! [0]
+(void) new Q3IconViewItem(
+ iconView, // A pointer to a Q3IconView
+ "This is the text of the item",
+ aPixmap);
+//! [0]
+
+
+//! [1]
+Q3IconViewItem *item;
+for (item = iconView->firstItem(); item; item = item->nextItem())
+ do_something_with(item);
+//! [1]
+
+
+//! [2]
+Q3IconViewItem *item;
+for (item = iconView->firstItem(); item; item = item->nextItem())
+ do_something_with(item);
+//! [2]
+
+
+//! [3]
+int MyIconViewItem::compare(Q3IconViewItem *i) const
+{
+ return key().compare(i->key());
+}
+//! [3]
+
+
+//! [4]
+Q3IconView *iv = new Q3IconView(this);
+QDir dir(path, "*.xpm");
+for (uint i = 0; i < dir.count(); i++) {
+ (void) new Q3IconViewItem(iv, dir[i], QPixmap(path + dir[i]));
+}
+iv->resize(600, 400);
+iv->show();
+//! [4]
+
+
+//! [5]
+for (Q3IconViewItem *item = iv->firstItem(); item; item = item->nextItem())
+ do_something(item);
+//! [5]
+
+
+//! [6]
+Q3DragObject *MyIconView::dragObject()
+{
+ return new Q3TextDrag(currentItem()->text(), this);
+}
+//! [6]
+
+
+//! [7]
+bool MyIconViewItem::acceptDrop(const QMimeSource *mime) const
+{
+ if (mime->provides("text/plain"))
+ return true;
+ return false;
+}
+
+void MyIconViewItem::dropped(QDropEvent *evt, const Q3ValueList<Q3IconDragItem>&)
+{
+ QString label;
+ if (Q3TextDrag::decode(evt, label))
+ setText(label);
+}
+//! [7]
+
+
+//! [8]
+(void) new Q3IconViewItem(myIconview, "The text of the item", aPixmap);
+//! [8]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_itemviews_q3listview.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_itemviews_q3listview.cpp
new file mode 100644
index 000000000..615f124fd
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_itemviews_q3listview.cpp
@@ -0,0 +1,73 @@
+//! [0]
+(void) new Q3ListViewItem(listView, "Column 1", "Column 2");
+(void) new Q3ListViewItem(listView->firstChild(), "A", "B", "C");
+//! [0]
+
+
+//! [1]
+Q3ListViewItem * myChild = myItem->firstChild();
+while(myChild) {
+ doSomething(myChild);
+ myChild = myChild->nextSibling();
+}
+//! [1]
+
+
+//! [2]
+Q3ListViewItemIterator it(listview);
+while (it.current()) {
+ Q3ListViewItem *item = it.current();
+ doSomething(item);
+ ++it;
+}
+//! [2]
+
+
+//! [3]
+int MyListViewItem::compare(Q3ListViewItem *i, int col,
+ bool ascending) const
+{
+ return key(col, ascending).compare(i->key(col, ascending));
+}
+//! [3]
+
+
+//! [4]
+Q3ListViewItem *i = itemAt(p);
+if (i) {
+ if (p.x() > header()->sectionPos(header()->mapToIndex(0)) +
+ treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + itemMargin() ||
+ p.x() < header()->sectionPos(header()->mapToIndex(0))) {
+ ; // p is not on root decoration
+ else
+ ; // p is on the root decoration
+}
+//! [4]
+
+
+//! [5]
+QRect r(listView->itemRect(item));
+r.setHeight(qMin(item->totalHeight(),
+ listView->viewport->height() - r.y()))
+//! [5]
+
+
+//! [6]
+QList<Q3ListViewItem *> lst;
+Q3ListViewItemIterator it(myListView);
+while (it.current()) {
+ if (it.current()->isSelected())
+ lst.append(it.current());
+ ++it;
+}
+//! [6]
+
+
+//! [7]
+QList<Q3ListViewItem *> lst;
+Q3ListViewItemIterator it(myListView, Selected);
+while (it.current()) {
+ lst.append(it.current());
+ ++it;
+}
+//! [7]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_itemviews_q3table.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_itemviews_q3table.cpp
new file mode 100644
index 000000000..47f9c4ebb
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_itemviews_q3table.cpp
@@ -0,0 +1,57 @@
+
+void wrapInFunction()
+{
+
+//! [0]
+for (int row = 0; row < table->numRows(); row++) {
+ for (int col = 0; col < table->numCols(); col++) {
+ table->setItem(row, col,
+ new Q3TableItem(table, Q3TableItem::WhenCurrent, QString::number(row * col)));
+ }
+}
+//! [0]
+
+
+//! [1]
+QWidget* MyTableItem::createEditor() const
+{
+ QHBox* hbox = new QHBox(table()->viewport());
+ hbox->setFocusProxy(new QLineEdit(hbox));
+ new QLineEdit(hbox);
+ return hbox;
+}
+//! [1]
+
+
+//! [2]
+p->setClipRect(table()->cellRect(row, col), QPainter::ClipPainter);
+//... your drawing code
+p->setClipping(false);
+//! [2]
+
+
+//! [3]
+Q3Table *table = new Q3Table(100, 250, this);
+table->setPixmap(3, 2, pix);
+table->setText(3, 2, "A pixmap");
+//! [3]
+
+
+//! [4]
+p->setClipRect(cellRect(row, col), QPainter::CoordPainter);
+//... your drawing code
+p->setClipping(false);
+//! [4]
+
+
+//! [5]
+Q3TableItem *i = item(row, col);
+if (initFromCell || (i && !i->isReplaceable()))
+ // If we had a Q3TableItem ask the base class to create the editor
+ return Q3Table::createEditor(row, col, initFromCell);
+else
+ return ...(create your own editor)
+//! [5]
+
+}
+
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3dns.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3dns.cpp
new file mode 100644
index 000000000..9638ff117
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3dns.cpp
@@ -0,0 +1,58 @@
+//! [0]
+QStringList list = myDns.qualifiedNames();
+QStringList::Iterator it = list.begin();
+while( it != list.end() ) {
+ myProcessing( *it );
+ ++it;
+}
+//! [0]
+
+
+//! [1]
+Q3ValueList<QHostAddress> list = myDns.addresses();
+Q3ValueList<QHostAddress>::Iterator it = list.begin();
+while( it != list.end() ) {
+ myProcessing( *it );
+ ++it;
+}
+//! [1]
+
+
+//! [2]
+Q3ValueList<Q3Dns::MailServer> list = myDns.mailServers();
+Q3ValueList<Q3Dns::MailServer>::Iterator it = list.begin();
+while( it != list.end() ) {
+ myProcessing( *it );
+ ++it;
+}
+//! [2]
+
+
+//! [3]
+Q3ValueList<Q3Dns::Server> list = myDns.servers();
+Q3ValueList<Q3Dns::Server>::Iterator it = list.begin();
+while( it != list.end() ) {
+ myProcessing( *it );
+ ++it;
+}
+//! [3]
+
+
+//! [4]
+QStringList list = myDns.hostNames();
+QStringList::Iterator it = list.begin();
+while( it != list.end() ) {
+ myProcessing( *it );
+ ++it;
+}
+//! [4]
+
+
+//! [5]
+QStringList list = myDns.texts();
+QStringList::Iterator it = list.begin();
+while( it != list.end() ) {
+ myProcessing( *it );
+ ++it;
+}
+//! [5]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3ftp.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3ftp.cpp
new file mode 100644
index 000000000..37e17d45b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3ftp.cpp
@@ -0,0 +1,65 @@
+//! [0]
+QUrlOperator op( "ftp://ftp.trolltech.com" );
+op.listChildren(); // Asks the server to provide a directory listing
+//! [0]
+
+
+//! [1]
+Q3Ftp *ftp = new Q3Ftp( this ); // this is an optional QObject parent
+ftp->connectToHost( "ftp.trolltech.com" );
+ftp->login();
+//! [1]
+
+
+//! [2]
+ftp->connectToHost( "ftp.trolltech.com" ); // id == 1
+ftp->login(); // id == 2
+ftp->cd( "qt" ); // id == 3
+ftp->get( "INSTALL" ); // id == 4
+ftp->close(); // id == 5
+//! [2]
+
+
+//! [3]
+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 )
+//! [3]
+
+
+//! [4]
+start( 1 )
+stateChanged( HostLookup )
+stateChanged( Connecting )
+stateChanged( Connected )
+finished( 1, false )
+
+start( 2 )
+finished( 2, true )
+
+done( true )
+//! [4]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3http.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3http.cpp
new file mode 100644
index 000000000..6729c5fa5
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3http.cpp
@@ -0,0 +1,74 @@
+//! [0]
+content-type: text/html
+//! [0]
+
+
+//! [1]
+header.setValue( "content-type", "text/html" );
+QString contentType = header.value( "content-type" );
+//! [1]
+
+
+//! [2]
+QUrlOperator op( "http://qtsoftware.com" );
+op.get( "index.html" );
+//! [2]
+
+
+//! [3]
+Q3HttpRequestHeader header( "GET", "/index.html" );
+header.setValue( "Host", "qtsoftware.com" );
+http->setHost( "qtsoftware.com" );
+http->request( header );
+//! [3]
+
+
+//! [4]
+http->setHost( "qtsoftware.com" ); // id == 1
+http->get( "/index.html" ); // id == 2
+//! [4]
+
+
+//! [5]
+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 )
+//! [5]
+
+
+//! [6]
+http->setHost( "www.foo.bar" ); // id == 1
+http->get( "/index.html" ); // id == 2
+http->post( "register.html", data ); // id == 3
+//! [6]
+
+
+//! [7]
+requestStarted( 1 )
+requestFinished( 1, false )
+
+requestStarted( 2 )
+stateChanged( HostLookup )
+requestFinished( 2, true )
+
+done( true )
+
+stateChanged( Unconnected )
+//! [7]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3localfs.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3localfs.cpp
new file mode 100644
index 000000000..243be9eb8
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3localfs.cpp
@@ -0,0 +1,4 @@
+//! [0]
+Q3UrlOperator op( "file:///tmp" );
+op.listChildren(); // Asks the server to provide a directory listing
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3networkprotocol.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3networkprotocol.cpp
new file mode 100644
index 000000000..51d1059a2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3networkprotocol.cpp
@@ -0,0 +1,8 @@
+//! [0]
+Q3NetworkProtocol::registerNetworkProtocol( "nntp", new Q3NetworkProtocolFactory<Nntp> );
+//! [0]
+
+
+//! [1]
+Q3Ftp *ftp = Q3NetworkProtocol::getNetworkProtocol( "ftp" );
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3socket.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3socket.cpp
new file mode 100644
index 000000000..34474fb6e
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3socket.cpp
@@ -0,0 +1,4 @@
+//! [0]
+while( !socket->canReadLine() ) // WRONG
+ ;
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3socketdevice.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3socketdevice.cpp
new file mode 100644
index 000000000..cd50fd215
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3socketdevice.cpp
@@ -0,0 +1,4 @@
+//! [0]
+::close( sd->socket() );
+sd->writeBlock( someData, 42 );
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3url.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3url.cpp
new file mode 100644
index 000000000..3b78a571f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3url.cpp
@@ -0,0 +1,43 @@
+//! [0]
+Q3Url url( "http://qtsoftware.com" );
+// or
+Q3Url url( "file:///home/myself/Mail", "Inbox" );
+//! [0]
+
+
+//! [1]
+Q3Url url( "http://qtsoftware.com" );
+QString s = url;
+// or
+QString s( "http://qtsoftware.com" );
+Q3Url url( s );
+//! [1]
+
+
+//! [2]
+Q3Url url( "ftp://ftp.trolltech.com/qt/source", "qt-2.1.0.tar.gz" );
+//! [2]
+
+
+//! [3]
+Q3Url url( "ftp://ftp.trolltech.com/qt/source", "/usr/local" );
+//! [3]
+
+
+//! [4]
+Q3Url url( "ftp://ftp.trolltech.com/qt/source", "file:///usr/local" );
+//! [4]
+
+
+//! [5]
+QString url = http://qtsoftware.com
+Q3Url::encode( url );
+// url is now "http%3A//www%20trolltech%20com"
+//! [5]
+
+
+//! [6]
+QString url = "http%3A//www%20trolltech%20com"
+Q3Url::decode( url );
+// url is now "http://qtsoftware.com"
+//! [6]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3urloperator.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3urloperator.cpp
new file mode 100644
index 000000000..03b8f7bae
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_network_q3urloperator.cpp
@@ -0,0 +1,37 @@
+//! [0]
+Q3UrlOperator *op = new Q3UrlOperator();
+op->copy( QString("ftp://ftp.trolltech.com/qt/source/qt-2.1.0.tar.gz"),
+ "file:///tmp" );
+//! [0]
+
+
+//! [1]
+Q3UrlOperator op( "http://www.whatever.org/cgi-bin/search.pl?cmd=Hello" );
+op.get();
+//! [1]
+
+
+//! [2]
+Q3UrlOperator op( "ftp://ftp.whatever.org/pub" );
+// do some other stuff like op.listChildren() or op.mkdir( "new_dir" )
+op.get( "a_file.txt" );
+//! [2]
+
+
+//! [3]
+Q3UrlOperator op( "http://www.whatever.org/cgi-bin" );
+op.get( "search.pl?cmd=Hello" ); // WRONG!
+//! [3]
+
+
+//! [4]
+Q3UrlOperator op( "ftp://ftp.whatever.com/home/me/filename.dat" );
+op.put( data );
+//! [4]
+
+
+//! [5]
+Q3UrlOperator op( "ftp://ftp.whatever.com/home/me" );
+// do some other stuff like op.listChildren() or op.mkdir( "new_dir" )
+op.put( data, "filename.dat" );
+//! [5]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_other_q3accel.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_other_q3accel.cpp
new file mode 100644
index 000000000..ba315c0d9
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_other_q3accel.cpp
@@ -0,0 +1,40 @@
+//! [0]
+QPushButton p("&Exit", parent); // automatic shortcut Alt+E
+Q3PopupMenu *fileMenu = new fileMenu(parent);
+fileMenu->insertItem("Undo", parent, SLOT(undo()),
+ Qt::CTRL + Qt::Key_Z);
+//! [0]
+
+
+//! [1]
+accelerator->insertItem(QKeySequence("M"));
+//! [1]
+
+
+//! [2]
+Q3Accel *a = new Q3Accel(myWindow);
+a->connectItem(a->insertItem(Qt::CTRL + Qt::Key_P),
+ myWindow, SLOT(printDoc()));
+//! [2]
+
+
+//! [3]
+Q3Accel *a = new Q3Accel(myWindow); // create accels for myWindow
+a->insertItem(CTRL + Key_P, 200); // Ctrl+P, e.g. to print document
+a->insertItem(ALT + Key_X, 201); // Alt+X, e.g. to quit
+a->insertItem(UNICODE_ACCEL + 'q', 202); // Unicode 'q', e.g. to quit
+a->insertItem(Key_D); // gets a unique negative id < -1
+a->insertItem(CTRL + SHIFT + Key_P); // gets a unique negative id < -1
+//! [3]
+
+
+//! [4]
+a->connectItem(201, mainView, SLOT(quit()));
+//! [4]
+
+
+//! [5]
+Q3PopupMenu *file = new Q3PopupMenu(this);
+file->insertItem(p1, tr("&Open..."), this, SLOT(open()),
+ Q3Accel::stringToKey(tr("Ctrl+O", "File|Open")));
+//! [5]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_other_q3mimefactory.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_other_q3mimefactory.cpp
new file mode 100644
index 000000000..f00ad7363
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_other_q3mimefactory.cpp
@@ -0,0 +1,32 @@
+//! [0]
+static const char* myimage_data[]={
+"...",
+...
+"..."};
+//! [0]
+
+
+//! [1]
+Q3MimeSourceFactory::defaultFactory()->setImage("myimage", QImage(myimage_data));
+//! [1]
+
+
+//! [2]
+QLabel* label = new QLabel(
+ "Rich text with embedded image:<img source=\"myimage\">"
+ "Isn't that <em>cute</em>?");
+//! [2]
+
+
+//! [3]
+delete label;
+Q3MimeSourceFactory::defaultFactory()->setData("myimage", 0);
+//! [3]
+
+
+//! [4]
+setExtensionType("html", "text/html;charset=iso8859-1");
+setExtensionType("htm", "text/html;charset=iso8859-1");
+setExtensionType("txt", "text/plain");
+setExtensionType("xml", "text/xml;charset=UTF-8");
+//! [4]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_other_q3process.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_other_q3process.cpp
new file mode 100644
index 000000000..2ce94bb20
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_other_q3process.cpp
@@ -0,0 +1,8 @@
+//! [0]
+QStringList list = myProcess.arguments();
+QStringList::Iterator it = list.begin();
+while( it != list.end() ) {
+ myProcessing( *it );
+ ++it;
+}
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_other_q3process_unix.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_other_q3process_unix.cpp
new file mode 100644
index 000000000..c443c2e75
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_other_q3process_unix.cpp
@@ -0,0 +1,4 @@
+//! [0]
+process->tryTerminate();
+QTimer::singleShot( 5000, process, SLOT(kill()) );
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_painting_q3paintdevicemetrics.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_painting_q3paintdevicemetrics.cpp
new file mode 100644
index 000000000..1e807d5cc
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_painting_q3paintdevicemetrics.cpp
@@ -0,0 +1,4 @@
+//! [0]
+Q3PaintDeviceMetrics pdm(myWidget);
+double aspect = (double)pdm.widthMM() / (double)pdm.heightMM();
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_painting_q3painter.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_painting_q3painter.cpp
new file mode 100644
index 000000000..e93225001
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_painting_q3painter.cpp
@@ -0,0 +1,4 @@
+//! [0]
+QPainter p(myWidget);
+p.drawArc(QRect(10,10, 70,100), 100*16, 160*16); // draws a "(" arc
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_painting_q3picture.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_painting_q3picture.cpp
new file mode 100644
index 000000000..709b3860a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_painting_q3picture.cpp
@@ -0,0 +1,14 @@
+//! [0]
+Q3Picture picture;
+picture.load("drawing.svg", SVG);
+//! [0]
+
+
+//! [1]
+Q3Picture picture;
+QPainter painter;
+painter.begin(&picture); // paint in picture
+...
+painter.end(); // painting done
+picture.save("drawing.svg", SVG); // save picture
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3databrowser.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3databrowser.cpp
new file mode 100644
index 000000000..cb86b323f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3databrowser.cpp
@@ -0,0 +1,8 @@
+//! [0]
+QStringList list = myDataBrowser.sort();
+QStringList::Iterator it = list.begin();
+while(it != list.end()) {
+ myProcessing(*it);
+ ++it;
+}
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3datatable.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3datatable.cpp
new file mode 100644
index 000000000..aa72f4421
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3datatable.cpp
@@ -0,0 +1,8 @@
+//! [0]
+QStringList list = myDataTable.sort();
+QStringList::Iterator it = list.begin();
+while( it != list.end() ) {
+ myProcessing( *it );
+ ++it;
+}
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3dataview.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3dataview.cpp
new file mode 100644
index 000000000..b0b9a5922
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3dataview.cpp
@@ -0,0 +1,4 @@
+//! [0]
+myView.setRecord(record);
+myView.readFields();
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlcursor.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlcursor.cpp
new file mode 100644
index 000000000..b3b643d96
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlcursor.cpp
@@ -0,0 +1,100 @@
+//! [0]
+Q3SqlCursor cur( "staff" ); // Specify the table/view name
+cur.select(); // We'll retrieve every record
+while ( cur.next() ) {
+ qDebug( cur.value( "id" ).toString() + ": " +
+ cur.value( "surname" ).toString() + ' ' +
+ cur.value( "salary" ).toString() );
+}
+//! [0]
+
+
+//! [1]
+Q3SqlCursor cur( "prices" );
+cur.select( "id=202" );
+if ( cur.next() ) {
+ QSqlRecord *buffer = cur.primeUpdate();
+ double price = buffer->value( "price" ).toDouble();
+ double newprice = price * 1.05;
+ buffer->setValue( "price", newprice );
+ cur.update();
+}
+//! [1]
+
+
+//! [2]
+Q3SqlCursor cur("Employee"); // Use the Employee table or view
+cur.select("deptno=10"); // select all records in department 10
+while(cur.next()) {
+ ... // process data
+}
+...
+// select records in other departments, ordered by department number
+cur.select("deptno>10", cur.index("deptno"));
+...
+//! [2]
+
+
+//! [3]
+Q3SqlCursor cur("Employee");
+cur.select("deptno=10"); // select all records in department 10
+while(cur.next()) {
+ ... // process data
+}
+...
+cur.select(); // re-selects all records in department 10
+...
+//! [3]
+
+
+//! [4]
+Q3SqlCursor cur("Employee");
+QSqlIndex pk = cur.primaryIndex();
+cur.setValue("id", 10);
+cur.select(pk, pk); // generates "SELECT ... FROM Employee WHERE id=10 ORDER BY id"
+...
+//! [4]
+
+
+//! [5]
+Q3SqlCursor cur("Employee");
+cur.setMode(Q3SqlCursor::Writable); // allow insert/update/delete
+...
+cur.setMode(Q3SqlCursor::Insert | Q3SqlCursor::Update); // allow inserts and updates only
+...
+cur.setMode(Q3SqlCursor::ReadOnly); // no inserts/updates/deletes allowed
+
+//! [5]
+
+
+//! [6]
+Q3SqlCursor cur("prices");
+QSqlRecord *buffer = cur.primeInsert();
+buffer->setValue("id", 53981);
+buffer->setValue("name", "Thingy");
+buffer->setValue("price", 105.75);
+cur.insert();
+//! [6]
+
+
+//! [7]
+Q3SqlCursor cur("prices");
+cur.select("id=202");
+if (cur.next()) {
+ QSqlRecord *buffer = cur.primeUpdate();
+ double price = buffer->value("price").toDouble();
+ double newprice = price * 1.05;
+ buffer->setValue("price", newprice);
+ cur.update();
+}
+//! [7]
+
+
+//! [8]
+Q3SqlCursor cur("prices");
+cur.select("id=999");
+if (cur.next()) {
+ cur.primeDelete();
+ cur.del();
+}
+//! [8]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlform.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlform.cpp
new file mode 100644
index 000000000..e91b7ed1b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlform.cpp
@@ -0,0 +1,26 @@
+//! [0]
+QLineEdit myEditor(this);
+Q3SqlForm myForm(this);
+Q3SqlCursor myCursor("mytable");
+
+// Execute a query to make the cursor valid
+myCursor.select();
+// Move the cursor to a valid record (the first record)
+myCursor.next();
+// Set the form's record pointer to the cursor's edit buffer (which
+// contains the current record's values)
+myForm.setRecord(myCursor.primeUpdate());
+
+// Insert a field into the form that uses myEditor to edit the
+// field 'somefield' in 'mytable'
+myForm.insert(&myEditor, "somefield");
+
+// Update myEditor with the value from the mapped database field
+myForm.readFields();
+...
+// Let the user edit the form
+...
+// Update the database
+myForm.writeFields(); // Update the cursor's edit buffer from the form
+myCursor.update(); // Update the database from the cursor's buffer
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlmanager_p.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlmanager_p.cpp
new file mode 100644
index 000000000..9d5b2c152
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlmanager_p.cpp
@@ -0,0 +1,11 @@
+//! [0]
+Q3SqlCursor* myCursor = myManager.cursor();
+...
+QSqlRecord* buf = myCursor->primeUpdate();
+buf->setValue("name", "Ola");
+buf->setValue("city", "Oslo");
+...
+myCursor->update(); // update current record
+myCursor->select(); // refresh the cursor
+myManager.findBuffer(myCursor->primaryIndex()); // go to the updated record
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlpropertymap.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlpropertymap.cpp
new file mode 100644
index 000000000..55146de18
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlpropertymap.cpp
@@ -0,0 +1,35 @@
+//! [0]
+Q3SqlPropertyMap *myMap = new Q3SqlPropertyMap();
+Q3SqlForm *myForm = new Q3SqlForm(this);
+MyEditor myEditor(this);
+
+// Set the Q3SqlForm's record buffer to the update buffer of
+// a pre-existing Q3SqlCursor called 'cur'.
+myForm->setRecord(cur->primeUpdate());
+
+// Install the customized map
+myMap->insert("MyEditor", "content");
+myForm->installPropertyMap(myMap); // myForm now owns myMap
+...
+// Insert a field into the form that uses a myEditor to edit the
+// field 'somefield'
+myForm->insert(&myEditor, "somefield");
+
+// Update myEditor with the value from the mapped database field
+myForm->readFields();
+...
+// Let the user edit the form
+...
+// Update the database fields with the values in the form
+myForm->writeFields();
+...
+//! [0]
+
+
+//! [1]
+Q3SqlPropertyMap *myMap = new Q3SqlPropertyMap;
+
+myMap->insert("MyEditor", "content");
+Q3SqlPropertyMap::installDefaultMap(myMap);
+...
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlselectcursor.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlselectcursor.cpp
new file mode 100644
index 000000000..bfb7b04ea
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlselectcursor.cpp
@@ -0,0 +1,11 @@
+//! [0]
+...
+Q3SqlSelectCursor* cur = new Q3SqlSelectCursor("SELECT id, firstname, lastname FROM author");
+Q3DataTable* table = new Q3DataTable(this);
+table->setSqlCursor(cur, true, true);
+table->refresh();
+...
+cur->exec("SELECT * FROM books");
+table->refresh();
+...
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_text_q3simplerichtext.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_text_q3simplerichtext.cpp
new file mode 100644
index 000000000..073d71610
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_text_q3simplerichtext.cpp
@@ -0,0 +1,3 @@
+//! [0]
+Q3SimpleRichText myrichtext(contents, mywidget->font());
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_text_q3textbrowser.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_text_q3textbrowser.cpp
new file mode 100644
index 000000000..b042efb9d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_text_q3textbrowser.cpp
@@ -0,0 +1,3 @@
+//! [0]
+mimeSourceFactory()->setExtensionType("qml", "text/utf8");
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_text_q3textedit.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_text_q3textedit.cpp
new file mode 100644
index 000000000..e8d5784a2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_text_q3textedit.cpp
@@ -0,0 +1,31 @@
+//! [0]
+QFile file(fileName); // Read the text from a file
+if (file.open(IO_ReadOnly)) {
+ QTextStream stream(&file);
+ textEdit->setText(stream.read());
+}
+
+QFile file(fileName); // Write the text to a file
+if (file.open(IO_WriteOnly)) {
+ QTextStream stream(&file);
+ stream << textEdit->text();
+ textEdit->setModified(false);
+}
+//! [0]
+
+
+//! [1]
+This is <font color=red>red</font> while <b>this</b> is <font color=blue>blue</font>.
+<font color=green><font color=yellow>Yellow,</font> and <u>green</u>.
+//! [1]
+
+
+//! [2]
+Q3TextEdit * log = new Q3TextEdit(this);
+log->setTextFormat(Qt::LogText);
+Q3StyleSheetItem * item = new Q3StyleSheetItem(log->styleSheet(), "mytag");
+item->setColor("red");
+item->setFontWeight(QFont::Bold);
+item->setFontUnderline(true);
+log->append("This is a <mytag>custom tag</mytag>!");
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_text_q3textstream.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_text_q3textstream.cpp
new file mode 100644
index 000000000..664a6909b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_text_q3textstream.cpp
@@ -0,0 +1,29 @@
+//! [0]
+QString str;
+Q3TextStream ts( &str, IO_WriteOnly );
+ts << "pi = " << 3.14; // str == "pi = 3.14"
+//! [0]
+
+
+//! [1]
+QString str = "pi = 3.14";
+Q3TextStream ts( &str, IO_WriteOnly );
+ts << "2+2 = " << 2+2; // str == "2+2 = 414"
+//! [1]
+
+
+//! [2]
+QByteArray array;
+Q3TextStream ts( array, IO_WriteOnly );
+ts << "pi = " << 3.14 << '\0'; // array == "pi = 3.14"
+//! [2]
+
+
+//! [3]
+QByteArray array;
+QBuffer buf( array );
+buf.open( IO_WriteOnly );
+Q3TextStream ts( &buf );
+ts << "pi = " << 3.14 << '\0'; // array == "pi = 3.14"
+buf.close();
+//! [3]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_tools_q3cstring.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_tools_q3cstring.cpp
new file mode 100644
index 000000000..9985e9d56
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_tools_q3cstring.cpp
@@ -0,0 +1,40 @@
+//! [0]
+Q3CString str("helloworld", 6); // assigns "hello" to str
+//! [0]
+
+
+//! [1]
+Q3CString a; // a.data() == 0, a.size() == 0, a.length() == 0
+Q3CString b == ""; // b.data() == "", b.size() == 1, b.length() == 0
+a.isNull(); // true because a.data() == 0
+a.isEmpty(); // true because a.length() == 0
+b.isNull(); // false because b.data() == ""
+b.isEmpty(); // true because b.length() == 0
+//! [1]
+
+
+//! [2]
+Q3CString s = "truncate this string";
+s.truncate(5); // s == "trunc"
+//! [2]
+
+
+//! [3]
+Q3CString s;
+s.sprintf("%d - %s", 1, "first"); // result < 256 chars
+
+Q3CString big(25000); // very long string
+big.sprintf("%d - %s", 2, longString); // result < 25000 chars
+//! [3]
+
+
+//! [4]
+Q3CString s("apple");
+Q3CString t = s.leftJustify(8, '.'); // t == "apple..."
+//! [4]
+
+
+//! [5]
+Q3CString s("pie");
+Q3CString t = s.rightJustify(8, '.'); // t == ".....pie"
+//! [5]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_tools_q3deepcopy.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_tools_q3deepcopy.cpp
new file mode 100644
index 000000000..36f7491ee
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_tools_q3deepcopy.cpp
@@ -0,0 +1,58 @@
+//! [0]
+// all 5 strings share the same data
+QString s1 = "abcd";
+QString s2 = s1;
+QString s3 = s2;
+QString s4 = s3;
+QString s5 = s2;
+//! [0]
+
+
+//! [1]
+// s1, s2 and s5 share the same data, neither s3 nor s4 are shared
+QString s1 = "abcd";
+QString s2 = s1;
+Q3DeepCopy<QString> s3 = s2; // s3 is a deep copy of s2
+QString s4 = s3; // s4 is a deep copy of s3
+QString s5 = s2;
+//! [1]
+
+
+//! [2]
+// s1, s2 and s5 share the same data, s3 and s4 share the same data
+QString s1 = "abcd";
+QString s2 = s1;
+QString s3 = Q3DeepCopy<QString>( s2 ); // s3 is a deep copy of s2
+QString s4 = s3; // s4 is a shallow copy of s3
+QString s5 = s2;
+//! [2]
+
+
+//! [3]
+Q3DeepCopy<QString> global_string; // global string data
+QMutex global_mutex; // mutex to protext global_string
+
+...
+
+void setGlobalString( const QString &str )
+{
+ global_mutex.lock();
+ global_string = str; // global_string is a deep copy of str
+ global_mutex.unlock();
+}
+
+...
+
+void MyThread::run()
+{
+ global_mutex.lock();
+ QString str = global_string; // str is a deep copy of global_string
+ global_mutex.unlock();
+
+ // process the string data
+ ...
+
+ // update global_string
+ setGlobalString( str );
+}
+//! [3]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_tools_q3garray.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_tools_q3garray.cpp
new file mode 100644
index 000000000..710826205
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_tools_q3garray.cpp
@@ -0,0 +1,20 @@
+//! [0]
+static uchar bindata[] = { 231, 1, 44, ... };
+QByteArray a;
+a.setRawData(bindata, sizeof(bindata)); // a points to bindata
+QDataStream s(a, IO_ReadOnly); // open on a's data
+s >> <something>; // read raw bindata
+s.close();
+a.resetRawData(bindata, sizeof(bindata)); // finished
+//! [0]
+
+
+//! [1]
+static uchar bindata[] = { 231, 1, 44, ... };
+QByteArray a, b;
+a.setRawData(bindata, sizeof(bindata)); // a points to bindata
+a.resize(8); // will crash
+b = a; // will crash
+a[2] = 123; // might crash
+ // forget to resetRawData - will crash
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_tools_q3signal.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_tools_q3signal.cpp
new file mode 100644
index 000000000..7793ba2bc
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_tools_q3signal.cpp
@@ -0,0 +1,38 @@
+//! [0]
+#include <q3signal.h>
+
+class MyClass
+{
+public:
+ MyClass();
+ ~MyClass();
+
+ void doSomething();
+
+ void connect(QObject *receiver, const char *member);
+
+private:
+ Q3Signal *sig;
+};
+
+MyClass::MyClass()
+{
+ sig = new Q3Signal;
+}
+
+MyClass::~MyClass()
+{
+ delete sig;
+}
+
+void MyClass::doSomething()
+{
+ // ... does something
+ sig->activate(); // emits the signal
+}
+
+void MyClass::connect(QObject *receiver, const char *member)
+{
+ sig->connect(receiver, member);
+}
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3combobox.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3combobox.cpp
new file mode 100644
index 000000000..90d7b149d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3combobox.cpp
@@ -0,0 +1,15 @@
+//! [0]
+Q3ComboBox *c = new Q3ComboBox(this, tr("read-only combobox"));
+//! [0]
+
+
+//! [1]
+Q3ComboBox *c1 = new Q3ComboBox(false, this, tr("read-only combobox"));
+Q3ComboBox *c2 = new Q3ComboBox(true, this, tr("editable combobox"));
+//! [1]
+
+
+//! [2]
+static const char* items[] = { "red", "green", "blue", 0 };
+combo->insertStrList( items );
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3datetimeedit.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3datetimeedit.cpp
new file mode 100644
index 000000000..74070ec4b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3datetimeedit.cpp
@@ -0,0 +1,28 @@
+
+void wrapInFunction()
+{
+
+//! [0]
+Q3DateEdit *dateEdit = new Q3DateEdit(QDate::currentDate(), this);
+dateEdit->setRange(QDate::currentDate().addDays(-365),
+ QDate::currentDate().addDays( 365));
+dateEdit->setOrder(Q3DateEdit::MDY);
+dateEdit->setAutoAdvance(true);
+//! [0]
+
+
+//! [1]
+QTime timeNow = QTime::currentTime();
+Q3TimeEdit *timeEdit = new Q3TimeEdit(timeNow, this);
+timeEdit->setRange(timeNow, timeNow.addSecs(60 * 60));
+//! [1]
+
+
+//! [2]
+Q3DateTimeEdit *dateTimeEdit = new Q3DateTimeEdit(QDateTime::currentDateTime(), this);
+dateTimeEdit->dateEdit()->setRange(QDateTime::currentDate(),
+ QDateTime::currentDate().addDays(7));
+//! [2]
+
+}
+
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3dockarea.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3dockarea.cpp
new file mode 100644
index 000000000..bde7d84ec
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3dockarea.cpp
@@ -0,0 +1,8 @@
+//! [0]
+ts << *myDockArea;
+//! [0]
+
+
+//! [1]
+ts >> *myDockArea;
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3dockwindow.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3dockwindow.cpp
new file mode 100644
index 000000000..1476dcb48
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3dockwindow.cpp
@@ -0,0 +1,4 @@
+//! [0]
+Q3ToolBar *fileTools = new Q3ToolBar(this, "File Actions");
+moveDockWindow(fileTools, Left);
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3gridview.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3gridview.cpp
new file mode 100644
index 000000000..43dca3e66
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3gridview.cpp
@@ -0,0 +1,6 @@
+//! [0]
+p->setClipRect(cellRect(), QPainter::CoordPainter);
+//... your drawing code
+p->setClipping(false);
+
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3header.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3header.cpp
new file mode 100644
index 000000000..684d18212
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3header.cpp
@@ -0,0 +1,6 @@
+//! [0]
+// Allow resizing of all current and future sections
+header->setResizeEnabled(true);
+// Disable resizing of section 3, (the fourth section added)
+header->setResizeEnabled(false, 3);
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3mainwindow.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3mainwindow.cpp
new file mode 100644
index 000000000..c63b481d9
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3mainwindow.cpp
@@ -0,0 +1,45 @@
+//! [0]
+Q3MainWindow *mw = new Q3MainWindow;
+QTextEdit *edit = new QTextEdit(mw, "editor");
+edit->setFocus();
+mw->setWindowTitle("Main Window");
+mw->setCentralWidget(edit);
+mw->show();
+//! [0]
+
+
+//! [1]
+Q3ToolBar *tb = new Q3ToolBar(this);
+addDockWindow(tb, tr("Menubar"), Top, false);
+QMenuBar *mb = new QMenuBar(tb);
+mb->setFrameStyle(QFrame::NoFrame);
+tb->setStretchableWidget(mb);
+setDockEnabled(tb, Left, false);
+setDockEnabled(tb, Right, false);
+//! [1]
+
+
+//! [2]
+QFile file(filename);
+if (file.open(IO_WriteOnly)) {
+ QTextStream stream(&file);
+ stream << *mainWindow;
+ file.close();
+}
+//! [2]
+
+
+//! [3]
+QFile file(filename);
+if (file.open(IO_ReadOnly)) {
+ QTextStream stream(&file);
+ stream >> *mainWindow;
+ file.close();
+}
+//! [3]
+
+
+//! [4]
+Q3PopupMenu * help = new Q3PopupMenu(this);
+help->insertItem("What's &This", this , SLOT(enterWhatsThis()), Qt::SHIFT+Qt::Key_F1);
+//! [4]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3scrollview.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3scrollview.cpp
new file mode 100644
index 000000000..58d5acfee
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3scrollview.cpp
@@ -0,0 +1,61 @@
+//! [0]
+Q3ScrollView* sv = new Q3ScrollView(...);
+QWidget *widget = new QWidget(sv->viewport());
+QVBoxLayout *layout = new QVBoxLayout(widget);
+addChild(widget);
+//! [0]
+
+
+//! [1]
+QLabel* child1 = new QLabel("CHILD", widget);
+QLabel* child2 = new QLabel("CHILD", widget);
+QLabel* child3 = new QLabel("CHILD", widget);
+layout->addWidget(child1);
+layout->addWidget(child2);
+layout->addWidget(child3);
+...
+//! [1]
+
+
+//! [2]
+Q3ScrollView* sv = new Q3ScrollView(...);
+QLabel* child1 = new QLabel("CHILD", sv->viewport());
+sv->addChild(child1);
+QLabel* child2 = new QLabel("CHILD", sv->viewport());
+sv->addChild(child2);
+QLabel* child3 = new QLabel("CHILD", sv->viewport());
+sv->addChild(child3);
+//! [2]
+
+
+//! [3]
+Q3ScrollView* sv = new Q3ScrollView(...);
+sv->enableClipper(true);
+QLabel* child1 = new QLabel("CHILD", sv->viewport());
+sv->addChild(child1);
+QLabel* child2 = new QLabel("CHILD", sv->viewport());
+sv->addChild(child2);
+QLabel* child3 = new QLabel("CHILD", sv->viewport());
+sv->addChild(child3);
+//! [3]
+
+
+//! [4]
+{
+ // Fill a 40000 by 50000 rectangle at (100000,150000)
+
+ // Calculate the coordinates...
+ int x1 = 100000, y1 = 150000;
+ int x2 = x1+40000-1, y2 = y1+50000-1;
+
+ // Clip the coordinates so X/Windows will not have problems...
+ if (x1 < clipx) x1=clipx;
+ if (y1 < clipy) y1=clipy;
+ if (x2 > clipx+clipw-1) x2=clipx+clipw-1;
+ if (y2 > clipy+cliph-1) y2=clipy+cliph-1;
+
+ // Paint using the small coordinates...
+ if (x2 >= x1 && y2 >= y1)
+ p->fillRect(x1, y1, x2-x1+1, y2-y1+1, red);
+}
+//! [4]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3whatsthis.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3whatsthis.cpp
new file mode 100644
index 000000000..f7b48ba6f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_widgets_q3whatsthis.cpp
@@ -0,0 +1,3 @@
+//! [0]
+(void)Q3WhatsThis::whatsThisButton( my_help_tool_bar );
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qtestlib_qtestcase.cpp b/doc/codesnippets/doc/src/snippets/code/src_qtestlib_qtestcase.cpp
new file mode 100644
index 000000000..c143e334d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qtestlib_qtestcase.cpp
@@ -0,0 +1,188 @@
+
+void wrapInFunction()
+{
+
+//! [0]
+QVERIFY(1 + 1 == 2);
+//! [0]
+
+
+//! [1]
+QVERIFY2(1 + 1 == 2, "A breach in basic arithmetic occured.");
+//! [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]
+
+}
+
diff --git a/doc/codesnippets/doc/src/snippets/code/src_script_qscriptable.cpp b/doc/codesnippets/doc/src/snippets/code/src_script_qscriptable.cpp
new file mode 100644
index 000000000..16d441bd4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_script_qscriptable.cpp
@@ -0,0 +1,19 @@
+//! [0]
+class MyScriptableObject(QObject, QScriptable):
+...
+ def doSomething(self):
+ ...
+ def doSomethingElse(self):
+ ...
+//! [0]
+
+
+//! [1]
+
+def doSomething(self):
+ self.context().throwError('Threw an error from a slot')
+
+def doSomethingElse(self):
+ return self.thisObject()
+
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_script_qscriptclass.cpp b/doc/codesnippets/doc/src/snippets/code/src_script_qscriptclass.cpp
new file mode 100644
index 000000000..0042d1d92
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_script_qscriptclass.cpp
@@ -0,0 +1,9 @@
+//! [0]
+if extension == Callable:
+ context = argument
+ engine = context.engine()
+ sum = 0
+ for i in range(0, context.argumentCount()):
+ sum += context.argument(i).toNumber()
+ return sum
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_script_qscriptcontext.cpp b/doc/codesnippets/doc/src/snippets/code/src_script_qscriptcontext.cpp
new file mode 100644
index 000000000..21e4d13f7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_script_qscriptcontext.cpp
@@ -0,0 +1,23 @@
+//! [0]
+foo(20.5, "hello", Object())
+//! [0]
+
+
+//! [1]
+def Person_prototype_fullName(context, engine):
+ self = context.selfObject()
+ result = self.property("firstName").toString()
+ result += QLatin1String(" ")
+ result += self.property("lastName").toString()
+ return result
+//! [1]
+
+
+//! [2]
+def myInclude(ctx, eng):
+ fileName = ctx.argument(0).toString()
+ contents = readTheFile(fileName)
+ ctx.setActivationObject(ctx.parentContext().activationObject())
+ ctx.setThisObject(ctx.parentContext().selfObject())
+ return eng.evaluate(contents, fileName)
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_script_qscriptengine.cpp b/doc/codesnippets/doc/src/snippets/code/src_script_qscriptengine.cpp
new file mode 100644
index 000000000..3733261db
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_script_qscriptengine.cpp
@@ -0,0 +1,270 @@
+//! [0]
+myEngine = QScriptEngine()
+three = myEngine.evaluate("1 + 2")
+//! [0]
+
+
+//! [1]
+fun = myEngine.evaluate("function(a, b) { return a + b }");
+args = QScriptValueList()
+args << 1 << 2
+threeAgain = fun.call(QScriptValue(), args)
+//! [1]
+
+
+//! [2]
+fileName = "helloworld.qs"
+scriptFile = QFile(fileName)
+if !scriptFile.open(QIODevice.ReadOnly):
+ # handle error
+stream = QTextStream(scriptFile)
+contents = stream.readAll()
+scriptFile.close()
+myEngine.evaluate(contents, fileName)
+//! [2]
+
+
+//! [3]
+myEngine.globalObject().setProperty("myNumber", 123)
+...
+myNumberPlusOne = myEngine.evaluate("myNumber + 1")
+//! [3]
+
+
+//! [4]
+result = myEngine.evaluate(...)
+if myEngine.hasUncaughtException():
+ line = myEngine.uncaughtExceptionLineNumber()
+ print "uncaught exception at line", line, ":", result.toString()
+//! [4]
+
+
+//! [5]
+button = QPushButton()
+QScriptValue scriptButton = myEngine.QObject(button)
+myEngine.globalObject().setProperty("button", scriptButton)
+
+myEngine.evaluate("button.checkable = True")
+
+print scriptButton.property("checkable").toBoolean()
+scriptButton.property("show").call() # call the show() slot
+//! [5]
+
+
+//! [6]
+def myAdd(context, engine):
+ a = context.argument(0)
+ b = context.argument(1)
+ return a.toNumber() + b.toNumber()
+//! [6]
+
+
+//! [7]
+fun = myEngine.Function(myAdd)
+myEngine.globalObject().setProperty("myAdd", fun)
+//! [7]
+
+
+//! [8]
+result = myEngine.evaluate("myAdd(myNumber, 1)")
+//! [8]
+
+
+//! [9]
+def Foo(context, engine):
+ if context.calledAsConstructor():
+ # initialize the object
+ context.selfObject().setProperty("bar", ...)
+ # ...
+ # return a non-object value to indicate that the
+ # selfObject() should be the result of the " Foo()" expression
+ return engine.undefinedValue()
+ else:
+ # not called as " Foo()", just "Foo()"
+ # create our own object and return that one
+ object = engine.Object()
+ object.setPrototype(context.callee().property("prototype"))
+ object.setProperty("baz", ...)
+ return object
+...
+
+fooProto = engine.Object()
+fooProto.setProperty("whatever", ...)
+engine.globalObject().setProperty("Foo", engine->Function(Foo, fooProto))
+//! [9]
+
+
+//! [10]
+class Bar:
+ ...
+
+def constructBar(context, engine):
+ bar = Bar()
+ # initialize from arguments in context, if desired
+ ...
+ return engine.toScriptValue(bar)
+
+class BarPrototype(QObject, QScriptable):
+# provide the scriptable interface of self type using slots and properties
+...
+
+...
+
+# create and register the Bar prototype and constructor in the engine
+barPrototypeObject = BarPrototype(...)
+barProto = engine.QObject(barPrototypeObject)
+engine.setDefaultPrototype(qMetaTypeId(Bar), barProto)
+barCtor = engine.Function(constructBar, barProto)
+engine.globalObject().setProperty("Bar", barCtor)
+//! [10]
+
+
+//! [11]
+def getSetFoo(context,engine):
+ callee = context.callee()
+ if context.argumentCount() == 1: # writing?
+ callee.setProperty("value", context.argument(0))
+ return callee.property("value")
+}
+
+....
+
+object = engine.Object()
+object.setProperty("foo", engine.Function(getSetFoo),
+ QScriptValue.PropertyGetter | QScriptValue::PropertySetter)
+//! [11]
+
+
+//! [12]
+object = engine.Object()
+object.setProperty("foo", engine.Function(getFoo), QScriptValue.PropertyGetter)
+object.setProperty("foo", engine.Function(setFoo), QScriptValue.PropertySetter)
+//! [12]
+
+
+//! [13]
+Q_SCRIPT_DECLARE_QMETAOBJECT(QLineEdit, QWidget*)
+
+...
+
+lineEditClass = engine.scriptValueFromQMetaObject(QLineEdit)
+engine.globalObject().setProperty("QLineEdit", lineEditClass)
+//! [13]
+
+
+//! [14]
+if hello && world:
+ print("hello world")
+//! [14]
+
+
+//! [15]
+if hello &&
+//! [15]
+
+
+//! [16]
+0 = 0
+//! [16]
+
+
+//! [17]
+./test.js
+//! [17]
+
+
+//! [18]
+foo["bar"]
+//! [18]
+
+
+//! [19]
+engine = QScriptEngine()
+context = engine.pushContext()
+context.activationObject().setProperty("myArg", 123)
+engine.evaluate("var tmp = myArg + 42")
+...
+engine.popContext()
+//! [19]
+
+
+//! [20]
+class MyStruct:
+ x = 0
+ y = 0
+//! [20]
+
+
+//! [21]
+Q_DECLARE_METATYPE(MyStruct)
+//! [21]
+
+
+//! [22]
+def toScriptValue(engine, s):
+ obj = engine.Object()
+ obj.setProperty("x", s.x)
+ obj.setProperty("y", s.y)
+ return obj
+
+def fromScriptValue(obj, s):
+ s.x = obj.property("x").toInt32()
+ s.y = obj.property("y").toInt32()
+//! [22]
+
+
+//! [23]
+qScriptRegisterMetaType(engine, toScriptValue, fromScriptValue)
+//! [23]
+
+
+//! [24]
+s = context.argument(0)
+...
+s2 = MyStruct()
+s2.x = s.x + 10
+s2.y = s.y + 20
+v = engine.toScriptValue(s2)
+//! [24]
+
+
+//! [25]
+def createMyStruct(cx, engine):
+ s = MyStruct()
+ s.x = 123
+ s.y = 456
+ return engine.toScriptValue(s)
+...
+
+ctor = engine.Function(createMyStruct)
+engine.globalObject().setProperty("MyStruct", ctor)
+//! [25]
+
+
+//! [26]
+Q_DECLARE_METATYPE(QVector<int>)
+
+...
+
+qScriptRegisterSequenceMetaType<QVector<int> >(engine)
+...
+v = engine.evaluate("[5, 1, 3, 2]")
+v.sort()
+a = engine.toScriptValue(v)
+print a.toString() # outputs "[1, 2, 3, 5]"
+//! [26]
+
+//! [27]
+def mySpecialQObjectConstructor(context, engine):
+ parent = context.argument(0).toQObject()
+ object = QObject(parent)
+ return engine.QObject(object, QScriptEngine.ScriptOwnership)
+
+...
+
+ctor = engine.Function(mySpecialQObjectConstructor)
+metaObject = engine.QMetaObject(QObject.staticMetaObject, ctor)
+engine.globalObject().setProperty("QObject", metaObject)
+
+result = engine.evaluate(" QObject()")
+//! [27]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_script_qscriptengineagent.cpp b/doc/codesnippets/doc/src/snippets/code/src_script_qscriptengineagent.cpp
new file mode 100644
index 000000000..649d782f3
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_script_qscriptengineagent.cpp
@@ -0,0 +1,12 @@
+//! [0]
+var a = Math.random() + 2;
+//! [0]
+
+
+//! [1]
+function cube(a) {
+ return a * a * a;
+}
+
+var a = cube(3);
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_script_qscriptvalue.cpp b/doc/codesnippets/doc/src/snippets/code/src_script_qscriptvalue.cpp
new file mode 100644
index 000000000..2557f8636
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_script_qscriptvalue.cpp
@@ -0,0 +1,41 @@
+//! [0]
+myEngine = QScriptEngine()
+myObject = myEngine.newObject()
+myOtherObject = myEngine.newObject()
+myObject.setProperty("myChild", myOtherObject)
+myObject.setProperty("name", "John Doe")
+//! [0]
+
+
+//! [1]
+val = QScriptValue(myEngine, 123)
+myObject.setProperty("myReadOnlyProperty", val, QScriptValue.ReadOnly)
+//! [1]
+
+
+//! [2]
+engine = QScriptEngine()
+engine.evaluate("function fullName() { return this.firstName + ' ' + this.lastName; }")
+engine.evaluate("somePerson = { firstName: 'John', lastName: 'Doe' }")
+
+global_ = engine.globalObject()
+fullName = global_.property("fullName")
+who = global_.property("somePerson")
+print fullName.call(who).toString() # "John Doe"
+
+engine.evaluate("function cube(x) { return x * x * x; }")
+QScriptValue cube = global_.property("cube")
+args = QScriptValueList()
+args << 3
+print cube.call(QScriptValue(), args).toNumber() # 27
+//! [2]
+
+
+//! [3]
+
+def myNativeFunction(context, engine):
+ otherFunction = ...
+
+ return otherFunction.call(context.thisObject(), context.argumentsObject())
+
+//! [3]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_script_qscriptvalueiterator.cpp b/doc/codesnippets/doc/src/snippets/code/src_script_qscriptvalueiterator.cpp
new file mode 100644
index 000000000..a8bb1f3fd
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_script_qscriptvalueiterator.cpp
@@ -0,0 +1,28 @@
+//! [0]
+object = QScriptValue()
+...
+it = QScriptValueIterator(object)
+while it.hasNext():
+ it.next()
+ print "%s:%s" % (it.name(), it.value().toString())
+//! [0]
+
+
+//! [1]
+QScriptValue obj = ... // the object to iterate over
+while obj.isObject():
+ it = QScriptValueIterator(obj)
+ while it.hasNext():
+ it.next()
+ print it.name()
+ obj = obj.prototype()
+//! [1]
+
+
+//! [2]
+while it.hasNext():
+ it.next()
+ if it.flags() & QScriptValue::SkipInEnumeration:
+ continue
+ print "found enumerated property: %s" % it.name()
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqldatabase.cpp b/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqldatabase.cpp
new file mode 100644
index 000000000..4a252e827
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqldatabase.cpp
@@ -0,0 +1,96 @@
+//! [0]
+# WRONG
+db = QSqlDatabase.database("sales")
+query = QSqlQuery("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]
+db = QSqlDatabase.database("sales")
+query = QSqlQuery("SELECT NAME, DOB FROM EMPLOYEES", db)
+# Both "db" and "query" are destroyed because they are out of scope
+QSqlDatabase.removeDatabase("sales") # correct
+//! [1]
+
+
+//! [2]
+class MyDatabaseDriverCreatorBase(QtSql.QSqlDriverCreatorBase):
+ ...
+ def createObject(self):
+ return MyDatabaseDriver()
+
+mydriver = MyDatabaseDriverCreatorBase()
+QtSql.QSqlDatabase.registerSqlDriver("MYDRIVER", mydriver)
+db = QtSql.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!
+ pass
+...
+//! [3]
+
+
+//! [4]
+...
+# MySQL connection
+db.setConnectOptions("CLIENT_SSL=1;CLIENT_IGNORE_SPACE=1") # use an SSL connection to the server
+if not db.open():
+ db.setConnectOptions() # clears the connect option string
+ ...
+...
+# PostgreSQL connection
+db.setConnectOptions("requiressl=1") # enable PostgreSQL SSL connections
+if not db.open():
+ db.setConnectOptions() # clear options
+ ...
+...
+# ODBC connection
+# set ODBC options
+db.setConnectOptions("SQL_ATTR_ACCESS_MODE=SQL_MODE_READ_ONLY;SQL_ATTR_TRACE=SQL_OPT_TRACE_ON")
+if not db.open():
+ db.setConnectOptions() # don't try to set this option
+ ...
+//! [4]
+
+
+//! [5]
+#include "qtdir/src/sql/drivers/psql/qsql_psql.cpp"
+//! [5]
+
+
+//! [6]
+con = PQconnectdb("host=server user=bart password=simpson dbname=springfield")
+drv = QPSQLDriver(con)
+db = QSqlDatabase.addDatabase(drv) # becomes the new default connection
+query = QSqlQuery()
+query.exec_("SELECT NAME, ID FROM STAFF")
+...
+//! [6]
+
+
+//! [7]
+unix:LIBS += -lpq
+win32:LIBS += libpqdll.lib
+//! [7]
+
+
+//! [8]
+db = QSqlDatabase()
+print(db.isValid()) # Returns False
+
+db = QSqlDatabase.database("sales")
+print(db.isValid()) # Returns True if "sales" connection exists
+
+QSqlDatabase.removeDatabase("sales")
+print(db.isValid()) # Returns False
+//! [8]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqldriver.cpp b/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqldriver.cpp
new file mode 100644
index 000000000..26f427110
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqldriver.cpp
@@ -0,0 +1,23 @@
+//! [0]
+db = QSqlDatabase.addDatabase("SQLITE3")
+v = QVariant(db.driver().handle())
+if v.isValid() && v.typeName() == "sqlite3*":
+ # v.data() returns a pointer to the handle
+ sqlite3 *handle = *static_cast<sqlite3 **>(v.data())
+ if handle != 0: # check that it is not NULL
+ doSomething()
+//! [0]
+
+
+//! [1]
+# Impossible to translate to python
+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/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlerror.cpp b/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlerror.cpp
new file mode 100644
index 000000000..2c5fd83eb
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlerror.cpp
@@ -0,0 +1,6 @@
+//! [0]
+model = QSqlQueryModel()
+model.setQuery("select * from myTable")
+if model.lastError().isValid():
+ print model.lastError()
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlindex.cpp b/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlindex.cpp
new file mode 100644
index 000000000..25bcf3d3d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlindex.cpp
@@ -0,0 +1,5 @@
+//! [0]
+strlist = myIndex.toStringList()
+for i in strlist:
+ myProcessing(i)
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlquery.cpp b/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlquery.cpp
new file mode 100644
index 000000000..769f0be6c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlquery.cpp
@@ -0,0 +1,40 @@
+//! [0]
+SELECT forename, surname FROM people
+//! [0]
+
+
+//! [1]
+q = QSqlQuery("select * from employees")
+rec = q.record()
+
+print "Number of columns: %d" % rec.count()
+
+nameCol = rec.indexOf("name") # index of the field "name"
+while q.next():
+ print q.value(nameCol).toString() # output all names
+//! [1]
+
+
+//! [2]
+q = QSqlQuery()
+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 not q.execBatch():
+ print q.lastError()
+//! [2]
+
+
+//! [3]
+1 Harald
+2 Boris
+3 Trond
+4 NULL
+//! [3]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlresult.cpp b/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlresult.cpp
new file mode 100644
index 000000000..81d665641
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlresult.cpp
@@ -0,0 +1,38 @@
+//! [0]
+q = QSqlQuery()
+q.prepare("insert into test (i1, i2, s) values (?, ?, ?)")
+
+col1 = QVariant([1, 3])
+col2 = QVariant([2, 4])
+col3 = QVariant(["hello", "world"])
+
+q.bindValue(0, col1)
+q.bindValue(1, col2)
+q.bindValue(2, col3)
+
+if not q.execBatch():
+ print q.lastError()
+//! [0]
+
+
+//! [1]
+query = QSqlQuery ...
+v = query.result().handle()
+if v.isValid() and (v.typeName() == "sqlite3_stmt*"):
+ # v.data() returns a pointer to the handle
+ handle = v.data()
+ if handle != 0: # check that it is not NULL
+ ...
+//! [1]
+
+
+//! [2]
+if v.typeName() == "PGresult*":
+ handle = v.data()
+ if handle != 0 ...
+
+if v.typeName() == "MYSQL_STMT*":
+ handle = v.data()
+ if handle != 0 ...
+}
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_sql_models_qsqlquerymodel.cpp b/doc/codesnippets/doc/src/snippets/code/src_sql_models_qsqlquerymodel.cpp
new file mode 100644
index 000000000..bc8e7b21f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_sql_models_qsqlquerymodel.cpp
@@ -0,0 +1,12 @@
+//! [0]
+while myModel.canFetchMore():
+ myModel.fetchMore()
+//! [0]
+
+
+//! [1]
+model = QSqlQueryModel()
+model.setQuery("select * from MyTable")
+if model.lastError().isValid():
+ print model.lastError()
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_svg_qgraphicssvgitem.cpp b/doc/codesnippets/doc/src/snippets/code/src_svg_qgraphicssvgitem.cpp
new file mode 100644
index 000000000..21a033fa5
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_svg_qgraphicssvgitem.cpp
@@ -0,0 +1,11 @@
+//! [0]
+renderer = QSvgRenderer(QLatin1String("SvgCardDeck.svg"))
+black = QGraphicsSvgItem()
+red = QGraphicsSvgItem()
+
+black.setSharedRenderer(renderer)
+black.setElementId(QLatin1String("black_joker"))
+
+red.setSharedRenderer(renderer)
+red.setElementId(QLatin1String("red_joker"))
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_xml_dom_qdom.cpp b/doc/codesnippets/doc/src/snippets/code/src_xml_dom_qdom.cpp
new file mode 100644
index 000000000..d4c8c1979
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_xml_dom_qdom.cpp
@@ -0,0 +1,180 @@
+//! [0]
+doc = QDomDocument()
+impl = QDomImplementation()
+
+# 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)
+elt1 = doc.createElement("foo~bar")
+
+# This will create an element with the tag name "foobar".
+impl.setInvalidDataPolicy(QDomImplementation.DropInvalidData)
+elt2 = doc.createElement("foo~bar")
+
+# This will create a null element.
+impl.setInvalidDataPolicy(QDomImplementation::ReturnNullNode)
+elt3 = doc.createElement("foo~bar")
+//! [0]
+
+
+//! [1]
+d = QDomDocument()
+d.setContent(someXML)
+n = d.firstChild()
+while !n.isNull():
+ if n.isElement():
+ e = n.toElement()
+ print "Element name: %s" % e.tagName()
+ 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://qtsoftware.com" color="red" />
+//! [7]
+
+
+//! [8]
+e = # some QDomElement...
+#...
+a = e.attributeNode("href")
+print a.value() # prints "http://qtsoftware.com"
+a.setValue("http://doc.trolltech.com") # change the node's attribute
+a2 = e.attributeNode("href")
+print a2.value() # prints "http://doc.trolltech.com"
+//! [8]
+
+
+//! [9]
+e = # some QDomElement...
+#...
+s = e.text()
+//! [9]
+
+
+//! [10]
+text = QString()
+element = doc.documentElement()
+
+n = element.firstChild()
+while True:
+ if not n.isNull()
+ break
+ t = n.toText()
+ if !t.isNull():
+ text += t.data()
+
+ n = n.nextSibling()
+//! [10]
+
+
+//! [11]
+doc = # some QDomDocument ...
+root = doc.firstChildElement("database")
+elt = root.firstChildElement("entry")
+while True:
+ if not elt.isNull():
+ break
+ # ...
+ 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]
+doc = QDomDocument("mydocument")
+file = QFile("mydocument.xml")
+if not file.open(QIODevice::ReadOnly):
+ return
+if not doc.setContent(&file):
+ file.close()
+ return
+file.close()
+
+# print out the element names of all elements that are direct children
+# of the outermost element.
+docElem = doc.documentElement()
+
+n = docElem.firstChild()
+while not n.isNull():
+ e = n.toElement() # try to convert the node to an element.
+ if not e.isNull():
+ print e.tagName() # the node really is an element.
+ n = n.nextSibling()
+}
+
+# Here we append a new element to the end of the document
+elem = doc.createElement("img")
+elem.setAttribute("src", "myimage.png")
+docElem.appendChild(elem)
+//! [16]
+
+
+//! [17]
+doc = QDomDocument("MyML")
+root = doc.createElement("MyML")
+doc.appendChild(root)
+
+tag = doc.createElement("Greeting")
+root.appendChild(tag)
+
+t = doc.createTextNode("Hello World")
+tag.appendChild(t)
+
+xml = doc.toString()
+//! [17]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_xml_sax_qxml.cpp b/doc/codesnippets/doc/src/snippets/code/src_xml_sax_qxml.cpp
new file mode 100644
index 000000000..9df91ab39
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_xml_sax_qxml.cpp
@@ -0,0 +1,3 @@
+//! [0]
+xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", True)
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstracturiresolver.cpp b/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstracturiresolver.cpp
new file mode 100644
index 000000000..990a84968
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstracturiresolver.cpp
@@ -0,0 +1,3 @@
+//! [0]
+return baseURI.resolved(relative);
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstractxmlforwarditerator.cpp b/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstractxmlforwarditerator.cpp
new file mode 100644
index 000000000..f31ea3f5c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstractxmlforwarditerator.cpp
@@ -0,0 +1,3 @@
+//! [0]
+OutputType inputToOutputItem(const InputType &inputType) const;
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstractxmlnodemodel.cpp b/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstractxmlnodemodel.cpp
new file mode 100644
index 000000000..351a30be2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstractxmlnodemodel.cpp
@@ -0,0 +1,22 @@
+//! [0]
+myInstance = QXmlNodeModelIndex();
+//! [0]
+
+//! [1]
+QFile queryFile(argv[1]);
+QFile chemistryData(argv[2]);
+QString moleculeName = argv[3];
+
+QXmlQuery query;
+query.setQuery(&queryFile, QUrl::fromLocalFile(queryFile.fileName()));
+
+ChemistryNodeModel myNodeModel(query.namePool(), chemistryData);
+QXmlNodeModelIndex startNode = myNodeModel.nodeFor(moleculeName);
+query.bindVariable("queryRoot", startNode);
+
+QFile out;
+out.open(stdout, QIODevice::WriteOnly);
+
+QXmlSerializer serializer(query, &out);
+query.evaluateTo(&serializer);
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstractxmlreceiver.cpp b/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstractxmlreceiver.cpp
new file mode 100644
index 000000000..e286fa98c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstractxmlreceiver.cpp
@@ -0,0 +1,7 @@
+//! [0]
+QXmlQuery query;
+query.setQuery("doc('index.html')/html/body/p[1]");
+
+QXmlSerializer serializer(query, myOutputDevice);
+query.evaluateTo(&serializer);
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qsimplexmlnodemodel.cpp b/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qsimplexmlnodemodel.cpp
new file mode 100644
index 000000000..0906328f8
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qsimplexmlnodemodel.cpp
@@ -0,0 +1,19 @@
+//! [0]
+QXmlNodeModelIndex MyTreeModel::nextFromSimpleAxis(SimpleAxis axis, const QXmlNodeModelIndex &ni) const
+{
+ // Convert the QXmlNodeModelIndex to a value that is specific to what we represent.
+ const MyValue value = toMyValue(ni);
+
+ switch(axis)
+ {
+ case Parent:
+ return toNodeIndex(value.parent());
+ case FirstChild:
+ case PreviousSibling:
+ case NextSibling:
+ // and so on
+ ;
+ }
+ return QXmlNodeModelIndex();
+}
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlformatter.cpp b/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlformatter.cpp
new file mode 100644
index 000000000..d7e6ab1db
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlformatter.cpp
@@ -0,0 +1,8 @@
+//! [0]
+QXmlQuery query;
+query.setQuery("doc('index.html')/html/body/p[1]");
+
+QXmlFormatter formatter(query, myOutputDevice);
+formatter.setIndentationDepth(2);
+query.evaluateTo(&formatter);
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlname.cpp b/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlname.cpp
new file mode 100644
index 000000000..2c891b5e6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlname.cpp
@@ -0,0 +1,8 @@
+// Fills the bits from begin to end with 1s and leaves the rest as 0.
+
+template<typename IntegralT>
+inline IntegralT bitmask(IntegralT begin, IntegralT end)
+{
+ IntegralT filled_bits = (1 << (end - begin + 1)) - 1;
+ return filled_bits << begin;
+}
diff --git a/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlquery.cpp b/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlquery.cpp
new file mode 100644
index 000000000..76e1b34de
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlquery.cpp
@@ -0,0 +1,152 @@
+//! [0]
+ QXmlNamePool namePool(query.namePool());
+ query.bindVariable(QXmlName(namePool, localName), value);
+//! [0]
+
+
+{
+//! [1]
+ QByteArray myDocument;
+ QBuffer buffer(&myDocument); // This is a QIODevice.
+ buffer.open(QIODevice::ReadOnly);
+ QXmlQuery query;
+ query.bindVariable("myDocument", &buffer);
+ query.setQuery("doc($myDocument)");
+//! [1]
+}
+
+
+{
+ QIODevice *device = 0;
+//! [2]
+ QXmlNamePool namePool(query.namePool());
+ query.bindVariable(QXmlName(namePool, localName), device);
+//! [2]
+
+}
+
+{
+ QIODevice *myOutputDevice = 0;
+//! [3]
+ QFile xq("myquery.xq");
+
+ QXmlQuery query;
+ query.setQuery(&xq, QUrl::fromLocalFile(xq.fileName()));
+
+ QXmlSerializer serializer(query, myOutputDevice);
+ query.evaluateTo(&serializer);
+//! [3]
+}
+
+{
+ QIODevice *myOutputDevice = 0;
+//! [4]
+ QFile xq("myquery.xq");
+ QString fileName("the filename");
+ QString publisherName("the publisher");
+ qlonglong year = 1234;
+
+ QXmlQuery query;
+
+ query.bindVariable("file", QVariant(fileName));
+ query.bindVariable("publisher", QVariant(publisherName));
+ query.bindVariable("year", QVariant(year));
+
+ query.setQuery(&xq, QUrl::fromLocalFile(xq.fileName()));
+
+ QXmlSerializer serializer(query, myOutputDevice);
+ query.evaluateTo(&serializer);
+//! [4]
+}
+
+{
+//! [5]
+ QFile xq("myquery.xq");
+ QString fileName("the filename");
+ QString publisherName("the publisher");
+ qlonglong year = 1234;
+
+ QXmlQuery query;
+
+ query.bindVariable("file", QVariant(fileName));
+ query.bindVariable("publisher", QVariant(publisherName));
+ query.bindVariable("year", QVariant(year));
+
+ query.setQuery(&xq, QUrl::fromLocalFile(xq.fileName()));
+
+ QXmlResultItems result;
+ query.evaluateTo(&result);
+ QXmlItem item(result.next());
+ while (!item.isNull()) {
+ if (item.isAtomicValue()) {
+ QVariant v = item.toAtomicValue();
+ switch (v.type()) {
+ case QVariant::LongLong:
+ // xs:integer
+ break;
+ case QVariant::String:
+ // xs:string
+ break;
+ default:
+ // error
+ break;
+ }
+ }
+ else if (item.isNode()) {
+ QXmlNodeModelIndex i = item.toNodeModelIndex();
+ // process node
+ }
+ item = result.next();
+ }
+//! [5]
+}
+
+{
+//! [6]
+ QFile xq("myquery.xq");
+
+ QXmlQuery query;
+ query.setQuery(&xq, QUrl::fromLocalFile(xq.fileName()));
+
+ QXmlResultItems result;
+ query.evaluateTo(&result);
+ QXmlItem item(result.next());
+ while (!item.isNull()) {
+ if (item.isAtomicValue()) {
+ QVariant v = item.toAtomicValue();
+ switch (v.type()) {
+ case QVariant::LongLong:
+ // xs:integer
+ break;
+ case QVariant::String:
+ // xs:string
+ break;
+ default:
+ if (v.userType() == qMetaTypeId<QXmlName>()) {
+ QXmlName n = qVariantValue<QXmlName>(v);
+ // process QXmlName n...
+ }
+ else {
+ // error
+ }
+ break;
+ }
+ }
+ else if (item.isNode()) {
+ QXmlNodeModelIndex i = item.toNodeModelIndex();
+ // process node
+ }
+ item = result.next();
+ }
+//! [6]
+}
+
+{
+ QIODevice *out = 0;
+//! [7]
+ QXmlQuery query(QXmlQuery::XSLT20);
+ query.setFocus(QUrl("myInput.xml"));
+ query.setQuery(QUrl("myStylesheet.xsl"));
+ query.evaluateTo(out);
+//! [7]
+}
diff --git a/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlresultitems.cpp b/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlresultitems.cpp
new file mode 100644
index 000000000..190d6106d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlresultitems.cpp
@@ -0,0 +1,16 @@
+//! [0]
+QXmlQuery query;
+query.setQuery("<e/>, 1, 'two'");
+QXmlResultItems result;
+
+if (query.isValid()) {
+ query.evaluateTo(&result);
+ QXmlItem item(result.next());
+ while (!item.isNull()) {
+ // use item
+ item = result.next();
+ }
+ if (result.hasError())
+ /* Runtime error! */;
+}
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlserializer.cpp b/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlserializer.cpp
new file mode 100644
index 000000000..e286fa98c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlserializer.cpp
@@ -0,0 +1,7 @@
+//! [0]
+QXmlQuery query;
+query.setQuery("doc('index.html')/html/body/p[1]");
+
+QXmlSerializer serializer(query, myOutputDevice);
+query.evaluateTo(&serializer);
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/code/tools_assistant_compat_lib_qassistantclient.cpp b/doc/codesnippets/doc/src/snippets/code/tools_assistant_compat_lib_qassistantclient.cpp
new file mode 100644
index 000000000..f5097a9f8
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/tools_assistant_compat_lib_qassistantclient.cpp
@@ -0,0 +1,25 @@
+//! [0]
+ QProcess *process = new QProcess(this);
+ QString app = QLibraryInfo::location(QLibraryInfo::BinariesPath)
+ + QLatin1String("/assistant");
+
+ process->start(app, QStringList() << QLatin1String("-enableRemoteControl"));
+ if (!process->waitForStarted()) {
+ QMessageBox::critical(this, tr("Remote Control"),
+ tr("Could not start Qt Assistant from %1.").arg(app));
+ return;
+ }
+
+ // show index page
+ QTextStream str(process);
+ str << QLatin1String("SetSource qthelp://mycompany.com/doc/index.html")
+ << QLatin1Char('\0') << endl;
+ }
+//! [0]
+
+
+//! [1]
+ CONFIG += assistant
+//! [1]
+
+
diff --git a/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_extension_default_extensionfactory.cpp b/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_extension_default_extensionfactory.cpp
new file mode 100644
index 000000000..cdfd07648
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_extension_default_extensionfactory.cpp
@@ -0,0 +1,35 @@
+//! [0]
+ QObject *ANewExtensionFactory::createExtension(QObject *object,
+ const QString &iid, QObject *parent) const
+ {
+ if (iid != Q_TYPEID(QDesignerContainerExtension))
+ return 0;
+
+ if (MyCustomWidget *widget = qobject_cast<MyCustomWidget*>
+ (object))
+ return new MyContainerExtension(widget, parent);
+
+ return 0;
+ }
+//! [0]
+
+
+//! [1]
+ QObject *AGeneralExtensionFactory::createExtension(QObject *object,
+ const QString &iid, QObject *parent) const
+ {
+ MyCustomWidget *widget = qobject_cast<MyCustomWidget*>(object);
+
+ if (widget && (iid == Q_TYPEID(QDesignerTaskMenuExtension))) {
+ return new MyTaskMenuExtension(widget, parent);
+
+ } else if (widget && (iid == Q_TYPEID(QDesignerContainerExtension))) {
+ return new MyContainerExtension(widget, parent);
+
+ } else {
+ return 0;
+ }
+ }
+//! [1]
+
+
diff --git a/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_extension_extension.cpp b/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_extension_extension.cpp
new file mode 100644
index 000000000..60bd0ccc4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_extension_extension.cpp
@@ -0,0 +1,15 @@
+//! [0]
+ QDesignerPropertySheetExtension *propertySheet;
+ QExtensionManager manager = formEditor->extensionManager();
+
+ propertySheet = qt_extension<QDesignerPropertySheetExtension*>(manager, widget);
+
+ if(propertySheet) {...}
+//! [0]
+
+
+//! [1]
+ Q_DECLARE_EXTENSION_INTERFACE(MyExtension, "com.mycompany.myproduct.myextension")
+//! [1]
+
+
diff --git a/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_extension_qextensionmanager.cpp b/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_extension_qextensionmanager.cpp
new file mode 100644
index 000000000..47cee58d3
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_extension_qextensionmanager.cpp
@@ -0,0 +1,17 @@
+//! [0]
+ void MyPlugin::initialize(QDesignerFormEditorInterface *formEditor)
+ {
+ if (initialized)
+ return;
+
+ QExtensionManager *manager = formEditor->extensionManager();
+ Q_ASSERT(manager != 0);
+
+ manager->registerExtensions(new MyExtensionFactory(manager),
+ Q_TYPEID(QDesignerTaskMenuExtension));
+
+ initialized = true;
+ }
+//! [0]
+
+
diff --git a/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformeditor.cpp b/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformeditor.cpp
new file mode 100644
index 000000000..ef13069d0
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformeditor.cpp
@@ -0,0 +1,11 @@
+//! [0]
+ QDesignerObjectInspectorInterface *objectInspector = 0;
+ objectInspector = formEditor->objectInspector();
+
+ QDesignerFormWindowManagerInterface *manager = 0;
+ manager = formEditor->formWindowManager();
+
+ objectInspector->setFormWindow(manager->formWindow(0));
+//! [0]
+
+
diff --git a/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindow.cpp b/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindow.cpp
new file mode 100644
index 000000000..840697d86
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindow.cpp
@@ -0,0 +1,25 @@
+//! [0]
+ QDesignerFormWindowInterface *formWindow;
+ formWindow = QDesignerFormWindowInterface::findFormWindow(myWidget);
+//! [0]
+
+
+//! [1]
+ QList<QDesignerFormWindowInterface *> forms;
+ QDesignerFormWindowInterface *formWindow;
+
+ QDesignerFormWindowManagerInterface *manager = formEditor->formWindowManager();
+
+ for (int i = 0; i < manager->formWindowCount(); i++) {
+ formWindow = manager->formWindow(i);
+ forms.append(formWindow);
+ }
+//! [1]
+
+
+//! [2]
+ if (formWindow->isManaged(myWidget))
+ formWindow->manageWidget(myWidget->childWidget);
+//! [2]
+
+
diff --git a/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindowcursor.cpp b/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindowcursor.cpp
new file mode 100644
index 000000000..fbe4fb8b7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindowcursor.cpp
@@ -0,0 +1,8 @@
+//! [0]
+ QDesignerFormWindowInterface *formWindow = 0;
+ formWindow = QDesignerFormWindowInterface::findFormWindow(myWidget);
+
+ formWindow->cursor()->setProperty(myWidget, myProperty, newValue);
+//! [0]
+
+
diff --git a/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindowmanager.cpp b/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindowmanager.cpp
new file mode 100644
index 000000000..b54f0a6db
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindowmanager.cpp
@@ -0,0 +1,11 @@
+//! [0]
+ QDesignerFormWindowManagerInterface *manager = 0;
+ QDesignerFormWindowInterface *formWindow = 0;
+
+ manager = formEditor->formWindowManager();
+ formWindow = manager->formWindow(0);
+
+ manager->setActiveFormWindow(formWindow);
+//! [0]
+
+
diff --git a/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractobjectinspector.cpp b/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractobjectinspector.cpp
new file mode 100644
index 000000000..ef13069d0
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractobjectinspector.cpp
@@ -0,0 +1,11 @@
+//! [0]
+ QDesignerObjectInspectorInterface *objectInspector = 0;
+ objectInspector = formEditor->objectInspector();
+
+ QDesignerFormWindowManagerInterface *manager = 0;
+ manager = formEditor->formWindowManager();
+
+ objectInspector->setFormWindow(manager->formWindow(0));
+//! [0]
+
+
diff --git a/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractpropertyeditor.cpp b/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractpropertyeditor.cpp
new file mode 100644
index 000000000..bbc396fcf
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractpropertyeditor.cpp
@@ -0,0 +1,23 @@
+//! [0]
+ QDesignerPropertyEditorInterface *propertyEditor = 0;
+ propertyEditor = formEditor->propertyEditor();
+
+ connect(propertyEditor, SIGNAL(propertyChanged(QString, QVariant)),
+ this, SLOT(checkProperty(QString, QVariant)));
+//! [0]
+
+
+//! [1]
+ void checkProperty(QString property, QVariant value) {
+ QDesignerPropertyEditorInterface *propertyEditor = 0;
+ propertyEditor = formEditor->propertyEditor();
+
+ QObject *object = propertyeditor->object();
+ MyCustomWidget *widget = qobject_cast<MyCustomWidget>(object);
+
+ if (widget && property == aProperty && value != expectedValue)
+ {...}
+ }
+//! [1]
+
+
diff --git a/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractwidgetbox.cpp b/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractwidgetbox.cpp
new file mode 100644
index 000000000..b80c59ead
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractwidgetbox.cpp
@@ -0,0 +1,30 @@
+//! [0]
+ QDesignerWidgetBoxInterface *widgetBox = 0:
+ widgetBox = formEditor->widgetBox();
+
+ widgetBox->load();
+//! [0]
+
+
+//! [1]
+ QString originalFile = widgetBox->fileName();
+
+ widgetBox->setFileName("myWidgetBox.xml");
+ widgetBox->save();
+//! [1]
+
+
+//! [2]
+ widgetBox->setFileName(originalFile);
+ widgetBox->load();
+//! [2]
+
+
+//! [3]
+ if (widgetBox->filename() != "myWidgetBox.xml") {
+ widgetBox->setFileName("myWidgetBox.xml");
+ widgetBox->load();
+ }
+//! [3]
+
+
diff --git a/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_uilib_abstractformbuilder.cpp b/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_uilib_abstractformbuilder.cpp
new file mode 100644
index 000000000..b572fba88
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_uilib_abstractformbuilder.cpp
@@ -0,0 +1,17 @@
+//! [0]
+ MyForm::MyForm(QWidget *parent)
+ : QWidget(parent)
+ {
+ QFormBuilder builder;
+ QFile file(":/forms/myWidget.ui");
+ file.open(QFile::ReadOnly);
+ QWidget *myWidget = builder.load(&file, this);
+ file.close();
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(myWidget);
+ setLayout(layout);
+ }
+//! [0]
+
+
diff --git a/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_uilib_formbuilder.cpp b/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_uilib_formbuilder.cpp
new file mode 100644
index 000000000..a88dab58e
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_uilib_formbuilder.cpp
@@ -0,0 +1,26 @@
+//! [0]
+ MyForm::MyForm(QWidget *parent)
+ : QWidget(parent)
+ {
+ QFormBuilder builder;
+ QFile file(":/forms/myWidget.ui");
+ file.open(QFile::ReadOnly);
+ QWidget *myWidget = builder.load(&file, this);
+ file.close();
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(myWidget);
+ setLayout(layout);
+ }
+//! [0]
+
+
+//! [1]
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/forms">
+ <file>mywidget.ui</file>
+ </qresource>
+ </RCC>
+//! [1]
+
+
diff --git a/doc/codesnippets/doc/src/snippets/code/tools_patternist_qapplicationargumentparser.cpp b/doc/codesnippets/doc/src/snippets/code/tools_patternist_qapplicationargumentparser.cpp
new file mode 100644
index 000000000..da28cd518
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/tools_patternist_qapplicationargumentparser.cpp
@@ -0,0 +1,5 @@
+//! [0]
+ \include main.cpp
+//! [0]
+
+
diff --git a/doc/codesnippets/doc/src/snippets/code/tools_shared_qtgradienteditor_qtgradientdialog.cpp b/doc/codesnippets/doc/src/snippets/code/tools_shared_qtgradienteditor_qtgradientdialog.cpp
new file mode 100644
index 000000000..72e86ba59
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/tools_shared_qtgradienteditor_qtgradientdialog.cpp
@@ -0,0 +1,44 @@
+//! [0]
+ bool ok;
+ QGradient gradient = QtGradientDialog::getGradient(&ok, QRadialGradient(), this);
+ if (ok) {
+ // the user clicked OK and gradient is set to the gradient the user selected
+ } else {
+ // the user canceled the dialog; gradient is set to the initial
+ // value, in this case radial gradient
+ }
+//! [0]
+
+
+//! [1]
+ bool detailsVisible;
+ QColor::Spec spec;
+ QGradient gradient;
+
+ QtGradientDialog dlg(this);
+ dlg.setDetailsVisible(detailsVisible);
+ dlg.setSpec(spec);
+ dlg.setGradient(gradient);
+ if (dlg.exec() != QDialog::Accepted)
+ return;
+
+ gradient = dlg.gradient();
+ // detailsVisible and spec properties can be changed interactively by the user too,
+ // we store the values of these properties for the next time QtGradientDialog is executed.
+ detailsVisible = dlg.detailsVisible();
+ spec = dlg.spec();
+//! [1]
+
+
+//! [2]
+ QtGradientDialog dlg;
+ dlg.setBackgroundCheckered(true);
+//! [2]
+
+
+//! [3]
+ QtGradientDialog dlg;
+ dlg.setBackgroundCheckered(false);
+//! [3]
+
+
diff --git a/doc/codesnippets/doc/src/snippets/code/tools_shared_qtpropertybrowser_qtpropertybrowser.cpp b/doc/codesnippets/doc/src/snippets/code/tools_shared_qtpropertybrowser_qtpropertybrowser.cpp
new file mode 100644
index 000000000..62f431900
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/tools_shared_qtpropertybrowser_qtpropertybrowser.cpp
@@ -0,0 +1,47 @@
+//! [0]
+ QtSpinBoxFactory *factory;
+ QSet<QtIntPropertyManager *> managers = factory->propertyManagers();
+//! [0]
+
+
+//! [1]
+ QtBrowserItem *item;
+ QList<QtBrowserItem *> childrenItems = item->children();
+
+ QList<QtProperty *> childrenProperties = item->property()->subProperties();
+//! [1]
+
+
+//! [2]
+ QtProperty *property1, *property2, *property3;
+
+ property2->addSubProperty(property1);
+ property3->addSubProperty(property2);
+
+ QtAbstractPropertyBrowser *editor;
+
+ editor->addProperty(property1);
+ editor->addProperty(property2);
+ editor->addProperty(property3);
+//! [2]
+
+
+//! [3]
+ QtIntPropertyManager *intManager;
+ QtDoublePropertyManager *doubleManager;
+
+ QtProperty *myInteger = intManager->addProperty();
+ QtProperty *myDouble = doubleManager->addProperty();
+
+ QtSpinBoxFactory *spinBoxFactory;
+ QtDoubleSpinBoxFactory *doubleSpinBoxFactory;
+
+ QtAbstractPropertyBrowser *editor;
+ editor->setFactoryForManager(intManager, spinBoxFactory);
+ editor->setFactoryForManager(doubleManager, doubleSpinBoxFactory);
+
+ editor->addProperty(myInteger);
+ editor->addProperty(myDouble);
+//! [3]
+
+
diff --git a/doc/codesnippets/doc/src/snippets/code/tools_shared_qtpropertybrowser_qtvariantproperty.cpp b/doc/codesnippets/doc/src/snippets/code/tools_shared_qtpropertybrowser_qtvariantproperty.cpp
new file mode 100644
index 000000000..fbc96824b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/tools_shared_qtpropertybrowser_qtvariantproperty.cpp
@@ -0,0 +1,16 @@
+//! [0]
+ QtVariantPropertyManager *variantPropertyManager;
+ QtProperty *property;
+
+ variantPropertyManager->setValue(property, 10);
+//! [0]
+
+
+//! [1]
+ QtVariantPropertyManager *variantPropertyManager;
+ QtVariantProperty *property;
+
+ property->setValue(10);
+//! [1]
+
+
diff --git a/doc/codesnippets/doc/src/snippets/code/tools_shared_qttoolbardialog_qttoolbardialog.cpp b/doc/codesnippets/doc/src/snippets/code/tools_shared_qttoolbardialog_qttoolbardialog.cpp
new file mode 100644
index 000000000..9162b63b7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/tools_shared_qttoolbardialog_qttoolbardialog.cpp
@@ -0,0 +1,12 @@
+//! [0]
+ QtToolBarManager *toolBarManager;
+
+ void MyMainWindow::customize()
+ {
+ QtToolBarDialog dialog(this);
+ dialog.setToolBarManager(toolBarManager);
+ dialog.exec();
+ }
+//! [0]
+
+
diff --git a/doc/codesnippets/doc/src/snippets/complexpingpong-example.qdoc b/doc/codesnippets/doc/src/snippets/complexpingpong-example.qdoc
new file mode 100644
index 000000000..257f7029e
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/complexpingpong-example.qdoc
@@ -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/codesnippets/doc/src/snippets/console/dbus_pingpong.txt b/doc/codesnippets/doc/src/snippets/console/dbus_pingpong.txt
new file mode 100644
index 000000000..3c700db5c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/console/dbus_pingpong.txt
@@ -0,0 +1,3 @@
+[qtuser@workstation:~/dev/qt-4.4/examples/dbus/pingpong]$ ./pong &
+[qtuser@workstation:~/dev/qt-4.4/examples/dbus/pingpong]$ ./ping Hello
+Reply was: ping("Hello") got called
diff --git a/doc/codesnippets/doc/src/snippets/coordsys/coordsys.cpp b/doc/codesnippets/doc/src/snippets/coordsys/coordsys.cpp
new file mode 100644
index 000000000..d4860a9a2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/coordsys/coordsys.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+class MyWidget : public QWidget
+{
+public:
+ MyWidget();
+
+protected:
+ void paintEvent(QPaintEvent *);
+};
+
+MyWidget::MyWidget()
+{
+ QPalette palette(MyWidget::palette());
+ palette.setColor(backgroundRole(), Qt::white);
+ setPalette(palette);
+}
+
+void MyWidget::paintEvent(QPaintEvent *)
+{
+ QPainter painter(this);
+ painter.setRenderHint(QPainter::Antialiasing);
+ painter.setPen(Qt::darkGreen);
+ painter.drawRect(1, 2, 6, 4);
+
+ //painter.setPen(Qt::darkGray);
+ //painter.drawLine(2, 8, 6, 2);
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MyWidget widget;
+ widget.show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/coordsys/coordsys.pro b/doc/codesnippets/doc/src/snippets/coordsys/coordsys.pro
new file mode 100644
index 000000000..b6aac7cfc
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/coordsys/coordsys.pro
@@ -0,0 +1 @@
+SOURCES += coordsys.cpp
diff --git a/doc/codesnippets/doc/src/snippets/customstyle/customstyle.cpp b/doc/codesnippets/doc/src/snippets/customstyle/customstyle.cpp
new file mode 100644
index 000000000..5de098719
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/customstyle/customstyle.cpp
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "customstyle.h"
+
+CustomStyle::CustomStyle()
+{
+//! [0]
+ if widget:
+//! [0] //! [1]
+//! [1]
+}
+
+//! [2]
+def drawPrimitive(element, option, painter, widget):
+ if element == PE_IndicatorSpinUp or element == PE_IndicatorSpinDown:
+ points = QPolygon(3)
+ x = option->rect.x()
+ y = option->rect.y()
+ w = option->rect.width() / 2
+ 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/codesnippets/doc/src/snippets/customstyle/customstyle.h b/doc/codesnippets/doc/src/snippets/customstyle/customstyle.h
new file mode 100644
index 000000000..9b794a957
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/customstyle/customstyle.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CUSTOMSTYLE_H
+#define CUSTOMSTYLE_H
+
+#include <QWindowsStyle>
+
+//! [0]
+class CustomStyle(QWindowsStyle):
+ ...
+
+ def drawPrimitive(PrimitiveElement element, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const;
+ # element : PrimitiveElement
+ # option : QStyleOption
+ # painter : QPainter
+ # widget : QWidget
+ ...
+//! [0]
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/customstyle/customstyle.pro b/doc/codesnippets/doc/src/snippets/customstyle/customstyle.pro
new file mode 100644
index 000000000..af0ee4e14
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/customstyle/customstyle.pro
@@ -0,0 +1,2 @@
+HEADERS += customstyle.h
+SOURCES += customstyle.cpp main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/customstyle/main.cpp b/doc/codesnippets/doc/src/snippets/customstyle/main.cpp
new file mode 100644
index 000000000..a78f16202
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/customstyle/main.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [using a custom style]
+#include <QtGui>
+
+#include "customstyle.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication::setStyle(new CustomStyle);
+ QApplication app(argc, argv);
+ QSpinBox spinBox;
+ spinBox.show();
+ return app.exec();
+}
+//! [using a custom style]
diff --git a/doc/codesnippets/doc/src/snippets/customviewstyle.cpp b/doc/codesnippets/doc/src/snippets/customviewstyle.cpp
new file mode 100644
index 000000000..6cfbac72c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/customviewstyle.cpp
@@ -0,0 +1,29 @@
+#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/codesnippets/doc/src/snippets/dbus-pingpong-example.qdoc b/doc/codesnippets/doc/src/snippets/dbus-pingpong-example.qdoc
new file mode 100644
index 000000000..13a34a82c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dbus-pingpong-example.qdoc
@@ -0,0 +1,3 @@
+$ ./pong &
+$ ./ping Hello
+Reply was: ping("Hello") got called
diff --git a/doc/codesnippets/doc/src/snippets/designer/autoconnection/autoconnection.pro b/doc/codesnippets/doc/src/snippets/designer/autoconnection/autoconnection.pro
new file mode 100644
index 000000000..fba94debf
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/designer/autoconnection/autoconnection.pro
@@ -0,0 +1,5 @@
+TEMPLATE = app
+FORMS = imagedialog.ui
+HEADERS = imagedialog.h
+SOURCES = imagedialog.cpp \
+ main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/designer/autoconnection/imagedialog.cpp b/doc/codesnippets/doc/src/snippets/designer/autoconnection/imagedialog.cpp
new file mode 100644
index 000000000..259a67622
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/designer/autoconnection/imagedialog.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "imagedialog.h"
+
+ImageDialog::ImageDialog(QWidget *parent)
+ : QDialog(parent)
+{
+ setupUi(this);
+ okButton->setAutoDefault(false);
+ cancelButton->setAutoDefault(false);
+
+ colorDepthCombo->addItem(tr("2 colors (1 bit per pixel)"));
+ colorDepthCombo->addItem(tr("4 colors (2 bits per pixel)"));
+ colorDepthCombo->addItem(tr("16 colors (4 bits per pixel)"));
+ colorDepthCombo->addItem(tr("256 colors (8 bits per pixel)"));
+ colorDepthCombo->addItem(tr("65536 colors (16 bits per pixel)"));
+ colorDepthCombo->addItem(tr("16 million colors (24 bits per pixel)"));
+
+ connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
+}
+
+void ImageDialog::on_okButton_clicked()
+{
+ if (nameLineEdit->text().isEmpty())
+ (void) QMessageBox::information(this, tr("No Image Name"),
+ tr("Please supply a name for the image."), QMessageBox::Cancel);
+ else
+ accept();
+}
diff --git a/doc/codesnippets/doc/src/snippets/designer/autoconnection/imagedialog.h b/doc/codesnippets/doc/src/snippets/designer/autoconnection/imagedialog.h
new file mode 100644
index 000000000..ce3ea4d1b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/designer/autoconnection/imagedialog.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef IMAGEDIALOG_H
+#define IMAGEDIALOG_H
+
+#include "ui_imagedialog.h"
+
+//! [0]
+class ImageDialog : public QDialog, private Ui::ImageDialog
+{
+ Q_OBJECT
+
+public:
+ ImageDialog(QWidget *parent = 0);
+
+private slots:
+ void on_okButton_clicked();
+};
+//! [0]
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/designer/autoconnection/imagedialog.ui b/doc/codesnippets/doc/src/snippets/designer/autoconnection/imagedialog.ui
new file mode 100644
index 000000000..1c5e546f2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/designer/autoconnection/imagedialog.ui
@@ -0,0 +1,389 @@
+<ui version="4.0" >
+ <comment></comment>
+ <class>ImageDialog</class>
+ <widget class="QDialog" >
+ <property name="objectName" >
+ <string notr="true" >ImageDialog</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>320</width>
+ <height>180</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Create Image</string>
+ </property>
+ <layout class="QVBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>9</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <layout class="QGridLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="widthLabel" >
+ <property name="objectName" >
+ <string notr="true" >widthLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>27</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Width:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="heightLabel" >
+ <property name="objectName" >
+ <string notr="true" >heightLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>55</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Height:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" >
+ <widget class="QComboBox" name="colorDepthCombo" >
+ <property name="objectName" >
+ <string notr="true" >colorDepthCombo</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>83</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="insertPolicy" >
+ <enum>QComboBox::InsertAtBottom</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QLineEdit" name="nameLineEdit" >
+ <property name="objectName" >
+ <string notr="true" >nameLineEdit</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>83</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>Untitled image</string>
+ </property>
+ <property name="echoMode" >
+ <enum>QLineEdit::Normal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QSpinBox" name="spinBox" >
+ <property name="objectName" >
+ <string notr="true" >spinBox</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>1</y>
+ <width>227</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="buttonSymbols" >
+ <enum>QAbstractSpinBox::UpDownArrows</enum>
+ </property>
+ <property name="value" >
+ <number>32</number>
+ </property>
+ <property name="maximum" >
+ <number>1024</number>
+ </property>
+ <property name="minimum" >
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QSpinBox" name="spinBox_2" >
+ <property name="objectName" >
+ <string notr="true" >spinBox_2</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>27</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="buttonSymbols" >
+ <enum>QAbstractSpinBox::UpDownArrows</enum>
+ </property>
+ <property name="value" >
+ <number>32</number>
+ </property>
+ <property name="maximum" >
+ <number>1024</number>
+ </property>
+ <property name="minimum" >
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" >
+ <widget class="QLabel" name="nameLabel" >
+ <property name="objectName" >
+ <string notr="true" >nameLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>1</y>
+ <width>67</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Name:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" >
+ <widget class="QLabel" name="colorDepthLabel" >
+ <property name="objectName" >
+ <string notr="true" >colorDepthLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>83</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Color depth:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer>
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>9</x>
+ <y>121</y>
+ <width>302</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <spacer>
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>1</y>
+ <width>128</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="okButton" >
+ <property name="objectName" >
+ <string notr="true" >okButton</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>135</x>
+ <y>1</y>
+ <width>80</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>OK</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cancelButton" >
+ <property name="objectName" >
+ <string notr="true" >cancelButton</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>221</x>
+ <y>1</y>
+ <width>80</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <pixmapfunction></pixmapfunction>
+ <tabstops>
+ <tabstop>nameLineEdit</tabstop>
+ <tabstop>spinBox</tabstop>
+ <tabstop>spinBox_2</tabstop>
+ <tabstop>colorDepthCombo</tabstop>
+ <tabstop>okButton</tabstop>
+ <tabstop>cancelButton</tabstop>
+ </tabstops>
+ <connections>
+ <connection>
+ <sender>nameLineEdit</sender>
+ <signal>returnPressed()</signal>
+ <receiver>okButton</receiver>
+ <slot>animateClick()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>-1</x>
+ <y>7</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>-1</x>
+ <y>7</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/doc/codesnippets/doc/src/snippets/designer/autoconnection/main.cpp b/doc/codesnippets/doc/src/snippets/designer/autoconnection/main.cpp
new file mode 100644
index 000000000..1e9c57215
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/designer/autoconnection/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "imagedialog.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ ImageDialog *dialog = new ImageDialog;
+ dialog->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/designer/designer.pro b/doc/codesnippets/doc/src/snippets/designer/designer.pro
new file mode 100644
index 000000000..1445ca58b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/designer/designer.pro
@@ -0,0 +1,6 @@
+TEMPLATE = subdirs
+SUBDIRS = autoconnection \
+ imagedialog \
+ multipleinheritance \
+ noautoconnection \
+ singleinheritance
diff --git a/doc/codesnippets/doc/src/snippets/designer/imagedialog/imagedialog.pro b/doc/codesnippets/doc/src/snippets/designer/imagedialog/imagedialog.pro
new file mode 100644
index 000000000..164a7b2cb
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/designer/imagedialog/imagedialog.pro
@@ -0,0 +1,3 @@
+TEMPLATE = app
+FORMS = imagedialog.ui
+SOURCES = main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/designer/imagedialog/imagedialog.ui b/doc/codesnippets/doc/src/snippets/designer/imagedialog/imagedialog.ui
new file mode 100644
index 000000000..1c5e546f2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/designer/imagedialog/imagedialog.ui
@@ -0,0 +1,389 @@
+<ui version="4.0" >
+ <comment></comment>
+ <class>ImageDialog</class>
+ <widget class="QDialog" >
+ <property name="objectName" >
+ <string notr="true" >ImageDialog</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>320</width>
+ <height>180</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Create Image</string>
+ </property>
+ <layout class="QVBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>9</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <layout class="QGridLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="widthLabel" >
+ <property name="objectName" >
+ <string notr="true" >widthLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>27</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Width:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="heightLabel" >
+ <property name="objectName" >
+ <string notr="true" >heightLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>55</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Height:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" >
+ <widget class="QComboBox" name="colorDepthCombo" >
+ <property name="objectName" >
+ <string notr="true" >colorDepthCombo</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>83</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="insertPolicy" >
+ <enum>QComboBox::InsertAtBottom</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QLineEdit" name="nameLineEdit" >
+ <property name="objectName" >
+ <string notr="true" >nameLineEdit</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>83</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>Untitled image</string>
+ </property>
+ <property name="echoMode" >
+ <enum>QLineEdit::Normal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QSpinBox" name="spinBox" >
+ <property name="objectName" >
+ <string notr="true" >spinBox</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>1</y>
+ <width>227</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="buttonSymbols" >
+ <enum>QAbstractSpinBox::UpDownArrows</enum>
+ </property>
+ <property name="value" >
+ <number>32</number>
+ </property>
+ <property name="maximum" >
+ <number>1024</number>
+ </property>
+ <property name="minimum" >
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QSpinBox" name="spinBox_2" >
+ <property name="objectName" >
+ <string notr="true" >spinBox_2</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>27</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="buttonSymbols" >
+ <enum>QAbstractSpinBox::UpDownArrows</enum>
+ </property>
+ <property name="value" >
+ <number>32</number>
+ </property>
+ <property name="maximum" >
+ <number>1024</number>
+ </property>
+ <property name="minimum" >
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" >
+ <widget class="QLabel" name="nameLabel" >
+ <property name="objectName" >
+ <string notr="true" >nameLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>1</y>
+ <width>67</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Name:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" >
+ <widget class="QLabel" name="colorDepthLabel" >
+ <property name="objectName" >
+ <string notr="true" >colorDepthLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>83</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Color depth:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer>
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>9</x>
+ <y>121</y>
+ <width>302</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <spacer>
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>1</y>
+ <width>128</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="okButton" >
+ <property name="objectName" >
+ <string notr="true" >okButton</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>135</x>
+ <y>1</y>
+ <width>80</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>OK</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cancelButton" >
+ <property name="objectName" >
+ <string notr="true" >cancelButton</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>221</x>
+ <y>1</y>
+ <width>80</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <pixmapfunction></pixmapfunction>
+ <tabstops>
+ <tabstop>nameLineEdit</tabstop>
+ <tabstop>spinBox</tabstop>
+ <tabstop>spinBox_2</tabstop>
+ <tabstop>colorDepthCombo</tabstop>
+ <tabstop>okButton</tabstop>
+ <tabstop>cancelButton</tabstop>
+ </tabstops>
+ <connections>
+ <connection>
+ <sender>nameLineEdit</sender>
+ <signal>returnPressed()</signal>
+ <receiver>okButton</receiver>
+ <slot>animateClick()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>-1</x>
+ <y>7</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>-1</x>
+ <y>7</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/doc/codesnippets/doc/src/snippets/designer/imagedialog/main.cpp b/doc/codesnippets/doc/src/snippets/designer/imagedialog/main.cpp
new file mode 100644
index 000000000..d47631aa6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/designer/imagedialog/main.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "ui_imagedialog.h"
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QDialog *window = new QDialog;
+ Ui::ImageDialog ui;
+ ui.setupUi(window);
+
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/imagedialog.cpp b/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/imagedialog.cpp
new file mode 100644
index 000000000..199bd0aca
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/imagedialog.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "imagedialog.h"
+
+ImageDialog::ImageDialog(QWidget *parent)
+ : QDialog(parent)
+{
+ setupUi(this);
+
+ colorDepthCombo->addItem(tr("2 colors (1 bit per pixel)"));
+ colorDepthCombo->addItem(tr("4 colors (2 bits per pixel)"));
+ colorDepthCombo->addItem(tr("16 colors (4 bits per pixel)"));
+ colorDepthCombo->addItem(tr("256 colors (8 bits per pixel)"));
+ colorDepthCombo->addItem(tr("65536 colors (16 bits per pixel)"));
+ colorDepthCombo->addItem(tr("16 million colors (24 bits per pixel)"));
+
+ connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
+ connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
+}
diff --git a/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/imagedialog.h b/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/imagedialog.h
new file mode 100644
index 000000000..0eccd28b5
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/imagedialog.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef IMAGEDIALOG_H
+#define IMAGEDIALOG_H
+
+#include "ui_imagedialog.h"
+
+class ImageDialog : public QDialog, private Ui::ImageDialog
+{
+ Q_OBJECT
+
+public:
+ ImageDialog(QWidget *parent = 0);
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/imagedialog.ui b/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/imagedialog.ui
new file mode 100644
index 000000000..1c5e546f2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/imagedialog.ui
@@ -0,0 +1,389 @@
+<ui version="4.0" >
+ <comment></comment>
+ <class>ImageDialog</class>
+ <widget class="QDialog" >
+ <property name="objectName" >
+ <string notr="true" >ImageDialog</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>320</width>
+ <height>180</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Create Image</string>
+ </property>
+ <layout class="QVBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>9</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <layout class="QGridLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="widthLabel" >
+ <property name="objectName" >
+ <string notr="true" >widthLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>27</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Width:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="heightLabel" >
+ <property name="objectName" >
+ <string notr="true" >heightLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>55</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Height:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" >
+ <widget class="QComboBox" name="colorDepthCombo" >
+ <property name="objectName" >
+ <string notr="true" >colorDepthCombo</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>83</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="insertPolicy" >
+ <enum>QComboBox::InsertAtBottom</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QLineEdit" name="nameLineEdit" >
+ <property name="objectName" >
+ <string notr="true" >nameLineEdit</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>83</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>Untitled image</string>
+ </property>
+ <property name="echoMode" >
+ <enum>QLineEdit::Normal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QSpinBox" name="spinBox" >
+ <property name="objectName" >
+ <string notr="true" >spinBox</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>1</y>
+ <width>227</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="buttonSymbols" >
+ <enum>QAbstractSpinBox::UpDownArrows</enum>
+ </property>
+ <property name="value" >
+ <number>32</number>
+ </property>
+ <property name="maximum" >
+ <number>1024</number>
+ </property>
+ <property name="minimum" >
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QSpinBox" name="spinBox_2" >
+ <property name="objectName" >
+ <string notr="true" >spinBox_2</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>27</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="buttonSymbols" >
+ <enum>QAbstractSpinBox::UpDownArrows</enum>
+ </property>
+ <property name="value" >
+ <number>32</number>
+ </property>
+ <property name="maximum" >
+ <number>1024</number>
+ </property>
+ <property name="minimum" >
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" >
+ <widget class="QLabel" name="nameLabel" >
+ <property name="objectName" >
+ <string notr="true" >nameLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>1</y>
+ <width>67</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Name:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" >
+ <widget class="QLabel" name="colorDepthLabel" >
+ <property name="objectName" >
+ <string notr="true" >colorDepthLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>83</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Color depth:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer>
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>9</x>
+ <y>121</y>
+ <width>302</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <spacer>
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>1</y>
+ <width>128</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="okButton" >
+ <property name="objectName" >
+ <string notr="true" >okButton</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>135</x>
+ <y>1</y>
+ <width>80</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>OK</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cancelButton" >
+ <property name="objectName" >
+ <string notr="true" >cancelButton</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>221</x>
+ <y>1</y>
+ <width>80</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <pixmapfunction></pixmapfunction>
+ <tabstops>
+ <tabstop>nameLineEdit</tabstop>
+ <tabstop>spinBox</tabstop>
+ <tabstop>spinBox_2</tabstop>
+ <tabstop>colorDepthCombo</tabstop>
+ <tabstop>okButton</tabstop>
+ <tabstop>cancelButton</tabstop>
+ </tabstops>
+ <connections>
+ <connection>
+ <sender>nameLineEdit</sender>
+ <signal>returnPressed()</signal>
+ <receiver>okButton</receiver>
+ <slot>animateClick()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>-1</x>
+ <y>7</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>-1</x>
+ <y>7</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/main.cpp b/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/main.cpp
new file mode 100644
index 000000000..1e9c57215
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "imagedialog.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ ImageDialog *dialog = new ImageDialog;
+ dialog->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/multipleinheritance.pro b/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/multipleinheritance.pro
new file mode 100644
index 000000000..fba94debf
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/multipleinheritance.pro
@@ -0,0 +1,5 @@
+TEMPLATE = app
+FORMS = imagedialog.ui
+HEADERS = imagedialog.h
+SOURCES = imagedialog.cpp \
+ main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/designer/noautoconnection/imagedialog.cpp b/doc/codesnippets/doc/src/snippets/designer/noautoconnection/imagedialog.cpp
new file mode 100644
index 000000000..b6b949272
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/designer/noautoconnection/imagedialog.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "imagedialog.h"
+
+//! [0]
+ImageDialog::ImageDialog(QWidget *parent)
+ : QDialog(parent)
+{
+ setupUi(this);
+ okButton->setAutoDefault(false);
+ cancelButton->setAutoDefault(false);
+//! [0]
+
+ colorDepthCombo->addItem(tr("2 colors (1 bit per pixel)"));
+ colorDepthCombo->addItem(tr("4 colors (2 bits per pixel)"));
+ colorDepthCombo->addItem(tr("16 colors (4 bits per pixel)"));
+ colorDepthCombo->addItem(tr("256 colors (8 bits per pixel)"));
+ colorDepthCombo->addItem(tr("65536 colors (16 bits per pixel)"));
+ colorDepthCombo->addItem(tr("16 million colors (24 bits per pixel)"));
+
+ connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
+//! [1]
+ connect(okButton, SIGNAL(clicked()), this, SLOT(checkValues()));
+}
+//! [1]
+
+//! [2]
+void ImageDialog::checkValues()
+{
+ if (nameLineEdit->text().isEmpty())
+ (void) QMessageBox::information(this, tr("No Image Name"),
+ tr("Please supply a name for the image."), QMessageBox::Cancel);
+ else
+ accept();
+}
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/designer/noautoconnection/imagedialog.h b/doc/codesnippets/doc/src/snippets/designer/noautoconnection/imagedialog.h
new file mode 100644
index 000000000..b074a1f4f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/designer/noautoconnection/imagedialog.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef IMAGEDIALOG_H
+#define IMAGEDIALOG_H
+
+#include "ui_imagedialog.h"
+
+//! [0]
+class ImageDialog : public QDialog, private Ui::ImageDialog
+{
+ Q_OBJECT
+
+public:
+ ImageDialog(QWidget *parent = 0);
+
+private slots:
+ void checkValues();
+};
+//! [0]
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/designer/noautoconnection/imagedialog.ui b/doc/codesnippets/doc/src/snippets/designer/noautoconnection/imagedialog.ui
new file mode 100644
index 000000000..1c5e546f2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/designer/noautoconnection/imagedialog.ui
@@ -0,0 +1,389 @@
+<ui version="4.0" >
+ <comment></comment>
+ <class>ImageDialog</class>
+ <widget class="QDialog" >
+ <property name="objectName" >
+ <string notr="true" >ImageDialog</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>320</width>
+ <height>180</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Create Image</string>
+ </property>
+ <layout class="QVBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>9</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <layout class="QGridLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="widthLabel" >
+ <property name="objectName" >
+ <string notr="true" >widthLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>27</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Width:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="heightLabel" >
+ <property name="objectName" >
+ <string notr="true" >heightLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>55</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Height:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" >
+ <widget class="QComboBox" name="colorDepthCombo" >
+ <property name="objectName" >
+ <string notr="true" >colorDepthCombo</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>83</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="insertPolicy" >
+ <enum>QComboBox::InsertAtBottom</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QLineEdit" name="nameLineEdit" >
+ <property name="objectName" >
+ <string notr="true" >nameLineEdit</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>83</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>Untitled image</string>
+ </property>
+ <property name="echoMode" >
+ <enum>QLineEdit::Normal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QSpinBox" name="spinBox" >
+ <property name="objectName" >
+ <string notr="true" >spinBox</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>1</y>
+ <width>227</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="buttonSymbols" >
+ <enum>QAbstractSpinBox::UpDownArrows</enum>
+ </property>
+ <property name="value" >
+ <number>32</number>
+ </property>
+ <property name="maximum" >
+ <number>1024</number>
+ </property>
+ <property name="minimum" >
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QSpinBox" name="spinBox_2" >
+ <property name="objectName" >
+ <string notr="true" >spinBox_2</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>27</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="buttonSymbols" >
+ <enum>QAbstractSpinBox::UpDownArrows</enum>
+ </property>
+ <property name="value" >
+ <number>32</number>
+ </property>
+ <property name="maximum" >
+ <number>1024</number>
+ </property>
+ <property name="minimum" >
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" >
+ <widget class="QLabel" name="nameLabel" >
+ <property name="objectName" >
+ <string notr="true" >nameLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>1</y>
+ <width>67</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Name:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" >
+ <widget class="QLabel" name="colorDepthLabel" >
+ <property name="objectName" >
+ <string notr="true" >colorDepthLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>83</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Color depth:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer>
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>9</x>
+ <y>121</y>
+ <width>302</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <spacer>
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>1</y>
+ <width>128</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="okButton" >
+ <property name="objectName" >
+ <string notr="true" >okButton</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>135</x>
+ <y>1</y>
+ <width>80</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>OK</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cancelButton" >
+ <property name="objectName" >
+ <string notr="true" >cancelButton</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>221</x>
+ <y>1</y>
+ <width>80</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <pixmapfunction></pixmapfunction>
+ <tabstops>
+ <tabstop>nameLineEdit</tabstop>
+ <tabstop>spinBox</tabstop>
+ <tabstop>spinBox_2</tabstop>
+ <tabstop>colorDepthCombo</tabstop>
+ <tabstop>okButton</tabstop>
+ <tabstop>cancelButton</tabstop>
+ </tabstops>
+ <connections>
+ <connection>
+ <sender>nameLineEdit</sender>
+ <signal>returnPressed()</signal>
+ <receiver>okButton</receiver>
+ <slot>animateClick()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>-1</x>
+ <y>7</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>-1</x>
+ <y>7</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/doc/codesnippets/doc/src/snippets/designer/noautoconnection/main.cpp b/doc/codesnippets/doc/src/snippets/designer/noautoconnection/main.cpp
new file mode 100644
index 000000000..1e9c57215
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/designer/noautoconnection/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "imagedialog.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ ImageDialog *dialog = new ImageDialog;
+ dialog->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/designer/noautoconnection/noautoconnection.pro b/doc/codesnippets/doc/src/snippets/designer/noautoconnection/noautoconnection.pro
new file mode 100644
index 000000000..fba94debf
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/designer/noautoconnection/noautoconnection.pro
@@ -0,0 +1,5 @@
+TEMPLATE = app
+FORMS = imagedialog.ui
+HEADERS = imagedialog.h
+SOURCES = imagedialog.cpp \
+ main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/designer/singleinheritance/imagedialog.cpp b/doc/codesnippets/doc/src/snippets/designer/singleinheritance/imagedialog.cpp
new file mode 100644
index 000000000..6c6b8d605
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/designer/singleinheritance/imagedialog.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "imagedialog.h"
+
+ImageDialog::ImageDialog(QWidget *parent)
+ : QDialog(parent)
+{
+ ui.setupUi(this);
+
+ ui.colorDepthCombo->addItem(tr("2 colors (1 bit per pixel)"));
+ ui.colorDepthCombo->addItem(tr("4 colors (2 bits per pixel)"));
+ ui.colorDepthCombo->addItem(tr("16 colors (4 bits per pixel)"));
+ ui.colorDepthCombo->addItem(tr("256 colors (8 bits per pixel)"));
+ ui.colorDepthCombo->addItem(tr("65536 colors (16 bits per pixel)"));
+ ui.colorDepthCombo->addItem(tr("16 million colors (24 bits per pixel)"));
+
+ connect(ui.okButton, SIGNAL(clicked()), this, SLOT(accept()));
+ connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
+}
diff --git a/doc/codesnippets/doc/src/snippets/designer/singleinheritance/imagedialog.h b/doc/codesnippets/doc/src/snippets/designer/singleinheritance/imagedialog.h
new file mode 100644
index 000000000..68137dbee
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/designer/singleinheritance/imagedialog.h
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef IMAGEDIALOG_H
+#define IMAGEDIALOG_H
+
+#include "ui_imagedialog.h"
+
+class ImageDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ ImageDialog(QWidget *parent = 0);
+
+private:
+ Ui::ImageDialog ui;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/designer/singleinheritance/imagedialog.ui b/doc/codesnippets/doc/src/snippets/designer/singleinheritance/imagedialog.ui
new file mode 100644
index 000000000..1c5e546f2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/designer/singleinheritance/imagedialog.ui
@@ -0,0 +1,389 @@
+<ui version="4.0" >
+ <comment></comment>
+ <class>ImageDialog</class>
+ <widget class="QDialog" >
+ <property name="objectName" >
+ <string notr="true" >ImageDialog</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>320</width>
+ <height>180</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Create Image</string>
+ </property>
+ <layout class="QVBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>9</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <layout class="QGridLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="widthLabel" >
+ <property name="objectName" >
+ <string notr="true" >widthLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>27</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Width:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="heightLabel" >
+ <property name="objectName" >
+ <string notr="true" >heightLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>55</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Height:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" >
+ <widget class="QComboBox" name="colorDepthCombo" >
+ <property name="objectName" >
+ <string notr="true" >colorDepthCombo</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>83</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="insertPolicy" >
+ <enum>QComboBox::InsertAtBottom</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QLineEdit" name="nameLineEdit" >
+ <property name="objectName" >
+ <string notr="true" >nameLineEdit</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>83</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>Untitled image</string>
+ </property>
+ <property name="echoMode" >
+ <enum>QLineEdit::Normal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QSpinBox" name="spinBox" >
+ <property name="objectName" >
+ <string notr="true" >spinBox</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>1</y>
+ <width>227</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="buttonSymbols" >
+ <enum>QAbstractSpinBox::UpDownArrows</enum>
+ </property>
+ <property name="value" >
+ <number>32</number>
+ </property>
+ <property name="maximum" >
+ <number>1024</number>
+ </property>
+ <property name="minimum" >
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QSpinBox" name="spinBox_2" >
+ <property name="objectName" >
+ <string notr="true" >spinBox_2</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>27</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="buttonSymbols" >
+ <enum>QAbstractSpinBox::UpDownArrows</enum>
+ </property>
+ <property name="value" >
+ <number>32</number>
+ </property>
+ <property name="maximum" >
+ <number>1024</number>
+ </property>
+ <property name="minimum" >
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" >
+ <widget class="QLabel" name="nameLabel" >
+ <property name="objectName" >
+ <string notr="true" >nameLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>1</y>
+ <width>67</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Name:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" >
+ <widget class="QLabel" name="colorDepthLabel" >
+ <property name="objectName" >
+ <string notr="true" >colorDepthLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>83</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Color depth:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer>
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>9</x>
+ <y>121</y>
+ <width>302</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <spacer>
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>1</y>
+ <width>128</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="okButton" >
+ <property name="objectName" >
+ <string notr="true" >okButton</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>135</x>
+ <y>1</y>
+ <width>80</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>OK</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cancelButton" >
+ <property name="objectName" >
+ <string notr="true" >cancelButton</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>221</x>
+ <y>1</y>
+ <width>80</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <pixmapfunction></pixmapfunction>
+ <tabstops>
+ <tabstop>nameLineEdit</tabstop>
+ <tabstop>spinBox</tabstop>
+ <tabstop>spinBox_2</tabstop>
+ <tabstop>colorDepthCombo</tabstop>
+ <tabstop>okButton</tabstop>
+ <tabstop>cancelButton</tabstop>
+ </tabstops>
+ <connections>
+ <connection>
+ <sender>nameLineEdit</sender>
+ <signal>returnPressed()</signal>
+ <receiver>okButton</receiver>
+ <slot>animateClick()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>-1</x>
+ <y>7</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>-1</x>
+ <y>7</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/doc/codesnippets/doc/src/snippets/designer/singleinheritance/main.cpp b/doc/codesnippets/doc/src/snippets/designer/singleinheritance/main.cpp
new file mode 100644
index 000000000..1e9c57215
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/designer/singleinheritance/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "imagedialog.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ ImageDialog *dialog = new ImageDialog;
+ dialog->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/designer/singleinheritance/singleinheritance.pro b/doc/codesnippets/doc/src/snippets/designer/singleinheritance/singleinheritance.pro
new file mode 100644
index 000000000..fba94debf
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/designer/singleinheritance/singleinheritance.pro
@@ -0,0 +1,5 @@
+TEMPLATE = app
+FORMS = imagedialog.ui
+HEADERS = imagedialog.h
+SOURCES = imagedialog.cpp \
+ main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/dialogs/dialogs.cpp b/doc/codesnippets/doc/src/snippets/dialogs/dialogs.cpp
new file mode 100644
index 000000000..e6e2521b4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dialogs/dialogs.cpp
@@ -0,0 +1,120 @@
+############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Nokia Corporation (qt-info@nokia.com)
+##
+## This file is part of the documentation of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at http://www.qtsoftware.com/contact.
+## $QT_END_LICENSE$
+##
+############################################################################
+
+
+//! [0]
+def find(self)
+
+ if !self.findDialog:
+ self.findDialog = FindDialog(self)
+ connect(findDialog, SIGNAL("findNext()"), self, SLOT("findNext()"))
+
+
+ self.findDialog.show()
+ self.findDialog.raise()
+ self.findDialog.activateWindow()
+
+//! [0]
+
+//! [1]
+def countWords(self):
+ dialog = WordCountDialog(self)
+ dialog.setWordCount(document().wordCount())
+ dialog.exec_()
+
+//! [1]
+
+//! [2]
+ mb = QMessageBox("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]
+
+//! [3]
+ progress = QProgressDialog("Copying files...", "Abort Copy", 0, numFiles, self)
+ progress.setWindowModality(Qt.WindowModal)
+
+ for i in rang(numFiles):
+ progress.setValue(i)
+
+ if progress.wasCanceled():
+ break
+ #... copy one file
+
+ progress.setValue(numFiles)
+//! [3]
+
+//! [4]
+# Operation constructor
+def __init__(self, parent):
+ QObject.__init__(self, parent)
+
+ pd = QProgressDialog("Operation in progress.", "Cancel", 0, 100)
+ connect(pd, SIGNAL("canceled()"), self, SLOT("cancel()"))
+ t = QTimer(self)
+ connect(t, SIGNAL("timeout()"), self, SLOT("perform()"))
+ t.start(0)
+
+//! [4] //! [5]
+
+def perform(self):
+
+ pd.setValue(steps)
+ #... perform one percent of the operation
+ steps++
+ if steps > pd.maximum():
+ t.stop()
+
+//! [5] //! [6]
+
+def cancel(self):
+
+ t.stop()
+ #... cleanup
+
+//! [6]
+
+
diff --git a/doc/codesnippets/doc/src/snippets/dialogs/dialogs.pro b/doc/codesnippets/doc/src/snippets/dialogs/dialogs.pro
new file mode 100644
index 000000000..fd5d36328
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dialogs/dialogs.pro
@@ -0,0 +1 @@
+SOURCES += dialogs.cpp
diff --git a/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/modules.html b/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/modules.html
new file mode 100644
index 000000000..9c67393da
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/modules.html
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<!-- /home/dboddie/dev/qt-4.0/doc/src/classes.qdoc -->
+<head>
+ <title>Qt 4.0: Qt Classes by Module</title>
+ <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
+a:link { color: #004faf; text-decoration: none }
+a:visited { color: #672967; text-decoration: none }
+td.postheader { font-family: sans-serif }
+tr.address { font-family: sans-serif }
+body { background: #ffffff; color: black; }</style>
+ <link rel="next" href="qtcore.html" />
+ <link rel="start" href="index.html" />
+</head>
+<body>
+<h1 align="center">Qt Classes by Module</h1>
+<table align="center" cellpadding="2" cellspacing="1" border="0">
+<tr valign="top" bgcolor="#f0f0f0"><td>QtCore</td><td>Core classes used by other modules.</td></tr>
+<tr valign="top" bgcolor="#e0e0e0"><td>QtGui</td><td>Graphical User Interface components</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td>QtNetwork</td><td>Classes for network programming.</td></tr>
+<tr valign="top" bgcolor="#e0e0e0"><td>QtOpenGL</td><td>OpenGL support classes.</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td>QtSql</td><td>Classes for database integration using SQL.</td></tr>
+<tr valign="top" bgcolor="#e0e0e0"><td>QtXml</td><td>Classes for handling XML.</td></tr>
+</table>
+</body>
+</html>
diff --git a/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtcore.html b/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtcore.html
new file mode 100644
index 000000000..947ad4038
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtcore.html
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<!-- /home/dboddie/dev/qt-4.0/doc/src/classes.qdoc -->
+<head>
+ <title>Qt 4.0: QtCore Classes</title>
+ <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
+a:link { color: #004faf; text-decoration: none }
+a:visited { color: #672967; text-decoration: none }
+td.postheader { font-family: sans-serif }
+tr.address { font-family: sans-serif }
+body { background: #ffffff; color: black; }</style>
+ <link rel="prev" href="modules.html" />
+ <link rel="contents" href="modules.html" />
+ <link rel="next" href="qtgui.html" />
+</head>
+<body>
+<h1 align="center">QtCore Classes</h1>
+<p><table width="100%">
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAbstractEventDispatcher</b></td><td>Manages Qt's event queue, excluding GUI-related events</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAbstractItemModel</b></td><td>The abstract interface for item model classes</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAbstractListModel</b></td><td>Abstract model that can be subclassed to create one-dimensional list models</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAbstractTableModel</b></td><td>Abstract model that can be subclassed to create table models</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QBasicTimer</b></td><td>Timer events for </td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QBitArray</b></td><td>Array of bits</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QBuffer</b></td><td>QIODevice interface for a QByteArray</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QByteArray</b></td><td>Array of bytes</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QByteArrayMatcher</b></td><td>Holds a sequence of bytes that can be quickly matched in a byte array</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QCache</b></td><td>Template class that provides a cache</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QChar</b></td><td>16-bit Unicode character</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QChildEvent</b></td><td>Event parameters for child object events</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QCoreApplication</b></td><td>Event loop for Qt applications</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QCustomEvent</b></td><td>Support for custom events</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDataStream</b></td><td>Serialization of binary data to a QIODevice</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDate</b></td><td>Date functions</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDateTime</b></td><td>Date and time functions</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDir</b></td><td>Access to directory structures and their contents</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QEvent</b></td><td>The base class of all event classes. Event objects contain event parameters</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFile</b></td><td>Interface for reading from and writing to files</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFileEngine</b></td><td>Abstraction for accessing the filesystem</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFileEngineHandler</b></td><td>Allows custom QFileEngines to be plugged into Qt</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFileInfo</b></td><td>System-independent file information</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QHash</b></td><td>Template class that provides a hash-table-based dictionary</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QIODevice</b></td><td>The base interface class of all I/O devices in Qt</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLatin1Char</b></td><td>8-bit ASCII/Latin-1 character</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLatin1String</b></td><td>Thin wrapper around an ASCII/Latin-1 encoded string literal</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLibrary</b></td><td>Loads shared libraries at runtime</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLibraryInfo</b></td><td>Information about the Qt library</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLine</b></td><td>Two-dimensional vector that uses integer point coordinates for accuracy</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLineF</b></td><td>Two-dimensional vector that uses floating point coordinates for accuracy</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLinkedList</b></td><td>Template class that provides linked lists</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QList</b></td><td>Template class that provides lists</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLocale</b></td><td>Converts between numbers and their string representations in various languages</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMap</b></td><td>Template class that provides a skip-list-based dictionary</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMetaClassInfo</b></td><td>Additional information about a class</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMetaEnum</b></td><td>Meta data about an enumerator</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMetaMember</b></td><td>Meta data about a member function</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMetaObject</b></td><td>Meta information about Qt objects</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMetaProperty</b></td><td>Meta data about a property</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMetaType</b></td><td>Manages named types in the meta object system</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMimeData</b></td><td>Container for data that records information about its MIME type</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QModelIndex</b></td><td>Used to locate data in a data model</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMultiHash</b></td><td>Convenience QHash subclass that provides multi-valued hashes</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMultiMap</b></td><td>Convenience QMap subclass that provides multi-valued maps</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMutex</b></td><td>Access serialization between threads</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMutexLocker</b></td><td>Convenience class that simplifies locking and unlocking mutexes</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QObject</b></td><td>The base class of all Qt objects</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QObjectCleanupHandler</b></td><td>Watches the lifetime of multiple QObjects</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPair</b></td><td>Template class that stores a pair of items</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPersistentModelIndex</b></td><td>Used to locate data in a data model</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPluginLoader</b></td><td>Loads a plugin at runtime</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPoint</b></td><td>Defines a point in the plane</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPointF</b></td><td>Point object that uses floating point coordinates for accuracy</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPointer</b></td><td>Template class that provides guarded pointers to QObjects</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QProcess</b></td><td>Used to start external programs and to communicate with them</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QQueue</b></td><td>Generic container that provides a queue</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QReadLocker</b></td><td>Convenience class that simplifies locking and unlocking read-write locks for read access</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QReadWriteLock</b></td><td>Read-write locking</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QRect</b></td><td>Defines a rectangle in the plane</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QRectF</b></td><td>Defines a rectangle in the plane using floating point coordinates for accuracy</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QRegExp</b></td><td>Pattern matching using regular expressions</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QResource</b></td><td>Access to application resource data</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSemaphore</b></td><td>General counting semaphore</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSet</b></td><td>Template class that provides a hash-table-based set</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSettings</b></td><td>Persistent platform-independent application settings</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSharedData</b></td><td>Base class for shared data objects</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSharedDataPointer</b></td><td>Pointer to a shared data object</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSignal</b></td><td>Can be used to send signals for classes that do not inherit QObject</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSignalMapper</b></td><td>Bundles signals from identifiable senders</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSize</b></td><td>Defines the size of a two-dimensional object</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSizeF</b></td><td>Defines the size of a two-dimensional object using floating point values for accuracy</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSocketNotifier</b></td><td>Support for monitoring activity on a file descriptor</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStack</b></td><td>Template class that provides a stack</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QString</b></td><td>Unicode character string</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStringList</b></td><td>List of strings</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTemporaryFile</b></td><td>I/O device that operates on temporary files</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextCodec</b></td><td>Conversions between text encodings</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextCodecPlugin</b></td><td>Abstract base for custom QTextCodec plugins</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextDecoder</b></td><td>State-based decoder</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextEncoder</b></td><td>State-based encoder</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextIStream</b></td><td>Convenience class for input streams</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextOStream</b></td><td>Convenience class for output streams</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextStream</b></td><td>Convenient interface for reading and writing text</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QThread</b></td><td>Platform-independent threads</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QThreadStorage</b></td><td>Per-thread data storage</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTime</b></td><td>Clock time functions</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTimer</b></td><td>Repetitive and single-shot timers</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTimerEvent</b></td><td>Parameters that describe a timer event</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTranslator</b></td><td>Internationalization support for text output</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTranslatorMessage</b></td><td>Translator message and its properties</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTsciiCodec</b></td><td>Conversion to and from the Tamil TSCII encoding</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QUrl</b></td><td>Convenient interface for working with URLs</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QUuid</b></td><td>Defines a Universally Unique Identifier (UUID)</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QVarLengthArray</b></td><td>Low-level variable-length array</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QVariant</b></td><td>Acts like a union for the most common Qt data types</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QVector</b></td><td>Template class that provides a dynamic array</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWaitCondition</b></td><td>Condition variable for synchronizing threads</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWriteLocker</b></td><td>Convenience class that simplifies locking and unlocking read-write locks for write access</td></tr>
+</table></p>
+</body>
+</html>
diff --git a/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtgui.html b/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtgui.html
new file mode 100644
index 000000000..9182b4cb4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtgui.html
@@ -0,0 +1,276 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<!-- /home/dboddie/dev/qt-4.0/doc/src/classes.qdoc -->
+<head>
+ <title>Qt 4.0: QtGui Classes</title>
+ <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
+a:link { color: #004faf; text-decoration: none }
+a:visited { color: #672967; text-decoration: none }
+td.postheader { font-family: sans-serif }
+tr.address { font-family: sans-serif }
+body { background: #ffffff; color: black; }</style>
+ <link rel="prev" href="qtcore.html" />
+ <link rel="contents" href="modules.html" />
+ <link rel="next" href="qtnetwork.html" />
+</head>
+<body>
+<h1 align="center">QtGui Classes</h1>
+<p><table width="100%">
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAbstractButton</b></td><td>The abstract base class of button widgets, providing functionality common to buttons</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAbstractItemDelegate</b></td><td>Used to display and edit data items from a model</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAbstractItemView</b></td><td>The basic functionality for item view classes</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAbstractScrollArea</b></td><td>Scrolling area with on-demand scroll bars</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAbstractSlider</b></td><td>Integer value within a range</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAbstractSpinBox</b></td><td>Spinwidget and a line edit to display values</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAbstractTextDocumentLayout</b></td><td>Abstract base class used to implement custom layouts for QTextDocuments</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAccessible</b></td><td>Enums and static functions relating to accessibility</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAccessibleInterface</b></td><td>Defines an interface that exposes information about accessible objects</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAccessibleObject</b></td><td>Implements parts of the QAccessibleInterface for QObjects</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAccessiblePlugin</b></td><td>Abstract base for accessibility plugins</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAccessibleWidget</b></td><td>Implements the QAccessibleInterface for QWidgets</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAction</b></td><td>Abstract user interface action that can be inserted into widgets with QWidget::addAction()</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QActionGroup</b></td><td>Groups actions together</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QApplication</b></td><td>Manages the GUI application's control flow and main settings</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QBitmap</b></td><td>Monochrome (1-bit depth) pixmaps</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QBoxLayout</b></td><td>Lines up child widgets horizontally or vertically</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QBrush</b></td><td>Defines the fill pattern of shapes drawn by a QPainter</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QButtonGroup</b></td><td>Container to organize groups of button widgets</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QCDEStyle</b></td><td>CDE look and feel</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QCheckBox</b></td><td>Checkbox with a text label</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QClipboard</b></td><td>Access to the window system clipboard</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QCloseEvent</b></td><td>Parameters that describe a close event</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QColor</b></td><td>Colors based on RGB or HSV values</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QColorDialog</b></td><td>Dialog widget for specifying colors</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QColorGroup</b></td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QComboBox</b></td><td>Combined button and popup list</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QCommonStyle</b></td><td>Encapsulates the common Look and Feel of a GUI</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QConicalGradient</b></td><td>Used in combination with QBrush to specify a conical gradient brush</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QContextMenuEvent</b></td><td>Parameters that describe a context menu event</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QCopChannel</b></td><td>Communication capabilities between several clients</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QCursor</b></td><td>Mouse cursor with an arbitrary shape</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDateTimeEdit</b></td><td>Widget for editing dates and times</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDecoration</b></td><td>Allows the appearance of the Qtopia Core Window Manager to be customized</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDecorationFactory</b></td><td>Creates QDecoration objects</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDecorationPlugin</b></td><td>Abstract base for custom QDecoration plugins</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDesktopWidget</b></td><td>Access to screen information on multi-head systems</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDial</b></td><td>Rounded range control (like a speedometer or potentiometer)</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDialog</b></td><td>The base class of dialog windows</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDirModel</b></td><td>Data model for the local filesystem</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDirectPainter</b></td><td>Direct access to the video hardware</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDockWidget</b></td><td>Widget that can be docked inside a QMainWindow or floated as a top-level window on the desktop</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDoubleSpinBox</b></td><td>Spin box widget that takes doubles</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDoubleValidator</b></td><td>Range checking of floating-point numbers</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDrag</b></td><td>Support for MIME-based drag and drop data transfer</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDragEnterEvent</b></td><td>Event which is sent to a widget when a drag and drop action enters it</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDragLeaveEvent</b></td><td>Event that is sent to a widget when a drag and drop action leaves it</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDragMoveEvent</b></td><td>Event which is sent while a drag and drop action is in progress</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDropEvent</b></td><td>Event which is sent when a drag and drop action is completed</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QErrorMessage</b></td><td>Error message display dialog</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFileDialog</b></td><td>Dialog that allow users to select files or directories</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFileIconProvider</b></td><td>File icon for the QDirModel class</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFileOpenEvent</b></td><td>Event that will be sent when there is a request to open a file</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFocusEvent</b></td><td>Event parameters for widget focus events</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFocusFrame</b></td><td>Focus frame which can be outside of a widget's normal paintable area</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFont</b></td><td>Font used for drawing text</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFontDatabase</b></td><td>Information about the fonts available in the underlying window system</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFontDialog</b></td><td>Dialog widget for selecting a font</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFontInfo</b></td><td>General information about fonts</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFontMetrics</b></td><td>Font metrics information</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFontMetricsF</b></td><td>Font metrics information</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFrame</b></td><td>The base class of widgets that can have a frame</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QGfxDriverFactory</b></td><td>Creates QScreen objects for Qtopia Core</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QGfxDriverPlugin</b></td><td>Abstract base for Qtopia Core graphics driver plugins</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QGradient</b></td><td>Used in combination with QBrush to specify gradient fills</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QGridLayout</b></td><td>Lays out widgets in a grid</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QGridWidget</b></td><td>Simple geometry management of its children</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QGroupBox</b></td><td>Group box frame with a title</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QHBoxLayout</b></td><td>Lines up widgets horizontally</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QHBoxWidget</b></td><td>Horizontal geometry management for its child widgets</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QHeaderView</b></td><td>Header row or header column for item views</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QHideEvent</b></td><td>Event which is sent after a widget is hidden</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QHoverEvent</b></td><td>Parameters that describe a mouse event</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QIcon</b></td><td>Scalable icons in different modes and states</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QIconDragEvent</b></td><td>Indicates that a main icon drag has begun</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QIconEngine</b></td><td>Abstract base class for QIcon renderers</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QIconEnginePlugin</b></td><td>Abstract base for custom QIconEngine plugins</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QImage</b></td><td>Hardware-independent pixmap that allows direct access to the pixel data, and can be used as a paint device</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QImageIOHandler</b></td><td>Defines the common image I/O interface for all image formats in Qt</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QImageIOHandlerFactoryInterface</b></td><td>The factory interface for QImageIOPlugin</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QImageIOPlugin</b></td><td>Defines an interface for writing an image format plugin</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QImageReader</b></td><td>Format independent interface for reading images from files or other devices</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QImageWriter</b></td><td>Format independent interface for writing images to files or other devices</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QInputContext</b></td><td>Abstracts the input method dependent data and composing state</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QInputContextPlugin</b></td><td>Abstract base for custom QInputContext plugins</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QInputDialog</b></td><td>Simple convenience dialog to get a single value from the user</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QInputEvent</b></td><td>The base class for events that describe user input</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QInputMethodEvent</b></td><td>Parameters for input method events</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QIntValidator</b></td><td>Validator that ensures a string contains a valid integer within a specified range</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QItemDelegate</b></td><td>Display and editing facilities for data items from a model</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QItemSelection</b></td><td>Manages information about selected items in a model</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QItemSelectionModel</b></td><td>Keeps track of a view's selected items</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QItemSelectionRange</b></td><td>Manages information about a range of selected items in a model</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QKbdDriverFactory</b></td><td>Creates QWSKeyboardHandler objects for Qtopia Core</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QKbdDriverPlugin</b></td><td>Abstract base for Qtopia Core keyboard driver plugins</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QKeyEvent</b></td><td>Describes a key event</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QKeySequence</b></td><td>Encapsulates a key sequence as used by shortcuts</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLCDNumber</b></td><td>Displays a number with LCD-like digits</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLabel</b></td><td>Text or image display</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLayout</b></td><td>The base class of geometry managers</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLayoutItem</b></td><td>Abstract item that a QLayout manipulates</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLineEdit</b></td><td>One-line text editor</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLinearGradient</b></td><td>Used in combination with QBrush to specify a linear gradient brush</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QListView</b></td><td>Default model/view implementation of a list, and of an icon view</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QListWidget</b></td><td>Item-based list widget</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QListWidgetItem</b></td><td>Item for use with the QListWidget item view class</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMacMime</b></td><td>Maps open-standard MIME to Mac flavors</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMacStyle</b></td><td>Implements an Appearance Manager style</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMainWindow</b></td><td>Main application window</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMatrix</b></td><td>2D transformations of a coordinate system</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMenu</b></td><td>Menu widget for use in menu bars, context menus, and other popup menus</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMenuBar</b></td><td>Horizontal menu bar</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMenuItem</b></td><td>Represents an item in a menu</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMessageBox</b></td><td>Modal dialog with a short message, an icon, and some buttons</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMotifPlusStyle</b></td><td>More sophisticated Motif-ish look and feel</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMotifStyle</b></td><td>Motif look and feel</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMouseDriverFactory</b></td><td>Creates QWSMouseHandler objects for Qtopia Core</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMouseDriverPlugin</b></td><td>Abstract base for Qtopia Core mouse driver plugins</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMouseEvent</b></td><td>Parameters that describe a mouse event</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMoveEvent</b></td><td>Event parameters for move events</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMovie</b></td><td>Convenience class for playing movies with QImageReader</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPaintDevice</b></td><td>The base class of objects that can be painted</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPaintEngine</b></td><td>Abstract definition of how QPainter draws to a given device on a given platform</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPaintEvent</b></td><td>Event parameters for paint events</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPainter</b></td><td>Does low-level painting e.g. on widgets</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPainterPath</b></td><td>Container for painting operations, enabling graphical shapes to be constructed and reused</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPalette</b></td><td>Color groups for each widget state</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPen</b></td><td>Defines how a QPainter should draw lines and outlines of shapes</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPicture</b></td><td>Paint device that records and replays QPainter commands</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPictureFormatPlugin</b></td><td>Abstract base for custom picture format plugins</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPictureIO</b></td><td>Parameters for loading and saving pictures</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPixmap</b></td><td>Off-screen, pixel-based paint device</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPixmapCache</b></td><td>Application-wide cache for pixmaps</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPlatinumStyle</b></td><td>Mac/Platinum look and feel</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPolygon</b></td><td>Vector of points</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPolygonF</b></td><td>Vector of points</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPrintEngine</b></td><td>Defines an interface for how QPrinter interacts with a given printing subsystem</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPrinter</b></td><td>Paint device that paints on a printer</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QProgressBar</b></td><td>Horizontal progress bar</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QProgressDialog</b></td><td>Feedback on the progress of a slow operation</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QProxyModel</b></td><td>Support for filtering and sorting data that is passed between another model and a view</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPushButton</b></td><td>Command button</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QRadialGradient</b></td><td>Used in combination with QBrush to specify a radial gradient brush</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QRadioButton</b></td><td>Radio button with a text label</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QRegExpValidator</b></td><td>Used to check a string against a regular expression</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QRegion</b></td><td>Clip region for a painter</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QResizeEvent</b></td><td>Event parameters for resize events</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QRubberBand</b></td><td>Rectangle or line that can indicate a selection or a boundary</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSGIStyle</b></td><td>SGI/Irix look and feel</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QScreen</b></td><td>And its descendants manage the framebuffer and palette</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QScrollArea</b></td><td>Scrolling view onto another widget</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QScrollBar</b></td><td>Vertical or horizontal scroll bar</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSessionManager</b></td><td>Access to the session manager</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QShortcut</b></td><td>Used to create keyboard shortcuts</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QShowEvent</b></td><td>Event that is sent when a widget is shown</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSizeGrip</b></td><td>Corner-grip for resizing a top-level window</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSizePolicy</b></td><td>Layout attribute describing horizontal and vertical resizing policy</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSlider</b></td><td>Vertical or horizontal slider</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSound</b></td><td>Access to the platform audio facilities</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSpacerItem</b></td><td>Blank space in a layout</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSpinBox</b></td><td>Spin box widget</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSplashScreen</b></td><td>Splash screen that can be shown during application startup</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSplitter</b></td><td>Implements a splitter widget</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSplitterHandle</b></td><td>Handle functionality of the splitter</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStackedLayout</b></td><td>Stack of widgets where only one widget is visible at a time</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStackedWidget</b></td><td>Stack of widgets where only one widget is visible at a time</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStandardItemModel</b></td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStatusBar</b></td><td>Horizontal bar suitable for presenting status information</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyle</b></td><td>Abstract base class that encapsulates the look and feel of a GUI</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleFactory</b></td><td>Creates QStyle objects</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleHintReturn</b></td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOption</b></td><td>Stores the parameters used by QStyle functions</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionButton</b></td><td>Used to describe the parameters for drawing buttons</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionComboBox</b></td><td>Used to describe the parameter for drawing a combobox</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionComplex</b></td><td>Used to hold parameters that are common to all complex controls</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionDockWidget</b></td><td>Used to describe the parameters for drawing a dock window</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionFocusRect</b></td><td>Used to describe the parameters for drawing a focus rectangle with QStyle</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionFrame</b></td><td>Used to describe the parameters for drawing a frame</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionHeader</b></td><td>Used to describe the parameters for drawing a header</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionMenuItem</b></td><td>Used to describe the parameter necessary for drawing a menu item</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionProgressBar</b></td><td>Used to describe the parameters necessary for drawing a progress bar</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionQ3DockWindow</b></td><td>Used to describe the parameters for drawing various parts of a </td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionQ3ListView</b></td><td>Used to describe the parameters for drawing a Q3ListView</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionQ3ListViewItem</b></td><td>Used to describe an item drawn in a Q3ListView</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionSlider</b></td><td>Used to describe the parameters needed for drawing a slider</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionSpinBox</b></td><td>Used to describe the parameters necessary for drawing a spin box</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionTab</b></td><td>Used to describe the parameters for drawing a tab bar</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionTitleBar</b></td><td>Used to describe the parameters for drawing a title bar</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionToolBox</b></td><td>Used to describe the parameters needed for drawing a tool box</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionToolButton</b></td><td>Used to describe the parameters for drawing a tool button</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionViewItem</b></td><td>Used to describe the parameters used to draw an item in a view widget</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStylePainter</b></td><td>Convenience class for drawing QStyle elements inside a widget</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStylePlugin</b></td><td>Abstract base for custom QStyle plugins</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTabBar</b></td><td>Tab bar, e.g. for use in tabbed dialogs</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTabWidget</b></td><td>Stack of tabbed widgets</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTableView</b></td><td>Default model/view implementation of a table view</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTableWidget</b></td><td>Item-based table view with a default model</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTableWidgetItem</b></td><td>Item for use with the QTableWidget class</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTableWidgetSelectionRange</b></td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTabletEvent</b></td><td>Parameters that describe a Tablet event</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextBlock</b></td><td>Container for text fragments in a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextBlockFormat</b></td><td>Formatting information for blocks of text in a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextBlockGroup</b></td><td>Container for text blocks within a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextBrowser</b></td><td>Rich text browser with hypertext navigation</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextCharFormat</b></td><td>Formatting information for characters in a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextCursor</b></td><td>Offers an API to access and modify QTextDocuments</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextDocument</b></td><td>Holds formatted text that can be viewed and edited using a QTextEdit</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextDocumentFragment</b></td><td>Represents a piece of formatted text from a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextEdit</b></td><td>Widget that is used to edit and display both plain and rich text</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextFormat</b></td><td>Formatting information for a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextFragment</b></td><td>Holds a piece of text in a QTextDocument with a single QTextCharFormat</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextFrame</b></td><td>Represents a frame in a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextFrameFormat</b></td><td>Formatting information for frames in a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextImageFormat</b></td><td>Formatting information for images in a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextInlineObject</b></td><td>Represents an inline object in a QTextLayout</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextLayout</b></td><td>Used to lay out and paint a single paragraph of text</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextLength</b></td><td>Encapsulates the different types of length used in a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextLine</b></td><td>Represents a line of text inside a QTextLayout</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextList</b></td><td>Decorated list of items in a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextListFormat</b></td><td>Formatting information for lists in a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextObject</b></td><td>Base class for different kinds of objects that can group parts of a QTextDocument together</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextOption</b></td><td>Description of general rich text properties</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextTable</b></td><td>Represents a table in a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextTableCell</b></td><td>Represents the properties of a cell in a QTextTable</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextTableFormat</b></td><td>Formatting information for tables in a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QToolBar</b></td><td>Movable panel that contains a set of controls</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QToolBarChangeEvent</b></td><td>Event that is sent whenever a the toolbar button is clicked on Mac OS X</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QToolBox</b></td><td>Column of tabbed widget items</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QToolButton</b></td><td>Quick-access button to commands or options, usually used inside a QToolBar</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QToolTip</b></td><td>Tool tips (balloon help) for any widget</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTreeView</b></td><td>Default model/view implementation of a tree view</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTreeWidget</b></td><td>Tree view that uses a predefined tree model</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTreeWidgetItem</b></td><td>Item for use with the QTreeWidget convenience class</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QVBoxLayout</b></td><td>Lines up widgets vertically</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QVBoxWidget</b></td><td>Vertical geometry management of its child widgets</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QValidator</b></td><td>Validation of input text</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWSInputMethod</b></td><td>International input methods for Qtopia Core</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWSKeyboardHandler</b></td><td>Implements the keyboard driver for Qtopia Core</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWSMouseHandler</b></td><td>Mouse driver for Qtopia Core</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWSServer</b></td><td>Server-specific functionality in Qtopia Core</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWSWindow</b></td><td>Server-specific functionality in Qtopia Core</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWhatsThis</b></td><td>Simple description of any widget, i.e. answering the question &quot;What's this?&quot;</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWhatsThisAction</b></td><td>Ready-made action to invoke &quot;What's This&quot; context help</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWheelEvent</b></td><td>Parameters that describe a wheel event</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWidget</b></td><td>The base class of all user interface objects</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWidgetContainerPlugin</b></td><td>Abstract base for complex custom container QWidget plugins</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWidgetItem</b></td><td>Layout item that represents a widget</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWidgetPlugin</b></td><td>Abstract base for custom QWidget plugins</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWindowsMime</b></td><td>Maps open-standard MIME to Window Clipboard formats</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWindowsStyle</b></td><td>Microsoft Windows-like look and feel</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWindowsXPStyle</b></td><td>Microsoft WindowsXP-like look and feel</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWorkspace</b></td><td>Workspace window that be used in an MDI application</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QX11Info</b></td><td>Information about the X display configuration</td></tr>
+</table></p>
+</body>
+</html>
diff --git a/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtnetwork.html b/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtnetwork.html
new file mode 100644
index 000000000..01e1fa48b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtnetwork.html
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<!-- /home/dboddie/dev/qt-4.0/doc/src/classes.qdoc -->
+<head>
+ <title>Qt 4.0: QtNetwork Classes</title>
+ <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
+a:link { color: #004faf; text-decoration: none }
+a:visited { color: #672967; text-decoration: none }
+td.postheader { font-family: sans-serif }
+tr.address { font-family: sans-serif }
+body { background: #ffffff; color: black; }</style>
+ <link rel="prev" href="qtgui.html" />
+ <link rel="contents" href="modules.html" />
+ <link rel="next" href="qtopengl.html" />
+</head>
+<body>
+<h1 align="center">QtNetwork Classes</h1>
+<p><table width="100%">
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAbstractSocket</b></td><td>The base functionality common to all socket types</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFtp</b></td><td>Implementation of the FTP protocol</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QHostAddress</b></td><td>IP address</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QHostInfo</b></td><td>Static functions for host name lookups</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QHttp</b></td><td>Implementation of the HTTP protocol</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QHttpHeader</b></td><td>Header information for HTTP</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QHttpRequestHeader</b></td><td>Request header information for HTTP</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QHttpResponseHeader</b></td><td>Response header information for HTTP</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTcpServer</b></td><td>TCP-based server</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTcpSocket</b></td><td>TCP socket</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QUdpSocket</b></td><td>UDP socket</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QUrlInfo</b></td><td>Stores information about URLs</td></tr>
+</table></p>
+</body>
+</html>
diff --git a/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtopengl.html b/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtopengl.html
new file mode 100644
index 000000000..c42c4ae26
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtopengl.html
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<!-- /home/dboddie/dev/qt-4.0/doc/src/classes.qdoc -->
+<head>
+ <title>Qt 4.0: QtOpenGL Classes</title>
+ <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
+a:link { color: #004faf; text-decoration: none }
+a:visited { color: #672967; text-decoration: none }
+td.postheader { font-family: sans-serif }
+tr.address { font-family: sans-serif }
+body { background: #ffffff; color: black; }</style>
+ <link rel="prev" href="qtnetwork.html" />
+ <link rel="contents" href="modules.html" />
+ <link rel="next" href="qtsql.html" />
+</head>
+<body>
+<h1 align="center">QtOpenGL Classes</h1>
+<p><table width="100%">
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QGLColormap</b></td><td>Used for installing custom colormaps into QGLWidgets</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QGLContext</b></td><td>Encapsulates an OpenGL rendering context</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QGLFormat</b></td><td>The display format of an OpenGL rendering context</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QGLWidget</b></td><td>Widget for rendering OpenGL graphics</td></tr>
+</table></p>
+</body>
+</html>
diff --git a/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtsql.html b/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtsql.html
new file mode 100644
index 000000000..db44d6d36
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtsql.html
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<!-- /home/dboddie/dev/qt-4.0/doc/src/classes.qdoc -->
+<head>
+ <title>Qt 4.0: QtSql Classes</title>
+ <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
+a:link { color: #004faf; text-decoration: none }
+a:visited { color: #672967; text-decoration: none }
+td.postheader { font-family: sans-serif }
+tr.address { font-family: sans-serif }
+body { background: #ffffff; color: black; }</style>
+ <link rel="prev" href="qtopengl.html" />
+ <link rel="contents" href="modules.html" />
+ <link rel="next" href="qtxml.html" />
+</head>
+<body>
+<h1 align="center">QtSql Classes</h1>
+<p><table width="100%">
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlDatabase</b></td><td>Represents a connection to a database</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlDriver</b></td><td>Abstract base class for accessing specific SQL databases</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlDriverCreator</b></td><td>Template class that provides a SQL driver factory for a specific driver type</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlDriverCreatorBase</b></td><td>The base class for SQL driver factories</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlDriverPlugin</b></td><td>Abstract base for custom QSqlDriver plugins</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlError</b></td><td>SQL database error information</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlField</b></td><td>Manipulates the fields in SQL database tables and views</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlIndex</b></td><td>Functions to manipulate and describe database indexes</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlQuery</b></td><td>Means of executing and manipulating SQL statements</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlQueryModel</b></td><td>Read-only data model for SQL result sets</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlRecord</b></td><td>Encapsulates a database record</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlRelation</b></td><td>Stores information about an SQL foreign key</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlRelationalDelegate</b></td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlRelationalTableModel</b></td><td>Editable data model for a single database table, with foreign key support</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlResult</b></td><td>Abstract interface for accessing data from specific SQL databases</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlTableModel</b></td><td>Editable data model for a single database table</td></tr>
+</table></p>
+</body>
+</html>
diff --git a/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtxml.html b/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtxml.html
new file mode 100644
index 000000000..d10d54237
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtxml.html
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<!-- /home/dboddie/dev/qt-4.0/doc/src/classes.qdoc -->
+<head>
+ <title>Qt 4.0: QtXml Classes</title>
+ <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
+a:link { color: #004faf; text-decoration: none }
+a:visited { color: #672967; text-decoration: none }
+td.postheader { font-family: sans-serif }
+tr.address { font-family: sans-serif }
+body { background: #ffffff; color: black; }</style>
+ <link rel="prev" href="qtsql.html" />
+ <link rel="contents" href="modules.html" />
+</head>
+<body>
+<h1 align="center">QtXml Classes</h1>
+<p><table width="100%">
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomAttr</b></td><td>Represents one attribute of a QDomElement</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomCDATASection</b></td><td>Represents an XML CDATA section</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomCharacterData</b></td><td>Represents a generic string in the DOM</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomComment</b></td><td>Represents an XML comment</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomDocument</b></td><td>Represents an XML document</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomDocumentFragment</b></td><td>Tree of QDomNodes which is not usually a complete QDomDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomDocumentType</b></td><td>The representation of the DTD in the document tree</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomElement</b></td><td>Represents one element in the DOM tree</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomEntity</b></td><td>Represents an XML entity</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomEntityReference</b></td><td>Represents an XML entity reference</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomImplementation</b></td><td>Information about the features of the DOM implementation</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomNamedNodeMap</b></td><td>Collection of nodes that can be accessed by name</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomNode</b></td><td>The base class for all the nodes in a DOM tree</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomNodeList</b></td><td>List of QDomNode objects</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomNotation</b></td><td>Represents an XML notation</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomProcessingInstruction</b></td><td>Represents an XML processing instruction</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomText</b></td><td>Represents text data in the parsed XML document</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlAttributes</b></td><td>XML attributes</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlContentHandler</b></td><td>Interface to report the logical content of XML data</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlDTDHandler</b></td><td>Interface to report DTD content of XML data</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlDeclHandler</b></td><td>Interface to report declaration content of XML data</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlDefaultHandler</b></td><td>Default implementation of all the XML handler classes</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlEntityResolver</b></td><td>Interface to resolve external entities contained in XML data</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlErrorHandler</b></td><td>Interface to report errors in XML data</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlInputSource</b></td><td>The input data for the QXmlReader subclasses</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlLexicalHandler</b></td><td>Interface to report the lexical content of XML data</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlLocator</b></td><td>The XML handler classes with information about the parsing position within a file</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlNamespaceSupport</b></td><td>Helper class for XML readers which want to include namespace support</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlParseException</b></td><td>Used to report errors with the QXmlErrorHandler interface</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlReader</b></td><td>Interface for XML readers (i.e. parsers)</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlSimpleReader</b></td><td>Implementation of a simple XML parser</td></tr>
+</table></p>
+</body>
+</html>
diff --git a/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/titles.txt b/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/titles.txt
new file mode 100644
index 000000000..016825d87
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/titles.txt
@@ -0,0 +1,7 @@
+Qt Classes by Module :/Resources/modules.html
+QtCore :/Resources/qtcore.html
+QtGui :/Resources/qtgui.html
+QtNetwork :/Resources/qtnetwork.html
+QtOpenGL :/Resources/qtopengl.html
+QtSql :/Resources/qtsql.html
+QtXml :/Resources/qtxml.html
diff --git a/doc/codesnippets/doc/src/snippets/dockwidgets/dockwidgets.pro b/doc/codesnippets/doc/src/snippets/dockwidgets/dockwidgets.pro
new file mode 100644
index 000000000..11d80f3f4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dockwidgets/dockwidgets.pro
@@ -0,0 +1,4 @@
+HEADERS = mainwindow.h
+RESOURCES = dockwidgets.qrc
+SOURCES = main.cpp \
+ mainwindow.cpp
diff --git a/doc/codesnippets/doc/src/snippets/dockwidgets/dockwidgets.qrc b/doc/codesnippets/doc/src/snippets/dockwidgets/dockwidgets.qrc
new file mode 100644
index 000000000..8c462a517
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dockwidgets/dockwidgets.qrc
@@ -0,0 +1,12 @@
+<RCC>
+ <qresource>
+ <file>Resources/titles.txt</file>
+ <file>Resources/modules.html</file>
+ <file>Resources/qtcore.html</file>
+ <file>Resources/qtgui.html</file>
+ <file>Resources/qtnetwork.html</file>
+ <file>Resources/qtopengl.html</file>
+ <file>Resources/qtsql.html</file>
+ <file>Resources/qtxml.html</file>
+ </qresource>
+</RCC>
diff --git a/doc/codesnippets/doc/src/snippets/dockwidgets/main.cpp b/doc/codesnippets/doc/src/snippets/dockwidgets/main.cpp
new file mode 100644
index 000000000..cf11d555f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dockwidgets/main.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QMainWindow *window = new MainWindow;
+ window->show();
+ window->resize(640, 480);
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/dockwidgets/mainwindow.cpp b/doc/codesnippets/doc/src/snippets/dockwidgets/mainwindow.cpp
new file mode 100644
index 000000000..ffbf32783
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dockwidgets/mainwindow.cpp
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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/codesnippets/doc/src/snippets/dockwidgets/mainwindow.h b/doc/codesnippets/doc/src/snippets/dockwidgets/mainwindow.h
new file mode 100644
index 000000000..cf5904524
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dockwidgets/mainwindow.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+class QDockWidget;
+class QListWidget;
+class QListWidgetItem;
+class QTextBrowser;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+public:
+ MainWindow(QWidget *parent = 0);
+
+private slots:
+ void updateText(QListWidgetItem *item);
+
+private:
+ void setupContents();
+ void setupDockWindow();
+ void setupMenus();
+
+ QDockWidget *contentsWindow;
+ QListWidget *headingList;
+ QTextBrowser *textBrowser;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/draganddrop/draganddrop.pro b/doc/codesnippets/doc/src/snippets/draganddrop/draganddrop.pro
new file mode 100644
index 000000000..67bc32bd1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/draganddrop/draganddrop.pro
@@ -0,0 +1,5 @@
+HEADERS = dragwidget.h \
+ mainwindow.h
+SOURCES = dragwidget.cpp \
+ main.cpp \
+ mainwindow.cpp
diff --git a/doc/codesnippets/doc/src/snippets/draganddrop/dragwidget.cpp b/doc/codesnippets/doc/src/snippets/draganddrop/dragwidget.cpp
new file mode 100644
index 000000000..4f2e431f1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/draganddrop/dragwidget.cpp
@@ -0,0 +1,154 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "dragwidget.h"
+
+DragWidget::DragWidget(QWidget *parent)
+ : QFrame(parent)
+{
+ setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
+ dragDropLabel = new QLabel("", this);
+ dragDropLabel->setAlignment(Qt::AlignHCenter);
+
+ QHBoxLayout *layout = new QHBoxLayout(this);
+ layout->addStretch(0);
+ layout->addWidget(dragDropLabel);
+ layout->addStretch(0);
+
+ setAcceptDrops(true);
+}
+
+// Accept all actions, but deal with them separately later.
+//! [0]
+void DragWidget::dragEnterEvent(QDragEnterEvent *event)
+{
+ event->acceptProposedAction();
+}
+//! [0]
+
+//! [1]
+void DragWidget::dropEvent(QDropEvent *event)
+{
+ if (event->source() == this && event->possibleActions() & Qt::MoveAction)
+ return;
+//! [1]
+
+//! [2]
+ if (event->proposedAction() == Qt::MoveAction) {
+ event->acceptProposedAction();
+ // Process the data from the event.
+//! [2]
+ emit dragResult(tr("The data was moved here."));
+//! [3]
+ } else if (event->proposedAction() == Qt::CopyAction) {
+ event->acceptProposedAction();
+ // Process the data from the event.
+//! [3]
+ emit dragResult(tr("The data was copied here."));
+//! [4]
+ } else {
+ // Ignore the drop.
+ return;
+ }
+//! [4]
+ // End of quote
+
+ emit mimeTypes(event->mimeData()->formats());
+ setData(event->mimeData()->formats()[0],
+ event->mimeData()->data(event->mimeData()->formats()[0]));
+//! [5]
+}
+//! [5]
+
+//! [6]
+void DragWidget::mousePressEvent(QMouseEvent *event)
+{
+ if (event->button() == Qt::LeftButton)
+ dragStartPosition = event->pos();
+}
+//! [6]
+
+//! [7]
+void DragWidget::mouseMoveEvent(QMouseEvent *event)
+{
+ if (!(event->buttons() & Qt::LeftButton))
+ return;
+ if ((event->pos() - dragStartPosition).manhattanLength()
+ < QApplication::startDragDistance())
+ return;
+
+ QDrag *drag = new QDrag(this);
+ QMimeData *mimeData = new QMimeData;
+
+ mimeData->setData(mimeType, data);
+ drag->setMimeData(mimeData);
+
+ Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction);
+//! [7]
+
+ switch (dropAction) {
+ case Qt::CopyAction:
+ emit dragResult(tr("The text was copied."));
+ break;
+ case Qt::MoveAction:
+ emit dragResult(tr("The text was moved."));
+ break;
+ default:
+ emit dragResult(tr("Unknown action."));
+ break;
+ }
+//! [8]
+}
+//! [8]
+
+void DragWidget::setData(const QString &mimetype, const QByteArray &newData)
+{
+ mimeType = mimetype;
+ data = QByteArray(newData);
+
+ dragDropLabel->setText(tr("%1 bytes").arg(data.size()));
+
+ QStringList formats;
+ formats << mimetype;
+ emit mimeTypes(formats);
+}
diff --git a/doc/codesnippets/doc/src/snippets/draganddrop/dragwidget.h b/doc/codesnippets/doc/src/snippets/draganddrop/dragwidget.h
new file mode 100644
index 000000000..23d0acec4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/draganddrop/dragwidget.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DRAGWIDGET_H
+#define DRAGWIDGET_H
+
+#include <QByteArray>
+#include <QFrame>
+#include <QString>
+#include <QStringList>
+
+class QComboBox;
+class QFrame;
+class QLabel;
+class QTextBrowser;
+
+class DragWidget : public QFrame
+{
+ Q_OBJECT
+
+public:
+ DragWidget(QWidget *parent);
+ void setData(const QString &mimetype, const QByteArray &newData);
+
+signals:
+ void dragResult(const QString &actionText);
+ void mimeTypes(const QStringList &types);
+
+protected:
+ void dragEnterEvent(QDragEnterEvent *event);
+ void dropEvent(QDropEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+
+private:
+ QByteArray data;
+ QLabel *dragDropLabel;
+ QPoint dragStartPosition;
+ QString mimeType;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/draganddrop/main.cpp b/doc/codesnippets/doc/src/snippets/draganddrop/main.cpp
new file mode 100644
index 000000000..f5644d733
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/draganddrop/main.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window1 = new MainWindow;
+ MainWindow *window2 = new MainWindow;
+ window1->show();
+ window2->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/draganddrop/mainwindow.cpp b/doc/codesnippets/doc/src/snippets/draganddrop/mainwindow.cpp
new file mode 100644
index 000000000..34a731d6f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/draganddrop/mainwindow.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "dragwidget.h"
+#include "mainwindow.h"
+
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+{
+ QFrame *centralWidget = new QFrame(this);
+
+ QLabel *mimeTypeLabel = new QLabel(tr("MIME types:"), centralWidget);
+ mimeTypeCombo = new QComboBox(centralWidget);
+
+ QLabel *dataLabel = new QLabel(tr("Amount of data (bytes):"), centralWidget);
+ dragWidget = new DragWidget(centralWidget);
+
+ connect(dragWidget, SIGNAL(mimeTypes(const QStringList &)),
+ this, SLOT(setMimeTypes(const QStringList &)));
+ connect(dragWidget, SIGNAL(dragResult(const QString &)),
+ this, SLOT(setDragResult(const QString &)));
+
+ QVBoxLayout *mainLayout = new QVBoxLayout(centralWidget);
+ mainLayout->addWidget(mimeTypeLabel);
+ mainLayout->addWidget(mimeTypeCombo);
+ mainLayout->addSpacing(32);
+ mainLayout->addWidget(dataLabel);
+ mainLayout->addWidget(dragWidget);
+
+ statusBar();
+ dragWidget->setData(QString("text/plain"), QByteArray("Hello world"));
+ setCentralWidget(centralWidget);
+ setWindowTitle(tr("Drag and Drop"));
+}
+
+void MainWindow::setDragResult(const QString &actionText)
+{
+ statusBar()->showMessage(actionText);
+}
+
+void MainWindow::setMimeTypes(const QStringList &types)
+{
+ mimeTypeCombo->clear();
+ mimeTypeCombo->addItems(types);
+}
diff --git a/doc/codesnippets/doc/src/snippets/draganddrop/mainwindow.h b/doc/codesnippets/doc/src/snippets/draganddrop/mainwindow.h
new file mode 100644
index 000000000..f70dcc111
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/draganddrop/mainwindow.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+#include <QPixmap>
+#include <QPoint>
+
+class QComboBox;
+class QLabel;
+class QLineEdit;
+class QMouseEvent;
+class QTextEdit;
+class DragWidget;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow(QWidget *parent = 0);
+
+public slots:
+ void setDragResult(const QString &actionText);
+ void setMimeTypes(const QStringList &types);
+
+private:
+ QComboBox *mimeTypeCombo;
+ DragWidget *dragWidget;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/dragging/dragging.pro b/doc/codesnippets/doc/src/snippets/dragging/dragging.pro
new file mode 100644
index 000000000..bedfc76ab
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dragging/dragging.pro
@@ -0,0 +1,4 @@
+HEADERS = mainwindow.h
+RESOURCES = images.qrc
+SOURCES = main.cpp \
+ mainwindow.cpp
diff --git a/doc/codesnippets/doc/src/snippets/dragging/images.qrc b/doc/codesnippets/doc/src/snippets/dragging/images.qrc
new file mode 100644
index 000000000..30b8a2986
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dragging/images.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>images/file.png</file>
+</qresource>
+</RCC>
diff --git a/doc/codesnippets/doc/src/snippets/dragging/images/file.png b/doc/codesnippets/doc/src/snippets/dragging/images/file.png
new file mode 100644
index 000000000..9520080ed
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dragging/images/file.png
Binary files differ
diff --git a/doc/codesnippets/doc/src/snippets/dragging/main.cpp b/doc/codesnippets/doc/src/snippets/dragging/main.cpp
new file mode 100644
index 000000000..af1e7d5ac
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dragging/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/dragging/mainwindow.cpp b/doc/codesnippets/doc/src/snippets/dragging/mainwindow.cpp
new file mode 100644
index 000000000..0d9444c74
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dragging/mainwindow.cpp
@@ -0,0 +1,63 @@
+############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Nokia Corporation (qt-info@nokia.com)
+##
+## This file is part of the documentation of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at http://www.qtsoftware.com/contact.
+## $QT_END_LICENSE$
+##
+############################################################################
+
+
+//! [0]
+def mousePressEvent(self, event):
+ if event.button() == Qt.LeftButton
+ && iconLabel.geometry().contains(event.pos()):
+
+//! [1]
+ drag = QDrag(self)
+ mimeData = QMimeData()
+
+ mimeData.setText(commentEdit.toPlainText())
+ drag.setMimeData(mimeData)
+//! [1]
+ drag.setPixmap(iconPixmap)
+
+ dropAction = drag.exec_()
+//! [0]
+
+//! [2]
+
+
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/dragging/mainwindow.h b/doc/codesnippets/doc/src/snippets/dragging/mainwindow.h
new file mode 100644
index 000000000..3e7b4449d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dragging/mainwindow.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+#include <QPixmap>
+#include <QPoint>
+
+class QLabel;
+class QLineEdit;
+class QMouseEvent;
+class QTextEdit;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow(QWidget *parent = 0);
+
+protected:
+ void mousePressEvent(QMouseEvent *event);
+
+private:
+ QLabel *iconLabel;
+ QLineEdit *nameEdit;
+ QPixmap iconPixmap;
+ QPoint dragStartPosition;
+ QTextEdit *commentEdit;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/dropactions/dropactions.pro b/doc/codesnippets/doc/src/snippets/dropactions/dropactions.pro
new file mode 100644
index 000000000..6283406f2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dropactions/dropactions.pro
@@ -0,0 +1,3 @@
+HEADERS = window.h
+SOURCES = main.cpp \
+ window.cpp
diff --git a/doc/codesnippets/doc/src/snippets/dropactions/main.cpp b/doc/codesnippets/doc/src/snippets/dropactions/main.cpp
new file mode 100644
index 000000000..cb3e0e76c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dropactions/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "window.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Window *window = new Window;
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/dropactions/window.cpp b/doc/codesnippets/doc/src/snippets/dropactions/window.cpp
new file mode 100644
index 000000000..985114110
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dropactions/window.cpp
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "window.h"
+
+Window::Window(QWidget *parent)
+ : QWidget(parent)
+{
+ QLabel *textLabel = new QLabel(tr("Data:"), this);
+ textBrowser = new QTextBrowser(this);
+
+ QLabel *mimeTypeLabel = new QLabel(tr("MIME types:"), this);
+ mimeTypeCombo = new QComboBox(this);
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->addWidget(textLabel);
+ layout->addWidget(textBrowser);
+ layout->addWidget(mimeTypeLabel);
+ layout->addWidget(mimeTypeCombo);
+/*
+ ...
+ setAcceptDrops(true);
+*/
+ setAcceptDrops(true);
+ setWindowTitle(tr("Drop Actions"));
+}
+
+void Window::dragEnterEvent(QDragEnterEvent *event)
+{
+ if (event->mimeData()->hasFormat("text/plain"))
+ event->acceptProposedAction();
+}
+
+void Window::dropEvent(QDropEvent *event)
+{
+ QMenu actionMenu(this);
+ QAction *copyAction = 0;
+ QAction *moveAction = 0;
+ QAction *linkAction = 0;
+ QAction *ignoreAction = 0;
+ if (event->possibleActions() & Qt::CopyAction)
+ copyAction = actionMenu.addAction(tr("Copy"));
+ if (event->possibleActions() & Qt::MoveAction)
+ moveAction = actionMenu.addAction(tr("Move"));
+ if (event->possibleActions() & Qt::LinkAction)
+ linkAction = actionMenu.addAction(tr("Link"));
+ if (event->possibleActions() & Qt::IgnoreAction)
+ ignoreAction = actionMenu.addAction(tr("Ignore"));
+
+ QAction *result = actionMenu.exec(QCursor::pos());
+
+ if (copyAction && result == copyAction)
+ event->setDropAction(Qt::CopyAction);
+ else if (moveAction && result == moveAction)
+ event->setDropAction(Qt::MoveAction);
+ else if (linkAction && result == linkAction)
+ event->setDropAction(Qt::LinkAction);
+ else {
+ event->setDropAction(Qt::IgnoreAction);
+ return;
+ }
+
+ textBrowser->setPlainText(event->mimeData()->text());
+ mimeTypeCombo->clear();
+ mimeTypeCombo->addItems(event->mimeData()->formats());
+}
diff --git a/doc/codesnippets/doc/src/snippets/dropactions/window.h b/doc/codesnippets/doc/src/snippets/dropactions/window.h
new file mode 100644
index 000000000..6211baac1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dropactions/window.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QString>
+#include <QStringList>
+#include <QWidget>
+
+class QComboBox;
+class QFrame;
+class QTextBrowser;
+
+class Window : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Window(QWidget *parent = 0);
+
+protected:
+ void dragEnterEvent(QDragEnterEvent *event);
+ void dropEvent(QDropEvent *event);
+
+private:
+ QComboBox *mimeTypeCombo;
+ QFrame *dropFrame;
+ QTextBrowser *textBrowser;
+ QString oldText;
+ QStringList oldMimeTypes;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/droparea.cpp b/doc/codesnippets/doc/src/snippets/droparea.cpp
new file mode 100644
index 000000000..01512098f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/droparea.cpp
@@ -0,0 +1,136 @@
+/############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Nokia Corporation (qt-info@nokia.com)
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at http://www.qtsoftware.com/contact.
+## $QT_END_LICENSE$
+##
+############################################################################/
+
+from PySide.QtGui import *
+
+
+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]
+def paste(self):
+ clipboard = QApplication.clipboard()
+ mimeData = clipboard.mimeData()
+
+ if mimeData.hasImage():
+ setPixmap(mimeData.imageData())
+ elif mimeData.hasHtml():
+ setText(mimeData.html())
+ setTextFormat(Qt.RichText)
+ elif (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 (QByteArray imageFormat, imageFormats) {
+ if (format.mid(6) == QString(imageFormat)) {
+ pixmap.loadFromData(data, imageFormat)
+ break
+ }
+ }
+ return pixmap
+}
diff --git a/doc/codesnippets/doc/src/snippets/dropevents/dropevents.pro b/doc/codesnippets/doc/src/snippets/dropevents/dropevents.pro
new file mode 100644
index 000000000..6283406f2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dropevents/dropevents.pro
@@ -0,0 +1,3 @@
+HEADERS = window.h
+SOURCES = main.cpp \
+ window.cpp
diff --git a/doc/codesnippets/doc/src/snippets/dropevents/main.cpp b/doc/codesnippets/doc/src/snippets/dropevents/main.cpp
new file mode 100644
index 000000000..38f3840fc
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dropevents/main.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "window.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ Window *window = new Window;
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/dropevents/window.cpp b/doc/codesnippets/doc/src/snippets/dropevents/window.cpp
new file mode 100644
index 000000000..c98b0be59
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dropevents/window.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "window.h"
+
+//! [0]
+Window::Window(QWidget *parent)
+ : QWidget(parent)
+{
+//! [0]
+ QLabel *textLabel = new QLabel(tr("Data:"), this);
+ textBrowser = new QTextBrowser(this);
+
+ QLabel *mimeTypeLabel = new QLabel(tr("MIME types:"), this);
+ mimeTypeCombo = new QComboBox(this);
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->addWidget(textLabel);
+ layout->addWidget(textBrowser);
+ layout->addWidget(mimeTypeLabel);
+ layout->addWidget(mimeTypeCombo);
+
+//! [1]
+ setAcceptDrops(true);
+//! [1]
+ setWindowTitle(tr("Drop Events"));
+//! [2]
+}
+//! [2]
+
+//! [3]
+void Window::dragEnterEvent(QDragEnterEvent *event)
+{
+ if (event->mimeData()->hasFormat("text/plain"))
+ event->acceptProposedAction();
+}
+//! [3]
+
+//! [4]
+void Window::dropEvent(QDropEvent *event)
+{
+ textBrowser->setPlainText(event->mimeData()->text());
+ mimeTypeCombo->clear();
+ mimeTypeCombo->addItems(event->mimeData()->formats());
+
+ event->acceptProposedAction();
+}
+//! [4]
diff --git a/doc/codesnippets/doc/src/snippets/dropevents/window.h b/doc/codesnippets/doc/src/snippets/dropevents/window.h
new file mode 100644
index 000000000..6211baac1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/dropevents/window.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QString>
+#include <QStringList>
+#include <QWidget>
+
+class QComboBox;
+class QFrame;
+class QTextBrowser;
+
+class Window : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Window(QWidget *parent = 0);
+
+protected:
+ void dragEnterEvent(QDragEnterEvent *event);
+ void dropEvent(QDropEvent *event);
+
+private:
+ QComboBox *mimeTypeCombo;
+ QFrame *dropFrame;
+ QTextBrowser *textBrowser;
+ QString oldText;
+ QStringList oldMimeTypes;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/droprectangle/droprectangle.pro b/doc/codesnippets/doc/src/snippets/droprectangle/droprectangle.pro
new file mode 100644
index 000000000..6283406f2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/droprectangle/droprectangle.pro
@@ -0,0 +1,3 @@
+HEADERS = window.h
+SOURCES = main.cpp \
+ window.cpp
diff --git a/doc/codesnippets/doc/src/snippets/droprectangle/main.cpp b/doc/codesnippets/doc/src/snippets/droprectangle/main.cpp
new file mode 100644
index 000000000..cb3e0e76c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/droprectangle/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "window.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Window *window = new Window;
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/droprectangle/window.cpp b/doc/codesnippets/doc/src/snippets/droprectangle/window.cpp
new file mode 100644
index 000000000..c7152e3f9
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/droprectangle/window.cpp
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "window.h"
+
+Window::Window(QWidget *parent)
+ : QWidget(parent)
+{
+ QLabel *textLabel = new QLabel(tr("Data:"), this);
+ textBrowser = new QTextBrowser(this);
+
+ QLabel *mimeTypeLabel = new QLabel(tr("MIME types:"), this);
+ mimeTypeCombo = new QComboBox(this);
+
+ dropFrame = new QFrame(this);
+ dropFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
+ QLabel *dropLabel = new QLabel(tr("Drop items here"), dropFrame);
+ dropLabel->setAlignment(Qt::AlignHCenter);
+
+ QVBoxLayout *dropFrameLayout = new QVBoxLayout(dropFrame);
+ dropFrameLayout->addWidget(dropLabel);
+
+ QHBoxLayout *dropLayout = new QHBoxLayout;
+ dropLayout->addStretch(0);
+ dropLayout->addWidget(dropFrame);
+ dropLayout->addStretch(0);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout(this);
+ mainLayout->addWidget(textLabel);
+ mainLayout->addWidget(textBrowser);
+ mainLayout->addWidget(mimeTypeLabel);
+ mainLayout->addWidget(mimeTypeCombo);
+ mainLayout->addSpacing(32);
+ mainLayout->addLayout(dropLayout);
+
+ setAcceptDrops(true);
+ setWindowTitle(tr("Drop Rectangle"));
+}
+
+//! [0]
+void Window::dragMoveEvent(QDragMoveEvent *event)
+{
+ if (event->mimeData()->hasFormat("text/plain")
+ && event->answerRect().intersects(dropFrame->geometry()))
+
+ event->acceptProposedAction();
+}
+//! [0]
+
+void Window::dropEvent(QDropEvent *event)
+{
+ textBrowser->setPlainText(event->mimeData()->text());
+ mimeTypeCombo->clear();
+ mimeTypeCombo->addItems(event->mimeData()->formats());
+
+ event->acceptProposedAction();
+}
diff --git a/doc/codesnippets/doc/src/snippets/droprectangle/window.h b/doc/codesnippets/doc/src/snippets/droprectangle/window.h
new file mode 100644
index 000000000..f97fa5898
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/droprectangle/window.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QString>
+#include <QStringList>
+#include <QWidget>
+
+class QComboBox;
+class QFrame;
+class QTextBrowser;
+
+class Window : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Window(QWidget *parent = 0);
+
+protected:
+ void dragMoveEvent(QDragMoveEvent *event);
+ void dropEvent(QDropEvent *event);
+
+private:
+ QComboBox *mimeTypeCombo;
+ QFrame *dropFrame;
+ QTextBrowser *textBrowser;
+ QString oldText;
+ QStringList oldMimeTypes;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/eventfilters/eventfilters.pro b/doc/codesnippets/doc/src/snippets/eventfilters/eventfilters.pro
new file mode 100644
index 000000000..b569a336e
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/eventfilters/eventfilters.pro
@@ -0,0 +1,3 @@
+HEADERS = filterobject.h
+SOURCES = filterobject.cpp \
+ main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/eventfilters/filterobject.cpp b/doc/codesnippets/doc/src/snippets/eventfilters/filterobject.cpp
new file mode 100644
index 000000000..9cc9b6548
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/eventfilters/filterobject.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "filterobject.h"
+
+FilterObject::FilterObject(QObject *parent)
+ : QObject(parent), target(0)
+{
+}
+
+//! [0]
+bool FilterObject::eventFilter(QObject *object, QEvent *event)
+{
+ if (object == target && event->type() == QEvent::KeyPress) {
+ QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
+ if (keyEvent->key() == Qt::Key_Tab) {
+ // Special tab handling
+ return true;
+ } else
+ return false;
+ }
+ return false;
+}
+//! [0]
+
+void FilterObject::setFilteredObject(QObject *object)
+{
+ if (target)
+ target->removeEventFilter(this);
+
+ target = object;
+
+ if (target)
+ target->installEventFilter(this);
+}
diff --git a/doc/codesnippets/doc/src/snippets/eventfilters/filterobject.h b/doc/codesnippets/doc/src/snippets/eventfilters/filterobject.h
new file mode 100644
index 000000000..f8191baa5
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/eventfilters/filterobject.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef FILTEROBJECT_H
+#define FILTEROBJECT_H
+
+#include <QObject>
+
+class FilterObject : public QObject
+{
+ Q_OBJECT
+
+public:
+ FilterObject(QObject *parent = 0);
+ bool eventFilter(QObject *object, QEvent *event);
+ void setFilteredObject(QObject *object);
+
+private:
+ QObject *target;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/eventfilters/main.cpp b/doc/codesnippets/doc/src/snippets/eventfilters/main.cpp
new file mode 100644
index 000000000..374687aa6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/eventfilters/main.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QTextEdit>
+
+#include "filterobject.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QTextEdit editor;
+ FilterObject filter;
+ filter.setFilteredObject(&editor);
+ editor.show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/events/events.cpp b/doc/codesnippets/doc/src/snippets/events/events.cpp
new file mode 100644
index 000000000..c39180e6d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/events/events.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QCheckBox>
+#include <QMouseEvent>
+
+class MyCheckBox : public QCheckBox
+{
+public:
+ void mousePressEvent(QMouseEvent *event);
+};
+
+//! [0]
+void MyCheckBox::mousePressEvent(QMouseEvent *event)
+{
+ if (event->button() == Qt::LeftButton) {
+ // handle left mouse button here
+ } else {
+ // pass on other buttons to base class
+ QCheckBox::mousePressEvent(event);
+ }
+}
+//! [0]
+
+class MyWidget : public QWidget
+{
+public:
+ bool event(QEvent *event);
+};
+
+static const int MyCustomEventType = 1099;
+
+class MyCustomEvent : public QEvent
+{
+public:
+ MyCustomEvent() : QEvent((QEvent::Type)MyCustomEventType) {}
+};
+
+//! [1]
+bool MyWidget::event(QEvent *event)
+{
+ if (event->type() == QEvent::KeyPress) {
+ QKeyEvent *ke = static_cast<QKeyEvent *>(event);
+ if (ke->key() == Qt::Key_Tab) {
+ // special tab handling here
+ return true;
+ }
+ } else if (event->type() == MyCustomEventType) {
+ MyCustomEvent *myEvent = static_cast<MyCustomEvent *>(event);
+ // custom event handling here
+ return true;
+ }
+
+ return QWidget::event(event);
+}
+//! [1]
+
+int main()
+{
+}
diff --git a/doc/codesnippets/doc/src/snippets/events/events.pro b/doc/codesnippets/doc/src/snippets/events/events.pro
new file mode 100644
index 000000000..9c4087454
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/events/events.pro
@@ -0,0 +1 @@
+SOURCES += events.cpp
diff --git a/doc/codesnippets/doc/src/snippets/explicitlysharedemployee/employee.cpp b/doc/codesnippets/doc/src/snippets/explicitlysharedemployee/employee.cpp
new file mode 100644
index 000000000..8f69934e5
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/explicitlysharedemployee/employee.cpp
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "employee.h"
+
+//! [0]
+EmployeeData::EmployeeData()
+{
+ id = -1;
+ name = 0;
+}
+//! [0]
+
+//! [1]
+EmployeeData::EmployeeData(const EmployeeData &other)
+//! [1] //! [2]
+ : QSharedData(other)
+{
+ id = other.id;
+ if (other.name) {
+ name = new QString(*other.name);
+ } else {
+ name = 0;
+ }
+}
+//! [2]
+
+//! [3]
+EmployeeData::~EmployeeData()
+//! [3] //! [4]
+{
+ delete name;
+}
+//! [4]
+
+//! [5]
+Employee::Employee()
+//! [5] //! [6]
+{
+ d = new EmployeeData;
+}
+//! [6]
+
+//! [7]
+Employee::Employee(int id, const QString &name)
+//! [7] //! [8]
+{
+ d = new EmployeeData;
+ setId(id);
+ setName(name);
+}
+//! [8]
+
+//! [9]
+void Employee::setName(const QString &name)
+//! [9] //! [10]
+{
+ if (!d->name)
+ d->name = new QString;
+ *d->name = name;
+}
+//! [10]
+
+//! [11]
+QString Employee::name() const
+//! [11] //! [12]
+{
+ if (!d->name)
+ return QString();
+ return *d->name;
+}
+//! [12]
diff --git a/doc/codesnippets/doc/src/snippets/explicitlysharedemployee/employee.h b/doc/codesnippets/doc/src/snippets/explicitlysharedemployee/employee.h
new file mode 100644
index 000000000..d628a246f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/explicitlysharedemployee/employee.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef EMPLOYEE_H
+#define EMPLOYEE_H
+
+#include <QSharedData>
+#include <QString>
+
+class EmployeeData : public QSharedData
+{
+public:
+ EmployeeData();
+ EmployeeData(const EmployeeData &other);
+ ~EmployeeData();
+
+ int id;
+ QString *name;
+};
+
+class Employee
+{
+public:
+ Employee();
+ Employee(int id, const QString &name);
+
+ void setId(int id) { d->id = id; }
+ void setName(const QString &name);
+
+ int id() const { return d->id; }
+ QString name() const;
+
+private:
+ QExplicitlySharedDataPointer<EmployeeData> d;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/explicitlysharedemployee/explicitlysharedemployee.pro b/doc/codesnippets/doc/src/snippets/explicitlysharedemployee/explicitlysharedemployee.pro
new file mode 100644
index 000000000..536a77de5
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/explicitlysharedemployee/explicitlysharedemployee.pro
@@ -0,0 +1,3 @@
+HEADERS = employee.h
+SOURCES = employee.cpp \
+ main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/explicitlysharedemployee/main.cpp b/doc/codesnippets/doc/src/snippets/explicitlysharedemployee/main.cpp
new file mode 100644
index 000000000..89dd92b68
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/explicitlysharedemployee/main.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "employee.h"
+
+int main()
+{
+ {
+ Employee e1(10, "Albrecht Durer");
+ Employee e2 = e1;
+ e1.setName("Hans Holbein");
+ }
+}
diff --git a/doc/codesnippets/doc/src/snippets/file/file.cpp b/doc/codesnippets/doc/src/snippets/file/file.cpp
new file mode 100644
index 000000000..0fdffc1e8
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/file/file.cpp
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QFile>
+#include <QTextStream>
+
+static void process_line(const QByteArray &)
+{
+}
+
+static void process_line(const QString &)
+{
+}
+
+static void noStream_snippet()
+{
+//! [0]
+ file = QFile("in.txt")
+ if not file.open(QIODevice.ReadOnly | QIODevice.Text):
+ return
+
+ while not file.atEnd():
+ line = file.readLine() # A QByteArray
+ process_line(line)
+//! [0]
+}
+
+static void readTextStream_snippet()
+{
+//! [1]
+ file = QFile("in.txt")
+ if not file.open(QIODevice.ReadOnly | QIODevice.Text):
+ return
+
+ in = QTextStream(file)
+ while not in.atEnd():
+ line = in.readLine() # A QByteArray
+ process_line(line)
+//! [1]
+}
+
+static void writeTextStream_snippet()
+{
+//! [2]
+ file = QFile("out.txt")
+ if not file.open(QIODevice.WriteOnly | QIODevice.Text):
+ return
+
+ out = QTextStream(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]
+ file = QFile("/proc/modules")
+ if not file.open(QIODevice.ReadOnly | QIODevice.Text):
+ return
+
+ in = QTextStream(file)
+ line = in.readLine()
+ while not line.isNull():
+ process_line(line)
+ line = in.readLine()
+//! [3]
+}
+
+int main()
+{
+ lineByLine_snippet();
+ writeStream_snippet();
+}
diff --git a/doc/codesnippets/doc/src/snippets/file/file.pro b/doc/codesnippets/doc/src/snippets/file/file.pro
new file mode 100644
index 000000000..bda6a9467
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/file/file.pro
@@ -0,0 +1,14 @@
+######################################################################
+# Automatically generated by qmake (1.08a) Tue Jan 4 17:11:37 2005
+######################################################################
+
+TEMPLATE = app
+CONFIG -= moc
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+SOURCES += file.cpp
+CONFIG += qt warn_on debug create_prl link_prl
+OBJECTS_DIR=.obj/debug-shared
+MOC_DIR=.moc/debug-shared
diff --git a/doc/codesnippets/doc/src/snippets/filedialogurls.cpp b/doc/codesnippets/doc/src/snippets/filedialogurls.cpp
new file mode 100644
index 000000000..4b59590fc
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/filedialogurls.cpp
@@ -0,0 +1,22 @@
+
+#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/codesnippets/doc/src/snippets/fileinfo/fileinfo.pro b/doc/codesnippets/doc/src/snippets/fileinfo/fileinfo.pro
new file mode 100644
index 000000000..2705d1f9a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/fileinfo/fileinfo.pro
@@ -0,0 +1,11 @@
+######################################################################
+# Automatically generated by qmake (2.01a) Thu Apr 3 11:48:36 2008
+######################################################################
+
+TEMPLATE = app
+TARGET =
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+SOURCES += main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/fileinfo/main.cpp b/doc/codesnippets/doc/src/snippets/fileinfo/main.cpp
new file mode 100644
index 000000000..55e05ba5e
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/fileinfo/main.cpp
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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]
+ fileInfo1 = QFileInfo("~/examples/191697/.")
+ fileInfo2 = QFileInfo("~/examples/191697/..")
+ fileInfo3 = QFileInfo("~/examples/191697/main.cpp")
+//! [0]
+//! [1]
+ fileInfo4 = QFileInfo(".")
+ fileInfo5 = QFileInfo("..")
+ fileInfo6 = QFileInfo("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/codesnippets/doc/src/snippets/graphicssceneadditemsnippet.cpp b/doc/codesnippets/doc/src/snippets/graphicssceneadditemsnippet.cpp
new file mode 100644
index 000000000..77ef50239
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/graphicssceneadditemsnippet.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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/codesnippets/doc/src/snippets/i18n-non-qt-class/i18n-non-qt-class.pro b/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/i18n-non-qt-class.pro
new file mode 100644
index 000000000..9abd1e880
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/i18n-non-qt-class.pro
@@ -0,0 +1,7 @@
+HEADERS = myclass.h
+RESOURCES = resources.qrc
+SOURCES = main.cpp \
+ myclass.cpp
+TRANSLATIONS = translations/i18n-non-qt-class_en.ts \
+ translations/i18n-non-qt-class_fr.ts
+QT -= gui
diff --git a/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/main.cpp b/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/main.cpp
new file mode 100644
index 000000000..c2cb843de
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/main.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore>
+#include "myclass.h"
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication app(argc, argv);
+
+ QTranslator translator;
+ translator.load(":/translations/i18n-non-qt-class_" + QLocale::system().name());
+ app.installTranslator(&translator);
+
+ MyClass instance;
+ return 0;
+}
diff --git a/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/myclass.cpp b/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/myclass.cpp
new file mode 100644
index 000000000..2a057c733
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/myclass.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include "myclass.h"
+
+MyClass::MyClass()
+{
+ std::cout << tr("Hello Qt!\n").toLocal8Bit().constData();
+}
diff --git a/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/myclass.h b/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/myclass.h
new file mode 100644
index 000000000..e22faa88d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/myclass.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MYCLASS_H
+#define MYCLASS_H
+
+#include <QCoreApplication>
+
+//! [0]
+class MyClass
+{
+ Q_DECLARE_TR_FUNCTIONS(MyClass)
+
+public:
+ MyClass();
+//! [0]
+ /* ... */
+//! [1]
+};
+//! [1]
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/myclass.ts b/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/myclass.ts
new file mode 100644
index 000000000..9bd90f244
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/myclass.ts
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS><TS version="1.1">
+<context>
+ <name>MyClass</name>
+ <message>
+ <location filename="myclass.cpp" line="6"/>
+ <source>Hello Qt!
+</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/resources.qrc b/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/resources.qrc
new file mode 100644
index 000000000..903ac8578
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/resources.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>translations/i18n-non-qt-class_en.qm</file>
+ <file>translations/i18n-non-qt-class_fr.qm</file>
+</qresource>
+</RCC>
diff --git a/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/translations/i18n-non-qt-class_en.ts b/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/translations/i18n-non-qt-class_en.ts
new file mode 100644
index 000000000..54f188694
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/translations/i18n-non-qt-class_en.ts
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS><TS version="1.1">
+<context>
+ <name>MyClass</name>
+ <message>
+ <location filename="../myclass.cpp" line="6"/>
+ <source>Hello Qt!
+</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/translations/i18n-non-qt-class_fr.ts b/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/translations/i18n-non-qt-class_fr.ts
new file mode 100644
index 000000000..3f3cebc23
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/translations/i18n-non-qt-class_fr.ts
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS><TS version="1.1" language="fr">
+<context>
+ <name>MyClass</name>
+ <message>
+ <location filename="../myclass.cpp" line="6"/>
+ <source>Hello Qt!
+</source>
+ <translation>Bonjour Qt!
+</translation>
+ </message>
+</context>
+</TS>
diff --git a/doc/codesnippets/doc/src/snippets/image/image.cpp b/doc/codesnippets/doc/src/snippets/image/image.cpp
new file mode 100644
index 000000000..093251ce8
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/image/image.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+ image = QImage()
+ ba = QByteArray()
+ buffer(ba)
+ buffer.open(QIODevice.WriteOnly)
+ image.save(buffer, "PNG") # writes image into ba in PNG format
+//! [0]
+//! [1]
+ pixmap = QPixmap()
+ bytes = QByteArray()
+ buffer(bytes)
+ buffer.open(QIODevice.WriteOnly)
+ pixmap.save(buffer, "PNG") # writes pixmap into bytes in PNG format
+//! [1]
+//! [2]
+ alpha = QPixmap("image-with-alpha.png")
+ alphacopy = alpha
+ alphacopy.setMask(alphacopy.mask())
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/image/image.pro b/doc/codesnippets/doc/src/snippets/image/image.pro
new file mode 100644
index 000000000..0df436abe
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/image/image.pro
@@ -0,0 +1 @@
+SOURCES += image.cpp
diff --git a/doc/codesnippets/doc/src/snippets/image/supportedformat.cpp b/doc/codesnippets/doc/src/snippets/image/supportedformat.cpp
new file mode 100644
index 000000000..2fa26aec8
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/image/supportedformat.cpp
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+ writer = QImageWriter()
+ writer.setFormat("png")
+ if writer.supportsOption(QImageIOHandler.Description):
+ print "Png supports embedded text"
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/inherited-slot/button.cpp b/doc/codesnippets/doc/src/snippets/inherited-slot/button.cpp
new file mode 100644
index 000000000..1f96e0221
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/inherited-slot/button.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QDebug>
+#include "button.h"
+
+Button::Button(QWidget *parent)
+ : QPushButton(parent)
+{
+}
+
+void Button::animateClick()
+{
+ qDebug() << "Extra code goes here...";
+ QPushButton::animateClick();
+}
diff --git a/doc/codesnippets/doc/src/snippets/inherited-slot/button.h b/doc/codesnippets/doc/src/snippets/inherited-slot/button.h
new file mode 100644
index 000000000..4527765b5
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/inherited-slot/button.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QPushButton>
+
+//! [Button class with reimplemented slot]
+class Button : public QPushButton
+{
+ Q_OBJECT
+
+public:
+ Button(QWidget *parent = 0);
+
+public slots:
+ void animateClick();
+};
+//! [Button class with reimplemented slot]
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/inherited-slot/inherited-slot.pro b/doc/codesnippets/doc/src/snippets/inherited-slot/inherited-slot.pro
new file mode 100644
index 000000000..702e9cc9c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/inherited-slot/inherited-slot.pro
@@ -0,0 +1,3 @@
+HEADERS = button.h
+SOURCES = main.cpp \
+ button.cpp
diff --git a/doc/codesnippets/doc/src/snippets/inherited-slot/main.cpp b/doc/codesnippets/doc/src/snippets/inherited-slot/main.cpp
new file mode 100644
index 000000000..c1b80559a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/inherited-slot/main.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QDebug>
+#include <QHBoxLayout>
+#include <QLineEdit>
+#include <QMetaMethod>
+#include <QWidget>
+#include "button.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QWidget window;
+ QHBoxLayout *layout = new QHBoxLayout(&window);
+ QLineEdit *lineEdit = new QLineEdit;
+ Button *button = new Button;
+
+ QObject::connect(lineEdit, SIGNAL(returnPressed()), button, SLOT(animateClick()));
+
+ layout->addWidget(lineEdit);
+ layout->addWidget(button);
+ window.show();
+
+ for (int i = 0; i < button->metaObject()->methodCount(); ++i)
+ qDebug() << i << button->metaObject()->method(i).signature();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/itemselection/itemselection.pro b/doc/codesnippets/doc/src/snippets/itemselection/itemselection.pro
new file mode 100644
index 000000000..b1126bfe7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/itemselection/itemselection.pro
@@ -0,0 +1,3 @@
+HEADERS = model.h
+SOURCES = main.cpp \
+ model.cpp
diff --git a/doc/codesnippets/doc/src/snippets/itemselection/main.cpp b/doc/codesnippets/doc/src/snippets/itemselection/main.cpp
new file mode 100644
index 000000000..5f057a155
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/itemselection/main.cpp
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ main.cpp
+
+ A simple example that shows how selections can be used directly on a model.
+ It shows the result of some selections made using a table view.
+*/
+
+#include <QApplication>
+#include <QItemSelection>
+#include <QItemSelectionModel>
+#include <QTableView>
+
+#include "model.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+//! [0]
+ TableModel *model = new TableModel(8, 4, &app);
+
+ QTableView *table = new QTableView(0);
+ table->setModel(model);
+
+ QItemSelectionModel *selectionModel = table->selectionModel();
+//! [0] //! [1]
+ QModelIndex topLeft;
+ QModelIndex bottomRight;
+
+ topLeft = model->index(0, 0, QModelIndex());
+ bottomRight = model->index(5, 2, QModelIndex());
+//! [1]
+
+//! [2]
+ QItemSelection selection(topLeft, bottomRight);
+ selectionModel->select(selection, QItemSelectionModel::Select);
+//! [2]
+
+//! [3]
+ QItemSelection toggleSelection;
+
+ topLeft = model->index(2, 1, QModelIndex());
+ bottomRight = model->index(7, 3, QModelIndex());
+ toggleSelection.select(topLeft, bottomRight);
+
+ selectionModel->select(toggleSelection, QItemSelectionModel::Toggle);
+//! [3]
+
+//! [4]
+ QItemSelection columnSelection;
+
+ topLeft = model->index(0, 1, QModelIndex());
+ bottomRight = model->index(0, 2, QModelIndex());
+
+ columnSelection.select(topLeft, bottomRight);
+
+ selectionModel->select(columnSelection,
+ QItemSelectionModel::Select | QItemSelectionModel::Columns);
+
+ QItemSelection rowSelection;
+
+ topLeft = model->index(0, 0, QModelIndex());
+ bottomRight = model->index(1, 0, QModelIndex());
+
+ rowSelection.select(topLeft, bottomRight);
+
+ selectionModel->select(rowSelection,
+ QItemSelectionModel::Select | QItemSelectionModel::Rows);
+//! [4]
+
+ table->setWindowTitle("Selected items in a table model");
+ table->show();
+ table->resize(460, 280);
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/itemselection/model.cpp b/doc/codesnippets/doc/src/snippets/itemselection/model.cpp
new file mode 100644
index 000000000..e759c5aa8
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/itemselection/model.cpp
@@ -0,0 +1,239 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ model.cpp
+
+ Provides a table model for use in various examples.
+*/
+
+#include <QtGui>
+
+#include "model.h"
+
+/*!
+ Constructs a table model with at least one row and one column.
+*/
+
+TableModel::TableModel(int rows, int columns, QObject *parent)
+ : QAbstractTableModel(parent)
+{
+ QStringList newList;
+
+ for (int column = 0; column < qMax(1, columns); ++column) {
+ newList.append("");
+ }
+
+ for (int row = 0; row < qMax(1, rows); ++row) {
+ rowList.append(newList);
+ }
+}
+
+
+/*!
+ Returns the number of items in the row list as the number of rows
+ in the model.
+*/
+
+int TableModel::rowCount(const QModelIndex &/*parent*/) const
+{
+ return rowList.size();
+}
+
+/*!
+ Returns the number of items in the first list item as the number of
+ columns in the model. All rows should have the same number of columns.
+*/
+
+int TableModel::columnCount(const QModelIndex &/*parent*/) const
+{
+ return rowList[0].size();
+}
+
+/*!
+ Returns an appropriate value for the requested data.
+ If the view requests an invalid index, an invalid variant is returned.
+ Any valid index that corresponds to a string in the list causes that
+ string to be returned for the display role; otherwise an invalid variant
+ is returned.
+*/
+
+QVariant TableModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ if (role == Qt::DisplayRole)
+ return rowList[index.row()][index.column()];
+ else
+ return QVariant();
+}
+
+/*!
+ Returns the appropriate header string depending on the orientation of
+ the header and the section. If anything other than the display role is
+ requested, we return an invalid variant.
+*/
+
+QVariant TableModel::headerData(int section, Qt::Orientation orientation,
+ int role) const
+{
+ if (role != Qt::DisplayRole)
+ return QVariant();
+
+ if (orientation == Qt::Horizontal)
+ return QString("Column %1").arg(section);
+ else
+ return QString("Row %1").arg(section);
+}
+
+/*!
+ Returns an appropriate value for the item's flags. Valid items are
+ enabled, selectable, and editable.
+*/
+
+Qt::ItemFlags TableModel::flags(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return Qt::ItemIsEnabled;
+
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
+}
+
+/*!
+ Changes an item in the model, but only if the following conditions
+ are met:
+
+ * The index supplied is valid.
+ * The role associated with editing text is specified.
+
+ The dataChanged() signal is emitted if the item is changed.
+*/
+
+bool TableModel::setData(const QModelIndex &index,
+ const QVariant &value, int role)
+{
+ if (!index.isValid() || role != Qt::EditRole)
+ return false;
+
+ rowList[index.row()][index.column()] = value.toString();
+ emit dataChanged(index, index);
+ return true;
+}
+
+/*!
+ Inserts a number of rows into the model at the specified position.
+*/
+
+bool TableModel::insertRows(int position, int rows, const QModelIndex &parent)
+{
+ int columns = columnCount();
+ beginInsertRows(parent, position, position + rows - 1);
+
+ for (int row = 0; row < rows; ++row) {
+ QStringList items;
+ for (int column = 0; column < columns; ++column)
+ items.append("");
+ rowList.insert(position, items);
+ }
+
+ endInsertRows();
+ return true;
+}
+
+/*!
+ Inserts a number of columns into the model at the specified position.
+ Each entry in the list is extended in turn with the required number of
+ empty strings.
+*/
+
+bool TableModel::insertColumns(int position, int columns,
+ const QModelIndex &parent)
+{
+ int rows = rowCount();
+ beginInsertColumns(parent, position, position + columns - 1);
+
+ for (int row = 0; row < rows; ++row) {
+ for (int column = position; column < columns; ++column) {
+ rowList[row].insert(position, "");
+ }
+ }
+
+ endInsertColumns();
+ return true;
+}
+
+/*!
+ Removes a number of rows from the model at the specified position.
+*/
+
+bool TableModel::removeRows(int position, int rows, const QModelIndex &parent)
+{
+ beginRemoveRows(parent, position, position + rows - 1);
+
+ for (int row = 0; row < rows; ++row) {
+ rowList.removeAt(position);
+ }
+
+ endRemoveRows();
+ return true;
+}
+
+/*!
+ Removes a number of columns from the model at the specified position.
+ Each row is shortened by the number of columns specified.
+*/
+
+bool TableModel::removeColumns(int position, int columns,
+ const QModelIndex &parent)
+{
+ int rows = rowCount();
+ beginRemoveColumns(parent, position, position + columns - 1);
+
+ for (int row = 0; row < rows; ++row) {
+ for (int column = 0; column < columns; ++column) {
+ rowList[row].removeAt(position);
+ }
+ }
+
+ endRemoveColumns();
+ return true;
+}
diff --git a/doc/codesnippets/doc/src/snippets/itemselection/model.h b/doc/codesnippets/doc/src/snippets/itemselection/model.h
new file mode 100644
index 000000000..1bb4441ef
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/itemselection/model.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MODEL_H
+#define MODEL_H
+
+#include <QAbstractTableModel>
+#include <QStringList>
+#include <QVariant>
+
+class TableModel : public QAbstractTableModel
+{
+ Q_OBJECT
+
+public:
+ TableModel(int rows = 1, int columns = 1, QObject *parent = 0);
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = Qt::EditRole);
+
+ bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex());
+ bool insertColumns(int position, int columns, const QModelIndex &parent = QModelIndex());
+ bool removeRows(int position, int rows, const QModelIndex &parent = QModelIndex());
+ bool removeColumns(int position, int columns, const QModelIndex &parent = QModelIndex());
+
+private:
+ QList<QStringList> rowList;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/javastyle.cpp b/doc/codesnippets/doc/src/snippets/javastyle.cpp
new file mode 100644
index 000000000..e0b9ec691
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/javastyle.cpp
@@ -0,0 +1,2746 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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/codesnippets/doc/src/snippets/layouts/layouts.cpp b/doc/codesnippets/doc/src/snippets/layouts/layouts.cpp
new file mode 100644
index 000000000..8db1285e4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/layouts/layouts.cpp
@@ -0,0 +1,117 @@
+/############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Nokia Corporation (qt-info@nokia.com)
+##
+## This file is part of the documentation of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at http://www.qtsoftware.com/contact.
+## $QT_END_LICENSE$
+##
+############################################################################/
+
+//! [0]
+ window = QWidget()
+//! [0] //! [1]
+ button1 = QPushButton("One")
+//! [1] //! [2]
+ button2 = QPushButton("Two")
+ button3 = QPushButton("Three")
+ button4 = QPushButton("Four")
+ button5 = QPushButton("Five")
+//! [2]
+
+//! [3]
+ layout = QHBoxLayout()
+//! [3] //! [4]
+ layout.addWidget(button1)
+ layout.addWidget(button2)
+ layout.addWidget(button3)
+ layout.addWidget(button4)
+ layout.addWidget(button5)
+
+ window.setLayout(layout)
+//! [4] //! [5]
+ window.show()
+//! [5]
+
+//! [6]
+ window = QWidget()
+//! [6] //! [7]
+ button1 = QPushButton("One")
+//! [7] //! [8]
+ button2 = QPushButton("Two")
+ button3 = QPushButton("Three")
+ button4 = QPushButton("Four")
+ button5 = QPushButton("Five")
+//! [8]
+
+//! [9]
+ layout = QVBoxLayout()
+
+//! [9] //! [10]
+ layout.addWidget(button1)
+ layout.addWidget(button2)
+ layout.addWidget(button3)
+ layout.addWidget(button4)
+ layout.addWidget(button5)
+
+ window.setLayout(layout)
+//! [10] //! [11]
+ window.show()
+//! [11]
+
+//! [12]
+ window = QWidget()
+//! [12] //! [13]
+ button1 = QPushButton("One")
+//! [13] //! [14]
+ button2 = QPushButton("Two")
+ button3 = QPushButton("Three")
+ button4 = QPushButton("Four")
+ button5 = QPushButton("Five")
+//! [14]
+
+//! [15]
+ layout = 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] //! [17]
+ window.show()
+//! [17]
diff --git a/doc/codesnippets/doc/src/snippets/layouts/layouts.pro b/doc/codesnippets/doc/src/snippets/layouts/layouts.pro
new file mode 100644
index 000000000..79dd54cc3
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/layouts/layouts.pro
@@ -0,0 +1,12 @@
+######################################################################
+# Automatically generated by qmake (2.00a) Wed May 4 15:30:40 2005
+######################################################################
+
+TEMPLATE = app
+INCLUDEPATH += .
+
+# Input
+SOURCES += layouts.cpp
+CONFIG += qt warn_on debug create_prl link_prl
+OBJECTS_DIR=.obj/debug-shared
+MOC_DIR=.moc/debug-shared
diff --git a/doc/codesnippets/doc/src/snippets/mainwindowsnippet.cpp b/doc/codesnippets/doc/src/snippets/mainwindowsnippet.cpp
new file mode 100644
index 000000000..92a9a9b40
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/mainwindowsnippet.cpp
@@ -0,0 +1,49 @@
+/############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Nokia Corporation (qt-info@nokia.com)
+##
+## This file is part of the documentation of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at http://www.qtsoftware.com/contact.
+## $QT_END_LICENSE$
+##
+############################################################################/
+
+//! [0]
+ dockWidget = QDockWidget(tr("Dock Widget"), self)
+ dockWidget.setAllowedAreas(Qt.LeftDockWidgetArea |
+ Qt.RightDockWidgetArea)
+ dockWidget.setWidget(dockWidgetContents)
+ addDockWidget(Qt.LeftDockWidgetArea, dockWidget)
+//! [0]
+
diff --git a/doc/codesnippets/doc/src/snippets/matrix/matrix.cpp b/doc/codesnippets/doc/src/snippets/matrix/matrix.cpp
new file mode 100644
index 000000000..fe8b942af
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/matrix/matrix.cpp
@@ -0,0 +1,103 @@
+############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Nokia Corporation (qt-info@nokia.com)
+##
+## This file is part of the documentation of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at http://www.qtsoftware.com/contact.
+## $QT_END_LICENSE$
+##
+############################################################################
+
+//! [0]
+def paintEvent(self, event):
+ painter = QPainter(self)
+ 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]
+
+
+//! [1]
+def paintEvent(self, event)
+
+ painter = QPainter(self)
+ painter.setPen(QPen(Qt.blue, 1, Qt.DashLine))
+ painter.drawRect(0, 0, 100, 100)
+
+ matrix = QMatrix()
+ 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]
+
+
+//! [2]
+def paintEvent(self, event)
+
+ pi = 3.14
+
+ a = pi/180 * 45.0
+ sina = sin(a)
+ cosa = cos(a)
+
+ translationMatrix = QMatrix(1, 0, 0, 1, 50.0, 50.0)
+ rotationMatrix = QMatrix(cosa, sina, -sina, cosa, 0, 0)
+ scalingMatrix = QMatrix(0.5, 0, 0, 1.0, 0, 0)
+
+ matrix = QMatrix()
+ matrix = scalingMatrix * rotationMatrix * translationMatrix
+
+ painter = QPainter(self)
+ 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]
+
diff --git a/doc/codesnippets/doc/src/snippets/matrix/matrix.pro b/doc/codesnippets/doc/src/snippets/matrix/matrix.pro
new file mode 100644
index 000000000..91c307dc4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/matrix/matrix.pro
@@ -0,0 +1,11 @@
+######################################################################
+# Automatically generated by qmake (2.00a) Fri Jan 6 16:44:56 2006
+######################################################################
+
+TEMPLATE = app
+TARGET +=
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+SOURCES += matrix.cpp
diff --git a/doc/codesnippets/doc/src/snippets/mdiareasnippets.cpp b/doc/codesnippets/doc/src/snippets/mdiareasnippets.cpp
new file mode 100644
index 000000000..abdc1e92c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/mdiareasnippets.cpp
@@ -0,0 +1,57 @@
+/############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Nokia Corporation (qt-info@nokia.com)
+##
+## This file is part of the documentation of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at http://www.qtsoftware.com/contact.
+## $QT_END_LICENSE$
+##
+############################################################################/
+
+//! [0]
+ mainWindow = QMainWindow()
+ mainWindow.setCentralWidget(mdiArea)
+//! [0]
+
+//! [1]
+ mdiArea = QMdiArea()
+ subWindow1 = QMdiSubWindow()
+ subWindow1.setWidget(internalWidget1)
+ subWindow1.setAttribute(Qt.WA_DeleteOnClose)
+ mdiArea.addSubWindow(subWindow1)
+
+ subWindow2 = QMdiSubWindow()
+ mdiArea.addSubWindow(internalWidget2)
+//! [1]
+
diff --git a/doc/codesnippets/doc/src/snippets/medianodesnippet.cpp b/doc/codesnippets/doc/src/snippets/medianodesnippet.cpp
new file mode 100644
index 000000000..8b74111ed
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/medianodesnippet.cpp
@@ -0,0 +1,29 @@
+#include <QtGui>
+
+#include <phonon/mediaobject.h>
+#include <phonon/audiooutput.h>
+#include <phonon/videowidget.h>
+#include <phonon/medianode.h>
+#include <phonon/path.h>
+
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+
+//![0]
+ Phonon::MediaObject *mediaObject = new Phonon::MediaObject;
+ Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput;
+ Phonon::VideoWidget *videoWidget = new Phonon::VideoWidget;
+
+ Phonon::createPath(mediaObject, audioOutput);
+ Phonon::createPath(mediaObject, videoWidget);
+
+ QList<Phonon::Path> inputPaths =
+ audioOutput->inputPaths(); // inputPaths = [ mediaObject ]
+ QList<Phonon::Path> outputPaths =
+ mediaObject->outputPaths(); // outputPaths = [ audioOutput, videoWidget ]
+//![0]
+
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/moc/main.cpp b/doc/codesnippets/doc/src/snippets/moc/main.cpp
new file mode 100644
index 000000000..027e572a2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/moc/main.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "myclass1.h"
+
+MyClass::MyClass(QObject *) {}
+MyClass::~MyClass() {}
+void MyClass::mySlot() {}
+#undef MyClass
+
+#include "myclass2.h"
+
+MyClass::MyClass(QObject *) {}
+MyClass::~MyClass() {}
+void MyClass::setPriority(Priority) {}
+MyClass::Priority MyClass::priority() const { return High; }
+#undef MyClass
+
+#include "myclass3.h"
+
+MyClass::MyClass(QObject *) {}
+MyClass::~MyClass() {}
+#undef MyClass
+
+int main()
+{
+ return 0;
+}
diff --git a/doc/codesnippets/doc/src/snippets/moc/moc.pro b/doc/codesnippets/doc/src/snippets/moc/moc.pro
new file mode 100644
index 000000000..f199abe8a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/moc/moc.pro
@@ -0,0 +1,2 @@
+HEADERS += myclass1.h myclass2.h myclass3.h
+SOURCES += main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/moc/myclass1.h b/doc/codesnippets/doc/src/snippets/moc/myclass1.h
new file mode 100644
index 000000000..80103323d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/moc/myclass1.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MYCLASS1_H
+#define MYCLASS1_H
+
+#include <QObject>
+
+#define MyClass MyClass1
+
+//! [0]
+class MyClass : public QObject
+{
+ Q_OBJECT
+
+public:
+ MyClass(QObject *parent = 0);
+ ~MyClass();
+
+signals:
+ void mySignal();
+
+public slots:
+ void mySlot();
+};
+//! [0]
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/moc/myclass2.h b/doc/codesnippets/doc/src/snippets/moc/myclass2.h
new file mode 100644
index 000000000..0f08904c8
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/moc/myclass2.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MYCLASS2_H
+#define MYCLASS2_H
+
+#include <QObject>
+
+#define MyClass MyClass2
+
+//! [0]
+class MyClass : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(Priority priority READ priority WRITE setPriority)
+ Q_ENUMS(Priority)
+
+public:
+ enum Priority { High, Low, VeryHigh, VeryLow };
+
+ MyClass(QObject *parent = 0);
+ ~MyClass();
+
+ void setPriority(Priority priority);
+ Priority priority() const;
+};
+//! [0]
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/moc/myclass3.h b/doc/codesnippets/doc/src/snippets/moc/myclass3.h
new file mode 100644
index 000000000..928ffc3e1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/moc/myclass3.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MYCLASS3_H
+#define MYCLASS3_H
+
+#include <QObject>
+
+//! [0]
+class MyClass : public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO("Author", "Oscar Peterson")
+ Q_CLASSINFO("Status", "Active")
+
+public:
+ MyClass(QObject *parent = 0);
+ ~MyClass();
+};
+//! [0]
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/modelview-subclasses/main.cpp b/doc/codesnippets/doc/src/snippets/modelview-subclasses/main.cpp
new file mode 100644
index 000000000..5502a8625
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/modelview-subclasses/main.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ main.cpp
+
+ An example of a main window application that used a subclassed model
+ and view to display data from sound files.
+*/
+
+#include <QApplication>
+
+#include "model.h"
+#include "view.h"
+#include "window.h"
+
+/*!
+ The main function for the linear model example. This creates and
+ populates a model with long integers then displays the contents of the
+ model using a QListView widget.
+*/
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ MainWindow *window = new MainWindow;
+
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/modelview-subclasses/model.cpp b/doc/codesnippets/doc/src/snippets/modelview-subclasses/model.cpp
new file mode 100644
index 000000000..77bb17b0c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/modelview-subclasses/model.cpp
@@ -0,0 +1,153 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ model.cpp
+
+ A simple model that uses a QVector as its data source.
+*/
+
+#include "model.h"
+
+/*!
+ Returns the number of items in the string list as the number of rows
+ in the model.
+*/
+
+int LinearModel::rowCount(const QModelIndex &parent) const
+{
+ Q_USING(parent);
+
+ return values.count();
+}
+
+/*
+ Returns an appropriate value for the requested data.
+ If the view requests an invalid index, an invalid variant is returned.
+ If a header is requested then we just return the column or row number,
+ depending on the orientation of the header.
+ Any valid index that corresponds to a string in the list causes that
+ string to be returned.
+*/
+
+/*!
+ Returns a model index for other component to use when referencing the
+ item specified by the given row, column, and type. The parent index
+ is ignored.
+*/
+
+QModelIndex LinearModel::index(int row, int column, const QModelIndex &parent) const
+{
+ if (parent == QModelIndex() && row >= 0 && row < rowCount()
+ && column == 0)
+ return createIndex(row, column, 0);
+ else
+ return QModelIndex();
+}
+
+QVariant LinearModel::data(const QModelIndex &index, int role) const
+{
+ Q_UNUSED(role);
+
+ if (!index.isValid())
+ return QVariant();
+
+ return values.at(index.row());
+}
+
+/*!
+ Returns Qt::ItemIsEditable so that all items in the vector can be edited.
+*/
+
+Qt::ItemFlags LinearModel::flags(const QModelIndex &index) const
+{
+ // all items in the model are editable
+ return QAbstractListModel::flags(index) | Qt::ItemIsEditable;
+}
+
+/*!
+ Changes an item in the string list, but only if the following conditions
+ are met:
+
+ * The index supplied is valid.
+ * The index corresponds to an item to be shown in a view.
+ * The role associated with editing text is specified.
+
+ The dataChanged() signal is emitted if the item is changed.
+*/
+
+bool LinearModel::setData(const QModelIndex &index,
+ const QVariant &value, int role)
+{
+ if (!index.isValid() || role != Qt::EditRole)
+ return false;
+ values.replace(index.row(), value.toInt());
+ emit dataChanged(index, index);
+ return true;
+}
+
+/*!
+ Inserts a number of rows into the model at the specified position.
+*/
+
+bool LinearModel::insertRows(int position, int rows, const QModelIndex &parent)
+{
+ beginInsertRows(parent, position, position + rows - 1);
+
+ values.insert(position, rows, 0);
+
+ endInsertRows();
+ return true;
+}
+
+/*!
+ Removes a number of rows from the model at the specified position.
+*/
+
+bool LinearModel::removeRows(int position, int rows, const QModelIndex &parent)
+{
+ beginRemoveRows(QModelIndex(), position, position+rows-1);
+
+ values.remove(position, rows);
+
+ endRemoveRows();
+ return true;
+}
diff --git a/doc/codesnippets/doc/src/snippets/modelview-subclasses/model.h b/doc/codesnippets/doc/src/snippets/modelview-subclasses/model.h
new file mode 100644
index 000000000..329af23ec
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/modelview-subclasses/model.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MODEL_H
+#define MODEL_H
+
+#include <QAbstractListModel>
+#include <QObject>
+#include <qvector.h>
+
+class LinearModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ LinearModel(QObject *parent = 0)
+ : QAbstractListModel(parent) {}
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role) const;
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = Qt::EditRole);
+
+ bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex());
+ bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex());
+
+private:
+ QVector<int> values;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/modelview-subclasses/view.cpp b/doc/codesnippets/doc/src/snippets/modelview-subclasses/view.cpp
new file mode 100644
index 000000000..3792cd3b8
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/modelview-subclasses/view.cpp
@@ -0,0 +1,315 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ view.cpp
+
+ Provides a view to represent a one-dimensional sequence of integers
+ obtained from a list model as a series of rows.
+*/
+
+#include <QAbstractItemModel>
+#include <QBrush>
+#include <QItemSelection>
+#include <QPainter>
+#include <QPaintEvent>
+#include <QPen>
+#include <QPoint>
+#include <QResizeEvent>
+#include <QScrollBar>
+#include <QSizePolicy>
+
+#include "view.h"
+
+LinearView::LinearView(QWidget *parent)
+ : QAbstractItemView(parent)
+{
+ setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+}
+
+/*!
+ Returns the position of the item in viewport coordinates.
+*/
+
+QRect LinearView::itemViewportRect(const QModelIndex &index) const
+{
+ QRect rect = itemRect(index);
+ QRect result(rect.left() - horizontalScrollBar()->value(),
+ rect.top() - verticalScrollBar()->value(),
+ rect.width(), viewport()->height());
+
+ return result;
+}
+
+/*!
+ Returns the rectangle of the item at position \a index in the
+ model. The rectangle is in contents coordinates.
+*/
+
+QRect LinearView::itemRect(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return QRect();
+ else
+ return QRect(index.row(), 0, 1, 1);
+}
+
+
+void LinearView::ensureVisible(const QModelIndex &index)
+{
+ QRect area = viewport()->rect();
+ QRect rect = itemViewportRect(index);
+
+ if (rect.left() < area.left())
+ horizontalScrollBar()->setValue(
+ horizontalScrollBar()->value() - rect.left());
+ else if (rect.right() > area.right())
+ horizontalScrollBar()->setValue(
+ horizontalScrollBar()->value() + rect.left() - area.width());
+}
+
+/*!
+ Returns the item that covers the coordinate given in the view.
+*/
+
+QModelIndex LinearView::itemAt(int x, int /* y */) const
+{
+ int row = x + horizontalScrollBar()->value();
+
+ return model()->index(row, 0, QModelIndex());
+}
+
+//void LinearView::dataChanged(const QModelIndex &/* topLeft */,
+// const QModelIndex &/* bottomRight */)
+//{
+// updateGeometries();
+// if (isVisible())
+// repaint();
+//}
+
+void LinearView::rowsInserted(const QModelIndex &/* parent */, int /* start */,
+ int /* end */)
+{
+ updateGeometries();
+ if (isVisible())
+ repaint();
+}
+
+void LinearView::rowsRemoved(const QModelIndex &/* parent */, int /* start */,
+ int /* end */)
+{
+ updateGeometries();
+ if (isVisible())
+ repaint();
+}
+/*
+void LinearView::verticalScrollbarAction(int action)
+{
+}
+
+void LinearView::horizontalScrollbarAction(int action)
+{
+}
+*/
+
+/*!
+ Select the items in the model that lie within the rectangle specified by
+ \a rect, using the selection \a command.
+*/
+
+void LinearView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command)
+{
+ QModelIndex leftIndex = itemAt(rect.left(), 0);
+ QModelIndex rightIndex = itemAt(rect.right(), 0);
+
+ QItemSelection selection(leftIndex, rightIndex);
+
+ selectionModel()->select(selection, command);
+}
+
+QModelIndex LinearView::moveCursor(QAbstractItemView::CursorAction cursorAction,
+ Qt::KeyboardModifiers)
+{
+ QModelIndex current = currentIndex();
+
+ switch (cursorAction) {
+ case MoveLeft:{
+ if (current.row() > 0)
+ return model()->index(current.row() - 1, 0, QModelIndex());
+ else
+ return model()->index(0, 0, QModelIndex());
+ break;}
+ case MoveRight:{
+ if (current.row() < rows(current) - 1)
+ return model()->index(current.row() + 1, 0, QModelIndex());
+ else
+ return model()->index(rows(current) - 1, 0,QModelIndex());
+ break;}
+ case MoveUp:
+ return current;
+ case MoveDown:
+ return current;
+ case MovePageUp:
+ return current;
+ case MovePageDown:
+ return current;
+ case MoveHome:
+ return model()->index(0, 0, QModelIndex());
+ case MoveEnd:
+ return model()->index(rows(current) - 1, 0, QModelIndex());
+ default:
+ return current;
+ }
+}
+
+int LinearView::horizontalOffset() const
+{
+ return horizontalScrollBar()->value();
+}
+
+int LinearView::verticalOffset() const
+{
+ return verticalScrollBar()->value();
+}
+
+/*!
+ Returns a rectangle corresponding to the selection in viewport cooridinates.
+*/
+
+QRect LinearView::selectionViewportRect(const QItemSelection &selection) const
+{
+ int ranges = selection.count();
+
+ if (ranges == 0)
+ return QRect();
+
+ // Note that we use the top and bottom functions of the selection range
+ // since the data is stored in rows.
+
+ int firstRow = selection.at(0).top();
+ int lastRow = selection.at(0).top();
+
+ for (int i = 0; i < ranges; ++i) {
+ firstRow = qMin(firstRow, selection.at(i).top());
+ lastRow = qMax(lastRow, selection.at(i).bottom());
+ }
+
+ QModelIndex firstItem = model()->index(qMin(firstRow, lastRow), 0,
+ QModelIndex());
+ QModelIndex lastItem = model()->index(qMax(firstRow, lastRow), 0,
+ QModelIndex());
+
+ QRect firstRect = itemViewportRect(firstItem);
+ QRect lastRect = itemViewportRect(lastItem);
+
+ return QRect(firstRect.left(), firstRect.top(),
+ lastRect.right() - firstRect.left(), firstRect.height());
+}
+
+void LinearView::paintEvent(QPaintEvent *event)
+{
+ QPainter painter(viewport());
+
+ QRect updateRect = event->rect();
+ QBrush background(Qt::black);
+ QPen foreground(Qt::white);
+
+ painter.fillRect(updateRect, background);
+ painter.setPen(foreground);
+
+ QModelIndex firstItem = itemAt(updateRect.left(), updateRect.top());
+ if (!firstItem.isValid())
+ firstItem = model()->index(0, 0, QModelIndex());
+
+ QModelIndex lastItem = itemAt(updateRect.right(), updateRect.bottom());
+ if (!lastItem.isValid())
+ lastItem = model()->index(rows() - 1, 0, QModelIndex());
+
+ int x = updateRect.left();
+ //int top = updateRect.top();
+ //int bottom = updateRect.bottom();
+
+ int row = firstItem.row();
+ QModelIndex index = model()->index(row, 0, QModelIndex());
+ int value = model()->data(index, Qt::DisplayRole).toInt();
+ int midPoint = viewport()->height()/2;
+ int y2 = midPoint - int(value * midPoint/255.0);
+
+ while (row <= lastItem.row()) {
+
+ QModelIndex index = model()->index(row, 0, QModelIndex());
+ int value = model()->data(index, Qt::DisplayRole).toInt();
+
+ int y1 = y2;
+ y2 = midPoint - int(value * midPoint/255.0);
+
+ painter.drawLine(x-1, y1, x, y2);
+ ++row; ++x;
+ }
+}
+
+void LinearView::resizeEvent(QResizeEvent * /* event */)
+{
+ updateGeometries();
+}
+
+void LinearView::updateGeometries()
+{
+ if (viewport()->width() < rows()) {
+ horizontalScrollBar()->setPageStep(viewport()->width());
+ horizontalScrollBar()->setRange(0, rows() - viewport()->width() - 1);
+ }
+}
+
+QSize LinearView::sizeHint() const
+{
+ return QSize(rows(), 200);
+}
+
+int LinearView::rows(const QModelIndex &index) const
+{
+ return model()->rowCount(model()->parent(index));
+}
+
+bool LinearView::isIndexHidden(const QModelIndex &index) const
+{
+ return false;
+}
diff --git a/doc/codesnippets/doc/src/snippets/modelview-subclasses/view.h b/doc/codesnippets/doc/src/snippets/modelview-subclasses/view.h
new file mode 100644
index 000000000..38073d7b5
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/modelview-subclasses/view.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef VIEW_H
+#define VIEW_H
+
+#include <QAbstractItemView>
+#include <QItemSelection>
+#include <QItemSelectionModel>
+#include <QModelIndex>
+#include <QRect>
+#include <QSize>
+#include <QWidget>
+
+class LinearView : public QAbstractItemView
+{
+ Q_OBJECT
+public:
+ LinearView(QWidget *parent = 0);
+
+ QRect itemViewportRect(const QModelIndex &index) const;
+ void ensureVisible(const QModelIndex &index);
+ QModelIndex itemAt(int x, int y) const;
+
+protected slots:
+ /*void dataChanged(const QModelIndex &topLeft, const QModelIndex
+ &bottomRight);*/
+ void rowsInserted(const QModelIndex &parent, int start, int end);
+ void rowsRemoved(const QModelIndex &parent, int start, int end);
+ /*void selectionChanged(const QItemSelection &deselected, const QItemSelection &selected);
+ void verticalScrollbarAction(int action);
+ void horizontalScrollbarAction(int action);*/
+
+protected:
+ void setSelection(const QRect&, QItemSelectionModel::SelectionFlags command);
+ QRect selectionViewportRect(const QItemSelection &selection) const;
+ QRect itemRect(const QModelIndex &item) const;
+ bool isIndexHidden(const QModelIndex &index) const;
+ int horizontalOffset() const;
+ int verticalOffset() const;
+ QModelIndex moveCursor(QAbstractItemView::CursorAction cursorAction,
+ Qt::KeyboardModifiers modifiers);
+
+ void paintEvent(QPaintEvent *event);
+ void resizeEvent(QResizeEvent *event);
+ QSize sizeHint() const;
+
+private:
+ int rows(const QModelIndex &index = QModelIndex()) const;
+ void updateGeometries();
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/modelview-subclasses/window.cpp b/doc/codesnippets/doc/src/snippets/modelview-subclasses/window.cpp
new file mode 100644
index 000000000..9af4ec7a3
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/modelview-subclasses/window.cpp
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QAction>
+#include <QDataStream>
+#include <QMenu>
+#include <QMenuBar>
+#include <QFile>
+#include <QFileDialog>
+#include <QListView>
+
+#include "window.h"
+
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+{
+ setWindowTitle("Model/View example");
+
+ setupModelView();
+
+ QAction *openAction = new QAction(tr("&Open"), this);
+ QAction *quitAction = new QAction(tr("E&xit"), this);
+ QMenu *fileMenu = new QMenu(tr("&File"), this);
+ fileMenu->addAction(openAction);
+ fileMenu->addAction(quitAction);
+ menuBar()->addMenu(fileMenu);
+
+ connect(openAction, SIGNAL(triggered()), this, SLOT(selectOpenFile()));
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+
+ setCentralWidget(view);
+}
+
+void MainWindow::setupModelView()
+{
+ model = new LinearModel(this);
+ view = new LinearView(this);
+ view->setModel(model);
+}
+
+void MainWindow::selectOpenFile()
+{
+ QString fileName = QFileDialog::getOpenFileName(this,
+ tr("Select a file to open"), "", tr("Sound files (*.wav)"));
+
+ if (!fileName.isEmpty())
+ openFile(fileName);
+}
+
+void MainWindow::openFile(const QString &fileName)
+{
+ QFile file(fileName);
+ int length = file.size();
+
+ if (file.open(QFile::ReadOnly)) {
+ model->removeRows(0, model->rowCount());
+
+ int rows = (length - 0x2c)/2;
+ model->insertRows(0, rows);
+
+ // Perform some dodgy tricks to extract the data from the file.
+ QDataStream stream(&file);
+ stream.setByteOrder(QDataStream::LittleEndian);
+
+ Q_INT16 left;
+ Q_INT16 right;
+
+ for (int row = 0; row < rows; ++row) {
+ QModelIndex index = model->index(row);
+
+ stream >> left >> right;
+ model->setData(index, int(left / 256));
+ }
+ }
+}
diff --git a/doc/codesnippets/doc/src/snippets/modelview-subclasses/window.h b/doc/codesnippets/doc/src/snippets/modelview-subclasses/window.h
new file mode 100644
index 000000000..7c7e3da1c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/modelview-subclasses/window.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+#include <QString>
+#include <QWidget>
+
+#include "model.h"
+#include "view.h"
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+public:
+ MainWindow::MainWindow(QWidget *parent = 0);
+
+public slots:
+ void selectOpenFile();
+
+private:
+ void setupModelView();
+ void openFile(const QString &fileName);
+
+ LinearModel *model;
+ LinearView *view;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/myscrollarea.cpp b/doc/codesnippets/doc/src/snippets/myscrollarea.cpp
new file mode 100644
index 000000000..0f3b17cea
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/myscrollarea.cpp
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+from PySide.QtCore import *
+from PySide.QtGui import *
+import sys
+
+class MyScrollArea (QAbstractScrollArea):
+ widget = None
+
+ def __init__(widget):
+ self.setWidget(widget);
+
+ def setWidget(w):
+ self.widget = w;
+ self.widget.setParent(viewport());
+ if not self.widget.testAttribute(Qt.WA_Resized):
+ self.widget.resize(widget.sizeHint())
+
+ self.verticalScrollBar().setValue(0)
+ self.verticalScrollBar().setValue(0)
+
+ self.updateArea()
+
+
+ def updateWidgetPosition():
+//! [0]
+ hvalue = self.horizontalScrollBar().value()
+ vvalue = self.verticalScrollBar().value()
+ topLeft = self.viewport().rect().topLeft()
+
+ self.widget.move(topLeft.x() - hvalue, topLeft.y() - vvalue)
+//! [0]
+
+
+ def scrollContentsBy(dx, dy):
+ self.updateWidgetPosition()
+
+ def updateArea():
+//! [1]
+ areaSize = viewport().size()
+ widgetSize = widget.size()
+
+ self.verticalScrollBar().setPageStep(widgetSize.height())
+ self.horizontalScrollBar().setPageStep(widgetSize.width())
+ self.verticalScrollBar().setRange(0, widgetSize.height() - areaSize.height())
+ self.horizontalScrollBar().setRange(0, widgetSize.width() - areaSize.width())
+ self.updateWidgetPosition()
+//! [1]
+
+ def resizeEvent(QResizeEvent):
+ self.updateArea()
+
+app = QApplication(sys.argv)
+pixmap = QPixmap("mypixmap.png")
+label = QLabel()
+label.setPixmap(pixmap)
+area = MyScrollArea(label)
+area.resize(300, 300)
+area.show()
+
+area.setWidget(label)
+
+app.exec_();
+
diff --git a/doc/codesnippets/doc/src/snippets/network/tcpwait.cpp b/doc/codesnippets/doc/src/snippets/network/tcpwait.cpp
new file mode 100644
index 000000000..7ebdc692d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/network/tcpwait.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+from PySide.QtGui import *
+from PySide.QtNetwork import QTcpSocket
+
+def main():
+ app = QCoreApplication()
+
+ socket = QTcpSocket()
+ socket.connectToHost("localhost", 1025)
+
+//! [0]
+ numRead = 0
+ numReadTotal = 0
+ buffer = ""
+
+ while(True):
+ 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/codesnippets/doc/src/snippets/ntfsp.cpp b/doc/codesnippets/doc/src/snippets/ntfsp.cpp
new file mode 100644
index 000000000..710674466
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/ntfsp.cpp
@@ -0,0 +1,11 @@
+
+
+//! [0]
+extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
+//! [0]
+
+//! [1]
+qt_ntfs_permission_lookup += 1 // turn checking on
+qt_ntfs_permission_lookup += 1 // turn it off again
+//! [1]
+
diff --git a/doc/codesnippets/doc/src/snippets/painterpath/painterpath.cpp b/doc/codesnippets/doc/src/snippets/painterpath/painterpath.cpp
new file mode 100644
index 000000000..9f5e41b2f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/painterpath/painterpath.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ QImage image(100, 100, QImage::Format_RGB32);
+
+ 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(&image);
+ painter.fillRect(0, 0, 100, 100, Qt::white);
+
+ painter.save();
+ painter.translate(0.5, 0.5);
+ painter.setPen(QPen(QColor(79, 106, 25), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
+ painter.setBrush(QColor(122, 163, 39));
+ painter.setRenderHint(QPainter::Antialiasing);
+
+ painter.drawPath(path);
+
+ painter.restore();
+ painter.end();
+
+ QLabel lab;
+ lab.setPixmap(QPixmap::fromImage(image));
+ lab.show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/painterpath/painterpath.pro b/doc/codesnippets/doc/src/snippets/painterpath/painterpath.pro
new file mode 100644
index 000000000..0a6ad4643
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/painterpath/painterpath.pro
@@ -0,0 +1 @@
+SOURCES += painterpath.cpp
diff --git a/doc/codesnippets/doc/src/snippets/patternist/anyHTMLElement.xq b/doc/codesnippets/doc/src/snippets/patternist/anyHTMLElement.xq
new file mode 100644
index 000000000..9f5ee1275
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/anyHTMLElement.xq
@@ -0,0 +1 @@
+doc('data.xml')/*:body
diff --git a/doc/codesnippets/doc/src/snippets/patternist/anyXLinkAttribute.xq b/doc/codesnippets/doc/src/snippets/patternist/anyXLinkAttribute.xq
new file mode 100644
index 000000000..059bcc081
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/anyXLinkAttribute.xq
@@ -0,0 +1,2 @@
+declare namespace xlink = "http://www.w3.org/1999/xlink";
+doc('image.svg')//@xlink:*
diff --git a/doc/codesnippets/doc/src/snippets/patternist/bracesIncluded.xq b/doc/codesnippets/doc/src/snippets/patternist/bracesIncluded.xq
new file mode 100644
index 000000000..3961c2838
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/bracesIncluded.xq
@@ -0,0 +1 @@
+<e>{sum((1, 2, 3))}</e>
diff --git a/doc/codesnippets/doc/src/snippets/patternist/bracesIncludedResult.xml b/doc/codesnippets/doc/src/snippets/patternist/bracesIncludedResult.xml
new file mode 100644
index 000000000..0004c7126
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/bracesIncludedResult.xml
@@ -0,0 +1 @@
+<e>6</e>
diff --git a/doc/codesnippets/doc/src/snippets/patternist/bracesOmitted.xq b/doc/codesnippets/doc/src/snippets/patternist/bracesOmitted.xq
new file mode 100644
index 000000000..ffbadd077
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/bracesOmitted.xq
@@ -0,0 +1 @@
+<e>sum({(1, 2, 3)})</e>
diff --git a/doc/codesnippets/doc/src/snippets/patternist/bracesOmittedResult.xml b/doc/codesnippets/doc/src/snippets/patternist/bracesOmittedResult.xml
new file mode 100644
index 000000000..744fb8fe6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/bracesOmittedResult.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<e>sum(1 2 3)</e> \ No newline at end of file
diff --git a/doc/codesnippets/doc/src/snippets/patternist/computedTreeFragment.xq b/doc/codesnippets/doc/src/snippets/patternist/computedTreeFragment.xq
new file mode 100644
index 000000000..c5b93ada6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/computedTreeFragment.xq
@@ -0,0 +1,14 @@
+declare default element namespace "http://example.com/Namespace";
+declare variable $documentElementName := "doc";
+
+element {$documentElementName}
+{
+ attribute xml:base {"http://example.com/"},
+ element anotherElement
+ {
+ comment {" a comment "},
+ processing-instruction target {"data"},
+ element anotherElement {()},
+ text {"some text"}
+ }
+}
diff --git a/doc/codesnippets/doc/src/snippets/patternist/copyAttribute.xq b/doc/codesnippets/doc/src/snippets/patternist/copyAttribute.xq
new file mode 100644
index 000000000..40e44942c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/copyAttribute.xq
@@ -0,0 +1,9 @@
+<html>
+ <body>
+ <p>
+ {
+ doc('feed.rss')/rss/@version
+ }
+ </p>
+ </body>
+</html>
diff --git a/doc/codesnippets/doc/src/snippets/patternist/copyID.xq b/doc/codesnippets/doc/src/snippets/patternist/copyID.xq
new file mode 100644
index 000000000..2409cafe6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/copyID.xq
@@ -0,0 +1,3 @@
+(: Copy the value of xml:id attribute from other.html. This is a comment by the way! :)
+<html xmlns="http://www.w3.org/1999/xhtml/"
+ xml:id="{doc("other.html")/html/@xml:id}"/>
diff --git a/doc/codesnippets/doc/src/snippets/patternist/directTreeFragment.xq b/doc/codesnippets/doc/src/snippets/patternist/directTreeFragment.xq
new file mode 100644
index 000000000..96bc963b4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/directTreeFragment.xq
@@ -0,0 +1,7 @@
+<doc xmlns="http://example.com/Namespace" xml:base="http://example.com/">
+
+ <!-- a comment -->
+ <?target data?>
+ <anotherElement/>
+ some text
+</doc>
diff --git a/doc/codesnippets/doc/src/snippets/patternist/doc.txt b/doc/codesnippets/doc/src/snippets/patternist/doc.txt
new file mode 100644
index 000000000..d30b057b2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/doc.txt
@@ -0,0 +1,35 @@
+<doc>
+ <p>
+ <span>1</span>
+ <span>2</span>
+ </p>
+ <p>
+ <span>3</span>
+ <span>4</span>
+ </p>
+ <p>
+ <span>5</span>
+ <span>6</span>
+ </p>
+ <p>
+ <span>7</span>
+ <span>8</span>
+ </p>
+ <p>
+ <span>9</span>
+ <span>a</span>
+ </p>
+ <p>
+ <span>b</span>
+ <span>c</span>
+ </p>
+ <p>
+ <span>d</span>
+ <span>e</span>
+ </p>
+ <p>
+ <span>f</span>
+ <span>0</span>
+ </p>
+</doc>
+
diff --git a/doc/codesnippets/doc/src/snippets/patternist/docPlainHTML.xq b/doc/codesnippets/doc/src/snippets/patternist/docPlainHTML.xq
new file mode 100644
index 000000000..622bec891
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/docPlainHTML.xq
@@ -0,0 +1 @@
+doc("myPlainHTML.html")/body
diff --git a/doc/codesnippets/doc/src/snippets/patternist/docPlainHTML2.xq b/doc/codesnippets/doc/src/snippets/patternist/docPlainHTML2.xq
new file mode 100644
index 000000000..5e7fbaedc
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/docPlainHTML2.xq
@@ -0,0 +1 @@
+doc("myPlainHTML.html")/html/body
diff --git a/doc/codesnippets/doc/src/snippets/patternist/embedDataInXHTML.xq b/doc/codesnippets/doc/src/snippets/patternist/embedDataInXHTML.xq
new file mode 100644
index 000000000..b513922a3
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/embedDataInXHTML.xq
@@ -0,0 +1,10 @@
+declare default element namespace "http://www.w3.org/1999/xhtml";
+<html>
+ <body>
+ {
+ for $i in doc("testResult.xml")/tests/test[@status = "failure"]
+ order by $i/@name
+ return <p>{$i/@name}</p>
+ }
+ </body>
+</html>
diff --git a/doc/codesnippets/doc/src/snippets/patternist/embedDataInXHTML2.xq b/doc/codesnippets/doc/src/snippets/patternist/embedDataInXHTML2.xq
new file mode 100644
index 000000000..754ddba87
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/embedDataInXHTML2.xq
@@ -0,0 +1,10 @@
+declare namespace x = "http://www.w3.org/1998/xhtml";
+<x:html>
+ <x:body>
+ {
+ for $i in doc("testResult.xml")/tests/test[@status = "failure"]
+ order by $i/@name
+ return <x:p>{$i/@name}</x:p>
+ }
+ </x:body>
+</x:html>
diff --git a/doc/codesnippets/doc/src/snippets/patternist/emptyParagraphs.xq b/doc/codesnippets/doc/src/snippets/patternist/emptyParagraphs.xq
new file mode 100644
index 000000000..6024d28a8
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/emptyParagraphs.xq
@@ -0,0 +1 @@
+doc('index.html')//p[string-length(.) = 0]
diff --git a/doc/codesnippets/doc/src/snippets/patternist/escapeCurlyBraces.xq b/doc/codesnippets/doc/src/snippets/patternist/escapeCurlyBraces.xq
new file mode 100644
index 000000000..669e7c197
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/escapeCurlyBraces.xq
@@ -0,0 +1,4 @@
+<doc>
+ This is one left followed by one right curly brace: {{ }}
+ Here they are again, but with character references: &#x7B; &#x7D;
+</doc>
diff --git a/doc/codesnippets/doc/src/snippets/patternist/escapeStringLiterals.xml b/doc/codesnippets/doc/src/snippets/patternist/escapeStringLiterals.xml
new file mode 100644
index 000000000..425ccb075
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/escapeStringLiterals.xml
@@ -0,0 +1,2 @@
+<p>"I hate quotations" -- Ralph Waldo Emerson"
+ '"I hate quotations"" -- Ralph Waldo Emerson"', appeared above</p> \ No newline at end of file
diff --git a/doc/codesnippets/doc/src/snippets/patternist/escapeStringLiterals.xq b/doc/codesnippets/doc/src/snippets/patternist/escapeStringLiterals.xq
new file mode 100644
index 000000000..4a6054ba6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/escapeStringLiterals.xq
@@ -0,0 +1,7 @@
+<p>
+{
+ """I hate quotations"" -- Ralph Waldo Emerson""",
+ "&#xA;",
+ '''"I hate quotations"" -- Ralph Waldo Emerson"'', appeared above'
+}
+</p>
diff --git a/doc/codesnippets/doc/src/snippets/patternist/expressionInsideAttribute.xq b/doc/codesnippets/doc/src/snippets/patternist/expressionInsideAttribute.xq
new file mode 100644
index 000000000..97f46b1c4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/expressionInsideAttribute.xq
@@ -0,0 +1,2 @@
+declare variable $additionalClass := "example";
+<p class="important {$additionalClass} obsolete"/>
diff --git a/doc/codesnippets/doc/src/snippets/patternist/filterOnPath.xq b/doc/codesnippets/doc/src/snippets/patternist/filterOnPath.xq
new file mode 100644
index 000000000..d23dfe8c7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/filterOnPath.xq
@@ -0,0 +1,2 @@
+let $doc := doc('doc.txt')
+return ($doc/doc/p/span)[1]
diff --git a/doc/codesnippets/doc/src/snippets/patternist/filterOnStep.xq b/doc/codesnippets/doc/src/snippets/patternist/filterOnStep.xq
new file mode 100644
index 000000000..46b77fa3c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/filterOnStep.xq
@@ -0,0 +1,2 @@
+let $doc := doc('doc.txt')
+return $doc/doc/p/span[1] \ No newline at end of file
diff --git a/doc/codesnippets/doc/src/snippets/patternist/firstParagraph.xq b/doc/codesnippets/doc/src/snippets/patternist/firstParagraph.xq
new file mode 100644
index 000000000..db5e2c720
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/firstParagraph.xq
@@ -0,0 +1 @@
+doc("index.html")/html/body/p[@xml:id = "thatSpecialOne"]
diff --git a/doc/codesnippets/doc/src/snippets/patternist/fnStringOnAttribute.xq b/doc/codesnippets/doc/src/snippets/patternist/fnStringOnAttribute.xq
new file mode 100644
index 000000000..b26e9f2f4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/fnStringOnAttribute.xq
@@ -0,0 +1,9 @@
+<html>
+ <body>
+ <p>
+ {
+ string(doc('feed.rss')/rss/@version)
+ }
+ </p>
+ </body>
+</html>
diff --git a/doc/codesnippets/doc/src/snippets/patternist/forClause.xq b/doc/codesnippets/doc/src/snippets/patternist/forClause.xq
new file mode 100644
index 000000000..a412dca47
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/forClause.xq
@@ -0,0 +1,3 @@
+for $i in(reverse(1 to 10)),
+ $d in xs:integer(doc("numbers.xml")/numbers/number)
+return ($i + $d)
diff --git a/doc/codesnippets/doc/src/snippets/patternist/forClause2.xq b/doc/codesnippets/doc/src/snippets/patternist/forClause2.xq
new file mode 100644
index 000000000..4fa505d53
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/forClause2.xq
@@ -0,0 +1,3 @@
+for $i in(reverse(1 to 10)),
+ $d in xs:integer(doc("numbers.xml")/numbers/number)
+return $i + $d
diff --git a/doc/codesnippets/doc/src/snippets/patternist/forClauseOnFeed.xq b/doc/codesnippets/doc/src/snippets/patternist/forClauseOnFeed.xq
new file mode 100644
index 000000000..9ec33397b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/forClauseOnFeed.xq
@@ -0,0 +1,6 @@
+for $item in doc('feed.rss')//item
+return <p>
+ {
+ $item/description/node()
+ }
+ </p>
diff --git a/doc/codesnippets/doc/src/snippets/patternist/indented.xml b/doc/codesnippets/doc/src/snippets/patternist/indented.xml
new file mode 100644
index 000000000..a312c63f2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/indented.xml
@@ -0,0 +1,5 @@
+<a>
+ <b/>
+ <c/>
+ <p>Some Text</p>
+</a>
diff --git a/doc/codesnippets/doc/src/snippets/patternist/introAcneRemover.xq b/doc/codesnippets/doc/src/snippets/patternist/introAcneRemover.xq
new file mode 100644
index 000000000..4e6ee8044
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/introAcneRemover.xq
@@ -0,0 +1,8 @@
+<result>
+ <para>The following skin care products have shipped, ordered by shipping date(oldest first):</para>
+ {
+ for $i in doc("myOrders.xml")/orders/order[@product = "Acme Skin Care"]
+ order by xs:date($i/@shippingDate) descending
+ return $i
+ }
+</result>
diff --git a/doc/codesnippets/doc/src/snippets/patternist/introExample2.xq b/doc/codesnippets/doc/src/snippets/patternist/introExample2.xq
new file mode 100644
index 000000000..411cc171f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/introExample2.xq
@@ -0,0 +1,5 @@
+<bibliography>
+{
+ doc($file)/bib/book[publisher = $publisher and @year > $year]/<book year="{@year}">{title}</book>
+}
+</bibliography>
diff --git a/doc/codesnippets/doc/src/snippets/patternist/introFileHierarchy.xml b/doc/codesnippets/doc/src/snippets/patternist/introFileHierarchy.xml
new file mode 100644
index 000000000..cfa6151ce
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/introFileHierarchy.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<directory name="home">
+
+ <file name="myNote.txt" mimetype="text/plain" size="8" extension="txt" uri="file:///home/frans/myNote.txt">
+ <content asBase64Binary="TXkgTm90ZSE=" asStringFromUTF-8="My Note!"/>
+ </file>
+
+ <directory name="src">
+ ...
+ </directory>
+
+ ...
+
+</directory>
diff --git a/doc/codesnippets/doc/src/snippets/patternist/introNavigateFS.xq b/doc/codesnippets/doc/src/snippets/patternist/introNavigateFS.xq
new file mode 100644
index 000000000..1f5a3a73e
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/introNavigateFS.xq
@@ -0,0 +1,12 @@
+declare variable $myRoot := <e/>; (: This line is a dummy and shouldn't appear in the documentation. :)
+<html>
+ <body>
+ {
+ $myRoot//file[@mimetype = 'text/xml' or @mimetype = 'application/xml']
+ /
+ (if(doc-available(@uri))
+ then ()
+ else <p>Failed to parse file {@uri}.</p>)
+ }
+ </body>
+</html>
diff --git a/doc/codesnippets/doc/src/snippets/patternist/introductionExample.xq b/doc/codesnippets/doc/src/snippets/patternist/introductionExample.xq
new file mode 100644
index 000000000..1a309dd7f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/introductionExample.xq
@@ -0,0 +1,3 @@
+<bibliography>
+{doc("library.xml")/bib/book[publisher="Addison-Wesley" and @year>1991]/<book year="{@year}">{title}</book>}
+</bibliography>
diff --git a/doc/codesnippets/doc/src/snippets/patternist/invalidLetOrderBy.xq b/doc/codesnippets/doc/src/snippets/patternist/invalidLetOrderBy.xq
new file mode 100644
index 000000000..d65f24066
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/invalidLetOrderBy.xq
@@ -0,0 +1,3 @@
+let $i := (2, 3, 1)
+order by $i[1]
+return $i
diff --git a/doc/codesnippets/doc/src/snippets/patternist/items.xq b/doc/codesnippets/doc/src/snippets/patternist/items.xq
new file mode 100644
index 000000000..0b46ec14e
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/items.xq
@@ -0,0 +1,5 @@
+<aNode/>,
+xs:base64Binary("FFFF"),
+current-date(),
+3e3, (: A floating point value :)
+attribute {"name"} {()}
diff --git a/doc/codesnippets/doc/src/snippets/patternist/letOrderBy.xq b/doc/codesnippets/doc/src/snippets/patternist/letOrderBy.xq
new file mode 100644
index 000000000..f4106d280
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/letOrderBy.xq
@@ -0,0 +1,4 @@
+for $a in (8, -4, 2)
+let $b := ($a * -1, $a)
+order by $a
+return $b
diff --git a/doc/codesnippets/doc/src/snippets/patternist/literalsAndOperators.xq b/doc/codesnippets/doc/src/snippets/patternist/literalsAndOperators.xq
new file mode 100644
index 000000000..ec4af33ba
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/literalsAndOperators.xq
@@ -0,0 +1,2 @@
+declare variable $date := fn:current-date(); (: This line should not be part of the example. It exists in order to make the query valid. :)
+fn:current-date() - $date > xs:dayTimeDuration("P365D")
diff --git a/doc/codesnippets/doc/src/snippets/patternist/mobeyDick.xml b/doc/codesnippets/doc/src/snippets/patternist/mobeyDick.xml
new file mode 100644
index 000000000..32d0b6cae
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/mobeyDick.xml
@@ -0,0 +1,4 @@
+<book xmlns:dc='http://purl.org/dc/elements/1.1'
+ xmlns='http://example.com/MyDefault'>
+ <dc:title>Mobey Dick</dc:title> ...
+</book>
diff --git a/doc/codesnippets/doc/src/snippets/patternist/nextLastParagraph.xq b/doc/codesnippets/doc/src/snippets/patternist/nextLastParagraph.xq
new file mode 100644
index 000000000..9424f792b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/nextLastParagraph.xq
@@ -0,0 +1 @@
+doc('index.html')//p[last() - 1]
diff --git a/doc/codesnippets/doc/src/snippets/patternist/nodeConstructorsAreExpressions.xq b/doc/codesnippets/doc/src/snippets/patternist/nodeConstructorsAreExpressions.xq
new file mode 100644
index 000000000..ce36e843a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/nodeConstructorsAreExpressions.xq
@@ -0,0 +1,4 @@
+let $docURI := 'maybeNotWellformed.xml'
+return if(doc-available($docURI))
+ then doc($docURI)//p/<para>{./node()}</para>
+ else <para>Failed to load {$docURI}</para>
diff --git a/doc/codesnippets/doc/src/snippets/patternist/nodeConstructorsInPaths.xq b/doc/codesnippets/doc/src/snippets/patternist/nodeConstructorsInPaths.xq
new file mode 100644
index 000000000..beb294fba
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/nodeConstructorsInPaths.xq
@@ -0,0 +1 @@
+doc('feed.rss')//item/<p>{description/node()}</p>
diff --git a/doc/codesnippets/doc/src/snippets/patternist/nodeTestChildElement.xq b/doc/codesnippets/doc/src/snippets/patternist/nodeTestChildElement.xq
new file mode 100644
index 000000000..7aa7b3437
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/nodeTestChildElement.xq
@@ -0,0 +1 @@
+doc('index.html')/descendant-or-self::element(p)/child::element(span)
diff --git a/doc/codesnippets/doc/src/snippets/patternist/notIndented.xml b/doc/codesnippets/doc/src/snippets/patternist/notIndented.xml
new file mode 100644
index 000000000..b3321f286
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/notIndented.xml
@@ -0,0 +1 @@
+<a><b/><c/><p>Some Text</p></a>
diff --git a/doc/codesnippets/doc/src/snippets/patternist/oneElementConstructor.xq b/doc/codesnippets/doc/src/snippets/patternist/oneElementConstructor.xq
new file mode 100644
index 000000000..b7eb615f8
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/oneElementConstructor.xq
@@ -0,0 +1 @@
+<myElement/>
diff --git a/doc/codesnippets/doc/src/snippets/patternist/paragraphsExceptTheFiveFirst.xq b/doc/codesnippets/doc/src/snippets/patternist/paragraphsExceptTheFiveFirst.xq
new file mode 100644
index 000000000..16438d188
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/paragraphsExceptTheFiveFirst.xq
@@ -0,0 +1 @@
+doc('index.html')//p[position() > 5]
diff --git a/doc/codesnippets/doc/src/snippets/patternist/paragraphsWithTables.xq b/doc/codesnippets/doc/src/snippets/patternist/paragraphsWithTables.xq
new file mode 100644
index 000000000..dbb9fcf94
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/paragraphsWithTables.xq
@@ -0,0 +1 @@
+doc('index.html')/html/body/p[table]
diff --git a/doc/codesnippets/doc/src/snippets/patternist/pathAB.xq b/doc/codesnippets/doc/src/snippets/patternist/pathAB.xq
new file mode 100644
index 000000000..26fd1e5dc
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/pathAB.xq
@@ -0,0 +1 @@
+doc('index.html')//p/span
diff --git a/doc/codesnippets/doc/src/snippets/patternist/pathsAllParagraphs.xq b/doc/codesnippets/doc/src/snippets/patternist/pathsAllParagraphs.xq
new file mode 100644
index 000000000..ba47900f9
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/pathsAllParagraphs.xq
@@ -0,0 +1 @@
+doc('index.html')//p
diff --git a/doc/codesnippets/doc/src/snippets/patternist/simpleHTML.xq b/doc/codesnippets/doc/src/snippets/patternist/simpleHTML.xq
new file mode 100644
index 000000000..93ac31ec6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/simpleHTML.xq
@@ -0,0 +1 @@
+doc("index.html")/html/body/p[@class="example"]
diff --git a/doc/codesnippets/doc/src/snippets/patternist/simpleXHTML.xq b/doc/codesnippets/doc/src/snippets/patternist/simpleXHTML.xq
new file mode 100644
index 000000000..fda537167
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/simpleXHTML.xq
@@ -0,0 +1,2 @@
+declare namespace x = "http://www.w3.org/1999/xhtml/";
+doc("index.html")/x:html/x:body/x:p[@class="example"]
diff --git a/doc/codesnippets/doc/src/snippets/patternist/svgDocumentElement.xml b/doc/codesnippets/doc/src/snippets/patternist/svgDocumentElement.xml
new file mode 100644
index 000000000..0c7be4e2d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/svgDocumentElement.xml
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg"/>
diff --git a/doc/codesnippets/doc/src/snippets/patternist/tablesInParagraphs.xq b/doc/codesnippets/doc/src/snippets/patternist/tablesInParagraphs.xq
new file mode 100644
index 000000000..fc92cf003
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/tablesInParagraphs.xq
@@ -0,0 +1 @@
+doc('index.html')/html/body/p/table
diff --git a/doc/codesnippets/doc/src/snippets/patternist/twoSVGElements.xq b/doc/codesnippets/doc/src/snippets/patternist/twoSVGElements.xq
new file mode 100644
index 000000000..ab4fe3580
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/twoSVGElements.xq
@@ -0,0 +1,5 @@
+declare namespace s = "http://www.w3.org/2000/svg";
+declare default element namespace "http://www.w3.org/2000/svg";
+let $doc := doc('image.svg')
+return ($doc/svg,
+ $doc/s:svg)
diff --git a/doc/codesnippets/doc/src/snippets/patternist/xmlStylesheet.xq b/doc/codesnippets/doc/src/snippets/patternist/xmlStylesheet.xq
new file mode 100644
index 000000000..9e022081b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/xmlStylesheet.xq
@@ -0,0 +1 @@
+<?xml-stylesheet type="test/xsl" href="formatter.xsl"?>
diff --git a/doc/codesnippets/doc/src/snippets/patternist/xsBooleanTrue.xq b/doc/codesnippets/doc/src/snippets/patternist/xsBooleanTrue.xq
new file mode 100644
index 000000000..897a99e4d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/xsBooleanTrue.xq
@@ -0,0 +1 @@
+xs:boolean("true")
diff --git a/doc/codesnippets/doc/src/snippets/patternist/xsvgDocumentElement.xml b/doc/codesnippets/doc/src/snippets/patternist/xsvgDocumentElement.xml
new file mode 100644
index 000000000..fb6a236e7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/patternist/xsvgDocumentElement.xml
@@ -0,0 +1 @@
+<x:svg xmlns:x="http://www.w3.org/2000/svg"/>
diff --git a/doc/codesnippets/doc/src/snippets/persistentindexes/main.cpp b/doc/codesnippets/doc/src/snippets/persistentindexes/main.cpp
new file mode 100644
index 000000000..8c6b8b54a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/persistentindexes/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/persistentindexes/mainwindow.cpp b/doc/codesnippets/doc/src/snippets/persistentindexes/mainwindow.cpp
new file mode 100644
index 000000000..338ea887d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/persistentindexes/mainwindow.cpp
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+#include "model.h"
+
+/*!
+ The main window constructor creates and populates a model with values
+ from a string list then displays the contents of the model using a
+ QListView widget.
+*/
+
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+{
+ 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"));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(itemsMenu);
+
+ QStringList numbers;
+ numbers << tr("One") << tr("Two") << tr("Three") << tr("Four") << tr("Five")
+ << tr("Six") << tr("Seven") << tr("Eight") << tr("Nine") << tr("Ten");
+
+ model = new StringListModel(numbers);
+ QListView *view = new QListView(this);
+ view->setModel(model);
+
+ selectionModel = view->selectionModel();
+
+ connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
+ connect(insertAction, SIGNAL(triggered()), this, SLOT(insertItem()));
+ connect(removeAction, SIGNAL(triggered()), this, SLOT(removeItem()));
+ connect(selectionModel,
+ SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
+ this, SLOT(updateMenus(const QModelIndex &)));
+
+ setCentralWidget(view);
+ setWindowTitle("View onto a string list model");
+}
+
+void MainWindow::insertItem()
+{
+ if (!selectionModel->currentIndex().isValid())
+ return;
+
+ QString itemText = QInputDialog::getText(this, tr("Insert Item"),
+ tr("Input text for the new item:"));
+
+ if (itemText.isNull())
+ return;
+
+ int row = selectionModel->currentIndex().row();
+
+ if (model->insertRows(row, 1))
+ model->setData(model->index(row, 0), itemText, Qt::EditRole);
+}
+
+void MainWindow::removeItem()
+{
+ if (!selectionModel->currentIndex().isValid())
+ return;
+
+ int row = selectionModel->currentIndex().row();
+
+ model->removeRows(row, 1);
+}
+
+void MainWindow::updateMenus(const QModelIndex &currentIndex)
+{
+ insertAction->setEnabled(currentIndex.isValid());
+ removeAction->setEnabled(currentIndex.isValid());
+}
diff --git a/doc/codesnippets/doc/src/snippets/persistentindexes/mainwindow.h b/doc/codesnippets/doc/src/snippets/persistentindexes/mainwindow.h
new file mode 100644
index 000000000..dbeef1419
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/persistentindexes/mainwindow.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+#include <QModelIndex>
+
+class QAbstractItemModel;
+class QAction;
+class QItemSelectionModel;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow(QWidget *parent = 0);
+
+private slots:
+ void insertItem();
+ void removeItem();
+ void updateMenus(const QModelIndex &currentIndex);
+
+private:
+ QAbstractItemModel *model;
+ QAction *insertAction;
+ QAction *removeAction;
+ QItemSelectionModel *selectionModel;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/persistentindexes/model.cpp b/doc/codesnippets/doc/src/snippets/persistentindexes/model.cpp
new file mode 100644
index 000000000..a60c095a4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/persistentindexes/model.cpp
@@ -0,0 +1,169 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ model.cpp
+
+ A simple model that uses a QStringList as its data source.
+*/
+
+#include <qdebug.h>
+
+#include "model.h"
+
+/*!
+ Returns the number of items in the string list as the number of rows
+ in the model.
+*/
+
+int StringListModel::rowCount(const QModelIndex &parent) const
+{
+ return stringList.count();
+}
+
+/*!
+ Returns an appropriate value for the requested data.
+ If the view requests an invalid index, an invalid variant is returned.
+ If a header is requested then we just return the column or row number,
+ depending on the orientation of the header.
+ Any valid index that corresponds to a string in the list causes that
+ string to be returned.
+*/
+
+QVariant StringListModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ if (index.row() < 0 || index.row() >= stringList.size())
+ return QVariant();
+
+ if (role == Qt::DisplayRole)
+ return stringList.at(index.row());
+ else
+ return QVariant();
+}
+
+/*!
+ Returns the appropriate header string depending on the orientation of
+ the header and the section. If anything other than the display role is
+ requested, we return an invalid variant.
+*/
+
+QVariant StringListModel::headerData(int section, Qt::Orientation orientation,
+ int role) const
+{
+ if (role != Qt::DisplayRole)
+ return QVariant();
+
+ if (orientation == Qt::Horizontal)
+ return QString("Column %1").arg(section);
+ else
+ return QString("Row %1").arg(section);
+}
+
+/*!
+ Returns an appropriate value for the item's flags. Valid items are
+ enabled, selectable, and editable.
+*/
+
+Qt::ItemFlags StringListModel::flags(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return Qt::ItemIsEnabled;
+
+ return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
+}
+
+/*!
+ Changes an item in the string list, but only if the following conditions
+ are met:
+
+ * The index supplied is valid.
+ * The index corresponds to an item to be shown in a view.
+ * The role associated with editing text is specified.
+
+ The dataChanged() signal is emitted if the item is changed.
+*/
+
+bool StringListModel::setData(const QModelIndex &index,
+ const QVariant &value, int role)
+{
+ if (index.isValid() && role == Qt::EditRole) {
+
+ stringList.replace(index.row(), value.toString());
+ emit dataChanged(index, index);
+ return true;
+ }
+ return false;
+}
+
+/*!
+ Inserts a number of rows into the model at the specified position.
+*/
+
+bool StringListModel::insertRows(int position, int rows, const QModelIndex &parent)
+{
+ beginInsertRows(parent, position, position + rows - 1);
+
+ for (int row = 0; row < rows; ++row) {
+ stringList.insert(position, "");
+ }
+
+ endInsertRows();
+ return true;
+}
+
+/*!
+ Removes a number of rows from the model at the specified position.
+*/
+
+bool StringListModel::removeRows(int position, int rows, const QModelIndex &parent)
+{
+ beginRemoveRows(parent, position, position + rows - 1);
+
+ for (int row = 0; row < rows; ++row) {
+ stringList.removeAt(position);
+ }
+
+ endRemoveRows();
+ return true;
+}
diff --git a/doc/codesnippets/doc/src/snippets/persistentindexes/model.h b/doc/codesnippets/doc/src/snippets/persistentindexes/model.h
new file mode 100644
index 000000000..3c3ca69fa
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/persistentindexes/model.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MODEL_H
+#define MODEL_H
+
+#include <QAbstractListModel>
+#include <QObject>
+#include <QStringList>
+
+class StringListModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ StringListModel(const QStringList &strings, QObject *parent = 0)
+ : QAbstractListModel(parent), stringList(strings) {}
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = Qt::EditRole);
+
+ bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex());
+ bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex());
+
+private:
+ QStringList stringList;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/persistentindexes/persistentindexes.pro b/doc/codesnippets/doc/src/snippets/persistentindexes/persistentindexes.pro
new file mode 100644
index 000000000..aaf41bd1c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/persistentindexes/persistentindexes.pro
@@ -0,0 +1,5 @@
+HEADERS = mainwindow.h \
+ model.h
+SOURCES = main.cpp \
+ mainwindow.cpp \
+ model.cpp
diff --git a/doc/codesnippets/doc/src/snippets/phonon.cpp b/doc/codesnippets/doc/src/snippets/phonon.cpp
new file mode 100644
index 000000000..e4d777323
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/phonon.cpp
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+Window::Window()
+{
+ {
+//![0]
+ Phonon::MediaObject *music =
+ Phonon::createPlayer(Phonon::MusicCategory,
+ Phonon::MediaSource("/path/mysong.wav"));
+ music->play();
+//![0]
+ }
+
+ {
+ QWidget *parentWidget = new QWidget;
+ QUrl url("Myfancymusic");
+//![1]
+ Phonon::VideoPlayer *player =
+ new Phonon::VideoPlayer(Phonon::VideoCategory, parentWidget);
+ player->play(url);
+//![1]
+ }
+
+ {
+//![2]
+ Phonon::MediaObject *mediaObject = new Phonon::MediaObject(this);
+ mediaObject->setCurrentSource(Phonon::MediaSource("/mymusic/barbiegirl.wav"));
+ Phonon::AudioOutput *audioOutput =
+ new Phonon::AudioOutput(Phonon::MusicCategory, this);
+ Phonon::Path path = Phonon::createPath(mediaObject, audioOutput);
+//![2]
+
+//![3]
+ Phonon::Effect *effect =
+ new Phonon::Effect(
+ Phonon::BackendCapabilities::availableAudioEffects()[0], this);
+ path.insertEffect(effect);
+//![3]
+ }
+
+ {
+//![4]
+ Phonon::MediaObject *mediaObject = new Phonon::MediaObject(this);
+
+ Phonon::VideoWidget *videoWidget = new Phonon::VideoWidget(this);
+ Phonon::createPath(mediaObject, videoWidget);
+
+ Phonon::AudioOutput *audioOutput =
+ new Phonon::AudioOutput(Phonon::VideoCategory, this);
+ Phonon::createPath(mediaObject, audioOutput);
+//![4]
+//![5]
+ mediaObject->play();
+//![5]
+ }
+}
diff --git a/doc/codesnippets/doc/src/snippets/phonon/samplebackend/main.cpp b/doc/codesnippets/doc/src/snippets/phonon/samplebackend/main.cpp
new file mode 100644
index 000000000..724ef5ce9
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/phonon/samplebackend/main.cpp
@@ -0,0 +1,115 @@
+//! [snippet]
+QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const QList<QVariant> &args)
+{
+ switch (c) {
+ case MediaObjectClass:
+ return new MediaObject(parent);
+ case VolumeFaderEffectClass:
+ return new VolumeFaderEffect(parent);
+ case AudioOutputClass:
+ return new AudioOutput(parent);
+ case AudioDataOutputClass:
+ return new AudioDataOutput(parent);
+ case VisualizationClass:
+ return new Visualization(parent);
+ case VideoDataOutputClass:
+ return new VideoDataOutput(parent);
+ case EffectClass:
+ return new Effect(args[0].toInt(), parent);
+ case VideoWidgetClass:
+ return new VideoWidget(qobject_cast<QWidget *>(parent));
+ }
+ return 0;
+}
+
+QSet<int> Backend::objectDescriptionIndexes(ObjectDescriptionType type) const
+{
+ QSet<int> set;
+ switch(type)
+ {
+ case Phonon::AudioOutputDeviceType:
+ // use AudioDeviceEnumerator to list ALSA and OSS devices
+ set << 10000 << 10001;
+ break;
+ case Phonon::AudioCaptureDeviceType:
+ set << 20000 << 20001;
+ break;
+ case Phonon::VideoOutputDeviceType:
+ break;
+ case Phonon::VideoCaptureDeviceType:
+ set << 30000 << 30001;
+ break;
+ case Phonon::VisualizationType:
+ case Phonon::AudioCodecType:
+ case Phonon::VideoCodecType:
+ case Phonon::ContainerFormatType:
+ break;
+ case Phonon::EffectType:
+ set << 0x7F000001;
+ break;
+ }
+ return set;
+}
+
+QHash<QByteArray, QVariant> Backend::objectDescriptionProperties(ObjectDescriptionType type, int index) const
+{
+ QHash<QByteArray, QVariant> ret;
+ switch (type) {
+ case Phonon::AudioOutputDeviceType:
+ switch (index) {
+ case 10000:
+ ret.insert("name", QLatin1String("internal Soundcard"));
+ break;
+ case 10001:
+ ret.insert("name", QLatin1String("USB Headset"));
+ ret.insert("icon", KIcon("usb-headset"));
+ ret.insert("available", false);
+ break;
+ }
+ break;
+ case Phonon::AudioCaptureDeviceType:
+ switch (index) {
+ case 20000:
+ ret.insert("name", QLatin1String("Soundcard"));
+ ret.insert("description", QLatin1String("first description"));
+ break;
+ case 20001:
+ ret.insert("name", QLatin1String("DV"));
+ ret.insert("description", QLatin1String("second description"));
+ break;
+ }
+ break;
+ case Phonon::VideoOutputDeviceType:
+ break;
+ case Phonon::VideoCaptureDeviceType:
+ switch (index) {
+ case 30000:
+ ret.insert("name", QLatin1String("USB Webcam"));
+ ret.insert("description", QLatin1String("first description"));
+ break;
+ case 30001:
+ ret.insert("name", QLatin1String("DV"));
+ ret.insert("description", QLatin1String("second description"));
+ break;
+ }
+ break;
+ case Phonon::VisualizationType:
+ break;
+ case Phonon::AudioCodecType:
+ break;
+ case Phonon::VideoCodecType:
+ break;
+ case Phonon::ContainerFormatType:
+ break;
+ case Phonon::EffectType:
+ switch (index) {
+ case 0x7F000001:
+ ret.insert("name", QLatin1String("Delay"));
+ ret.insert("description", QLatin1String("Simple delay effect with time, feedback and level controls."));
+ break;
+ }
+ break;
+ }
+ return ret;
+}
+//! [snippet]
diff --git a/doc/codesnippets/doc/src/snippets/phononeffectparameter.cpp b/doc/codesnippets/doc/src/snippets/phononeffectparameter.cpp
new file mode 100644
index 000000000..e0351f570
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/phononeffectparameter.cpp
@@ -0,0 +1,35 @@
+#include <QtGui>
+
+#include <phonon/backendcapabilities.h>
+#include <phonon/phononnamespace.h>
+#include <phonon/effect.h>
+#include <phonon/effectparameter.h>
+#include <phonon/effectwidget.h>
+
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+ app.setApplicationName("effectsnippets");
+
+ QList<Phonon::EffectDescription> effects =
+ Phonon::BackendCapabilities::availableAudioEffects();
+
+ Phonon::Effect *effect = new Phonon::Effect(effects.at(3));
+
+//![0]
+ QList<Phonon::EffectParameter> parameters = effect->parameters();
+
+ foreach(Phonon::EffectParameter parameter, parameters) {
+ // Do something with parameter
+ }
+//![0]
+
+//![1]
+ Phonon::EffectWidget *effectWidget = new Phonon::EffectWidget(effect);
+//![1]
+
+ effectWidget->show();
+
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/phononobjectdescription.cpp b/doc/codesnippets/doc/src/snippets/phononobjectdescription.cpp
new file mode 100644
index 000000000..b9d1f2976
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/phononobjectdescription.cpp
@@ -0,0 +1,40 @@
+#include <QtGui>
+
+#include <phonon/phononnamespace.h>
+#include <phonon/audiooutput.h>
+#include <phonon/seekslider.h>
+#include <phonon/mediaobject.h>
+#include <phonon/volumeslider.h>
+#include <phonon/backendcapabilities.h>
+#include <phonon/effect.h>
+#include <phonon/effectparameter.h>
+#include <phonon/objectdescriptionmodel.h>
+#include <QList>
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+
+//![0]
+ QList<Phonon::EffectDescription> effectDescriptions =
+ Phonon::BackendCapabilities::availableAudioEffects();
+
+//![1]
+ QList<Phonon::AudioOutputDevice> audioOutputDevices =
+ Phonon::BackendCapabilities::availableAudioOutputDevices();
+
+//![1]
+ foreach (Phonon::EffectDescription effectDescription, effectDescriptions) {
+ Phonon::Effect *effect = new Phonon::Effect(effectDescription);
+
+ // ... Do something with the effect, like insert it into a media graph
+ }
+
+ Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput;
+
+ audioOutput->setOutputDevice(audioOutputDevices[0]);
+//![0]
+
+ return app.exec();
+
+}
diff --git a/doc/codesnippets/doc/src/snippets/picture/picture.cpp b/doc/codesnippets/doc/src/snippets/picture/picture.cpp
new file mode 100644
index 000000000..9c9af819e
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/picture/picture.cpp
@@ -0,0 +1,112 @@
+############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Nokia Corporation (qt-info@nokia.com)
+##
+## This file is part of the documentation of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at http://www.qtsoftware.com/contact.
+## $QT_END_LICENSE$
+##
+############################################################################
+
+//! [0]
+ picture = QPicture()
+ painter = QPainter()
+ 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]
+
+//! [1]
+ picture = QPicture()
+ picture.load("drawing.pic") # load picture
+ painter = QPainter()
+ painter.begin(myImage) # paint in myImage
+ painter.drawPicture(0, 0, picture) # draw the picture at (0,0)
+ painter.end() # painting done
+//! [1]
+
+//! [2]
+ list = QPicture.inputFormatList()
+ for string in list:
+ myProcessing(string)
+//! [2]
+
+//! [3]
+ list = QPicture.outputFormatList()
+ for string in list:
+ myProcessing(string)
+//! [3]
+
+//! [4]
+ iio = QPictureIO()
+ pixmap = QPixmap()
+ iio.setFileName("vegeburger.pic")
+ if iio.read(): # OK
+ picture = iio.picture()
+ painter = QPainter(pixmap)
+ painter.drawPicture(0, 0, picture)
+
+//! [4]
+
+//! [5]
+ iio = QPictureIO()
+ picture = QPicture()
+ painter = QPainter(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]
+
+//! [6]
+def readSVG(picture):
+ # read the picture using the picture.ioDevice()
+
+//! [6]
+
+
+//! [7]
+def writeSVG(picture):
+ # write the picture using the picture.ioDevice()
+
+//! [7]
+
+
+//! [8]
+ # add the SVG picture handler
+ # ...
+//! [8]
diff --git a/doc/codesnippets/doc/src/snippets/picture/picture.pro b/doc/codesnippets/doc/src/snippets/picture/picture.pro
new file mode 100644
index 000000000..b46019f49
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/picture/picture.pro
@@ -0,0 +1,12 @@
+######################################################################
+# Automatically generated by qmake (2.00a) Sun Jun 26 15:25:59 2005
+######################################################################
+
+TEMPLATE = app
+INCLUDEPATH += .
+
+# Input
+SOURCES += picture.cpp
+OBJECTS_DIR=.obj/debug-shared
+MOC_DIR=.moc/debug-shared
+CONFIG += qt warn_on debug create_prl link_prl
diff --git a/doc/codesnippets/doc/src/snippets/plaintextlayout/main.cpp b/doc/codesnippets/doc/src/snippets/plaintextlayout/main.cpp
new file mode 100644
index 000000000..f0561b99b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/plaintextlayout/main.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "window.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Window *window = new Window;
+ window->resize(337, 343);
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/plaintextlayout/plaintextlayout.pro b/doc/codesnippets/doc/src/snippets/plaintextlayout/plaintextlayout.pro
new file mode 100644
index 000000000..6283406f2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/plaintextlayout/plaintextlayout.pro
@@ -0,0 +1,3 @@
+HEADERS = window.h
+SOURCES = main.cpp \
+ window.cpp
diff --git a/doc/codesnippets/doc/src/snippets/plaintextlayout/window.cpp b/doc/codesnippets/doc/src/snippets/plaintextlayout/window.cpp
new file mode 100644
index 000000000..c9ea6afec
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/plaintextlayout/window.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <math.h>
+
+#include "window.h"
+
+Window::Window(QWidget *parent)
+ : QWidget(parent)
+{
+ text = QString("Support for text rendering and layout in Qt 4 has been "
+ "redesigned around a system that allows textual content to "
+ "be represented in a more flexible way than was possible "
+ "with Qt 3. Qt 4 also provides a more convenient "
+ "programming interface for editing documents. These "
+ "improvements are made available through a reimplementation "
+ "of the existing text rendering engine, and the "
+ "introduction of several new classes. "
+ "See the relevant module overview for a detailed discussion "
+ "of this framework. The following sections provide a brief "
+ "overview of the main concepts behind Scribe.");
+
+ setWindowTitle(tr("Plain Text Layout"));
+}
+
+void Window::paintEvent(QPaintEvent *event)
+{
+//! [0]
+ QTextLayout textLayout(text, font);
+ qreal margin = 10;
+ qreal radius = qMin(width()/2.0, height()/2.0) - margin;
+ QFontMetrics fm(font);
+
+ qreal lineHeight = fm.height();
+ qreal y = 0;
+
+ textLayout.beginLayout();
+
+ while (1) {
+ // create a new line
+ QTextLine line = textLayout.createLine();
+ if (!line.isValid())
+ break;
+
+ qreal x1 = qMax(0.0, pow(pow(radius,2)-pow(radius-y,2), 0.5));
+ qreal x2 = qMax(0.0, pow(pow(radius,2)-pow(radius-(y+lineHeight),2), 0.5));
+ qreal x = qMax(x1, x2) + margin;
+ qreal lineWidth = (width() - margin) - x;
+
+ line.setLineWidth(lineWidth);
+ line.setPosition(QPointF(x, margin+y));
+ y += line.height();
+ }
+
+ textLayout.endLayout();
+
+ QPainter painter;
+ painter.begin(this);
+ painter.setRenderHint(QPainter::Antialiasing);
+ painter.fillRect(rect(), Qt::white);
+ painter.setBrush(QBrush(Qt::black));
+ painter.setPen(QPen(Qt::black));
+ textLayout.draw(&painter, QPoint(0,0));
+
+ painter.setBrush(QBrush(QColor("#a6ce39")));
+ painter.setPen(QPen(Qt::black));
+ painter.drawEllipse(QRectF(-radius, margin, 2*radius, 2*radius));
+ painter.end();
+//! [0]
+}
diff --git a/doc/codesnippets/doc/src/snippets/plaintextlayout/window.h b/doc/codesnippets/doc/src/snippets/plaintextlayout/window.h
new file mode 100644
index 000000000..d842378ec
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/plaintextlayout/window.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QWidget>
+
+class Window : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Window(QWidget *parent = 0);
+
+protected:
+ void paintEvent(QPaintEvent *event);
+
+private:
+ QFont font;
+ QString text;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/pointer/pointer.cpp b/doc/codesnippets/doc/src/snippets/pointer/pointer.cpp
new file mode 100644
index 000000000..7b6790152
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/pointer/pointer.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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/codesnippets/doc/src/snippets/polygon/polygon.cpp b/doc/codesnippets/doc/src/snippets/polygon/polygon.cpp
new file mode 100644
index 000000000..75263112b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/polygon/polygon.cpp
@@ -0,0 +1,87 @@
+############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Nokia Corporation (qt-info@nokia.com)
+##
+## This file is part of the documentation of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at http://www.qtsoftware.com/contact.
+## $QT_END_LICENSE$
+##
+############################################################################
+
+//! [0]
+ polygon = QPolygon()
+ polygon << QPoint(10, 20) << QPoint(20, 30)
+//! [0]
+
+//! [1]
+ polygon = QPolygonF()
+ polygon << QPointF(10.4, 20.5) << QPointF(20.2, 30.2)
+//! [1]
+
+//! [2]
+ points = [ 10, 20, 30, 40 ]
+ polygon = QPolygon()
+ polygon.setPoints(2, points)
+//! [2]
+
+//! [3]
+ polygon = QPolygon()
+ polygon.setPoints(2, 10, 20, 30, 40)
+//! [3]
+
+//! [4]
+ polygon = QPolygon(1)
+ polygon[0] = QPoint(4, 5)
+ polygon.putPoints(1, 2, 6,7, 8,9)
+//! [4]
+
+//! [5]
+ polygon = QPolygon(3)
+ polygon.putPoints(0, 3, 4,5, 0,0, 8,9)
+ polygon.putPoints(1, 1, 6,7)
+//! [5]
+
+//! [6]
+ polygon1 = QPolygon()
+ polygon1.putPoints(0, 3, 1,2, 0,0, 5,6)
+ # polygon1 is now the three-point polygon(1,2, 0,0, 5,6)
+
+ polygon2 = QPolygon()
+ 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]
+
diff --git a/doc/codesnippets/doc/src/snippets/polygon/polygon.pro b/doc/codesnippets/doc/src/snippets/polygon/polygon.pro
new file mode 100644
index 000000000..39841a5aa
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/polygon/polygon.pro
@@ -0,0 +1 @@
+SOURCES += polygon.cpp
diff --git a/doc/codesnippets/doc/src/snippets/porting4-dropevents/main.cpp b/doc/codesnippets/doc/src/snippets/porting4-dropevents/main.cpp
new file mode 100644
index 000000000..43df372e5
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/porting4-dropevents/main.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "window.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ MyWidget window;
+ window.show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/porting4-dropevents/porting4-dropevents.pro b/doc/codesnippets/doc/src/snippets/porting4-dropevents/porting4-dropevents.pro
new file mode 100644
index 000000000..6283406f2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/porting4-dropevents/porting4-dropevents.pro
@@ -0,0 +1,3 @@
+HEADERS = window.h
+SOURCES = main.cpp \
+ window.cpp
diff --git a/doc/codesnippets/doc/src/snippets/porting4-dropevents/window.cpp b/doc/codesnippets/doc/src/snippets/porting4-dropevents/window.cpp
new file mode 100644
index 000000000..ad59c68ce
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/porting4-dropevents/window.cpp
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "window.h"
+
+MyWidget::MyWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ QLabel *textLabel = new QLabel(tr("Data:"), this);
+ dataLabel = new QLabel(this);
+ dataLabel->setFixedSize(200, 200);
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->addWidget(textLabel);
+ layout->addWidget(dataLabel);
+
+ setAcceptDrops(true);
+ setWindowTitle(tr("Drop Events"));
+}
+
+//! [0]
+void MyWidget::dragEnterEvent(QDragEnterEvent *event)
+{
+ if (event->mimeData()->hasText() || event->mimeData()->hasImage())
+ event->acceptProposedAction();
+}
+//! [0]
+
+//! [1]
+void MyWidget::dropEvent(QDropEvent *event)
+{
+ if (event->mimeData()->hasText())
+ dataLabel->setText(event->mimeData()->text());
+ else if (event->mimeData()->hasImage()) {
+ QVariant imageData = event->mimeData()->imageData();
+ dataLabel->setPixmap(qvariant_cast<QPixmap>(imageData));
+ }
+ event->acceptProposedAction();
+}
+//! [1]
+
+//! [2]
+void MyWidget::mousePressEvent(QMouseEvent *event)
+{
+//! [2]
+ QString text = dataLabel->text();
+ QPixmap iconPixmap(32, 32);
+ iconPixmap.fill(qRgba(255, 0, 0, 127));
+ QImage image(100, 100, QImage::Format_RGB32);
+ image.fill(qRgb(0, 0, 255));
+
+//! [3]
+ if (event->button() == Qt::LeftButton) {
+
+ QDrag *drag = new QDrag(this);
+ QMimeData *mimeData = new QMimeData;
+
+ mimeData->setText(text);
+ mimeData->setImageData(image);
+ drag->setMimeData(mimeData);
+ drag->setPixmap(iconPixmap);
+
+ Qt::DropAction dropAction = drag->exec();
+//! [3]
+ // ...
+//! [4]
+ event->accept();
+ }
+//! [4]
+ else if (event->button() == Qt::MidButton) {
+
+ QDrag *drag = new QDrag(this);
+ QMimeData *mimeData = new QMimeData;
+
+ mimeData->setImageData(image);
+ drag->setMimeData(mimeData);
+ drag->setPixmap(iconPixmap);
+
+ Qt::DropAction dropAction = drag->exec();
+ // ...
+ event->accept();
+ }
+//! [5]
+}
+//! [5]
diff --git a/doc/codesnippets/doc/src/snippets/porting4-dropevents/window.h b/doc/codesnippets/doc/src/snippets/porting4-dropevents/window.h
new file mode 100644
index 000000000..1603d152a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/porting4-dropevents/window.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QString>
+#include <QStringList>
+#include <QWidget>
+
+class QComboBox;
+class QFrame;
+class QLabel;
+
+class MyWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ MyWidget(QWidget *parent = 0);
+
+protected:
+ void dragEnterEvent(QDragEnterEvent *event);
+ void dropEvent(QDropEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+
+private:
+ QComboBox *mimeTypeCombo;
+ QFrame *dropFrame;
+ QLabel *dataLabel;
+ QString oldText;
+ QStringList oldMimeTypes;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/printing-qprinter/errors.cpp b/doc/codesnippets/doc/src/snippets/printing-qprinter/errors.cpp
new file mode 100644
index 000000000..7c2874e26
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/printing-qprinter/errors.cpp
@@ -0,0 +1,18 @@
+//! [0]
+ printer = QPrinter()
+ printer.setOutputFormat(QPrinter.PdfFormat)
+ printer.setOutputFileName("/foobar/nonwritable.pdf")
+ QPainter painter
+ if painter.begin(printer): # failed to open file
+ print "failed to open file, is it writable?"
+ return 1
+
+ painter.drawText(10, 10, "Test")
+ if !printer.Page():
+ print "failed in flushing page to disk, disk full?"
+ return 1
+
+ painter.drawText(10, 10, "Test 2")
+ painter.end()
+//! [0]
+
diff --git a/doc/codesnippets/doc/src/snippets/printing-qprinter/main.cpp b/doc/codesnippets/doc/src/snippets/printing-qprinter/main.cpp
new file mode 100644
index 000000000..0f1ce119b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/printing-qprinter/main.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include "object.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Object object;
+ QTimer timer;
+ timer.setSingleShot(true);
+ timer.connect(&timer, SIGNAL(timeout()), &object, SLOT(print()));
+ timer.start(0);
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/printing-qprinter/object.cpp b/doc/codesnippets/doc/src/snippets/printing-qprinter/object.cpp
new file mode 100644
index 000000000..663fc1688
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/printing-qprinter/object.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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/codesnippets/doc/src/snippets/printing-qprinter/object.h b/doc/codesnippets/doc/src/snippets/printing-qprinter/object.h
new file mode 100644
index 000000000..cf7125f6b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/printing-qprinter/object.h
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QObject>
+
+class Object : public QObject
+{
+ Q_OBJECT
+
+public:
+ Object(QObject *parent = 0);
+
+public slots:
+ void print();
+};
diff --git a/doc/codesnippets/doc/src/snippets/printing-qprinter/printing-qprinter.pro b/doc/codesnippets/doc/src/snippets/printing-qprinter/printing-qprinter.pro
new file mode 100644
index 000000000..c50fc1967
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/printing-qprinter/printing-qprinter.pro
@@ -0,0 +1,3 @@
+SOURCES = main.cpp \
+ object.cpp
+HEADERS = object.h
diff --git a/doc/codesnippets/doc/src/snippets/process/process.cpp b/doc/codesnippets/doc/src/snippets/process/process.cpp
new file mode 100644
index 000000000..3baeb5888
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/process/process.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QProcess>
+
+bool zip()
+{
+//! [0]
+ gzip = QProcess()
+ gzip.start("gzip", QStringList() << "-c")
+ if not gzip.waitForStarted():
+ return False
+
+ gzip.write("Qt rocks!")
+ gzip.closeWriteChannel()
+
+ if not gzip.waitForFinished():
+ return False
+
+ 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/codesnippets/doc/src/snippets/process/process.pro b/doc/codesnippets/doc/src/snippets/process/process.pro
new file mode 100644
index 000000000..f96847de8
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/process/process.pro
@@ -0,0 +1 @@
+SOURCES += process.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qabstractsliderisnippet.cpp b/doc/codesnippets/doc/src/snippets/qabstractsliderisnippet.cpp
new file mode 100644
index 000000000..4149d622f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qabstractsliderisnippet.cpp
@@ -0,0 +1,510 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+QAbstractSliderPrivate::QAbstractSliderPrivate()
+ : minimum(0), maximum(99), singleStep(1), pageStep(10),
+ value(0), position(0), pressValue(-1), tracking(true), blocktracking(false), pressed(false),
+ invertedAppearance(false), invertedControls(false),
+ orientation(Qt::Horizontal), repeatAction(QAbstractSlider::SliderNoAction)
+{
+}
+
+QAbstractSliderPrivate::~QAbstractSliderPrivate()
+{
+}
+
+oid QAbstractSlider::setRange(int min, int max)
+{
+ Q_D(QAbstractSlider);
+ int oldMin = d->minimum;
+ int oldMax = d->maximum;
+ d->minimum = min;
+ d->maximum = qMax(min, max);
+ if (oldMin != d->minimum || oldMax != d->maximum) {
+ sliderChange(SliderRangeChange);
+ emit rangeChanged(d->minimum, d->maximum);
+ setValue(d->value); // re-bound
+ }
+}
+
+
+void QAbstractSliderPrivate::setSteps(int single, int page)
+{
+ Q_Q(QAbstractSlider);
+ singleStep = qAbs(single);
+ pageStep = qAbs(page);
+ q->sliderChange(QAbstractSlider::SliderStepsChange);
+}
+
+AbstractSlider::QAbstractSlider(QWidget *parent)
+ :QWidget(*new QAbstractSliderPrivate, parent, 0)
+{
+}
+
+QAbstractSlider::QAbstractSlider(QAbstractSliderPrivate &dd, QWidget *parent)
+ :QWidget(dd, parent, 0)
+{
+}
+
+QAbstractSlider::~QAbstractSlider()
+{
+}
+
+void QAbstractSlider::setOrientation(Qt::Orientation orientation)
+{
+ Q_D(QAbstractSlider);
+ if (d->orientation == orientation)
+ return;
+
+ d->orientation = orientation;
+ if (!testAttribute(Qt::WA_WState_OwnSizePolicy)) {
+ QSizePolicy sp = sizePolicy();
+ sp.transpose();
+ setSizePolicy(sp);
+ setAttribute(Qt::WA_WState_OwnSizePolicy, false);
+ }
+ update();
+ updateGeometry();
+}
+
+Qt::Orientation QAbstractSlider::orientation() const
+{
+ Q_D(const QAbstractSlider);
+ return d->orientation;
+}
+
+
+void QAbstractSlider::setMinimum(int min)
+{
+ Q_D(QAbstractSlider);
+ setRange(min, qMax(d->maximum, min));
+}
+
+int QAbstractSlider::minimum() const
+{
+ Q_D(const QAbstractSlider);
+ return d->minimum;
+}
+
+
+void QAbstractSlider::setMaximum(int max)
+{
+ Q_D(QAbstractSlider);
+ setRange(qMin(d->minimum, max), max);
+}
+
+int QAbstractSlider::maximum() const
+{
+ Q_D(const QAbstractSlider);
+ return d->maximum;
+}
+
+
+
+void QAbstractSlider::setSingleStep(int step)
+{
+ Q_D(QAbstractSlider);
+ d->setSteps(step, d->pageStep);
+}
+
+int QAbstractSlider::singleStep() const
+{
+ Q_D(const QAbstractSlider);
+ return d->singleStep;
+}
+
+
+void QAbstractSlider::setPageStep(int step)
+{
+ Q_D(QAbstractSlider);
+ d->setSteps(d->singleStep, step);
+}
+
+int QAbstractSlider::pageStep() const
+{
+ Q_D(const QAbstractSlider);
+ return d->pageStep;
+}
+
+oid QAbstractSlider::setTracking(bool enable)
+{
+ Q_D(QAbstractSlider);
+ d->tracking = enable;
+}
+
+bool QAbstractSlider::hasTracking() const
+{
+ Q_D(const QAbstractSlider);
+ return d->tracking;
+}
+
+
+
+void QAbstractSlider::setSliderDown(bool down)
+{
+ Q_D(QAbstractSlider);
+ bool doEmit = d->pressed != down;
+
+ d->pressed = down;
+
+ if (doEmit) {
+ if (down)
+ emit sliderPressed();
+ else
+ emit sliderReleased();
+ }
+
+ if (!down && d->position != d->value)
+ triggerAction(SliderMove);
+}
+
+bool QAbstractSlider::isSliderDown() const
+{
+ Q_D(const QAbstractSlider);
+ return d->pressed;
+}
+
+
+void QAbstractSlider::setSliderPosition(int position)
+{
+ Q_D(QAbstractSlider);
+ position = d->bound(position);
+ if (position == d->position)
+ return;
+ d->position = position;
+ if (!d->tracking)
+ update();
+ if (d->pressed)
+ emit sliderMoved(position);
+ if (d->tracking && !d->blocktracking)
+ triggerAction(SliderMove);
+}
+
+int QAbstractSlider::sliderPosition() const
+{
+ Q_D(const QAbstractSlider);
+ return d->position;
+}
+
+
+
+int QAbstractSlider::value() const
+{
+ Q_D(const QAbstractSlider);
+ return d->value;
+}
+
+//! [0]
+void QAbstractSlider::setValue(int value)
+//! [0]
+{
+ Q_D(QAbstractSlider);
+ value = d->bound(value);
+ if (d->value == value && d->position == value)
+ return;
+ d->value = value;
+ if (d->position != value) {
+ d->position = value;
+ if (d->pressed)
+ emit sliderMoved((d->position = value));
+ }
+#ifndef QT_NO_ACCESSIBILITY
+//! [1]
+ QAccessible::updateAccessibility(this, 0, QAccessible::ValueChanged);
+//! [1]
+#endif
+ sliderChange(SliderValueChange);
+ emit valueChanged(value);
+//! [2]
+}
+//! [2]
+
+bool QAbstractSlider::invertedAppearance() const
+{
+ Q_D(const QAbstractSlider);
+ return d->invertedAppearance;
+}
+
+void QAbstractSlider::setInvertedAppearance(bool invert)
+{
+ Q_D(QAbstractSlider);
+ d->invertedAppearance = invert;
+ update();
+}
+
+
+
+bool QAbstractSlider::invertedControls() const
+{
+ Q_D(const QAbstractSlider);
+ return d->invertedControls;
+}
+
+void QAbstractSlider::setInvertedControls(bool invert)
+{
+ Q_D(QAbstractSlider);
+ d->invertedControls = invert;
+}
+
+void QAbstractSlider::triggerAction(SliderAction action)
+{
+ Q_D(QAbstractSlider);
+ d->blocktracking = true;
+ switch (action) {
+ case SliderSingleStepAdd:
+ setSliderPosition(d->value + d->singleStep);
+ break;
+ case SliderSingleStepSub:
+ setSliderPosition(d->value - d->singleStep);
+ break;
+ case SliderPageStepAdd:
+ setSliderPosition(d->value + d->pageStep);
+ break;
+ case SliderPageStepSub:
+ setSliderPosition(d->value - d->pageStep);
+ break;
+ case SliderToMinimum:
+ setSliderPosition(d->minimum);
+ break;
+ case SliderToMaximum:
+ setSliderPosition(d->maximum);
+ break;
+ case SliderMove:
+ case SliderNoAction:
+ break;
+ };
+ emit actionTriggered(action);
+ d->blocktracking = false;
+ setValue(d->position);
+}
+
+void QAbstractSlider::setRepeatAction(SliderAction action, int thresholdTime, int repeatTime)
+{
+ Q_D(QAbstractSlider);
+ if ((d->repeatAction = action) == SliderNoAction) {
+ d->repeatActionTimer.stop();
+ } else {
+ d->repeatActionTime = repeatTime;
+ d->repeatActionTimer.start(thresholdTime, this);
+ }
+}
+
+QAbstractSlider::SliderAction QAbstractSlider::repeatAction() const
+{
+ Q_D(const QAbstractSlider);
+ return d->repeatAction;
+}
+
+void QAbstractSlider::timerEvent(QTimerEvent *e)
+{
+ Q_D(QAbstractSlider);
+ if (e->timerId() == d->repeatActionTimer.timerId()) {
+ if (d->repeatActionTime) { // was threshold time, use repeat time next time
+ d->repeatActionTimer.start(d->repeatActionTime, this);
+ d->repeatActionTime = 0;
+ }
+ if (d->repeatAction == SliderPageStepAdd)
+ d->setAdjustedSliderPosition(d->value + d->pageStep);
+ else if (d->repeatAction == SliderPageStepSub)
+ d->setAdjustedSliderPosition(d->value - d->pageStep);
+ else
+ triggerAction(d->repeatAction);
+ }
+}
+
+oid QAbstractSlider::sliderChange(SliderChange)
+{
+ update();
+}
+
+
+#ifndef QT_NO_WHEELEVENT
+void QAbstractSlider::wheelEvent(QWheelEvent * e)
+{
+ Q_D(QAbstractSlider);
+ e->ignore();
+ if (e->orientation() != d->orientation && !rect().contains(e->pos()))
+ return;
+
+ static qreal offset = 0;
+ static QAbstractSlider *offset_owner = 0;
+ if (offset_owner != this){
+ offset_owner = this;
+ offset = 0;
+ }
+
+ int step = qMin(QApplication::wheelScrollLines() * d->singleStep, d->pageStep);
+ if ((e->modifiers() & Qt::ControlModifier) || (e->modifiers() & Qt::ShiftModifier))
+ step = d->pageStep;
+ offset += e->delta() * step / 120;
+ if (d->invertedControls)
+ offset = -offset;
+
+ if (qAbs(offset) < 1)
+ return;
+
+ int prevValue = d->value;
+ d->position = d->value + int(offset); // value will be updated by triggerAction()
+ triggerAction(SliderMove);
+ if (prevValue == d->value) {
+ offset = 0;
+ } else {
+ offset -= int(offset);
+ e->accept();
+ }
+}
+#endif
+void QAbstractSlider::keyPressEvent(QKeyEvent *ev)
+{
+ Q_D(QAbstractSlider);
+ SliderAction action = SliderNoAction;
+ switch (ev->key()) {
+#ifdef QT_KEYPAD_NAVIGATION
+ case Qt::Key_Select:
+ if (QApplication::keypadNavigationEnabled())
+ setEditFocus(!hasEditFocus());
+ else
+ ev->ignore();
+ break;
+ case Qt::Key_Back:
+ if (QApplication::keypadNavigationEnabled() && hasEditFocus()) {
+ setValue(d->origValue);
+ setEditFocus(false);
+ } else
+ ev->ignore();
+ break;
+#endif
+
+ // It seems we need to use invertedAppearance for Left and right, otherwise, things look weird.
+ case Qt::Key_Left:
+#ifdef QT_KEYPAD_NAVIGATION
+ if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) {
+ ev->ignore();
+ return;
+ }
+ if (QApplication::keypadNavigationEnabled() && d->orientation == Qt::Vertical)
+ action = d->invertedControls ? SliderSingleStepSub : SliderSingleStepAdd;
+ else
+#endif
+ action = !d->invertedAppearance ? SliderSingleStepSub : SliderSingleStepAdd;
+ break;
+ case Qt::Key_Right:
+#ifdef QT_KEYPAD_NAVIGATION
+ if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) {
+ ev->ignore();
+ return;
+ }
+ if (QApplication::keypadNavigationEnabled() && d->orientation == Qt::Vertical)
+ action = d->invertedControls ? SliderSingleStepAdd : SliderSingleStepSub;
+ else
+#endif
+ action = !d->invertedAppearance ? SliderSingleStepAdd : SliderSingleStepSub;
+ break;
+ case Qt::Key_Up:
+#ifdef QT_KEYPAD_NAVIGATION
+ if (QApplication::keypadNavigationEnabled()) {
+ ev->ignore();
+ break;
+ }
+#endif
+ action = d->invertedControls ? SliderSingleStepSub : SliderSingleStepAdd;
+ break;
+ case Qt::Key_Down:
+#ifdef QT_KEYPAD_NAVIGATION
+ if (QApplication::keypadNavigationEnabled()) {
+ ev->ignore();
+ break;
+ }
+#endif
+ action = d->invertedControls ? SliderSingleStepAdd : SliderSingleStepSub;
+ break;
+ case Qt::Key_PageUp:
+ action = d->invertedControls ? SliderPageStepSub : SliderPageStepAdd;
+ break;
+ case Qt::Key_PageDown:
+ action = d->invertedControls ? SliderPageStepAdd : SliderPageStepSub;
+ break;
+ case Qt::Key_Home:
+ action = SliderToMinimum;
+ break;
+ case Qt::Key_End:
+ action = SliderToMaximum;
+ break;
+ default:
+ ev->ignore();
+ break;
+ }
+ if (action)
+ triggerAction(action);
+}
+
+void QAbstractSlider::changeEvent(QEvent *ev)
+{
+ Q_D(QAbstractSlider);
+ switch (ev->type()) {
+ case QEvent::EnabledChange:
+ if (!isEnabled()) {
+ d->repeatActionTimer.stop();
+ setSliderDown(false);
+ }
+ // fall through...
+ default:
+ QWidget::changeEvent(ev);
+ }
+}
+
+bool QAbstractSlider::event(QEvent *e)
+{
+#ifdef QT_KEYPAD_NAVIGATION
+ Q_D(QAbstractSlider);
+ switch (e->type()) {
+ case QEvent::FocusIn:
+ d->origValue = d->value;
+ break;
+ default:
+ break;
+ }
+#endif
+
+ return QWidget::event(e);
+}
+
+
diff --git a/doc/codesnippets/doc/src/snippets/qcalendarwidget/main.cpp b/doc/codesnippets/doc/src/snippets/qcalendarwidget/main.cpp
new file mode 100644
index 000000000..ee4e0abf4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qcalendarwidget/main.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QCalendarWidget>
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ QCalendarWidget calendar;
+ calendar.setSelectedDate(calendar.selectedDate().addDays(3));
+ calendar.setGridVisible(true);
+ calendar.show();
+
+ QCalendarWidget calendarMin;
+ calendarMin.setMinimumDate(calendarMin.selectedDate().addDays(-7));
+ calendarMin.setGridVisible(true);
+ calendarMin.show();
+
+ QCalendarWidget calendarMax;
+ calendarMax.setMaximumDate(calendarMax.selectedDate().addDays(7));
+ calendarMax.setGridVisible(true);
+ calendarMax.show();
+
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/qcalendarwidget/qcalendarwidget.pro b/doc/codesnippets/doc/src/snippets/qcalendarwidget/qcalendarwidget.pro
new file mode 100644
index 000000000..88c5e24c5
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qcalendarwidget/qcalendarwidget.pro
@@ -0,0 +1 @@
+SOURCES = main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qcolumnview/main.cpp b/doc/codesnippets/doc/src/snippets/qcolumnview/main.cpp
new file mode 100644
index 000000000..633183413
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qcolumnview/main.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QStandardItemModel model;
+
+ QStandardItem *name = new QStandardItem("Name");
+ QStandardItem *firstName = new QStandardItem("First Name");
+ QStandardItem *lastName = new QStandardItem("Last Name");
+
+ name->appendRow(firstName);
+ name->appendRow(lastName);
+ model.appendRow(name);
+
+ QStandardItem *john = new QStandardItem("John");
+ QStandardItem *smith = new QStandardItem("Smith");
+
+ firstName->appendRow(john);
+ lastName->appendRow(smith);
+
+ QStandardItem *address = new QStandardItem("Address");
+ QStandardItem *street = new QStandardItem("Street");
+ QStandardItem *city = new QStandardItem("City");
+ QStandardItem *state = new QStandardItem("State");
+ QStandardItem *country = new QStandardItem("Country");
+
+ address->appendRow(street);
+ address->appendRow(city);
+ address->appendRow(state);
+ address->appendRow(country);
+ model.appendRow(address);
+
+ QColumnView columnView;
+ columnView.setModel(&model);
+ columnView.show();
+
+ return app.exec();
+} \ No newline at end of file
diff --git a/doc/codesnippets/doc/src/snippets/qcolumnview/qcolumnview.pro b/doc/codesnippets/doc/src/snippets/qcolumnview/qcolumnview.pro
new file mode 100644
index 000000000..5254077af
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qcolumnview/qcolumnview.pro
@@ -0,0 +1 @@
+SOURCES = main.cpp \ No newline at end of file
diff --git a/doc/codesnippets/doc/src/snippets/qdbusextratypes/qdbusextratypes.cpp b/doc/codesnippets/doc/src/snippets/qdbusextratypes/qdbusextratypes.cpp
new file mode 100644
index 000000000..6f1370713
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qdbusextratypes/qdbusextratypes.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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/codesnippets/doc/src/snippets/qdbusextratypes/qdbusextratypes.pro b/doc/codesnippets/doc/src/snippets/qdbusextratypes/qdbusextratypes.pro
new file mode 100644
index 000000000..e31e8d941
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qdbusextratypes/qdbusextratypes.pro
@@ -0,0 +1,2 @@
+SOURCES += qdbusextratypes.cpp
+QT = core dbus
diff --git a/doc/codesnippets/doc/src/snippets/qdebug/qdebug.pro b/doc/codesnippets/doc/src/snippets/qdebug/qdebug.pro
new file mode 100644
index 000000000..e62a71cac
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qdebug/qdebug.pro
@@ -0,0 +1 @@
+SOURCES = qdebugsnippet.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qdebug/qdebugsnippet.cpp b/doc/codesnippets/doc/src/snippets/qdebug/qdebugsnippet.cpp
new file mode 100644
index 000000000..8382dc362
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qdebug/qdebugsnippet.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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/codesnippets/doc/src/snippets/qdir-filepaths/main.cpp b/doc/codesnippets/doc/src/snippets/qdir-filepaths/main.cpp
new file mode 100644
index 000000000..e39acc741
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qdir-filepaths/main.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QDir>
+#include <iostream>
+
+int main(int argc, char *argv[])
+{
+ QDir directory("Documents/Letters");
+ QString path = directory.filePath("contents.txt");
+ QString absolutePath = directory.absoluteFilePath("contents.txt");
+
+ std::cout << qPrintable(directory.dirName()) << std::endl;
+ std::cout << qPrintable(path) << std::endl;
+ std::cout << qPrintable(absolutePath) << std::endl;
+ return 0;
+}
diff --git a/doc/codesnippets/doc/src/snippets/qdir-filepaths/qdir-filepaths.pro b/doc/codesnippets/doc/src/snippets/qdir-filepaths/qdir-filepaths.pro
new file mode 100644
index 000000000..bba41b9c1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qdir-filepaths/qdir-filepaths.pro
@@ -0,0 +1 @@
+SOURCES = main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qdir-listfiles/main.cpp b/doc/codesnippets/doc/src/snippets/qdir-listfiles/main.cpp
new file mode 100644
index 000000000..d7615471d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qdir-listfiles/main.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+
+from PySide.QtCore import QDir, QCoreApplication
+import sys
+
+app = QCoreApplication(sys.argv)
+directory = QDir()
+directory.setFilter(QDir.Files | QDir.Hidden | QDir.NoSymLinks)
+directory.setSorting(QDir.Size | QDir.Reversed)
+
+for entry in directory.entryInfoList():
+ print "%s %s" % (entry.size(), entry.fileName())
+
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/qdir-listfiles/qdir-listfiles.pro b/doc/codesnippets/doc/src/snippets/qdir-listfiles/qdir-listfiles.pro
new file mode 100644
index 000000000..bba41b9c1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qdir-listfiles/qdir-listfiles.pro
@@ -0,0 +1 @@
+SOURCES = main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qdir-namefilters/main.cpp b/doc/codesnippets/doc/src/snippets/qdir-namefilters/main.cpp
new file mode 100644
index 000000000..d34fdf393
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qdir-namefilters/main.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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]
+ filters = QStringList()
+ 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/codesnippets/doc/src/snippets/qdir-namefilters/qdir-namefilters.pro b/doc/codesnippets/doc/src/snippets/qdir-namefilters/qdir-namefilters.pro
new file mode 100644
index 000000000..bba41b9c1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qdir-namefilters/qdir-namefilters.pro
@@ -0,0 +1 @@
+SOURCES = main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qfontdatabase/main.cpp b/doc/codesnippets/doc/src/snippets/qfontdatabase/main.cpp
new file mode 100644
index 000000000..ee83360f2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qfontdatabase/main.cpp
@@ -0,0 +1,65 @@
+/############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Nokia Corporation (qt-info@nokia.com)
+##
+## This file is part of the documentation of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at http://www.qtsoftware.com/contact.
+## $QT_END_LICENSE$
+##
+############################################################################/
+
+//! [0]
+ database = QFontDatabase()
+ fontTree = QTreeWidget()
+ fontTree.setColumnCount(2)
+ fontTree.setHeaderLabels(QStringList() << "Font" << "Smooth Sizes")
+
+ for family in database.families():
+ familyItem = QTreeWidgetItem(fontTree)
+ familyItem.setText(0, family)
+
+ for style in database.styles(family):
+ styleItem = QTreeWidgetItem(familyItem)
+ styleItem.setText(0, style)
+
+ sizes = 0
+ for points in database.smoothSizes(family, style):
+ sizes += QString.number(points) + " "
+
+ styleItem.setText(1, sizes.trimmed())
+
+//! [0] //! [1]
+
+//! [1]
+
diff --git a/doc/codesnippets/doc/src/snippets/qfontdatabase/qfontdatabase.pro b/doc/codesnippets/doc/src/snippets/qfontdatabase/qfontdatabase.pro
new file mode 100644
index 000000000..ce12e3b40
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qfontdatabase/qfontdatabase.pro
@@ -0,0 +1 @@
+SOURCES = main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qgl-namespace/main.cpp b/doc/codesnippets/doc/src/snippets/qgl-namespace/main.cpp
new file mode 100644
index 000000000..4ec08ba28
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qgl-namespace/main.cpp
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QGL>
+
+int main(int argc, char *argv[])
+{
+ return 0;
+}
diff --git a/doc/codesnippets/doc/src/snippets/qgl-namespace/qgl-namespace.pro b/doc/codesnippets/doc/src/snippets/qgl-namespace/qgl-namespace.pro
new file mode 100644
index 000000000..9be6edc90
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qgl-namespace/qgl-namespace.pro
@@ -0,0 +1,2 @@
+SOURCES = main.cpp
+QT += opengl
diff --git a/doc/codesnippets/doc/src/snippets/qlabel/main.cpp b/doc/codesnippets/doc/src/snippets/qlabel/main.cpp
new file mode 100644
index 000000000..0d5be08ee
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qlabel/main.cpp
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+class Updater : public QObject
+{
+ Q_OBJECT
+
+public:
+ Updater(QWidget *widget);
+
+public slots:
+ void adjustSize();
+
+private:
+ QWidget *widget;
+};
+
+Updater::Updater(QWidget *widget)
+ : widget(widget)
+{
+}
+
+void Updater::adjustSize()
+{
+ widget->adjustSize();
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QLabel *label = new QLabel("My label");
+ QLineEdit *editor = new QLineEdit("New text");
+ QWidget window;
+ //Updater updater(&label);
+ QObject::connect(editor, SIGNAL(textChanged(const QString &)),
+ label, SLOT(setText(const QString &)));
+ //QObject::connect(editor, SIGNAL(textChanged(const QString &)),
+ // &updater, SLOT(adjustSize()));
+ //editor.show();
+ //label.show();
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(label);
+ layout->addWidget(editor);
+ window.setLayout(layout);
+ window.show();
+ return app.exec();
+}
+
+#include "main.moc"
diff --git a/doc/codesnippets/doc/src/snippets/qlabel/qlabel.pro b/doc/codesnippets/doc/src/snippets/qlabel/qlabel.pro
new file mode 100644
index 000000000..bba41b9c1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qlabel/qlabel.pro
@@ -0,0 +1 @@
+SOURCES = main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qlineargradient/main.cpp b/doc/codesnippets/doc/src/snippets/qlineargradient/main.cpp
new file mode 100644
index 000000000..26e207fdc
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qlineargradient/main.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include "paintwidget.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ PaintWidget window;
+ window.show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/qlineargradient/paintwidget.cpp b/doc/codesnippets/doc/src/snippets/qlineargradient/paintwidget.cpp
new file mode 100644
index 000000000..c951af97b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qlineargradient/paintwidget.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include "paintwidget.h"
+
+PaintWidget::PaintWidget(QWidget *parent)
+ : QWidget(parent)
+{
+}
+
+void PaintWidget::paintEvent(QPaintEvent *event)
+{
+ QLinearGradient gradient1(rect().topLeft(), rect().bottomRight());
+ gradient1.setColorAt(0, QColor("#ffffcc"));
+ gradient1.setColorAt(1, QColor("#ccccff"));
+
+ QRectF ellipseRect(width()*0.25, height()*0.25, width()*0.5, height()*0.5);
+ QLinearGradient gradient2(ellipseRect.topLeft(), ellipseRect.bottomRight());
+ gradient2.setColorAt(0, QColor("#ccccff"));
+ gradient2.setColorAt(1, QColor("#ffffcc"));
+
+ QPainter painter;
+ painter.begin(this);
+ painter.setRenderHint(QPainter::Antialiasing);
+ painter.fillRect(rect(), QBrush(gradient1));
+ painter.setBrush(QBrush(gradient2));
+ painter.drawEllipse(ellipseRect);
+ painter.end();
+}
diff --git a/doc/codesnippets/doc/src/snippets/qlineargradient/paintwidget.h b/doc/codesnippets/doc/src/snippets/qlineargradient/paintwidget.h
new file mode 100644
index 000000000..a0fc94663
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qlineargradient/paintwidget.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PAINTWIDGET_H
+#define PAINTWIDGET_H
+
+#include <QWidget>
+
+class QPaintEvent;
+
+class PaintWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ PaintWidget(QWidget *parent = 0);
+
+protected:
+ void paintEvent(QPaintEvent *event);
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/qlineargradient/qlineargradient.pro b/doc/codesnippets/doc/src/snippets/qlineargradient/qlineargradient.pro
new file mode 100644
index 000000000..48c7d9e93
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qlineargradient/qlineargradient.pro
@@ -0,0 +1,3 @@
+HEADERS = paintwidget.h
+SOURCES = main.cpp \
+ paintwidget.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qlistview-dnd/main.cpp b/doc/codesnippets/doc/src/snippets/qlistview-dnd/main.cpp
new file mode 100644
index 000000000..af1e7d5ac
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qlistview-dnd/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/qlistview-dnd/mainwindow.cpp b/doc/codesnippets/doc/src/snippets/qlistview-dnd/mainwindow.cpp
new file mode 100644
index 000000000..41ec16073
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qlistview-dnd/mainwindow.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+#include "model.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ menuBar()->addMenu(fileMenu);
+
+// For convenient quoting:
+//! [0]
+QListView *listView = new QListView(this);
+listView->setSelectionMode(QAbstractItemView::ExtendedSelection);
+listView->setDragEnabled(true);
+listView->setAcceptDrops(true);
+listView->setDropIndicatorShown(true);
+//! [0]
+
+ this->listView = listView;
+
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+
+ setupListItems();
+
+ setCentralWidget(listView);
+ setWindowTitle(tr("List View"));
+}
+
+void MainWindow::setupListItems()
+{
+ QStringList items;
+ items << tr("Oak") << tr("Fir") << tr("Pine") << tr("Birch") << tr("Hazel")
+ << tr("Redwood") << tr("Sycamore") << tr("Chestnut")
+ << tr("Mahogany");
+
+ DragDropListModel *model = new DragDropListModel(items, this);
+ listView->setModel(model);
+}
diff --git a/doc/codesnippets/doc/src/snippets/qlistview-dnd/mainwindow.h b/doc/codesnippets/doc/src/snippets/qlistview-dnd/mainwindow.h
new file mode 100644
index 000000000..5a7773ef3
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qlistview-dnd/mainwindow.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+
+class QListView;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+private:
+ void setupListItems();
+
+ QListView *listView;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/qlistview-dnd/model.cpp b/doc/codesnippets/doc/src/snippets/qlistview-dnd/model.cpp
new file mode 100644
index 000000000..1b9130958
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qlistview-dnd/model.cpp
@@ -0,0 +1,168 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of an example program for Qt.
+** EDITIONS: NOLIMITS
+**
+****************************************************************************/
+
+/*
+ model.cpp
+
+ A simple model that uses a QStringList as its data source.
+*/
+
+#include <QtGui>
+
+#include "model.h"
+
+DragDropListModel::DragDropListModel(const QStringList &strings,
+ QObject *parent)
+ : QStringListModel(strings, parent)
+{
+}
+
+//! [0]
+bool DragDropListModel::dropMimeData(const QMimeData *data,
+ Qt::DropAction action, int row, int column, const QModelIndex &parent)
+{
+ if (action == Qt::IgnoreAction)
+ return true;
+
+ if (!data->hasFormat("application/vnd.text.list"))
+ return false;
+
+ if (column > 0)
+//! [0] //! [1]
+ return false;
+//! [1]
+
+//! [2]
+ int beginRow;
+
+ if (row != -1)
+ beginRow = row;
+//! [2] //! [3]
+ else if (parent.isValid())
+ beginRow = parent.row();
+//! [3] //! [4]
+ else
+ beginRow = rowCount(QModelIndex());
+//! [4]
+
+//! [5]
+ QByteArray encodedData = data->data("application/vnd.text.list");
+ QDataStream stream(&encodedData, QIODevice::ReadOnly);
+ QStringList newItems;
+ int rows = 0;
+
+ while (!stream.atEnd()) {
+ QString text;
+ stream >> text;
+ newItems << text;
+ ++rows;
+ }
+//! [5]
+
+//! [6]
+ insertRows(beginRow, rows, QModelIndex());
+ foreach (QString text, newItems) {
+ QModelIndex idx = index(beginRow, 0, QModelIndex());
+ setData(idx, text);
+ beginRow++;
+ }
+
+ return true;
+}
+//! [6]
+
+//! [7]
+Qt::ItemFlags DragDropListModel::flags(const QModelIndex &index) const
+{
+ Qt::ItemFlags defaultFlags = QStringListModel::flags(index);
+
+ if (index.isValid())
+ return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags;
+ else
+ return Qt::ItemIsDropEnabled | defaultFlags;
+}
+//! [7]
+
+//! [8]
+QMimeData *DragDropListModel::mimeData(const QModelIndexList &indexes) const
+{
+ QMimeData *mimeData = new QMimeData();
+ QByteArray encodedData;
+
+ QDataStream stream(&encodedData, QIODevice::WriteOnly);
+
+ foreach (QModelIndex index, indexes) {
+ if (index.isValid()) {
+ QString text = data(index, Qt::DisplayRole).toString();
+ stream << text;
+ }
+ }
+
+ mimeData->setData("application/vnd.text.list", encodedData);
+ return mimeData;
+}
+//! [8]
+
+//! [9]
+QStringList DragDropListModel::mimeTypes() const
+{
+ QStringList types;
+ types << "application/vnd.text.list";
+ return types;
+}
+//! [9]
+
+//! [10]
+Qt::DropActions DragDropListModel::supportedDropActions() const
+{
+ return Qt::CopyAction | Qt::MoveAction;
+}
+//! [10]
diff --git a/doc/codesnippets/doc/src/snippets/qlistview-dnd/model.h b/doc/codesnippets/doc/src/snippets/qlistview-dnd/model.h
new file mode 100644
index 000000000..2ecf447f2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qlistview-dnd/model.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of an example program for Qt.
+** EDITIONS: NOLIMITS
+**
+****************************************************************************/
+
+#ifndef MODEL_H
+#define MODEL_H
+
+#include <QObject>
+#include <QStringListModel>
+
+class DragDropListModel : public QStringListModel
+{
+ Q_OBJECT
+
+public:
+ DragDropListModel(const QStringList &strings, QObject *parent = 0);
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+
+ bool dropMimeData(const QMimeData *data, Qt::DropAction action,
+ int row, int column, const QModelIndex &parent);
+ QMimeData *mimeData(const QModelIndexList &indexes) const;
+ QStringList mimeTypes() const;
+ Qt::DropActions supportedDropActions() const;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/qlistview-dnd/qlistview-dnd.pro b/doc/codesnippets/doc/src/snippets/qlistview-dnd/qlistview-dnd.pro
new file mode 100644
index 000000000..71fa273a6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qlistview-dnd/qlistview-dnd.pro
@@ -0,0 +1,5 @@
+SOURCES = main.cpp \
+ mainwindow.cpp \
+ model.cpp
+HEADERS = mainwindow.h \
+ model.h
diff --git a/doc/codesnippets/doc/src/snippets/qlistview-using/main.cpp b/doc/codesnippets/doc/src/snippets/qlistview-using/main.cpp
new file mode 100644
index 000000000..af1e7d5ac
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qlistview-using/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/qlistview-using/mainwindow.cpp b/doc/codesnippets/doc/src/snippets/qlistview-using/mainwindow.cpp
new file mode 100644
index 000000000..108547b34
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qlistview-using/mainwindow.cpp
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+#include "model.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);
+
+ QStringList strings;
+ strings << tr("Oak") << tr("Fir") << tr("Pine") << tr("Birch")
+ << tr("Hazel") << tr("Redwood") << tr("Sycamore") << tr("Chestnut");
+ model = new StringListModel(strings, this);
+/* For convenient quoting:
+ QListView *listView = new QListView(this);
+*/
+ listView = new QListView(this);
+ listView->setModel(model);
+ listView->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(listView->selectionModel(),
+ SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
+ this, SLOT(updateMenus(const QModelIndex &)));
+
+ updateMenus(listView->selectionModel()->currentIndex());
+
+ setCentralWidget(listView);
+ setWindowTitle(tr("List View"));
+}
+
+void MainWindow::sortAscending()
+{
+ model->sort(0, Qt::AscendingOrder);
+}
+
+void MainWindow::sortDescending()
+{
+ model->sort(0, Qt::DescendingOrder);
+}
+
+void MainWindow::insertItem()
+{
+ QModelIndex currentIndex = listView->currentIndex();
+ if (!currentIndex.isValid())
+ return;
+
+ QString itemText = QInputDialog::getText(this, tr("Insert Item"),
+ tr("Input text for the new item:"));
+
+ if (itemText.isNull())
+ return;
+
+ if (model->insertRow(currentIndex.row(), QModelIndex())) {
+ QModelIndex newIndex = model->index(currentIndex.row(), 0, QModelIndex());
+ model->setData(newIndex, itemText, Qt::EditRole);
+
+ QString toolTipText = tr("Tooltip:") + itemText;
+ QString statusTipText = tr("Status tip:") + itemText;
+ QString whatsThisText = tr("What's This?:") + itemText;
+ model->setData(newIndex, toolTipText, Qt::ToolTipRole);
+ model->setData(newIndex, toolTipText, Qt::StatusTipRole);
+ model->setData(newIndex, whatsThisText, Qt::WhatsThisRole);
+ }
+}
+
+void MainWindow::removeItem()
+{
+ QModelIndex currentIndex = listView->currentIndex();
+ if (!currentIndex.isValid())
+ return;
+
+ model->removeRow(currentIndex.row(), QModelIndex());
+}
+
+void MainWindow::updateMenus(const QModelIndex &current)
+{
+ insertAction->setEnabled(current.isValid());
+ removeAction->setEnabled(current.isValid());
+}
diff --git a/doc/codesnippets/doc/src/snippets/qlistview-using/mainwindow.h b/doc/codesnippets/doc/src/snippets/qlistview-using/mainwindow.h
new file mode 100644
index 000000000..9333a0e18
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qlistview-using/mainwindow.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+#include <QModelIndex>
+
+class QAction;
+class QListView;
+class StringListModel;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void insertItem();
+ void removeItem();
+ void sortAscending();
+ void sortDescending();
+ void updateMenus(const QModelIndex &current);
+
+private:
+ QAction *insertAction;
+ QAction *removeAction;
+ QListView *listView;
+ StringListModel *model;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/qlistview-using/model.cpp b/doc/codesnippets/doc/src/snippets/qlistview-using/model.cpp
new file mode 100644
index 000000000..7344b5142
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qlistview-using/model.cpp
@@ -0,0 +1,175 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of an example program for Qt.
+** EDITIONS: NOLIMITS
+**
+****************************************************************************/
+
+/*
+ model.cpp
+
+ A simple model that uses a QStringList as its data source.
+*/
+
+#include "model.h"
+
+/*!
+ Returns the number of items in the string list as the number of rows
+ in the model.
+*/
+
+int StringListModel::rowCount(const QModelIndex &parent) const
+{
+ return stringList.count();
+}
+
+/*!
+ Returns an appropriate value for the requested data.
+ If the view requests an invalid index, an invalid variant is returned.
+ Any valid index that corresponds to a string in the list causes that
+ string to be returned.
+*/
+
+QVariant StringListModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ if (index.row() >= stringList.size())
+ return QVariant();
+
+ if (role == Qt::DisplayRole)
+ return stringList.at(index.row());
+ else
+ return QVariant();
+}
+
+/*!
+ Returns the appropriate header string depending on the orientation of
+ the header and the section. If anything other than the display role is
+ requested, we return an invalid variant.
+*/
+
+QVariant StringListModel::headerData(int section, Qt::Orientation orientation,
+ int role) const
+{
+ if (role != Qt::DisplayRole)
+ return QVariant();
+
+ if (orientation == Qt::Horizontal)
+ return QString("Column %1").arg(section);
+ else
+ return QString("Row %1").arg(section);
+}
+
+/*!
+ Returns an appropriate value for the item's flags. Valid items are
+ enabled, selectable, and editable.
+*/
+
+Qt::ItemFlags StringListModel::flags(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return Qt::ItemIsEnabled;
+
+ return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
+}
+
+/*!
+ Changes an item in the string list, but only if the following conditions
+ are met:
+
+ * The index supplied is valid.
+ * The index corresponds to an item to be shown in a view.
+ * The role associated with editing text is specified.
+
+ The dataChanged() signal is emitted if the item is changed.
+*/
+
+bool StringListModel::setData(const QModelIndex &index,
+ const QVariant &value, int role)
+{
+ if (index.isValid() && role == Qt::EditRole) {
+
+ stringList.replace(index.row(), value.toString());
+ emit dataChanged(index, index);
+ return true;
+ }
+ return false;
+}
+
+/*!
+ Inserts a number of rows into the model at the specified position.
+*/
+
+bool StringListModel::insertRows(int position, int rows, const QModelIndex &parent)
+{
+ beginInsertRows(QModelIndex(), position, position+rows-1);
+
+ for (int row = 0; row < rows; ++row) {
+ stringList.insert(position, "");
+ }
+
+ endInsertRows();
+ return true;
+}
+
+/*!
+ Removes a number of rows from the model at the specified position.
+*/
+
+bool StringListModel::removeRows(int position, int rows, const QModelIndex &parent)
+{
+ beginRemoveRows(QModelIndex(), position, position+rows-1);
+
+ for (int row = 0; row < rows; ++row) {
+ stringList.removeAt(position);
+ }
+
+ endRemoveRows();
+ return true;
+}
diff --git a/doc/codesnippets/doc/src/snippets/qlistview-using/model.h b/doc/codesnippets/doc/src/snippets/qlistview-using/model.h
new file mode 100644
index 000000000..9f5818c6c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qlistview-using/model.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of an example program for Qt.
+** EDITIONS: NOLIMITS
+**
+****************************************************************************/
+
+#ifndef MODEL_H
+#define MODEL_H
+
+#include <QAbstractListModel>
+#include <QObject>
+#include <QStringList>
+
+class StringListModel : public QAbstractListModel
+{
+ Q_OBJECT
+
+public:
+ StringListModel(const QStringList &strings, QObject *parent = 0)
+ : QAbstractListModel(parent), stringList(strings) {}
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = Qt::EditRole);
+
+ bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex());
+ bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex());
+
+private:
+ QStringList stringList;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/qlistview-using/qlistview-using.pro b/doc/codesnippets/doc/src/snippets/qlistview-using/qlistview-using.pro
new file mode 100644
index 000000000..71fa273a6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qlistview-using/qlistview-using.pro
@@ -0,0 +1,5 @@
+SOURCES = main.cpp \
+ mainwindow.cpp \
+ model.cpp
+HEADERS = mainwindow.h \
+ model.h
diff --git a/doc/codesnippets/doc/src/snippets/qlistwidget-dnd/main.cpp b/doc/codesnippets/doc/src/snippets/qlistwidget-dnd/main.cpp
new file mode 100644
index 000000000..af1e7d5ac
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qlistwidget-dnd/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/qlistwidget-dnd/mainwindow.cpp b/doc/codesnippets/doc/src/snippets/qlistwidget-dnd/mainwindow.cpp
new file mode 100644
index 000000000..080ecb489
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qlistwidget-dnd/mainwindow.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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"));
+
+ menuBar()->addMenu(fileMenu);
+
+// For convenient quoting:
+//! [0]
+QListWidget *listWidget = new QListWidget(this);
+listWidget->setSelectionMode(QAbstractItemView::SingleSelection);
+listWidget->setDragEnabled(true);
+listWidget->viewport()->setAcceptDrops(true);
+listWidget->setDropIndicatorShown(true);
+//! [0] //! [1]
+listWidget->setDragDropMode(QAbstractItemView::InternalMove);
+//! [1]
+
+ this->listWidget = listWidget;
+
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+
+ setupListItems();
+
+ setCentralWidget(listWidget);
+ setWindowTitle(tr("List Widget"));
+}
+
+void MainWindow::setupListItems()
+{
+ QListWidgetItem *item;
+ item = new QListWidgetItem(tr("Oak"), listWidget);
+ item = new QListWidgetItem(tr("Fir"), listWidget);
+ item = new QListWidgetItem(tr("Pine"), listWidget);
+ item = new QListWidgetItem(tr("Birch"), listWidget);
+ item = new QListWidgetItem(tr("Hazel"), listWidget);
+ item = new QListWidgetItem(tr("Redwood"), listWidget);
+ item = new QListWidgetItem(tr("Sycamore"), listWidget);
+ item = new QListWidgetItem(tr("Chestnut"), listWidget);
+ item = new QListWidgetItem(tr("Mahogany"), listWidget);
+}
diff --git a/doc/codesnippets/doc/src/snippets/qlistwidget-dnd/mainwindow.h b/doc/codesnippets/doc/src/snippets/qlistwidget-dnd/mainwindow.h
new file mode 100644
index 000000000..c68454d97
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qlistwidget-dnd/mainwindow.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+
+class QListWidget;
+class QListWidgetItem;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+private:
+ void setupListItems();
+
+ QListWidget *listWidget;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/qlistwidget-dnd/qlistwidget-dnd.pro b/doc/codesnippets/doc/src/snippets/qlistwidget-dnd/qlistwidget-dnd.pro
new file mode 100644
index 000000000..12a900a7c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qlistwidget-dnd/qlistwidget-dnd.pro
@@ -0,0 +1,3 @@
+SOURCES = main.cpp \
+ mainwindow.cpp
+HEADERS = mainwindow.h
diff --git a/doc/codesnippets/doc/src/snippets/qlistwidget-using/main.cpp b/doc/codesnippets/doc/src/snippets/qlistwidget-using/main.cpp
new file mode 100644
index 000000000..af1e7d5ac
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qlistwidget-using/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/qlistwidget-using/mainwindow.cpp b/doc/codesnippets/doc/src/snippets/qlistwidget-using/mainwindow.cpp
new file mode 100644
index 000000000..b8df442b5
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qlistwidget-using/mainwindow.cpp
@@ -0,0 +1,159 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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]
+ listWidget = QListWidget(self)
+//! [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]
+ QListWidgetItem(tr("Oak"), listWidget)
+ QListWidgetItem(tr("Fir"), listWidget)
+ QListWidgetItem(tr("Pine"), listWidget)
+//! [1]
+ new QListWidgetItem(tr("Birch"), listWidget);
+//! [2]
+ QListWidgetItem(tr("Hazel"), listWidget)
+//! [2]
+ new QListWidgetItem(tr("Redwood"), listWidget);
+//! [3]
+ QListWidgetItem(tr("Sycamore"), listWidget)
+ QListWidgetItem(tr("Chestnut"), listWidget)
+ 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]
+ newItem = 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/codesnippets/doc/src/snippets/qlistwidget-using/mainwindow.h b/doc/codesnippets/doc/src/snippets/qlistwidget-using/mainwindow.h
new file mode 100644
index 000000000..dbc420a68
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qlistwidget-using/mainwindow.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+
+class QAction;
+class QListWidget;
+class QListWidgetItem;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void insertItem();
+ void removeItem();
+ void sortAscending();
+ void sortDescending();
+ void updateMenus(QListWidgetItem *current);
+
+private:
+ void setupListItems();
+
+ QAction *insertAction;
+ QAction *removeAction;
+ QListWidget *listWidget;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/qlistwidget-using/qlistwidget-using.pro b/doc/codesnippets/doc/src/snippets/qlistwidget-using/qlistwidget-using.pro
new file mode 100644
index 000000000..12a900a7c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qlistwidget-using/qlistwidget-using.pro
@@ -0,0 +1,3 @@
+SOURCES = main.cpp \
+ mainwindow.cpp
+HEADERS = mainwindow.h
diff --git a/doc/codesnippets/doc/src/snippets/qmacnativewidget/main.mm b/doc/codesnippets/doc/src/snippets/qmacnativewidget/main.mm
new file mode 100644
index 000000000..66c6fbfd6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmacnativewidget/main.mm
@@ -0,0 +1,94 @@
+#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/codesnippets/doc/src/snippets/qmacnativewidget/qmacnativewidget.pro b/doc/codesnippets/doc/src/snippets/qmacnativewidget/qmacnativewidget.pro
new file mode 100644
index 000000000..15176e189
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmacnativewidget/qmacnativewidget.pro
@@ -0,0 +1,8 @@
+######################################################################
+# Automatically generated by qmake (2.01a) Thu Sep 4 15:50:09 2008
+######################################################################
+
+CONFIG+=x86_64
+
+OBJECTIVE_SOURCES += main.mm
+LIBS += -framework Cocoa -framework Carbon
diff --git a/doc/codesnippets/doc/src/snippets/qmake/comments.pro b/doc/codesnippets/doc/src/snippets/qmake/comments.pro
new file mode 100644
index 000000000..189d271ed
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmake/comments.pro
@@ -0,0 +1,10 @@
+#! [0]
+# Comments usually start at the beginning of a line, but they
+# can also follow other content on the same line.
+#! [0]
+
+#! [1]
+# To include a literal hash character, use the $$LITERAL_HASH variable:
+urlPieces = http://doc.trolltech.com/4.0/qtextdocument.html pageCount
+message($$join(urlPieces, $$LITERAL_HASH))
+#! [1]
diff --git a/doc/codesnippets/doc/src/snippets/qmake/configscopes.pro b/doc/codesnippets/doc/src/snippets/qmake/configscopes.pro
new file mode 100644
index 000000000..6ab7f7c42
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmake/configscopes.pro
@@ -0,0 +1,23 @@
+SOURCES = main.cpp
+#! [0]
+CONFIG += opengl
+#! [0]
+
+#! [1]
+opengl {
+ TARGET = application-gl
+} else {
+#! [1] #! [2]
+ TARGET = application
+#! [2] #! [3]
+}
+#! [3]
+
+#! [4]
+CONFIG(opengl) {
+ message(Building with OpenGL support.)
+} else {
+#! [4] #! [5]
+ message(OpenGL support is not available.)
+}
+#! [5]
diff --git a/doc/codesnippets/doc/src/snippets/qmake/debug_and_release.pro b/doc/codesnippets/doc/src/snippets/qmake/debug_and_release.pro
new file mode 100644
index 000000000..92e8dbf76
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmake/debug_and_release.pro
@@ -0,0 +1,14 @@
+#! [0]
+CONFIG += debug_and_release
+
+CONFIG(debug, debug|release) {
+ TARGET = debug_binary
+} else {
+#! [0] #! [1]
+ TARGET = release_binary
+}
+#! [1]
+
+#! [2]
+CONFIG += build_all
+#! [2]
diff --git a/doc/codesnippets/doc/src/snippets/qmake/delegate.h b/doc/codesnippets/doc/src/snippets/qmake/delegate.h
new file mode 100644
index 000000000..5b0c64bb7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmake/delegate.h
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
diff --git a/doc/codesnippets/doc/src/snippets/qmake/dereferencing.pro b/doc/codesnippets/doc/src/snippets/qmake/dereferencing.pro
new file mode 100644
index 000000000..ff0c97995
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmake/dereferencing.pro
@@ -0,0 +1,5 @@
+#! [0]
+TEMP_SOURCES = $$SOURCES
+#! [0]
+# Do something with the SOURCES variable then restore its old value.
+SOURCES = $$TEMP_SOURCES
diff --git a/doc/codesnippets/doc/src/snippets/qmake/destdir.pro b/doc/codesnippets/doc/src/snippets/qmake/destdir.pro
new file mode 100644
index 000000000..b2f943904
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmake/destdir.pro
@@ -0,0 +1,2 @@
+SOURCES = main.cpp
+DESTDIR = output
diff --git a/doc/codesnippets/doc/src/snippets/qmake/dirname.pro b/doc/codesnippets/doc/src/snippets/qmake/dirname.pro
new file mode 100644
index 000000000..59e1f20b3
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmake/dirname.pro
@@ -0,0 +1,6 @@
+#! [0]
+FILE = /etc/X11R6/XF86Config
+DIRNAME = $$dirname(FILE) #/etc/X11R6
+#! [0]
+message($$FILE)
+message($$DIRNAME)
diff --git a/doc/codesnippets/doc/src/snippets/qmake/environment.pro b/doc/codesnippets/doc/src/snippets/qmake/environment.pro
new file mode 100644
index 000000000..808bdeba4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmake/environment.pro
@@ -0,0 +1,9 @@
+#! [0] #! [1]
+DESTDIR = $$(PWD)
+message(The project will be installed in $$DESTDIR)
+#! [0]
+
+DESTDIR = $(PWD)
+message(The project will be installed in the value of PWD)
+message(when the Makefile is processed.)
+#! [1]
diff --git a/doc/codesnippets/doc/src/snippets/qmake/functions.pro b/doc/codesnippets/doc/src/snippets/qmake/functions.pro
new file mode 100644
index 000000000..276612071
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmake/functions.pro
@@ -0,0 +1,34 @@
+#! [0]
+EXTRAS = handlers tests docs
+for(dir, EXTRAS) {
+ exists($$dir) {
+ SUBDIRS += $$dir
+ }
+}
+#! [0]
+
+SOURCES = paintwidget_mac.cpp paintwidget_unix.cpp paintwidget_win.cpp
+macx {
+ SOURCES = $$find(SOURCES, "_mac")
+}
+
+#! [1]
+HEADERS = model.h
+HEADERS += $$OTHER_HEADERS
+HEADERS = $$unique(HEADERS)
+#! [1]
+
+CONFIG += debug
+#! [2]
+options = $$find(CONFIG, "debug") $$find(CONFIG, "release")
+#! [3]
+count(options, 2) {
+ message(Both release and debug specified.)
+}
+#! [2] #! [3]
+
+#! [4]
+eval(TARGET = myapp) {
+ message($$TARGET)
+}
+#! [4]
diff --git a/doc/codesnippets/doc/src/snippets/qmake/include.pro b/doc/codesnippets/doc/src/snippets/qmake/include.pro
new file mode 100644
index 000000000..37e715695
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmake/include.pro
@@ -0,0 +1,3 @@
+#! [0]
+include(other.pro)
+#! [0]
diff --git a/doc/codesnippets/doc/src/snippets/qmake/main.cpp b/doc/codesnippets/doc/src/snippets/qmake/main.cpp
new file mode 100644
index 000000000..5b0c64bb7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmake/main.cpp
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
diff --git a/doc/codesnippets/doc/src/snippets/qmake/model.cpp b/doc/codesnippets/doc/src/snippets/qmake/model.cpp
new file mode 100644
index 000000000..5b0c64bb7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmake/model.cpp
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
diff --git a/doc/codesnippets/doc/src/snippets/qmake/model.h b/doc/codesnippets/doc/src/snippets/qmake/model.h
new file mode 100644
index 000000000..5b0c64bb7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmake/model.h
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
diff --git a/doc/codesnippets/doc/src/snippets/qmake/other.pro b/doc/codesnippets/doc/src/snippets/qmake/other.pro
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmake/other.pro
diff --git a/doc/codesnippets/doc/src/snippets/qmake/paintwidget_unix.cpp b/doc/codesnippets/doc/src/snippets/qmake/paintwidget_unix.cpp
new file mode 100644
index 000000000..406053f77
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmake/paintwidget_unix.cpp
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+int main(int argc, char *argv[])
+{
+ return 0;
+}
diff --git a/doc/codesnippets/doc/src/snippets/qmake/project_location.pro b/doc/codesnippets/doc/src/snippets/qmake/project_location.pro
new file mode 100644
index 000000000..09d9b3d9d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmake/project_location.pro
@@ -0,0 +1,6 @@
+#! [project file]
+message($$_PRO_FILE_)
+#! [project file]
+#! [project file directory]
+message($$_PRO_FILE_PWD_)
+#! [project file directory]
diff --git a/doc/codesnippets/doc/src/snippets/qmake/qtconfiguration.pro b/doc/codesnippets/doc/src/snippets/qmake/qtconfiguration.pro
new file mode 100644
index 000000000..0c854d93a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmake/qtconfiguration.pro
@@ -0,0 +1,19 @@
+# Show information about the Qt installation.
+#! [0]
+message(Qt version: $$[QT_VERSION])
+message(Qt is installed in $$[QT_INSTALL_PREFIX])
+message(Qt resources can be found in the following locations:)
+message(Documentation: $$[QT_INSTALL_DOCS])
+message(Header files: $$[QT_INSTALL_HEADERS])
+message(Libraries: $$[QT_INSTALL_LIBS])
+message(Binary files (executables): $$[QT_INSTALL_BINS])
+message(Plugins: $$[QT_INSTALL_PLUGINS])
+message(Data files: $$[QT_INSTALL_DATA])
+message(Translation files: $$[QT_INSTALL_TRANSLATIONS])
+message(Settings: $$[QT_INSTALL_SETTINGS])
+message(Examples: $$[QT_INSTALL_EXAMPLES])
+message(Demonstrations: $$[QT_INSTALL_DEMOS])
+#! [0]
+
+# Show configuration information.
+message(CONFIG = $$CONFIG)
diff --git a/doc/codesnippets/doc/src/snippets/qmake/quoting.pro b/doc/codesnippets/doc/src/snippets/qmake/quoting.pro
new file mode 100644
index 000000000..62efb2042
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmake/quoting.pro
@@ -0,0 +1,8 @@
+#! [0]
+DEST = "Program Files"
+#! [0]
+count(DEST, 1) {
+ message(Only one item found in DEST.)
+} else {
+ message(More than one item found in DEST.)
+}
diff --git a/doc/codesnippets/doc/src/snippets/qmake/replace.pro b/doc/codesnippets/doc/src/snippets/qmake/replace.pro
new file mode 100644
index 000000000..504e01a01
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmake/replace.pro
@@ -0,0 +1,4 @@
+#! [0]
+MESSAGE = This is a tent.
+message($$replace(MESSAGE, tent, test))
+#! [0]
diff --git a/doc/codesnippets/doc/src/snippets/qmake/replacefunction.pro b/doc/codesnippets/doc/src/snippets/qmake/replacefunction.pro
new file mode 100644
index 000000000..98013ba42
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmake/replacefunction.pro
@@ -0,0 +1,46 @@
+#! [0]
+defineReplace(headersAndSources) {
+ variable = $$1
+ names = $$eval($$variable)
+ headers =
+ sources =
+
+ for(name, names) {
+ header = $${name}.h
+ exists($$header) {
+ headers += $$header
+ }
+ source = $${name}.cpp
+ exists($$source) {
+ sources += $$source
+ }
+ }
+ return($$headers $$sources)
+}
+#! [0]
+
+defineReplace(matchingFiles) {
+ names = $$ARGS
+ files =
+
+ for(name, names) {
+ header = $${name}.h
+ source = $${name}.cpp
+ exists($$header):exists($$source) {
+ files += $$header
+ files += $$source
+ }
+ }
+ return($$files)
+}
+
+names = delegate model view main
+message(Finding all headers and sources from the following list of names:)
+message($$names)
+allFiles = $$headersAndSources(names)
+message(Found: $$allFiles)
+
+message(Finding only matching headers and sources from the following list of names:)
+message($$names)
+matching = $$matchingFiles($$names)
+message(Found: $$matching)
diff --git a/doc/codesnippets/doc/src/snippets/qmake/scopes.pro b/doc/codesnippets/doc/src/snippets/qmake/scopes.pro
new file mode 100644
index 000000000..4e59afbac
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmake/scopes.pro
@@ -0,0 +1,42 @@
+#! [syntax]
+<condition> {
+ <command or definition>
+ ...
+}
+#! [syntax]
+
+#! [0]
+win32 {
+ SOURCES += paintwidget_win.cpp
+}
+#! [0]
+
+#! [1]
+!win32 {
+ SOURCES -= paintwidget_win.cpp
+}
+#! [1]
+
+unix {
+ SOURCES += paintwidget_unix.cpp
+}
+
+#! [2]
+macx {
+ debug {
+ HEADERS += debugging.h
+ }
+}
+#! [2]
+
+#! [3]
+macx:debug {
+ HEADERS += debugging.h
+}
+#! [3]
+
+#! [4]
+win32|macx {
+ HEADERS += debugging.h
+}
+#! [4]
diff --git a/doc/codesnippets/doc/src/snippets/qmake/shared_or_static.pro b/doc/codesnippets/doc/src/snippets/qmake/shared_or_static.pro
new file mode 100644
index 000000000..31c25ea44
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmake/shared_or_static.pro
@@ -0,0 +1,8 @@
+TEMPLIBS = $$[QT_INSTALL_LIBS] libQtGui.prl
+include($$join(TEMPLIBS, "/"))
+
+contains(QMAKE_PRL_CONFIG, shared) {
+ message(Shared Qt)
+} else {
+ message(Static Qt)
+}
diff --git a/doc/codesnippets/doc/src/snippets/qmake/specifications.pro b/doc/codesnippets/doc/src/snippets/qmake/specifications.pro
new file mode 100644
index 000000000..f9a0d0a1c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmake/specifications.pro
@@ -0,0 +1,7 @@
+#! [0]
+message($$QMAKESPEC)
+
+linux-g++ {
+ message(Linux)
+}
+#! [0]
diff --git a/doc/codesnippets/doc/src/snippets/qmake/testfunction.pro b/doc/codesnippets/doc/src/snippets/qmake/testfunction.pro
new file mode 100644
index 000000000..785ffed6b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmake/testfunction.pro
@@ -0,0 +1,20 @@
+#! [0]
+defineTest(allFiles) {
+ files = $$ARGS
+
+ for(file, files) {
+ !exists($$file) {
+ return(false)
+ }
+ }
+ return(true)
+}
+#! [0]
+
+files = delegate.h model.h view.h
+
+allFiles($$files) {
+ message(All files are present: $$files)
+} else {
+ message(Not all files are present: $$files)
+}
diff --git a/doc/codesnippets/doc/src/snippets/qmake/variables.pro b/doc/codesnippets/doc/src/snippets/qmake/variables.pro
new file mode 100644
index 000000000..bba5d9f72
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmake/variables.pro
@@ -0,0 +1,7 @@
+#! [0]
+HEADERS = mainwindow.h paintwidget.h
+#! [0] #! [1]
+SOURCES = main.cpp mainwindow.cpp \
+ paintwidget.cpp
+CONFIG += qt
+#! [1]
diff --git a/doc/codesnippets/doc/src/snippets/qmake/view.h b/doc/codesnippets/doc/src/snippets/qmake/view.h
new file mode 100644
index 000000000..5b0c64bb7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmake/view.h
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
diff --git a/doc/codesnippets/doc/src/snippets/qmetaobject-invokable/main.cpp b/doc/codesnippets/doc/src/snippets/qmetaobject-invokable/main.cpp
new file mode 100644
index 000000000..e2fdf13cf
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmetaobject-invokable/main.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QDebug>
+#include "window.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Window window;
+ qDebug() << window.metaObject()->methodCount();
+ window.show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/qmetaobject-invokable/qmetaobject-invokable.pro b/doc/codesnippets/doc/src/snippets/qmetaobject-invokable/qmetaobject-invokable.pro
new file mode 100644
index 000000000..4df19215f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmetaobject-invokable/qmetaobject-invokable.pro
@@ -0,0 +1,3 @@
+HEADERS = window.h
+SOURCES = main.cpp \
+ window.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qmetaobject-invokable/window.cpp b/doc/codesnippets/doc/src/snippets/qmetaobject-invokable/window.cpp
new file mode 100644
index 000000000..c48002173
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmetaobject-invokable/window.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "window.h"
+
+Window::Window()
+{
+}
+
+void Window::normalMethod()
+{
+ // Cannot be called by the meta-object system.
+ show();
+}
+
+void Window::invokableMethod()
+{
+ // Can be called by the meta-object system.
+ show();
+}
diff --git a/doc/codesnippets/doc/src/snippets/qmetaobject-invokable/window.h b/doc/codesnippets/doc/src/snippets/qmetaobject-invokable/window.h
new file mode 100644
index 000000000..c45d00ba2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qmetaobject-invokable/window.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QWidget>
+
+//! [Window class with invokable method]
+class Window : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Window();
+ void normalMethod();
+ Q_INVOKABLE void invokableMethod();
+};
+//! [Window class with invokable method]
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/qprocess-environment/main.cpp b/doc/codesnippets/doc/src/snippets/qprocess-environment/main.cpp
new file mode 100644
index 000000000..ed49da3e8
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qprocess-environment/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore>
+
+void startProcess()
+{
+//! [0]
+process = QProcess()
+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]
+}
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication app(argc, argv);
+ startProcess();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/qprocess-environment/qprocess-environment.pro b/doc/codesnippets/doc/src/snippets/qprocess-environment/qprocess-environment.pro
new file mode 100644
index 000000000..bba41b9c1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qprocess-environment/qprocess-environment.pro
@@ -0,0 +1 @@
+SOURCES = main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qprocess/qprocess-simpleexecution.cpp b/doc/codesnippets/doc/src/snippets/qprocess/qprocess-simpleexecution.cpp
new file mode 100644
index 000000000..09bb7cac8
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qprocess/qprocess-simpleexecution.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QtGui>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+//! [0]
+ ...
+//! [0]
+ parent = &app;
+
+//! [1]
+ program = QString("./path/to/Qt/examples/widgets/analogclock")
+//! [1]
+ program = "./../../../../examples/widgets/analogclock/analogclock";
+
+//! [2]
+ arguments = QStringList()
+ arguments << "-style" << "motif"
+
+ myProcess = QProcess(parent)
+ myProcess.start(program, arguments)
+//! [2]
+
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/qprocess/qprocess.pro b/doc/codesnippets/doc/src/snippets/qprocess/qprocess.pro
new file mode 100644
index 000000000..4dbc42903
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qprocess/qprocess.pro
@@ -0,0 +1,11 @@
+######################################################################
+# Automatically generated by qmake (2.00a) Mon Mar 20 17:17:02 2006
+######################################################################
+
+TEMPLATE = app
+TARGET +=
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+SOURCES += qprocess-simpleexecution.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qsignalmapper/buttonwidget.cpp b/doc/codesnippets/doc/src/snippets/qsignalmapper/buttonwidget.cpp
new file mode 100644
index 000000000..cc4e12de4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qsignalmapper/buttonwidget.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "buttonwidget.h"
+
+//! [0]
+
+def __init__(self, texts, parent):
+ QWidget.__init__(self, parent)
+
+ self.signalMapper = QSignalMapper(self)
+
+ layout = QGridLayout()
+
+ for text, index in enumerate(texts):
+ button = QPushButton(text)
+ self.connect(SIGNAL("clicked()"), self.signalMapper, SLOT("map()"))
+//! [0] //! [1]
+ self.signalMapper.setMapping(button, text)
+ layout.addWidget(button, index / 3, index % 3)
+
+ self.signalMapper.connect(SIGNAL("mapped(const QString &)"),
+//! [1] //! [2]
+ self, SLOT("clicked(const QString &)"))
+
+ self.setLayout(layout)
+
+//! [2]
diff --git a/doc/codesnippets/doc/src/snippets/qsignalmapper/buttonwidget.h b/doc/codesnippets/doc/src/snippets/qsignalmapper/buttonwidget.h
new file mode 100644
index 000000000..60712941a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qsignalmapper/buttonwidget.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef BUTTONWIDGET_H
+#define BUTTONWIDGET_H
+
+#include <qwidget.h>
+
+class QSignalMapper;
+class QString;
+class QStringList;
+
+//! [0]
+
+class ButtonWidget(QWidget):
+ def __init__(self, texts, parent=None):
+ QWidget.__init__(self, parent)
+ ...
+//! [0] //! [1]
+
+//! [1]
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/qsignalmapper/main.cpp b/doc/codesnippets/doc/src/snippets/qsignalmapper/main.cpp
new file mode 100644
index 000000000..7c8f6eca5
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qsignalmapper/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+
+#include "buttonwidget.h"
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QStringList texts;
+ texts << "January" << "February" << "March" << "April"
+ << "May" << "June" << "July" << "August"
+ << "September" << "October" << "November"
+ << "December";
+ MainWindow *mw = new MainWindow;
+ ButtonWidget *buttons = new ButtonWidget(texts, mw);
+ mw->setCentralWidget(buttons);
+ mw->show();
+ QObject::connect(buttons, SIGNAL(clicked(const QString &)),
+ mw, SLOT(buttonPressed(const QString &)));
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/qsignalmapper/mainwindow.h b/doc/codesnippets/doc/src/snippets/qsignalmapper/mainwindow.h
new file mode 100644
index 000000000..585a96450
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qsignalmapper/mainwindow.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QMainWindow>
+#include <QStatusBar>
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow()
+ {
+ statusBar()->showMessage(tr("Ready"));
+ }
+
+public slots:
+ void buttonPressed(const QString &text)
+ {
+ statusBar()->showMessage(tr("Chose %1").arg(text));
+ }
+};
diff --git a/doc/codesnippets/doc/src/snippets/qsignalmapper/qsignalmapper.pro b/doc/codesnippets/doc/src/snippets/qsignalmapper/qsignalmapper.pro
new file mode 100644
index 000000000..7c314025b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qsignalmapper/qsignalmapper.pro
@@ -0,0 +1,10 @@
+######################################################################
+# Automatically generated by qmake (1.08a) Wed Mar 10 15:35:05 2004
+######################################################################
+
+TEMPLATE = app
+INCLUDEPATH += .
+
+# Input
+HEADERS += buttonwidget.h mainwindow.h
+SOURCES += buttonwidget.cpp main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qsortfilterproxymodel-details/main.cpp b/doc/codesnippets/doc/src/snippets/qsortfilterproxymodel-details/main.cpp
new file mode 100644
index 000000000..8248a99c6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qsortfilterproxymodel-details/main.cpp
@@ -0,0 +1,70 @@
+############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Nokia Corporation (qt-info@nokia.com)
+##
+## This file is part of the documentation of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at http://www.qtsoftware.com/contact.
+## $QT_END_LICENSE$
+##
+############################################################################
+
+
+//! [0] //! [1]
+ treeView = QTreeView()
+//! [0]
+ model = MyItemModel(self)
+
+ treeView.setModel(model)
+//! [1]
+
+//! [2]
+ sourceModel = MyItemModel(self)
+ proxyModel = QSortFilterProxyModel(self)
+
+ 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]
+
diff --git a/doc/codesnippets/doc/src/snippets/qsortfilterproxymodel-details/qsortfilterproxymodel-details.pro b/doc/codesnippets/doc/src/snippets/qsortfilterproxymodel-details/qsortfilterproxymodel-details.pro
new file mode 100644
index 000000000..bba41b9c1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qsortfilterproxymodel-details/qsortfilterproxymodel-details.pro
@@ -0,0 +1 @@
+SOURCES = main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qsortfilterproxymodel/main.cpp b/doc/codesnippets/doc/src/snippets/qsortfilterproxymodel/main.cpp
new file mode 100644
index 000000000..710b1b0c5
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qsortfilterproxymodel/main.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QObject *parent = &app;
+
+ QStringList numbers;
+ numbers << "One" << "Two" << "Three" << "Four" << "Five";
+
+ QAbstractItemModel *stringListModel = new QStringListModel(numbers, parent);
+
+//! [0]
+ QSortFilterProxyModel *filterModel = new QSortFilterProxyModel(parent);
+ filterModel->setSourceModel(stringListModel);
+//! [0]
+
+ QWidget *window = new QWidget;
+
+//! [1]
+ QListView *filteredView = new QListView;
+ filteredView->setModel(filterModel);
+//! [1]
+ filteredView->setWindowTitle("Filtered view onto a string list model");
+
+ QLineEdit *patternEditor = new QLineEdit;
+ QObject::
+ connect(patternEditor, SIGNAL(textChanged(const QString &)),
+ filterModel, SLOT(setFilterRegExp(const QString &)));
+
+ QVBoxLayout *layout = new QVBoxLayout(window);
+ layout->addWidget(filteredView);
+ layout->addWidget(patternEditor);
+
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/qsortfilterproxymodel/qsortfilterproxymodel.pro b/doc/codesnippets/doc/src/snippets/qsortfilterproxymodel/qsortfilterproxymodel.pro
new file mode 100644
index 000000000..16181f21c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qsortfilterproxymodel/qsortfilterproxymodel.pro
@@ -0,0 +1 @@
+SOURCES = main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qsplashscreen/main.cpp b/doc/codesnippets/doc/src/snippets/qsplashscreen/main.cpp
new file mode 100644
index 000000000..1e4895316
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qsplashscreen/main.cpp
@@ -0,0 +1,57 @@
+############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Nokia Corporation (qt-info@nokia.com)
+##
+## This file is part of the documentation of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at http://www.qtsoftware.com/contact.
+## $QT_END_LICENSE$
+##
+############################################################################
+
+
+//! [0]
+def main():
+ app = QApplication(sys.argv)
+ pixmap = QPixmap(":/splash.png")
+ splash = QSplashScreen(pixmap)
+ splash.show()
+ app.processEvents()
+//! [0]
+
+//! [1]
+ window = QMainWindow()
+ window.show()
+ splash.finish(&window)
+ return app.exec_()
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/qsplashscreen/mainwindow.cpp b/doc/codesnippets/doc/src/snippets/qsplashscreen/mainwindow.cpp
new file mode 100644
index 000000000..a5b7cd5fd
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qsplashscreen/mainwindow.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ QLabel *label = new QLabel(tr("This is the main window."));
+ label->setAlignment(Qt::AlignCenter);
+ setCentralWidget(label);
+}
diff --git a/doc/codesnippets/doc/src/snippets/qsplashscreen/mainwindow.h b/doc/codesnippets/doc/src/snippets/qsplashscreen/mainwindow.h
new file mode 100644
index 000000000..61074daf1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qsplashscreen/mainwindow.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/qsplashscreen/qsplashscreen.pro b/doc/codesnippets/doc/src/snippets/qsplashscreen/qsplashscreen.pro
new file mode 100644
index 000000000..c79807987
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qsplashscreen/qsplashscreen.pro
@@ -0,0 +1,4 @@
+HEADERS = mainwindow.h
+RESOURCES = qsplashscreen.qrc
+SOURCES = main.cpp \
+ mainwindow.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qsplashscreen/qsplashscreen.qrc b/doc/codesnippets/doc/src/snippets/qsplashscreen/qsplashscreen.qrc
new file mode 100644
index 000000000..330ec7868
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qsplashscreen/qsplashscreen.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>splash.png</file>
+</qresource>
+</RCC>
diff --git a/doc/codesnippets/doc/src/snippets/qsplashscreen/splash.png b/doc/codesnippets/doc/src/snippets/qsplashscreen/splash.png
new file mode 100644
index 000000000..d82f6d218
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qsplashscreen/splash.png
Binary files differ
diff --git a/doc/codesnippets/doc/src/snippets/qsql-namespace/main.cpp b/doc/codesnippets/doc/src/snippets/qsql-namespace/main.cpp
new file mode 100644
index 000000000..0e0b77b81
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qsql-namespace/main.cpp
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QSql>
+
+int main(int argc, char *argv[])
+{
+ return 0;
+}
diff --git a/doc/codesnippets/doc/src/snippets/qsql-namespace/qsql-namespace.pro b/doc/codesnippets/doc/src/snippets/qsql-namespace/qsql-namespace.pro
new file mode 100644
index 000000000..e8183d3ce
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qsql-namespace/qsql-namespace.pro
@@ -0,0 +1,2 @@
+SOURCES = main.cpp
+QT += sql
diff --git a/doc/codesnippets/doc/src/snippets/qstack/main.cpp b/doc/codesnippets/doc/src/snippets/qstack/main.cpp
new file mode 100644
index 000000000..777e2ed8d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qstack/main.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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/codesnippets/doc/src/snippets/qstack/qstack.pro b/doc/codesnippets/doc/src/snippets/qstack/qstack.pro
new file mode 100644
index 000000000..721ae4b2e
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qstack/qstack.pro
@@ -0,0 +1,11 @@
+######################################################################
+# Automatically generated by qmake (2.00a) Wed Apr 5 15:41:54 2006
+######################################################################
+
+TEMPLATE = app
+TARGET +=
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+SOURCES += main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qstackedlayout/main.cpp b/doc/codesnippets/doc/src/snippets/qstackedlayout/main.cpp
new file mode 100644
index 000000000..88e3a8903
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qstackedlayout/main.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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/codesnippets/doc/src/snippets/qstackedlayout/qstackedlayout.pro b/doc/codesnippets/doc/src/snippets/qstackedlayout/qstackedlayout.pro
new file mode 100644
index 000000000..89c757cfd
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qstackedlayout/qstackedlayout.pro
@@ -0,0 +1,11 @@
+######################################################################
+# Automatically generated by qmake (2.00a) Thu Apr 6 10:47:18 2006
+######################################################################
+
+TEMPLATE = app
+TARGET +=
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+SOURCES += main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qstackedwidget/main.cpp b/doc/codesnippets/doc/src/snippets/qstackedwidget/main.cpp
new file mode 100644
index 000000000..b63f3b3d3
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qstackedwidget/main.cpp
@@ -0,0 +1,69 @@
+############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Nokia Corporation (qt-info@nokia.com)
+##
+## This file is part of the documentation of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at http://www.qtsoftware.com/contact.
+## $QT_END_LICENSE$
+##
+############################################################################
+
+
+//! [0]
+ firstPageWidget = QWidget()
+ secondPageWidget = QWidget()
+ thirdPageWidget = QWidget()
+
+ stackedWidget = QStackedWidget()
+ stackedWidget.addWidget(firstPageWidget)
+ stackedWidget.addWidget(secondPageWidget)
+ stackedWidget.addWidget(thirdPageWidget)
+
+//! [0] //! [1]
+ pageComboBox = 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]
+ layout = QVBoxLayout()
+//! [2]
+ layout.addWidget(pageComboBox)
+//! [3]
+ layout.addWidget(stackedWidget)
+ setLayout(layout)
+//! [3]
+
diff --git a/doc/codesnippets/doc/src/snippets/qstackedwidget/qstackedwidget.pro b/doc/codesnippets/doc/src/snippets/qstackedwidget/qstackedwidget.pro
new file mode 100644
index 000000000..227dd36e8
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qstackedwidget/qstackedwidget.pro
@@ -0,0 +1,11 @@
+######################################################################
+# Automatically generated by qmake (2.00a) Thu Apr 6 10:33:16 2006
+######################################################################
+
+TEMPLATE = app
+TARGET +=
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+SOURCES += main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qstandarditemmodel/main.cpp b/doc/codesnippets/doc/src/snippets/qstandarditemmodel/main.cpp
new file mode 100644
index 000000000..8efc38794
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qstandarditemmodel/main.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QApplication>
+
+class Widget : public QWidget
+{
+public:
+ Widget(QWidget *parentWidget = 0);
+};
+
+Widget::Widget(QWidget *parentWidget)
+ : QWidget(parentWidget)
+{
+ QStandardItemModel *model = new QStandardItemModel();
+ QModelIndex parent;
+ for (int i = 0; i < 4; ++i) {
+ parent = model->index(0, 0, parent);
+ model->insertRows(0, 1, parent);
+ model->insertColumns(0, 1, parent);
+ QModelIndex index = model->index(0, 0, parent);
+ model->setData(index, i);
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Widget widget;
+ widget.show();
+ return app.exec();
+}
+
diff --git a/doc/codesnippets/doc/src/snippets/qstandarditemmodel/qstandarditemmodel.pro b/doc/codesnippets/doc/src/snippets/qstandarditemmodel/qstandarditemmodel.pro
new file mode 100644
index 000000000..421ee5903
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qstandarditemmodel/qstandarditemmodel.pro
@@ -0,0 +1,11 @@
+######################################################################
+# Automatically generated by qmake (2.00a) Mon Apr 10 11:16:20 2006
+######################################################################
+
+TEMPLATE = app
+TARGET +=
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+SOURCES += main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qstatustipevent/main.cpp b/doc/codesnippets/doc/src/snippets/qstatustipevent/main.cpp
new file mode 100644
index 000000000..c0857620c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qstatustipevent/main.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use self file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, self file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of self file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0] //! [1]
+def __init__(self, parent):
+ QMainWindow.__init__(self, parent)
+//! [0]
+ myWidget = QWidget()
+ myWidget.setStatusTip(tr("This is my widget."))
+
+ setCentralWidget(myWidget)
+//! [1]
+
+//! [2]
+ fileMenu = menuBar().addMenu(tr("File"))
+
+ Act = QAction(self.tr("&New"), self)
+ Act.setStatusTip(tr("Create a new file."))
+ fileMenu.addAction(Act)
+//! [2]
+
+ statusBar().showMessage(self.tr("Ready"))
+ setWindowTitle(tr("QStatusTipEvent"))
+//! [3]
+
+//! [3]
+
diff --git a/doc/codesnippets/doc/src/snippets/qstatustipevent/qstatustipevent.pro b/doc/codesnippets/doc/src/snippets/qstatustipevent/qstatustipevent.pro
new file mode 100644
index 000000000..f4fe6ba33
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qstatustipevent/qstatustipevent.pro
@@ -0,0 +1,11 @@
+######################################################################
+# Automatically generated by qmake (2.00a) Tue Apr 11 12:09:28 2006
+######################################################################
+
+TEMPLATE = app
+TARGET +=
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+SOURCES += main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qstring/main.cpp b/doc/codesnippets/doc/src/snippets/qstring/main.cpp
new file mode 100644
index 000000000..e41cf3ea3
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qstring/main.cpp
@@ -0,0 +1,917 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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]
+ str = QString("Hello")
+//! [0]
+}
+
+void Widget.constCharArray()
+{
+//! [1]
+ # NOT USED IN PYSIDE
+ static const QChar data[4] = { 0x0055, 0x006e, 0x10e3, 0x03a3 }
+ QString str(data, 4)
+//! [1]
+}
+
+void Widget.characterReference()
+{
+//! [2]
+ str = QString()
+ str.resize(2)
+
+ str[0] = 'U')
+ str[1] = 'n')
+//! [2]
+}
+
+void Widget.atFunction()
+{
+//! [3]
+ str = QString()
+
+ for i in range(str.size()):
+ print str.at(i)
+//! [3]
+}
+
+void Widget.stringLiteral()
+{
+//! [4]
+ str = QString()
+ ...
+ if str == "auto" or str == "extern" \
+ or str == "static" or str == "register":
+ # ...
+//! [4]
+}
+
+void Widget.modify()
+{
+//! [5]
+ str = QString("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]
+ str = QString("We must be <b>bold</b>, very <b>bold</b>")
+ j = str.indexOf("<b>", 0)
+ while j != -1:
+ print "Found <b> tag at index position", j
+ j = str.indexOf("<b>", j+1)
+//! [6]
+}
+
+//! [7]
+ # Not needed in pyside
+ 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]
+ x = QString("free")
+ y = QString("dom")
+
+ x.append(y)
+ # x == "freedom"
+//! [9]
+
+//! [10]
+ x.insert(x.size(), y)
+//! [10]
+}
+
+void Widget.argFunction()
+{
+//! [11]
+ i = QString(...) # current file's number
+ total = QString(...) # number of files to process
+ fileName = QString(...) # current file's name
+
+ status = QString("Processing file %1 of %2: %3")
+ .arg(i).arg(total).arg(fileName)
+//! [11]
+
+//! [12] //! [13]
+ str QString()
+//! [12]
+ str = QString("%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]
+ str = QString("LOGOUT\r\n")
+ str.chop(2)
+ # str == "LOGOUT"
+//! [15]
+}
+
+void Widget.compareFunction()
+{
+ x = QString.compare("auto", "auto") # x == 0
+ y = QString.compare("auto", "car") # y < 0
+ z = QString.compare("car", "auto") # z > 0
+}
+
+void Widget.compareSensitiveFunction()
+{
+//! [16]
+ x = QString.compare("aUtO", "AuTo", Qt.CaseInsensitive); # x == 0
+ y = QString.compare("auto", "Car", Qt.CaseSensitive); # y > 0
+ z = QString.compare("auto", "Car", Qt.CaseInsensitive); # z < 0
+//! [16]
+}
+
+void Widget.containsFunction()
+{
+//! [17]
+ str = QString("Peter Pan")
+ str.contains("peter", Qt.CaseInsensitive) # returns true
+//! [17]
+}
+
+void Widget.countFunction()
+{
+//! [18]
+ str = QString("banana and panama")
+ str.count(QRegExp("a[nm]a")) # returns 4
+//! [18]
+}
+
+void Widget.dataFunction()
+{
+//! [19]
+// Not Needed
+ str = QString"Hello world"
+ QChar *data = str.data()
+ while (!data->isNull()) {
+ qDebug() << data->unicode()
+ ++data
+ }
+//! [19]
+}
+
+void Widget.endsWithFunction()
+{
+//! [20]
+ str = QString("Bananas")
+ str.endsWith("anas") # returns true
+ str.endsWith("pple") # returns false
+//! [20]
+}
+
+void Widget.fillFunction()
+{
+//! [21]
+ str = QString("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]
+ str = QString("the minimum")
+ str.indexOf(QRegExp("m[aeiou]"), 0) # returns 4
+//! [25]
+}
+
+void Widget.insertFunction()
+{
+//! [26]
+ str = QString("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]
+ str = QString("the minimum")
+ str.lastIndexOf(QRegExp("m[aeiou]")) # returns 8
+//! [30]
+}
+
+void Widget.leftFunction()
+{
+//! [31]
+ x = QString("Pineapple")
+ y = QString(x.left(4)) # y == "Pine"
+//! [31]
+}
+
+void Widget.leftJustifiedFunction()
+{
+//! [32]
+ s = QString("apple")
+ t = QString(s.leftJustified(8, '.')) # t == "apple..."
+//! [32]
+
+//! [33]
+ str = QString("Pineapple")
+ str = str.leftJustified(5, '.', True) # str == "Pinea"
+//! [33]
+}
+
+void Widget.midFunction()
+{
+//! [34]
+ x = QString("Nine pineapples")
+ y = QString(x.mid(5, 4)) # y == "pine"
+ z = QString(x.mid(5)) # z == "pineapples"
+//! [34]
+}
+
+void Widget.numberFunction()
+{
+//! [35]
+ a = 63
+ s = QString.number(a, 16) # s == "3f"
+ t = QString.number(a, 16).toUpper() # t == "3F"
+//! [35]
+}
+
+void Widget.prependFunction()
+{
+//! [36]
+ x = QString("ship")
+ y = QString("air")
+ x.prepend(y)
+ # x == "airship"
+//! [36]
+}
+
+void Widget.removeFunction()
+{
+//! [37]
+ s = QString("Montreal")
+ s.remove(1, 4)
+ # s == "Meal"
+//! [37]
+
+//! [38]
+ QString t = "Ali Baba"
+ t.remove(QChar('a'), Qt.CaseInsensitive)
+ # t == "li Bb"
+//! [38]
+
+//! [39]
+ r = QString("Telephone")
+ r.remove(QRegExp("[aeiou]."))
+ # r == "The"
+//! [39]
+}
+
+void Widget.replaceFunction()
+{
+//! [40]
+ x = QString("Say yes!")
+ y = QString("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]
+ s = QString("Banana")
+ s.replace(QRegExp("a[mn]"), "ox")
+ # s == "Boxoxa"
+//! [42]
+
+//! [43]
+ t = QString("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]
+ result = QString()
+ maxSize = 44
+
+ result.reserve(maxSize)
+ while condition:
+ result.append(nextChar)
+
+ result.squeeze()
+//! [44]
+}
+
+void Widget.resizeFunction()
+{
+//! [45]
+ s = QString("Hello world")
+ s.resize(5)
+ # s == "Hello"
+
+ s.resize(8)
+ # s == "Hello???" (where ? stands for any character)
+//! [45]
+
+//! [46]
+ t = QString("Hello")
+ t += QString(10, 'X')
+ # t == "HelloXXXXXXXXXX"
+//! [46]
+
+//! [47]
+ r = QString("Hello")
+ r = r.leftJustified(10, ' ')
+ # r == "Hello "
+//! [47]
+}
+
+void Widget.rightFunction()
+{
+//! [48]
+ x = QString("Pineapple")
+ y = x.right(5) # y == "apple"
+//! [48]
+}
+
+void Widget.rightJustifiedFunction()
+{
+//! [49]
+ s = QString("apple")
+ t = s.rightJustified(8, '.') # t == "...apple"
+//! [49]
+
+//! [50]
+ str = QString("Pineapple")
+ str = str.rightJustified(5, '.', True) # str == "Pinea"
+//! [50]
+}
+
+void Widget.sectionFunction()
+{ // NOT NEEDED
+//! [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]
+ str = QString()
+ str.setNum(1234) # str == "1234"
+//! [56]
+}
+
+void Widget.simplifiedFunction()
+{
+//! [57]
+ str = QString(" lots\t of\nwhitespace\r\n ")
+ str = str.simplified()
+ # str == "lots of whitespace"
+//! [57]
+}
+
+void Widget.sizeFunction()
+{
+//! [58]
+ str = QString("World")
+ n = str.size() # n == 5
+//! [58]
+}
+
+void Widget.splitFunction()
+{
+//! [59]
+ str = QString("Some text\n\twith strange whitespace.")
+ list = str.split(QRegExp("\\s+")) # A QStringList
+ # list: [ "Some", "text", "with", "strange", "whitespace." ]
+//! [59]
+
+//! [60]
+ str = QString("This time, a normal English sentence.")
+ list = str.split(QRegExp("\\W+"), QString.SkipEmptyParts)
+ # list: [ "This", "time", "a", "normal", "English", "sentence" ]
+//! [60]
+
+//! [61]
+ str = QString("Now: this sentence fragment.")
+ list = str.split(QRegExp("\\b"))
+ # list: [ "", "Now", ": ", "this", " ", "sentence", " ", "fragment", "." ]
+//! [61]
+}
+
+void Widget.splitCaseSensitiveFunction()
+{
+//! [62]
+ str = QString("a,,b,c")
+
+ list1 = str.split(",")
+ # list1: [ "a", "", "b", "c" ]
+
+ 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]
+ str = QString("1234.56")
+ val = str.toDouble()[0] # val == 1234.56
+//! [66]
+
+//! [67]
+ d, ok = QString( "1234.56e-02" ).toDouble() # ok == true, d == 12.3456
+//! [67]
+
+//! [68] //! [69]
+ QLocale.setDefault(QLocale.C)
+ d, ok = QString( "1234,56" ).toDouble() # ok == false
+//! [68]
+ d, ok = QString( "1234.56" ).toDouble() # ok == true, d == 1234.56
+
+//! [69] //! [70]
+ QLocale.setDefault(QLocale.German)
+ d, ok = QString( "1234,56" ).toDouble() # ok == true, d == 1234.56
+ d, ok = QString( "1234.56" ).toDouble() # ok == true, d == 1234.56
+
+//! [70]
+ QLocale.setDefault(QLocale.C)
+ d, ok = QString( "1,234,567.89" ).toDouble() # ok == false
+}
+
+void Widget.toFloatFunction()
+{
+//! [71]
+ str1 = QString("1234.56")
+ str1.toFloat() # returns (1234.56, True)
+
+ str2 = QString("R2D2")
+ str2.toFloat() # returns (0.0, False)
+//! [71]
+}
+
+void Widget.toIntFunction()
+{
+//! [72]
+ str = QString("FF")
+ hex, ok = str.toInt(16) # hex == 255, ok == true
+ dec, ok = str.toInt(10) # dec == 0, ok == false
+//! [72]
+}
+
+void Widget.toLongFunction()
+{
+//! [73]
+ str = QString("FF")
+
+ hex, ok = str.toLong(16) # hex == 255, ok == true
+ dec, ok = str.toLong(10) # dec == 0, ok == false
+//! [73]
+}
+
+void Widget.toLongLongFunction()
+{
+//! [74]
+ str = QString("FF")
+
+ hex, ok = str.toLongLong(16) # hex == 255, ok == true
+ dec, ok = str.toLongLong(10) # dec == 0, ok == false
+//! [74]
+}
+
+void Widget.toLowerFunction()
+{
+//! [75]
+ str = QString("TROlltECH")
+ str = str.toLower() # str == "trolltech"
+//! [75]
+}
+
+void Widget.toShortFunction()
+{
+//! [76]
+ str = QString("FF")
+
+ hex, ok = str.toShort(16) # hex == 255, ok == true
+ dec, ok = str.toShort(10) # dec == 0, ok == false
+//! [76]
+}
+
+void Widget.toUIntFunction()
+{
+//! [77]
+ str = QString("FF")
+
+ hex, ok = str.toUInt(16) # hex == 255, ok == true
+ dec, ok = str.toUInt(10) # dec == 0, ok == false
+//! [77]
+}
+
+void Widget.toULongFunction()
+{
+//! [78]
+ str = QString("FF")
+
+ hex, ok = str.toULong(16) # hex == 255, ok == true
+ dec, ok = str.toULong(10) # dec == 0, ok == false
+//! [78]
+}
+
+void Widget.toULongLongFunction()
+{
+//! [79]
+ QString str = "FF"
+
+ hex, ok = str.toULongLong(16) # hex == 255, ok == true
+ dec, ok = str.toULongLong(10) # dec == 0, ok == false
+//! [79]
+}
+
+void Widget.toUShortFunction()
+{
+//! [80]
+ str = QString("FF")
+
+ hex, ok = str.toUShort(16) # hex == 255, ok == true
+ dec, ok = str.toUShort(10) # dec == 0, ok == false
+//! [80]
+}
+
+void Widget.toUpperFunction()
+{
+//! [81]
+ str = QString("TeXt")
+ str = str.toUpper() # str == "TEXT"
+//! [81]
+}
+
+void Widget.trimmedFunction()
+{
+//! [82]
+ str = QString(" lots\t of\nwhitespace\r\n ")
+ str = str.trimmed()
+ # str == "lots\t of\nwhitespace"
+//! [82]
+}
+
+void Widget.truncateFunction()
+{
+//! [83]
+ str = QString("Vladivostok")
+ str.truncate(4)
+ # str == "Vlad"
+//! [83]
+}
+
+void Widget.plusEqualOperator()
+{
+//! [84]
+ x = QString("free")
+ y = QString("dom")
+ x += y
+ # x == "freedom"
+//! [84]
+}
+
+void Widget.arrayOperator()
+{
+//! [85]
+ str = QString(...)
+
+ if (str[0] == QChar('?'))
+ str[0] = QChar('_')
+//! [85]
+}
+
+void Widget.midRefFunction()
+{
+//! [midRef]
+ x = QString("Nine pineapples")
+ y = x.midRef(5, 4) # y == "pine"
+ z = x.midRef(5) # z == "pineapples"
+//! [midRef]
+}
+
+void Widget.leftRefFunction()
+{
+//! [leftRef]
+ x = QString("Pineapple")
+ y = x.leftRef(4) # y == "Pine"
+//! [leftRef]
+}
+
+void Widget.rightRefFunction()
+{
+//! [rightRef]
+ x = QString("Pineapple")
+ 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/codesnippets/doc/src/snippets/qstring/qstring.pro b/doc/codesnippets/doc/src/snippets/qstring/qstring.pro
new file mode 100644
index 000000000..71039d146
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qstring/qstring.pro
@@ -0,0 +1,11 @@
+######################################################################
+# Automatically generated by qmake (2.00a) Wed Apr 12 11:28:45 2006
+######################################################################
+
+TEMPLATE = app
+TARGET +=
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+SOURCES += main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qstringlist/main.cpp b/doc/codesnippets/doc/src/snippets/qstringlist/main.cpp
new file mode 100644
index 000000000..c80b50ecc
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qstringlist/main.cpp
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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]
+ fonts = QStringList()
+ fonts << "Arial" << "Helvetica" << "Times" << "Courier"
+//! [0]
+
+//! [1]
+ for i in range(fonts.size()):
+ print fonts.at(i)
+//! [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]
+ str = fonts.join(",")
+ # str == "Arial,Helvetica,Times,Courier"
+//! [4]
+
+//! [5] //! [6]
+ list = QStringList()
+//! [5]
+ list = str.split(",")
+ # list: ["Arial", "Helvetica", "Times", "Courier"]
+//! [6]
+
+//! [7]
+ monospacedFonts = fonts.filter(QRegExp("Courier|Fixed"))
+//! [7]
+
+//! [8]
+ files = QStringList()
+ 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]
+ longerList = (QStringList() << str1 << str2 << str3)
+//! [9]
+
+ list.clear()
+//! [10]
+ list << "Bill Murray" << "John Doe" << "Bill Clinton"
+
+//! [11]
+ result = QStringList()
+//! [11]
+ result = list.filter("Bill")
+ # result: ["Bill Murray", "Bill Clinton"]
+//! [10]
+
+ result.clear()
+//! [12]
+ for string in list:
+ if string.contains("Bill")
+ result += string
+//! [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/codesnippets/doc/src/snippets/qstringlist/qstringlist.pro b/doc/codesnippets/doc/src/snippets/qstringlist/qstringlist.pro
new file mode 100644
index 000000000..adb2f9e54
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qstringlist/qstringlist.pro
@@ -0,0 +1,11 @@
+######################################################################
+# Automatically generated by qmake (2.00a) Wed May 3 11:08:01 2006
+######################################################################
+
+TEMPLATE = app
+TARGET +=
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+SOURCES += main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qstringlistmodel/main.cpp b/doc/codesnippets/doc/src/snippets/qstringlistmodel/main.cpp
new file mode 100644
index 000000000..c1f9673e4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qstringlistmodel/main.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+class Widget : public QWidget
+{
+public:
+ Widget(QWidget *parent = 0);
+};
+
+Widget::Widget(QWidget *parent)
+ : QWidget(parent)
+{
+//! [0]
+ model = QStringListModel()
+ list = QStringList()
+ list.append("a")
+ list.append("b")
+ list.append("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/codesnippets/doc/src/snippets/qstringlistmodel/qstringlistmodel.pro b/doc/codesnippets/doc/src/snippets/qstringlistmodel/qstringlistmodel.pro
new file mode 100644
index 000000000..aaa359c85
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qstringlistmodel/qstringlistmodel.pro
@@ -0,0 +1,11 @@
+######################################################################
+# Automatically generated by qmake (2.00a) Wed May 3 15:25:22 2006
+######################################################################
+
+TEMPLATE = app
+TARGET +=
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+SOURCES += main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qstyleoption/main.cpp b/doc/codesnippets/doc/src/snippets/qstyleoption/main.cpp
new file mode 100644
index 000000000..11cba7452
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qstyleoption/main.cpp
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+def paintEvent(self, qpaintevent):
+ option = QStyleOptionButton()
+ option.initFrom(self)
+ if isDown():
+ option.state = QStyle.State_Sunken
+ else:
+ option.state = QStyle.State_Raised
+
+ if self.isDefault():
+ option.features = option.features or QStyleOptionButton.DefaultButton
+ option.text = self.text()
+ option.icon = self.icon()
+
+ painter = QPainter(self)
+ self.style().drawControl(QStyle.CE_PushButton, option, painter, self)
+//! [0]
+//! [1]
+ option = QStyleOptionFrame()
+
+ if isinstance(option, QStyleOptionFrameV2):
+ frameOptionV2 = QStyleOptionFrameV2(option)
+
+ # draw the frame using frameOptionV2
+
+//! [1]
+
+//! [2]
+ if isinstance(option, QStyleOptionProgressBarV2):
+ progressBarV2 = QStyleOptionProgressBarV2(option)
+
+ # draw the progress bar using progressBarV2
+
+//! [2]
+
+//! [3]
+ if isinstance(option, QStyleOptionTabV2):
+ tabV2 = QStyleOptionTabV2(option)
+
+ # draw the tab using tabV2
+
+//! [3]
+
+
+//! [4]
+def drawPrimitive(self, element, option, painter, widget):
+ if element == self.PE_FrameFocusRect:
+ focusRectOption = QStyleOptionFocusRect(option)
+ if focusRectOption:
+ # ...
+
+
+ # ...
+
+//! [4]
diff --git a/doc/codesnippets/doc/src/snippets/qstyleoption/qstyleoption.pro b/doc/codesnippets/doc/src/snippets/qstyleoption/qstyleoption.pro
new file mode 100644
index 000000000..2f17f036f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qstyleoption/qstyleoption.pro
@@ -0,0 +1,11 @@
+######################################################################
+# Automatically generated by qmake (2.00a) Thu Apr 20 16:22:46 2006
+######################################################################
+
+TEMPLATE = app
+TARGET +=
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+SOURCES += main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qstyleplugin/main.cpp b/doc/codesnippets/doc/src/snippets/qstyleplugin/main.cpp
new file mode 100644
index 000000000..6ac3314f9
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qstyleplugin/main.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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/codesnippets/doc/src/snippets/qstyleplugin/qstyleplugin.pro b/doc/codesnippets/doc/src/snippets/qstyleplugin/qstyleplugin.pro
new file mode 100644
index 000000000..d17c20f69
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qstyleplugin/qstyleplugin.pro
@@ -0,0 +1,11 @@
+######################################################################
+# Automatically generated by qmake (2.00a) Tue May 2 15:31:16 2006
+######################################################################
+
+TEMPLATE = app
+TARGET +=
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+SOURCES += main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qsvgwidget/main.cpp b/doc/codesnippets/doc/src/snippets/qsvgwidget/main.cpp
new file mode 100644
index 000000000..122a770c8
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qsvgwidget/main.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QtSvg>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+//! [0]
+ QSvgWidget window(":/files/spheres.svg");
+ window.show();
+//! [0]
+ QSvgRenderer *renderer = window.renderer();
+ QImage image(150, 150, QImage::Format_RGB32);
+ QPainter painter;
+ painter.begin(&image);
+ renderer->render(&painter);
+ painter.end();
+ image.save("spheres.png", "PNG", 9);
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/qsvgwidget/qsvgwidget.pro b/doc/codesnippets/doc/src/snippets/qsvgwidget/qsvgwidget.pro
new file mode 100644
index 000000000..d7e3698bb
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qsvgwidget/qsvgwidget.pro
@@ -0,0 +1,3 @@
+QT += svg
+RESOURCES = qsvgwidget.qrc
+SOURCES = main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qsvgwidget/qsvgwidget.qrc b/doc/codesnippets/doc/src/snippets/qsvgwidget/qsvgwidget.qrc
new file mode 100644
index 000000000..13d8b3612
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qsvgwidget/qsvgwidget.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/files" >
+ <file>spheres.svg</file>
+</qresource>
+</RCC>
diff --git a/doc/codesnippets/doc/src/snippets/qsvgwidget/spheres.svg b/doc/codesnippets/doc/src/snippets/qsvgwidget/spheres.svg
new file mode 100644
index 000000000..9e3819306
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qsvgwidget/spheres.svg
@@ -0,0 +1,79 @@
+<?xml version="1.0" standalone="no"?>
+<svg width="8cm" height="8cm" viewBox="0 0 400 400"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink/"
+ baseProfile="tiny" version="1.2">
+ <title>Spheres</title>
+ <desc>Gradient filled spheres with different colors.</desc>
+ <defs>
+ <!-- Create radial gradients for each circle to make them look like
+ spheres. -->
+ <radialGradient id="blueSphere" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" />
+ <stop offset="75%" stop-color="blue" />
+ <stop offset="100%" stop-color="#222244" />
+ </radialGradient>
+ <radialGradient id="redSphere" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" />
+ <stop offset="75%" stop-color="red" />
+ <stop offset="100%" stop-color="#442222" />
+ </radialGradient>
+ <radialGradient id="greenSphere" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" />
+ <stop offset="75%" stop-color="green" />
+ <stop offset="100%" stop-color="#113311" />
+ </radialGradient>
+ <radialGradient id="yellowSphere" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" />
+ <stop offset="75%" stop-color="yellow" />
+ <stop offset="100%" stop-color="#444422" />
+ </radialGradient>
+ <radialGradient id="shadow" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="50">
+ <stop offset="0%" stop-color="black" stop-opacity="1.0" />
+ <stop offset="100%" stop-color="white" stop-opacity="0.0" />
+ </radialGradient>
+
+ <!-- Define a shadow for each sphere. -->
+ <circle id="shadow" fill="url(#shadow)" cx="0" cy="0" r="100" />
+ </defs>
+ <g fill="#ffee99" stroke="none" >
+ <rect x="0" y="0" width="400" height="400" />
+ </g>
+ <g fill="white" stroke="none" >
+ <rect x="0" y="175" width="400" height="225" />
+ </g>
+ <g transform="translate(200,290) scale(2.0,1.0) rotate(45)" >
+ <rect fill="#a6ce39" x="-69" y="-69" width="138" height="138" />
+ <circle fill="black" cx="0" cy="0" r="50" />
+ <circle fill="#a6ce39" cx="0" cy="0" r="33" />
+ <path fill="black" d="M 37,50 L 50,37 L 12,-1 L 22,-11 L 10,-24 L -24,10
+ L -11,22 L -1,12 Z" />
+ </g>
+ <g transform="translate(200,175)">
+ <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+ <circle fill="url(#blueSphere)" cx="0" cy="0" r="100" />
+ </g>
+ <g transform="translate(315,240)">
+ <g transform="scale(0.5,0.5)">
+ <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+ <circle fill="url(#redSphere)" cx="0" cy="0" r="100" />
+ </g>
+ </g>
+ <g transform="translate(80,275)">
+ <g transform="scale(0.65,0.65)">
+ <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+ <circle fill="url(#greenSphere)" cx="0" cy="0" r="100" />
+ </g>
+ </g>
+ <g transform="translate(255,325)">
+ <g transform="scale(0.3,0.3)">
+ <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+ <circle fill="url(#yellowSphere)" cx="0" cy="0" r="100" />
+ </g>
+ </g>
+</svg>
diff --git a/doc/codesnippets/doc/src/snippets/qsvgwidget/sunflower.svg b/doc/codesnippets/doc/src/snippets/qsvgwidget/sunflower.svg
new file mode 100644
index 000000000..b60dd11a6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qsvgwidget/sunflower.svg
@@ -0,0 +1,188 @@
+<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
+<svg width="289.619" height="450.482"
+ xmlns="http://www.w3.org/2000/svg" baseProfile="tiny" version="1.1">
+ <defs>
+ <marker id="ArrowEnd" viewBox="0 0 10 10" refX="0" refY="5"
+ markerUnits="strokeWidth"
+ markerWidth="4"
+ markerHeight="3"
+ orient="auto">
+ <path d="M 0 0 L 10 5 L 0 10 z" />
+ </marker>
+ <marker id="ArrowStart" viewBox="0 0 10 10" refX="10" refY="5"
+ markerUnits="strokeWidth"
+ markerWidth="4"
+ markerHeight="3"
+ orient="auto">
+ <path d="M 10 0 L 0 5 L 10 10 z" />
+ </marker> </defs>
+<g>
+<defs><linearGradient id="1" x1="155.352" y1="450.482" x2="155.352" y2="140" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#9ded37"/>
+<stop offset="1" style="stop-color:#f8ff76"/>
+</linearGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#1)" d="M 132.72 145.241C 211.668 237.549 150.166 295.646 148.222 342.665C 146.89 374.889 171.099 410.104 185.352 445.241C 185.352 445.241 185.352 445.241 132.72 352.933C 106.405 306.779 159.036 306.779 159.036 237.549C 159.036 191.395 132.72 145.241 132.72 145.241z"/>
+<defs><radialGradient id="2" cx="145.352" cy="45.2408" r="47.7391" fx="145.352" fy="45.2408" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#2)" d="M 155.352 45.2408C 155.352 67.3199 150.872 85.2408 145.352 85.2408C 139.832 85.2408 135.352 67.3199 135.352 45.2408C 135.352 23.1618 139.832 5.24084 145.352 5.24084C 150.872 5.24084 155.352 23.1618 155.352 45.2408z"/>
+<defs><radialGradient id="3" cx="170.135" cy="48.3609" r="48.0339" fx="170.135" fy="48.3609" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#3)" d="M 179.823 50.8388C 174.351 72.2289 165.569 88.4808 160.221 87.1129C 154.874 85.7448 154.975 67.2728 160.447 45.8828C 165.919 24.4928 174.701 8.24084 180.048 9.60886C 185.396 10.9768 185.295 29.4489 179.823 50.8388z"/>
+<g>
+<defs><radialGradient id="4" cx="192.599" cy="57.0958" r="48.4248" fx="192.599" fy="57.0958" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#4)" d="M 201.476 61.6998C 191.31 81.2998 179.081 95.1448 174.181 92.6039C 169.282 90.0618 173.556 72.0909 183.722 52.4919C 193.888 32.8918 206.116 19.0468 211.016 21.5878C 215.916 24.1299 211.642 42.1008 201.476 61.6998z"/>
+<defs><radialGradient id="5" cx="213.162" cy="71.2758" r="48.6431" fx="213.162" fy="71.2758" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#5)" d="M 220.621 77.9368C 205.915 94.4048 190.636 104.788 186.519 101.112C 182.402 97.4348 190.997 81.0838 205.703 64.6148C 220.409 48.1469 235.688 37.7639 239.805 41.4398C 243.922 45.1169 235.327 61.4678 220.621 77.9368z"/>
+</g>
+<defs><radialGradient id="6" cx="229.082" cy="90.7439" r="48.5357" fx="229.082" fy="90.7439" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#6)" d="M 234.466 99.1708C 215.86 111.058 198.346 116.932 195.374 112.28C 192.403 107.629 205.092 94.2048 223.698 82.3168C 242.303 70.4298 259.817 64.5558 262.789 69.2079C 265.761 73.8589 253.071 87.2838 234.466 99.1708z"/>
+<defs><radialGradient id="7" cx="239.796" cy="113.308" r="48.1584" fx="239.796" fy="113.308" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#7)" d="M 242.923 122.806C 221.952 129.712 203.529 131.061 201.803 125.819C 200.076 120.576 215.697 110.715 236.668 103.81C 257.639 96.9038 276.063 95.5548 277.789 100.797C 279.515 106.04 263.895 115.901 242.923 122.806z"/>
+<g>
+<defs><radialGradient id="8" cx="244.53" cy="136.94" r="47.7879" fx="244.53" fy="136.94" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#8)" d="M 245.429 146.899C 223.44 148.885 205.188 146.035 204.692 140.538C 204.195 135.04 221.641 128.966 243.63 126.981C 265.62 124.995 283.871 127.845 284.368 133.342C 284.864 138.84 267.418 144.914 245.429 146.899z"/>
+<defs><radialGradient id="9" cx="243.651" cy="161.904" r="47.8795" fx="243.651" fy="161.904" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#9)" d="M 242.055 171.776C 220.259 168.25 203.284 160.965 204.165 155.516C 205.047 150.067 223.453 148.506 245.249 152.032C 267.044 155.558 284.02 162.843 283.138 168.292C 282.257 173.741 263.85 175.302 242.055 171.776z"/>
+</g>
+<g>
+<g>
+<g>
+<defs><radialGradient id="10" cx="236.069" cy="186.194" r="48.3388" fx="236.069" fy="186.194" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#10)" d="M 231.976 195.318C 211.831 186.281 197.314 174.858 199.573 169.822C 201.832 164.785 220.017 168.033 240.162 177.07C 260.306 186.107 274.824 197.53 272.565 202.566C 270.305 207.603 252.12 204.355 231.976 195.318z"/>
+<defs><radialGradient id="11" cx="223.077" cy="207.529" r="48.6188" fx="223.077" fy="207.529" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#11)" d="M 216.851 215.354C 199.575 201.606 188.341 186.942 191.778 182.623C 195.215 178.303 212.028 185.956 229.304 199.704C 246.581 213.452 257.814 228.116 254.377 232.435C 250.94 236.755 234.128 229.102 216.851 215.354z"/>
+</g>
+<g>
+<defs><radialGradient id="12" cx="205.914" cy="224.449" r="48.6182" fx="205.914" fy="224.449" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#12)" d="M 198.079 230.664C 184.358 213.366 176.731 196.542 181.055 193.111C 185.379 189.681 200.027 200.937 213.748 218.234C 227.469 235.532 235.097 252.356 230.772 255.787C 226.448 259.217 211.801 247.961 198.079 230.664z"/>
+<defs><radialGradient id="13" cx="184.559" cy="237.407" r="48.3362" fx="184.559" fy="237.407" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#13)" d="M 175.429 241.486C 166.422 221.328 163.203 203.138 168.242 200.886C 173.282 198.635 184.683 213.169 193.689 233.328C 202.695 253.486 205.915 271.676 200.875 273.928C 195.836 276.179 184.435 261.645 175.429 241.486z"/>
+</g>
+</g>
+<g>
+<g>
+<defs><radialGradient id="14" cx="160.281" cy="243.964" r="47.8592" fx="160.281" fy="243.964" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#14)" d="M 150.388 245.427C 147.158 223.586 148.968 205.202 154.428 204.395C 159.888 203.587 166.943 220.66 170.173 242.501C 173.404 264.342 171.594 282.726 166.134 283.534C 160.673 284.341 153.619 267.268 150.388 245.427z"/>
+<defs><radialGradient id="15" cx="135.307" cy="244.504" r="47.8021" fx="135.307" fy="244.504" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#15)" d="M 125.361 243.47C 127.645 221.509 133.954 204.148 139.444 204.719C 144.934 205.289 147.537 223.578 145.254 245.538C 142.971 267.499 136.661 284.86 131.171 284.289C 125.681 283.719 123.078 265.43 125.361 243.47z"/>
+</g>
+<g>
+<defs><radialGradient id="16" cx="111.808" cy="239.15" r="48.183" fx="111.808" fy="239.15" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#16)" d="M 102.353 235.894C 109.541 215.018 119.613 199.532 124.831 201.33C 130.05 203.127 128.452 221.53 121.263 242.406C 114.074 263.282 104.003 278.768 98.784 276.97C 93.5651 275.173 95.1639 256.77 102.353 235.894z"/>
+<defs><radialGradient id="17" cx="89.3906" cy="228.131" r="48.5494" fx="89.3906" fy="228.131" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#17)" d="M 81.0375 222.633C 93.1756 204.19 106.771 191.684 111.381 194.718C 115.992 197.753 109.882 215.186 97.7439 233.629C 85.6057 252.072 72.0108 264.578 67.4001 261.544C 62.7894 258.509 68.8993 241.076 81.0375 222.633z"/>
+</g>
+</g>
+</g>
+<g>
+<g>
+<g>
+<defs><radialGradient id="18" cx="53.7557" cy="185.38" r="48.3405" fx="53.7557" fy="185.38" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#18)" d="M 49.653 176.26C 69.7881 167.202 87.9697 163.935 90.2343 168.969C 92.4989 174.003 77.9935 185.441 57.8584 194.5C 37.7233 203.558 19.5417 206.825 17.2771 201.791C 15.0125 196.757 29.5179 185.319 49.653 176.26z"/>
+<defs><radialGradient id="19" cx="46.4327" cy="161.498" r="47.8981" fx="46.4327" fy="161.498" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#19)" d="M 44.7181 151.646C 66.47 147.861 84.894 149.202 85.8404 154.64C 86.7868 160.078 69.8991 167.564 48.1473 171.35C 26.3954 175.135 7.97139 173.794 7.02501 168.356C 6.07862 162.918 22.9663 155.432 44.7181 151.646z"/>
+</g>
+<g>
+<defs><radialGradient id="20" cx="45.1827" cy="137.429" r="47.7585" fx="45.1827" fy="137.429" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#20)" d="M 45.7397 127.445C 67.7843 128.674 85.4281 134.146 85.1206 139.657C 84.8131 145.168 66.6702 148.643 44.6257 147.413C 22.5811 146.184 4.93733 140.712 5.2448 135.201C 5.55227 129.69 23.6952 126.215 45.7397 127.445z"/>
+<defs><radialGradient id="21" cx="49.6787" cy="112.858" r="48.1368" fx="49.6787" fy="112.858" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#21)" d="M 52.6929 103.323C 73.7448 109.978 89.4821 119.652 87.8184 124.915C 86.1547 130.178 67.7165 129.048 46.6645 122.393C 25.6126 115.738 9.87529 106.064 11.539 100.801C 13.2027 95.5378 31.6409 96.6678 52.6929 103.323z"/>
+</g>
+</g>
+<g>
+<g>
+<defs><radialGradient id="22" cx="60.9007" cy="90.3528" r="48.5468" fx="60.9007" fy="90.3528" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#22)" d="M 66.3768 81.9858C 84.8509 94.0758 97.3927 107.639 94.3701 112.257C 91.3475 116.876 73.8987 110.811 55.4246 98.7198C 36.9505 86.6299 24.4087 73.0668 27.4313 68.4489C 30.4539 63.8298 47.9027 69.8948 66.3768 81.9858z"/>
+<defs><radialGradient id="23" cx="77.0826" cy="71.3239" r="48.6458" fx="77.0826" fy="71.3239" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#23)" d="M 84.4616 64.5748C 99.363 80.8669 108.152 97.1148 104.079 100.84C 100.006 104.565 84.6051 94.3648 69.7038 78.0728C 54.8024 61.7809 46.013 45.5338 50.086 41.8078C 54.1589 38.0829 69.5603 48.2828 84.4616 64.5748z"/>
+</g>
+<g>
+<defs><radialGradient id="24" cx="96.6928" cy="57.3108" r="48.4711" fx="96.6928" fy="57.3108" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#24)" d="M 105.406 52.4048C 116.239 71.6429 121.128 89.4579 116.318 92.1658C 111.508 94.8738 98.8115 81.4558 87.979 62.2168C 77.1465 42.9778 72.2579 25.1638 77.0676 22.4558C 81.8773 19.7478 94.5739 33.1658 105.406 52.4048z"/>
+<defs><radialGradient id="25" cx="119.819" cy="47.8708" r="48.0557" fx="119.819" fy="47.8708" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#25)" d="M 129.477 45.2769C 135.203 66.6008 135.524 85.0708 130.193 86.5018C 124.863 87.9338 115.888 71.7878 110.161 50.4648C 104.434 29.1408 104.113 10.6718 109.444 9.23984C 114.775 7.80783 123.75 23.9538 129.477 45.2769z"/>
+</g>
+</g>
+</g>
+<defs><radialGradient id="26" cx="69.0797" cy="209.914" r="48.6339" fx="69.0797" fy="209.914" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#26)" d="M 62.6124 202.287C 79.4523 188.008 96.0187 179.835 99.5885 184.045C 103.158 188.255 92.3869 203.262 75.547 217.541C 58.707 231.82 42.1406 239.993 38.5709 235.783C 35.0011 231.573 45.7725 216.566 62.6124 202.287z"/>
+<defs><radialGradient id="27" cx="145.352" cy="145.241" r="92.2646" fx="145.352" fy="145.241" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#fff82e"/>
+<stop offset="1" style="stop-color:#ffffff"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#27)" d="M 85.3517 145.241C 85.3517 178.359 112.234 205.241 145.352 205.241C 178.47 205.241 205.352 178.359 205.352 145.241C 205.352 112.123 178.47 85.2408 145.352 85.2408C 112.234 85.2408 85.3517 112.123 85.3517 145.241z"/>
+</g>
+</svg>
diff --git a/doc/codesnippets/doc/src/snippets/qt-namespace/main.cpp b/doc/codesnippets/doc/src/snippets/qt-namespace/main.cpp
new file mode 100644
index 000000000..9b83c47b7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qt-namespace/main.cpp
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <Qt>
+
+int main(int argc, char *argv[])
+{
+ return 0;
+}
diff --git a/doc/codesnippets/doc/src/snippets/qt-namespace/qt-namespace.pro b/doc/codesnippets/doc/src/snippets/qt-namespace/qt-namespace.pro
new file mode 100644
index 000000000..bba41b9c1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qt-namespace/qt-namespace.pro
@@ -0,0 +1 @@
+SOURCES = main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/Images/cubed.png b/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/Images/cubed.png
new file mode 100644
index 000000000..2cd9048ca
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/Images/cubed.png
Binary files differ
diff --git a/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/Images/squared.png b/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/Images/squared.png
new file mode 100644
index 000000000..bfdf99328
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/Images/squared.png
Binary files differ
diff --git a/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/images.qrc b/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/images.qrc
new file mode 100644
index 000000000..1d49b5286
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/images.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>Images/squared.png</file>
+ <file>Images/cubed.png</file>
+</qresource>
+</RCC>
diff --git a/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/main.cpp b/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/main.cpp
new file mode 100644
index 000000000..af1e7d5ac
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/mainwindow.cpp b/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/mainwindow.cpp
new file mode 100644
index 000000000..b27743cf1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/mainwindow.cpp
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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);
+
+ tableWidget = new QTableWidget(12, 3, this);
+ tableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ tableWidget->setDragEnabled(true);
+ tableWidget->setAcceptDrops(true);
+ tableWidget->setDropIndicatorShown(true);
+
+ QTableWidgetItem *valuesHeaderItem = new QTableWidgetItem(tr("Values"));
+ tableWidget->setHorizontalHeaderItem(0, valuesHeaderItem);
+ valuesHeaderItem->setTextAlignment(Qt::AlignVCenter);
+ QTableWidgetItem *squaresHeaderItem = new QTableWidgetItem(tr("Squares"));
+ squaresHeaderItem->setIcon(QIcon(QPixmap(":/Images/squared.png")));
+ squaresHeaderItem->setTextAlignment(Qt::AlignVCenter);
+ QTableWidgetItem *cubesHeaderItem = new QTableWidgetItem(tr("Cubes"));
+ cubesHeaderItem->setIcon(QIcon(QPixmap(":/Images/cubed.png")));
+ cubesHeaderItem->setTextAlignment(Qt::AlignVCenter);
+ 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) {
+ QTableWidgetItem *newItem = new QTableWidgetItem(tr("%1").arg(
+ pow((float)row, (float)column+1)));
+ tableWidget->setItem(row, column, newItem);
+ }
+ }
+ for (int column = 0; column < tableWidget->columnCount(); ++column) {
+ QTableWidgetItem *newItem = new QTableWidgetItem;
+ newItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
+ 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()
+{
+ 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));
+}
diff --git a/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/mainwindow.h b/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/mainwindow.h
new file mode 100644
index 000000000..d7a585c8f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/mainwindow.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+
+class QAction;
+class QTableWidget;
+class QTableWidgetItem;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void averageItems();
+ void sumItems();
+
+private:
+ void setupTableItems();
+
+ QAction *removeAction;
+ QTableWidget *tableWidget;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/qtablewidget-dnd.pro b/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/qtablewidget-dnd.pro
new file mode 100644
index 000000000..ffe134cbb
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/qtablewidget-dnd.pro
@@ -0,0 +1,4 @@
+SOURCES = main.cpp \
+ mainwindow.cpp
+HEADERS = mainwindow.h
+RESOURCES += images.qrc
diff --git a/doc/codesnippets/doc/src/snippets/qtablewidget-resizing/main.cpp b/doc/codesnippets/doc/src/snippets/qtablewidget-resizing/main.cpp
new file mode 100644
index 000000000..af1e7d5ac
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtablewidget-resizing/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/qtablewidget-resizing/mainwindow.cpp b/doc/codesnippets/doc/src/snippets/qtablewidget-resizing/mainwindow.cpp
new file mode 100644
index 000000000..76ef3fbf3
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtablewidget-resizing/mainwindow.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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 = QTableWidget()
+//! [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]
+ newItem = QTableWidgetItem(tr("%s" % ((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/codesnippets/doc/src/snippets/qtablewidget-resizing/mainwindow.h b/doc/codesnippets/doc/src/snippets/qtablewidget-resizing/mainwindow.h
new file mode 100644
index 000000000..b756f0b85
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtablewidget-resizing/mainwindow.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+
+class QAction;
+class QTableWidget;
+class QTableWidgetItem;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void changeHeight();
+ void changeWidth();
+
+private:
+ void setupTableItems();
+
+ QTableWidget *tableWidget;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/qtablewidget-resizing/qtablewidget-resizing.pro b/doc/codesnippets/doc/src/snippets/qtablewidget-resizing/qtablewidget-resizing.pro
new file mode 100644
index 000000000..12a900a7c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtablewidget-resizing/qtablewidget-resizing.pro
@@ -0,0 +1,3 @@
+SOURCES = main.cpp \
+ mainwindow.cpp
+HEADERS = mainwindow.h
diff --git a/doc/codesnippets/doc/src/snippets/qtablewidget-using/Images/cubed.png b/doc/codesnippets/doc/src/snippets/qtablewidget-using/Images/cubed.png
new file mode 100644
index 000000000..2cd9048ca
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtablewidget-using/Images/cubed.png
Binary files differ
diff --git a/doc/codesnippets/doc/src/snippets/qtablewidget-using/Images/squared.png b/doc/codesnippets/doc/src/snippets/qtablewidget-using/Images/squared.png
new file mode 100644
index 000000000..bfdf99328
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtablewidget-using/Images/squared.png
Binary files differ
diff --git a/doc/codesnippets/doc/src/snippets/qtablewidget-using/images.qrc b/doc/codesnippets/doc/src/snippets/qtablewidget-using/images.qrc
new file mode 100644
index 000000000..1d49b5286
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtablewidget-using/images.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>Images/squared.png</file>
+ <file>Images/cubed.png</file>
+</qresource>
+</RCC>
diff --git a/doc/codesnippets/doc/src/snippets/qtablewidget-using/main.cpp b/doc/codesnippets/doc/src/snippets/qtablewidget-using/main.cpp
new file mode 100644
index 000000000..af1e7d5ac
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtablewidget-using/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/qtablewidget-using/mainwindow.cpp b/doc/codesnippets/doc/src/snippets/qtablewidget-using/mainwindow.cpp
new file mode 100644
index 000000000..b14846bd4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtablewidget-using/mainwindow.cpp
@@ -0,0 +1,150 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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 = QTableWidget(12, 3, self)
+//! [0]
+ tableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
+
+//! [1]
+ valuesHeaderItem = 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]
+ cubesHeaderItem = 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]
+ newItem = QTableWidgetItem(tr("%s" % 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/codesnippets/doc/src/snippets/qtablewidget-using/mainwindow.h b/doc/codesnippets/doc/src/snippets/qtablewidget-using/mainwindow.h
new file mode 100644
index 000000000..2ace12512
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtablewidget-using/mainwindow.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+
+class QAction;
+class QTableWidget;
+class QTableWidgetItem;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void averageItems();
+ void sumItems();
+
+private:
+ void setupTableItems();
+
+ QAction *removeAction;
+//! [0]
+ QTableWidget *tableWidget;
+//! [0]
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/qtablewidget-using/qtablewidget-using.pro b/doc/codesnippets/doc/src/snippets/qtablewidget-using/qtablewidget-using.pro
new file mode 100644
index 000000000..ffe134cbb
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtablewidget-using/qtablewidget-using.pro
@@ -0,0 +1,4 @@
+SOURCES = main.cpp \
+ mainwindow.cpp
+HEADERS = mainwindow.h
+RESOURCES += images.qrc
diff --git a/doc/codesnippets/doc/src/snippets/qtcast/qtcast.cpp b/doc/codesnippets/doc/src/snippets/qtcast/qtcast.cpp
new file mode 100644
index 000000000..abc7b09ff
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtcast/qtcast.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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/codesnippets/doc/src/snippets/qtcast/qtcast.h b/doc/codesnippets/doc/src/snippets/qtcast/qtcast.h
new file mode 100644
index 000000000..bc4ecd1de
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtcast/qtcast.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTCAST_H
+#define QTCAST_H
+
+#include <QWidget>
+
+class MyWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ MyWidget();
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/qtcast/qtcast.pro b/doc/codesnippets/doc/src/snippets/qtcast/qtcast.pro
new file mode 100644
index 000000000..647616279
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtcast/qtcast.pro
@@ -0,0 +1,2 @@
+HEADERS = qtcast.h
+SOURCES = qtcast.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qtest-namespace/main.cpp b/doc/codesnippets/doc/src/snippets/qtest-namespace/main.cpp
new file mode 100644
index 000000000..bba771480
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtest-namespace/main.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QTest>
+
+int main(int argc, char *argv[])
+{
+ QTest::qSleep(10);
+ return 0;
+}
diff --git a/doc/codesnippets/doc/src/snippets/qtest-namespace/qtest-namespace.pro b/doc/codesnippets/doc/src/snippets/qtest-namespace/qtest-namespace.pro
new file mode 100644
index 000000000..0dfaf99de
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtest-namespace/qtest-namespace.pro
@@ -0,0 +1,2 @@
+SOURCES = main.cpp
+CONFIG += qtestlib
diff --git a/doc/codesnippets/doc/src/snippets/qtreeview-dnd/dragdropmodel.cpp b/doc/codesnippets/doc/src/snippets/qtreeview-dnd/dragdropmodel.cpp
new file mode 100644
index 000000000..9ae2f3892
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtreeview-dnd/dragdropmodel.cpp
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of an example program for Qt.
+** EDITIONS: NOLIMITS
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "dragdropmodel.h"
+
+DragDropModel::DragDropModel(const QStringList &strings, QObject *parent)
+ : TreeModel(strings, parent)
+{
+}
+
+bool DragDropModel::dropMimeData(const QMimeData *data,
+ Qt::DropAction action, int row, int column, const QModelIndex &parent)
+{
+ if (action == Qt::IgnoreAction)
+ return true;
+
+ if (!data->hasFormat("text/plain"))
+ return false;
+
+ int beginRow;
+
+ if (row != -1)
+ beginRow = row;
+ else if (parent.isValid())
+ beginRow = 0;
+ else
+ beginRow = rowCount(QModelIndex());
+
+ QByteArray encodedData = data->data("text/plain");
+ QDataStream stream(&encodedData, QIODevice::ReadOnly);
+ QHash<qint64, QMap<int,QHash<int,QString> > > newItems;
+
+ while (!stream.atEnd()) {
+ qint64 id;
+ int row;
+ int column;
+ QString text;
+ stream >> id >> row >> column >> text;
+ newItems[id][row][column] = text;
+ }
+ int rows = newItems.count();
+
+ insertRows(beginRow, rows, parent);
+ QMap<int,QHash<int,QString> > childItems;
+ foreach (childItems, newItems.values()) {
+ QHash<int,QString> rowItems;
+ foreach (rowItems, childItems.values()) {
+ foreach (int column, rowItems.keys()) {
+ QModelIndex idx = index(beginRow, column, parent);
+ setData(idx, rowItems[column]);
+ }
+ ++beginRow;
+ }
+ }
+
+ return true;
+}
+
+Qt::ItemFlags DragDropModel::flags(const QModelIndex &index) const
+{
+ Qt::ItemFlags defaultFlags = TreeModel::flags(index);
+
+ if (index.isValid())
+ return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags;
+ else
+ return Qt::ItemIsDropEnabled | defaultFlags;
+}
+
+QMimeData *DragDropModel::mimeData(const QModelIndexList &indexes) const
+{
+ QMimeData *mimeData = new QMimeData();
+ QByteArray encodedData;
+
+ QDataStream stream(&encodedData, QIODevice::WriteOnly);
+
+ foreach (QModelIndex index, indexes) {
+ if (index.isValid()) {
+ QString text = data(index, Qt::DisplayRole).toString();
+ stream << index.internalId() << index.row() << index.column() << text;
+ }
+ }
+
+ mimeData->setData("text/plain", encodedData);
+ return mimeData;
+}
+
+QStringList DragDropModel::mimeTypes() const
+{
+ QStringList types;
+ types << "text/plain";
+ return types;
+}
+
+Qt::DropActions DragDropModel::supportedDropActions() const
+{
+ return Qt::CopyAction | Qt::MoveAction;
+}
diff --git a/doc/codesnippets/doc/src/snippets/qtreeview-dnd/dragdropmodel.h b/doc/codesnippets/doc/src/snippets/qtreeview-dnd/dragdropmodel.h
new file mode 100644
index 000000000..88efb1f9d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtreeview-dnd/dragdropmodel.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of an example program for Qt.
+** EDITIONS: NOLIMITS
+**
+****************************************************************************/
+
+#ifndef DRAGDROPMODEL_H
+#define DRAGDROPMODEL_H
+
+#include "treemodel.h"
+
+class DragDropModel : public TreeModel
+{
+ Q_OBJECT
+
+public:
+ DragDropModel(const QStringList &strings, QObject *parent = 0);
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+
+ bool dropMimeData(const QMimeData *data, Qt::DropAction action,
+ int row, int column, const QModelIndex &parent);
+ QMimeData *mimeData(const QModelIndexList &indexes) const;
+ QStringList mimeTypes() const;
+ Qt::DropActions supportedDropActions() const;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/qtreeview-dnd/main.cpp b/doc/codesnippets/doc/src/snippets/qtreeview-dnd/main.cpp
new file mode 100644
index 000000000..af1e7d5ac
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtreeview-dnd/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/qtreeview-dnd/mainwindow.cpp b/doc/codesnippets/doc/src/snippets/qtreeview-dnd/mainwindow.cpp
new file mode 100644
index 000000000..d17817772
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtreeview-dnd/mainwindow.cpp
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+#include "dragdropmodel.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ menuBar()->addMenu(fileMenu);
+
+// For convenient quoting:
+ QTreeView *treeView = new QTreeView(this);
+ treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ treeView->setDragEnabled(true);
+ treeView->setAcceptDrops(true);
+ treeView->setDropIndicatorShown(true);
+
+ this->treeView = treeView;
+
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+
+ setupItems();
+
+ setCentralWidget(treeView);
+ setWindowTitle(tr("Tree View"));
+}
+
+void MainWindow::setupItems()
+{
+ QStringList items;
+ items << tr("Widgets\tUser interface objects used to create GUI applications.")
+ << tr(" QWidget\tThe basic building block for all other widgets.")
+ << tr(" QDialog\tThe base class for dialog windows.")
+ << tr("Tools\tUtilities and applications for Qt developers.")
+ << tr(" Qt Designer\tA GUI form designer for Qt applications.")
+ << tr(" Qt Assistant\tA documentation browser for Qt documentation.");
+
+ DragDropModel *model = new DragDropModel(items, this);
+ QModelIndex index = model->index(0, 0, QModelIndex());
+ model->insertRows(2, 3, index);
+ index = model->index(0, 0, QModelIndex());
+ index = model->index(2, 0, index);
+ model->setData(index, QVariant("QFrame"));
+ model->removeRows(3, 2, index.parent());
+ treeView->setModel(model);
+}
diff --git a/doc/codesnippets/doc/src/snippets/qtreeview-dnd/mainwindow.h b/doc/codesnippets/doc/src/snippets/qtreeview-dnd/mainwindow.h
new file mode 100644
index 000000000..fc1d0ecfa
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtreeview-dnd/mainwindow.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+
+class QTreeView;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+private:
+ void setupItems();
+
+ QTreeView *treeView;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/qtreeview-dnd/qtreeview-dnd.pro b/doc/codesnippets/doc/src/snippets/qtreeview-dnd/qtreeview-dnd.pro
new file mode 100644
index 000000000..5dfabfc83
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtreeview-dnd/qtreeview-dnd.pro
@@ -0,0 +1,9 @@
+SOURCES = dragdropmodel.cpp \
+ main.cpp \
+ mainwindow.cpp \
+ treeitem.cpp \
+ treemodel.cpp
+HEADERS = dragdropmodel.h \
+ mainwindow.h \
+ treeitem.h \
+ treemodel.h
diff --git a/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treeitem.cpp b/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treeitem.cpp
new file mode 100644
index 000000000..8f9261d60
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treeitem.cpp
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ treeitem.cpp
+
+ A container for items of data supplied by the simple tree model.
+*/
+
+#include <QStringList>
+
+#include "treeitem.h"
+
+TreeItem::TreeItem(const QList<QVariant> &data, TreeItem *parent)
+{
+ parentItem = parent;
+ itemData = data;
+}
+
+TreeItem::~TreeItem()
+{
+ qDeleteAll(childItems);
+}
+
+void TreeItem::appendChild(TreeItem *item)
+{
+ childItems.append(item);
+}
+
+TreeItem *TreeItem::child(int row)
+{
+ return childItems.value(row);
+}
+
+int TreeItem::childCount() const
+{
+ return childItems.count();
+}
+
+int TreeItem::columnCount() const
+{
+ return itemData.count();
+}
+
+QVariant TreeItem::data(int column) const
+{
+ return itemData.value(column);
+}
+
+bool TreeItem::insertChild(int row, TreeItem *item)
+{
+ if (row < 0 || row > childItems.count())
+ return false;
+
+ childItems.insert(row, item);
+ return true;
+}
+
+TreeItem *TreeItem::parent()
+{
+ return parentItem;
+}
+
+bool TreeItem::removeChild(int row)
+{
+ if (row < 0 || row >= childItems.count())
+ return false;
+
+ delete childItems.takeAt(row);
+ return true;
+}
+
+int TreeItem::row() const
+{
+ if (parentItem)
+ return parentItem->childItems.indexOf(const_cast<TreeItem*>(this));
+
+ return 0;
+}
+
+bool TreeItem::setData(int column, const QVariant &data)
+{
+ if (column < 0 || column >= itemData.count())
+ return false;
+
+ itemData.replace(column, data);
+ return true;
+}
diff --git a/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treeitem.h b/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treeitem.h
new file mode 100644
index 000000000..5c46ad84f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treeitem.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TREEITEM_H
+#define TREEITEM_H
+
+#include <QList>
+#include <QVariant>
+
+class TreeItem
+{
+public:
+ TreeItem(const QList<QVariant> &data, TreeItem *parent = 0);
+ ~TreeItem();
+
+ void appendChild(TreeItem *child);
+
+ TreeItem *child(int row);
+ int childCount() const;
+ int columnCount() const;
+ QVariant data(int column) const;
+ bool insertChild(int row, TreeItem *item);
+ TreeItem *parent();
+ bool removeChild(int row);
+ int row() const;
+ bool setData(int column, const QVariant &data);
+
+private:
+ QList<TreeItem*> childItems;
+ QList<QVariant> itemData;
+ TreeItem *parentItem;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treemodel.cpp b/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treemodel.cpp
new file mode 100644
index 000000000..f7e36de58
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treemodel.cpp
@@ -0,0 +1,263 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ treemodel.cpp
+
+ Provides a simple tree model to show how to create and use hierarchical
+ models.
+*/
+
+#include <QtGui>
+
+#include "treeitem.h"
+#include "treemodel.h"
+
+TreeModel::TreeModel(const QStringList &strings, QObject *parent)
+ : QAbstractItemModel(parent)
+{
+ QList<QVariant> rootData;
+ rootData << "Title" << "Summary";
+ rootItem = new TreeItem(rootData);
+ setupModelData(strings, rootItem);
+}
+
+TreeModel::~TreeModel()
+{
+ delete rootItem;
+}
+
+int TreeModel::columnCount(const QModelIndex &parent) const
+{
+ if (parent.isValid())
+ return static_cast<TreeItem*>(parent.internalPointer())->columnCount();
+ else
+ return rootItem->columnCount();
+}
+
+QVariant TreeModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ if (role != Qt::DisplayRole)
+ return QVariant();
+
+ TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
+
+ return item->data(index.column());
+}
+
+Qt::ItemFlags TreeModel::flags(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return Qt::ItemIsEnabled;
+
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+}
+
+QVariant TreeModel::headerData(int section, Qt::Orientation orientation,
+ int role) const
+{
+ if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
+ return rootItem->data(section);
+
+ return QVariant();
+}
+
+QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent)
+ const
+{
+ TreeItem *parentItem;
+
+ if (!parent.isValid())
+ parentItem = rootItem;
+ else
+ parentItem = static_cast<TreeItem*>(parent.internalPointer());
+
+ TreeItem *childItem = parentItem->child(row);
+ if (childItem)
+ return createIndex(row, column, childItem);
+ else
+ return QModelIndex();
+}
+
+bool TreeModel::insertRows(int position, int rows, const QModelIndex &parent)
+{
+ TreeItem *parentItem;
+
+ if (!parent.isValid())
+ parentItem = rootItem;
+ else
+ parentItem = static_cast<TreeItem*>(parent.internalPointer());
+
+ if (position < 0 || position > parentItem->childCount())
+ return false;
+
+ QList<QVariant> blankList;
+ for (int column = 0; column < columnCount(); ++column)
+ blankList << QVariant("");
+
+ beginInsertRows(parent, position, position + rows - 1);
+
+ for (int row = 0; row < rows; ++row) {
+ TreeItem *newItem = new TreeItem(blankList, parentItem);
+ if (!parentItem->insertChild(position, newItem))
+ break;
+ }
+
+ endInsertRows();
+ return true;
+}
+
+QModelIndex TreeModel::parent(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return QModelIndex();
+
+ TreeItem *childItem = static_cast<TreeItem*>(index.internalPointer());
+ TreeItem *parentItem = childItem->parent();
+
+ if (parentItem == rootItem)
+ return QModelIndex();
+
+ return createIndex(parentItem->row(), 0, parentItem);
+}
+
+bool TreeModel::removeRows(int position, int rows, const QModelIndex &parent)
+{
+ TreeItem *parentItem;
+
+ if (!parent.isValid())
+ parentItem = rootItem;
+ else
+ parentItem = static_cast<TreeItem*>(parent.internalPointer());
+
+ if (position < 0 || position > parentItem->childCount())
+ return false;
+
+ beginRemoveRows(parent, position, position + rows - 1);
+
+ for (int row = 0; row < rows; ++row) {
+ if (!parentItem->removeChild(position))
+ break;
+ }
+
+ endRemoveRows();
+ return true;
+}
+
+int TreeModel::rowCount(const QModelIndex &parent) const
+{
+ TreeItem *parentItem;
+
+ if (!parent.isValid())
+ parentItem = rootItem;
+ else
+ parentItem = static_cast<TreeItem*>(parent.internalPointer());
+
+ return parentItem->childCount();
+}
+
+bool TreeModel::setData(const QModelIndex &index,
+ const QVariant &value, int role)
+{
+ if (!index.isValid() || role != Qt::EditRole)
+ return false;
+
+ TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
+
+ if (item->setData(index.column(), value))
+ emit dataChanged(index, index);
+ else
+ return false;
+
+ return true;
+}
+
+void TreeModel::setupModelData(const QStringList &lines, TreeItem *parent)
+{
+ QList<TreeItem*> parents;
+ QList<int> indentations;
+ parents << parent;
+ indentations << 0;
+
+ int number = 0;
+
+ while (number < lines.count()) {
+ int position = 0;
+ while (position < lines[number].length()) {
+ if (lines[number].mid(position, 1) != " ")
+ break;
+ position++;
+ }
+
+ QString lineData = lines[number].mid(position).trimmed();
+
+ if (!lineData.isEmpty()) {
+ // Read the column data from the rest of the line.
+ QStringList columnStrings = lineData.split("\t", QString::SkipEmptyParts);
+ QList<QVariant> columnData;
+ for (int column = 0; column < columnStrings.count(); ++column)
+ columnData << columnStrings[column];
+
+ if (position > indentations.last()) {
+ // The last child of the current parent is now the new parent
+ // unless the current parent has no children.
+
+ if (parents.last()->childCount() > 0) {
+ parents << parents.last()->child(parents.last()->childCount()-1);
+ indentations << position;
+ }
+ } else {
+ while (position < indentations.last() && parents.count() > 0) {
+ parents.pop_back();
+ indentations.pop_back();
+ }
+ }
+
+ // Append a new item to the current parent's list of children.
+ parents.last()->appendChild(new TreeItem(columnData, parents.last()));
+ }
+
+ number++;
+ }
+}
diff --git a/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treemodel.h b/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treemodel.h
new file mode 100644
index 000000000..77fc5faea
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treemodel.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TREEMODEL_H
+#define TREEMODEL_H
+
+#include <QAbstractItemModel>
+#include <QModelIndex>
+#include <QVariant>
+
+class TreeItem;
+
+class TreeModel : public QAbstractItemModel
+{
+ Q_OBJECT
+
+public:
+ TreeModel(const QStringList &strings, QObject *parent = 0);
+ ~TreeModel();
+
+ QVariant data(const QModelIndex &index, int role) const;
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+ QModelIndex index(int row, int column,
+ const QModelIndex &parent = QModelIndex()) const;
+ QModelIndex parent(const QModelIndex &index) const;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+
+ bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex());
+ bool removeRows(int position, int rows, const QModelIndex &parent = QModelIndex());
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = Qt::EditRole);
+
+private:
+ void setupModelData(const QStringList &lines, TreeItem *parent);
+
+ TreeItem *rootItem;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/qtreewidget-using/main.cpp b/doc/codesnippets/doc/src/snippets/qtreewidget-using/main.cpp
new file mode 100644
index 000000000..af1e7d5ac
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtreewidget-using/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/qtreewidget-using/mainwindow.cpp b/doc/codesnippets/doc/src/snippets/qtreewidget-using/mainwindow.cpp
new file mode 100644
index 000000000..213e75a1f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtreewidget-using/mainwindow.cpp
@@ -0,0 +1,102 @@
+/############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Nokia Corporation (qt-info@nokia.com)
+##
+## This file is part of the documentation of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at http://www.qtsoftware.com/contact.
+## $QT_END_LICENSE$
+##
+############################################################################/
+
+//! [0]
+ treeWidget = QTreeWidget(self)
+//! [0]
+
+//! [1]
+ treeWidget.setColumnCount(2)
+//! [1] //! [2]
+ headers = QStringList()
+ headers << tr("Subject") << tr("Default")
+ treeWidget.setHeaderLabels(headers)
+//! [2]
+
+//! [3]
+ cities = QTreeWidgetItem(treeWidget)
+ cities.setText(0, tr("Cities"))
+ osloItem = QTreeWidgetItem(cities)
+ osloItem.setText(0, tr("Oslo"))
+ osloItem.setText(1, tr("Yes"))
+//! [3]
+
+//! [4] //! [5]
+ planets = QTreeWidgetItem(treeWidget, cities)
+//! [4]
+ planets.setText(0, tr("Planets"))
+//! [5]
+
+//! [6]
+ item = QTreeWidgetItem()
+//! [6]
+
+//! [7]
+ found = treeWidget.findItems(itemText, Qt.MatchWildcard)
+
+ for item in found:
+ treeWidget.setItemSelected(item, True)
+ # Show the item.text(0) for each item.
+
+//! [7]
+
+//! [8]
+ parent = currentItem.parent()
+ if parent:
+ Item = QTreeWidgetItem(parent, treeWidget.currentItem())
+ else
+//! [8] //! [9]
+ Item = QTreeWidgetItem(treeWidget, treeWidget.currentItem())
+//! [9]
+
+//! [10]
+ parent = currentItem.parent()
+
+ if parent:
+ index = parent.indexOfChild(treeWidget->currentItem())
+ delete parent.takeChild(index)
+ else:
+ index = treeWidget.indexOfTopLevelItem(treeWidget->currentItem())
+ delete treeWidget.takeTopLevelItem(index)
+//! [10] //! [11]
+
+//! [11]
+
diff --git a/doc/codesnippets/doc/src/snippets/qtreewidget-using/mainwindow.h b/doc/codesnippets/doc/src/snippets/qtreewidget-using/mainwindow.h
new file mode 100644
index 000000000..f695be7d6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtreewidget-using/mainwindow.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+
+class QAction;
+class QTreeWidget;
+class QTreeWidgetItem;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void findItems();
+ void insertItem();
+ void removeItem();
+ void sortAscending();
+ void sortDescending();
+ void updateMenus(QTreeWidgetItem *current);
+ void updateSortItems();
+
+private:
+ void setupTreeItems();
+
+ QAction *ascendingAction;
+ QAction *autoSortAction;
+ QAction *descendingAction;
+ QAction *insertAction;
+ QAction *removeAction;
+ QTreeWidget *treeWidget;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/qtreewidget-using/qtreewidget-using.pro b/doc/codesnippets/doc/src/snippets/qtreewidget-using/qtreewidget-using.pro
new file mode 100644
index 000000000..12a900a7c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtreewidget-using/qtreewidget-using.pro
@@ -0,0 +1,3 @@
+SOURCES = main.cpp \
+ mainwindow.cpp
+HEADERS = mainwindow.h
diff --git a/doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/main.cpp b/doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/main.cpp
new file mode 100644
index 000000000..af1e7d5ac
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/mainwindow.cpp b/doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/mainwindow.cpp
new file mode 100644
index 000000000..dbaeac326
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/mainwindow.cpp
@@ -0,0 +1,50 @@
+############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Nokia Corporation (qt-info@nokia.com)
+##
+## This file is part of the documentation of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at http://www.qtsoftware.com/contact.
+## $QT_END_LICENSE$
+##
+############################################################################
+
+
+//! [0]
+ it = QTreeWidgetItemIterator(treeWidget)
+ while it:
+ if it.text(0) == itemText:
+ *it.setSelected(True)
+ ++it
+//! [0]
+
diff --git a/doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/mainwindow.h b/doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/mainwindow.h
new file mode 100644
index 000000000..f695be7d6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/mainwindow.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+
+class QAction;
+class QTreeWidget;
+class QTreeWidgetItem;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void findItems();
+ void insertItem();
+ void removeItem();
+ void sortAscending();
+ void sortDescending();
+ void updateMenus(QTreeWidgetItem *current);
+ void updateSortItems();
+
+private:
+ void setupTreeItems();
+
+ QAction *ascendingAction;
+ QAction *autoSortAction;
+ QAction *descendingAction;
+ QAction *insertAction;
+ QAction *removeAction;
+ QTreeWidget *treeWidget;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/qtreewidgetitemiterator-using.pro b/doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/qtreewidgetitemiterator-using.pro
new file mode 100644
index 000000000..12a900a7c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/qtreewidgetitemiterator-using.pro
@@ -0,0 +1,3 @@
+SOURCES = main.cpp \
+ mainwindow.cpp
+HEADERS = mainwindow.h
diff --git a/doc/codesnippets/doc/src/snippets/qtscript/evaluation/evaluation.pro b/doc/codesnippets/doc/src/snippets/qtscript/evaluation/evaluation.pro
new file mode 100644
index 000000000..a495c0284
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtscript/evaluation/evaluation.pro
@@ -0,0 +1,2 @@
+SOURCES = main.cpp
+QT += script
diff --git a/doc/codesnippets/doc/src/snippets/qtscript/evaluation/main.cpp b/doc/codesnippets/doc/src/snippets/qtscript/evaluation/main.cpp
new file mode 100644
index 000000000..b661542ad
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtscript/evaluation/main.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtScript>
+
+int main(int argc, char *argv[])
+{
+//! [0]
+ QScriptEngine engine;
+ qDebug() << "the magic number is:" << engine.evaluate("1 + 2").toNumber();
+//! [0]
+ return 0;
+}
diff --git a/doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/main.cpp b/doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/main.cpp
new file mode 100644
index 000000000..20c077546
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/main.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QObject>
+#include <QtScript>
+#include "myobject.h"
+
+int main(int argc, char *argv[])
+{
+//! [0]
+ QScriptEngine engine;
+ QObject *someObject = new MyObject;
+ QScriptValue objectValue = engine.newQObject(someObject);
+ engine.globalObject().setProperty("myObject", objectValue);
+//! [0]
+ qDebug() << "myObject's calculate() function returns"
+ << engine.evaluate("myObject.calculate(10)").toNumber();
+ return 0;
+}
diff --git a/doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/myobject.cpp b/doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/myobject.cpp
new file mode 100644
index 000000000..9abc20f19
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/myobject.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "myobject.h"
+
+MyObject::MyObject()
+{
+}
+
+int MyObject::calculate(int value) const
+{
+ int total = 0;
+ for (int i = 0; i <= value; ++i)
+ total += i;
+ return total;
+}
diff --git a/doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/myobject.h b/doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/myobject.h
new file mode 100644
index 000000000..6e5051ceb
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/myobject.h
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MYOBJECT_H
+#define MYOBJECT_H
+
+#include <QObject>
+
+class MyObject : public QObject
+{
+ Q_OBJECT
+
+public:
+ MyObject();
+
+public slots:
+ int calculate(int value) const;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/registeringobjects.pro b/doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/registeringobjects.pro
new file mode 100644
index 000000000..0a755e204
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/registeringobjects.pro
@@ -0,0 +1,4 @@
+SOURCES = main.cpp \
+ myobject.cpp
+HEADERS = myobject.h
+QT += script
diff --git a/doc/codesnippets/doc/src/snippets/qtscript/registeringvalues/main.cpp b/doc/codesnippets/doc/src/snippets/qtscript/registeringvalues/main.cpp
new file mode 100644
index 000000000..b44fc0e19
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtscript/registeringvalues/main.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtScript>
+
+int main(int argc, char *argv[])
+{
+ QScriptEngine engine;
+//! [0]
+ engine.globalObject().setProperty("foo", 123);
+ qDebug() << "foo times two is:" << engine.evaluate("foo * 2").toNumber();
+//! [0]
+ return 0;
+}
+
diff --git a/doc/codesnippets/doc/src/snippets/qtscript/registeringvalues/registeringvalues.pro b/doc/codesnippets/doc/src/snippets/qtscript/registeringvalues/registeringvalues.pro
new file mode 100644
index 000000000..a495c0284
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtscript/registeringvalues/registeringvalues.pro
@@ -0,0 +1,2 @@
+SOURCES = main.cpp
+QT += script
diff --git a/doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/main.cpp b/doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/main.cpp
new file mode 100644
index 000000000..3834e9847
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/main.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QTextEdit>
+#include <QTimer>
+#include <QtScript>
+#include "myobject.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QScriptEngine engine;
+ QFile scriptFile(":/object.js");
+ scriptFile.open(QFile::ReadOnly);
+ engine.evaluate(scriptFile.readAll());
+ scriptFile.close();
+
+ QTextEdit editor;
+ QTimer timer;
+ QScriptValue constructor = engine.evaluate("Object");
+ QScriptValueList arguments;
+ arguments << engine.newQObject(&timer);
+ arguments << engine.newQObject(&editor);
+ QScriptValue object = constructor.construct(arguments);
+ if (engine.hasUncaughtException()) {
+ qDebug() << engine.uncaughtException().toString();
+ }
+
+ editor.show();
+ timer.start(1000);
+
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/object.js b/doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/object.js
new file mode 100644
index 000000000..44ad0e657
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/object.js
@@ -0,0 +1,18 @@
+function Object(timer, editor)
+{
+ this.editor = editor;
+ this.counter = 0;
+ timer.timeout.connect(notify);
+ timer.timeout.connect(this, this.addLine);
+}
+
+Object.prototype.addLine = function()
+{
+ this.editor.append(this.counter);
+ this.counter += 1;
+}
+
+function notify()
+{
+ print("timeout() received");
+}
diff --git a/doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/scriptedslot.pro b/doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/scriptedslot.pro
new file mode 100644
index 000000000..a10f06ec8
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/scriptedslot.pro
@@ -0,0 +1,3 @@
+RESOURCES = scriptedslot.qrc
+SOURCES = main.cpp
+QT += script
diff --git a/doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/scriptedslot.qrc b/doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/scriptedslot.qrc
new file mode 100644
index 000000000..fc7ff67b9
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/scriptedslot.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/" >
+ <file>object.js</file>
+ </qresource>
+</RCC>
diff --git a/doc/codesnippets/doc/src/snippets/quiloader/main.cpp b/doc/codesnippets/doc/src/snippets/quiloader/main.cpp
new file mode 100644
index 000000000..2365942c8
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/quiloader/main.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QtUiTools>
+
+#include "mywidget.h"
+
+//! [0]
+def loadCustomWidget(parent):
+ loader = QUiLoader()
+
+ 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/codesnippets/doc/src/snippets/quiloader/myform.ui b/doc/codesnippets/doc/src/snippets/quiloader/myform.ui
new file mode 100644
index 000000000..00702e860
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/quiloader/myform.ui
@@ -0,0 +1,130 @@
+<ui version="4.0" >
+ <author></author>
+ <comment></comment>
+ <exportmacro></exportmacro>
+ <class>Form</class>
+ <widget class="QWidget" name="Form" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>258</width>
+ <height>224</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Export Document</string>
+ </property>
+ <layout class="QVBoxLayout" >
+ <property name="margin" >
+ <number>8</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QGroupBox" name="groupBox" >
+ <property name="title" >
+ <string>Export Options</string>
+ </property>
+ <layout class="QGridLayout" >
+ <property name="margin" >
+ <number>8</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item row="1" column="0" >
+ <widget class="QRadioButton" name="radioButton_2" >
+ <property name="text" >
+ <string>&amp;DocBook</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" >
+ <widget class="QRadioButton" name="radioButton" >
+ <property name="text" >
+ <string>&amp;LaTeX</string>
+ </property>
+ <property name="checked" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QCheckBox" name="checkBox_2" >
+ <property name="text" >
+ <string>Include p&amp;ictures</string>
+ </property>
+ <property name="checked" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QCheckBox" name="checkBox" >
+ <property name="text" >
+ <string>&amp;Compress</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QRadioButton" name="radioButton_2_2" >
+ <property name="text" >
+ <string>&amp;HTML</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" >
+ <widget class="QRadioButton" name="radioButton_3" >
+ <property name="text" >
+ <string>&amp;PostScript</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0" >
+ <widget class="QRadioButton" name="radioButton_4" >
+ <property name="text" >
+ <string>PD&amp;F</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QCheckBox" name="checkBox_3" >
+ <property name="text" >
+ <string>Include &amp;metadata</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" >
+ <widget class="QCheckBox" name="checkBox_4" >
+ <property name="text" >
+ <string>Create inde&amp;x</string>
+ </property>
+ <property name="checked" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <pixmapfunction></pixmapfunction>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/doc/codesnippets/doc/src/snippets/quiloader/mywidget.cpp b/doc/codesnippets/doc/src/snippets/quiloader/mywidget.cpp
new file mode 100644
index 000000000..26a334361
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/quiloader/mywidget.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QtUiTools>
+
+#include "mywidget.h"
+
+//! [0]
+class MyWidget(QWidget):
+ def __init__(self, parent):
+ loader = QUiLoader()
+ file = QFile(":/forms/myform.ui")
+ file.open(QFile.ReadOnly)
+ myWidget = loader.load(file, self)
+ file.close()
+
+ layout = QVBoxLayout()
+ layout.addWidget(myWidget)
+ self.setLayout(layout)
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/quiloader/mywidget.h b/doc/codesnippets/doc/src/snippets/quiloader/mywidget.h
new file mode 100644
index 000000000..0d6a774e4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/quiloader/mywidget.h
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MYWIDGET_H
+#define MYWIDGET_H
+
+#include <QWidget>
+
+class MyWidget : public QWidget
+{
+public:
+ MyWidget(QWidget *parent = 0);
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/quiloader/mywidget.qrc b/doc/codesnippets/doc/src/snippets/quiloader/mywidget.qrc
new file mode 100644
index 000000000..47684d68b
--- /dev/null
+++ b/doc/codesnippets/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/codesnippets/doc/src/snippets/quiloader/quiloader.pro b/doc/codesnippets/doc/src/snippets/quiloader/quiloader.pro
new file mode 100644
index 000000000..c82d0e5bb
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/quiloader/quiloader.pro
@@ -0,0 +1,4 @@
+HEADERS = mywidget.h
+SOURCES = main.cpp mywidget.cpp
+RESOURCES = mywidget.qrc
+CONFIG += uitools
diff --git a/doc/codesnippets/doc/src/snippets/qx11embedcontainer/main.cpp b/doc/codesnippets/doc/src/snippets/qx11embedcontainer/main.cpp
new file mode 100644
index 000000000..d42f25e26
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qx11embedcontainer/main.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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/codesnippets/doc/src/snippets/qx11embedcontainer/qx11embedcontainer.pro b/doc/codesnippets/doc/src/snippets/qx11embedcontainer/qx11embedcontainer.pro
new file mode 100644
index 000000000..bba41b9c1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qx11embedcontainer/qx11embedcontainer.pro
@@ -0,0 +1 @@
+SOURCES = main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qx11embedwidget/embedwidget.cpp b/doc/codesnippets/doc/src/snippets/qx11embedwidget/embedwidget.cpp
new file mode 100644
index 000000000..ddafe17ff
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qx11embedwidget/embedwidget.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "embedwidget.h"
+
+EmbedWidget::EmbedWidget(QWidget *parent)
+ : QX11EmbedWidget(parent)
+{
+ gradient = QRadialGradient(100, 100, 90, 60, 60);
+ gradient.setColorAt(0.0, Qt::white);
+ gradient.setColorAt(0.9, QColor(192, 192, 255));
+ gradient.setColorAt(1.0, QColor(0, 32, 64));
+}
+
+QSize EmbedWidget::sizeHint() const
+{
+ return QSize(200, 200);
+}
+
+void EmbedWidget::paintEvent(QPaintEvent *event)
+{
+ QPainter painter;
+ painter.begin(this);
+ painter.setRenderHint(QPainter::Antialiasing);
+ painter.fillRect(event->rect(), QBrush(gradient));
+ painter.end();
+}
diff --git a/doc/codesnippets/doc/src/snippets/qx11embedwidget/embedwidget.h b/doc/codesnippets/doc/src/snippets/qx11embedwidget/embedwidget.h
new file mode 100644
index 000000000..dc6115ee1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qx11embedwidget/embedwidget.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef EMBEDWIDGET_H
+#define EMBEDWIDGET_H
+
+#include <QRadialGradient>
+#include <QSize>
+#include <QX11EmbedWidget>
+
+class QPaintEvent;
+
+class EmbedWidget : public QX11EmbedWidget
+{
+ Q_OBJECT
+
+public:
+ EmbedWidget(QWidget *parent = 0);
+ QSize sizeHint() const;
+
+protected:
+ void paintEvent(QPaintEvent *event);
+
+private:
+ QRadialGradient gradient;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/qx11embedwidget/main.cpp b/doc/codesnippets/doc/src/snippets/qx11embedwidget/main.cpp
new file mode 100644
index 000000000..dd0e15d8a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qx11embedwidget/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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/codesnippets/doc/src/snippets/qx11embedwidget/qx11embedwidget.pro b/doc/codesnippets/doc/src/snippets/qx11embedwidget/qx11embedwidget.pro
new file mode 100644
index 000000000..b72e0adff
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qx11embedwidget/qx11embedwidget.pro
@@ -0,0 +1,3 @@
+HEADERS = embedwidget.h
+SOURCES = embedwidget.cpp \
+ main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/qxmlquery/bindingExample.cpp b/doc/codesnippets/doc/src/snippets/qxmlquery/bindingExample.cpp
new file mode 100644
index 000000000..8ed9974af
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qxmlquery/bindingExample.cpp
@@ -0,0 +1,9 @@
+//! [0]
+ QBuffer device;
+ device.setData(myQString.toUtf8());
+ device.open(QIODevice::ReadOnly);
+
+ QXmlQuery query;
+ query.setQuery("doc($inputDocument)/query[theDocument]");
+ query.bindVariable("inputDocument", &device);
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/qxmlstreamwriter/main.cpp b/doc/codesnippets/doc/src/snippets/qxmlstreamwriter/main.cpp
new file mode 100644
index 000000000..5eaaf1417
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qxmlstreamwriter/main.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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://www.qtsoftware.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/codesnippets/doc/src/snippets/qxmlstreamwriter/qxmlstreamwriter.pro b/doc/codesnippets/doc/src/snippets/qxmlstreamwriter/qxmlstreamwriter.pro
new file mode 100644
index 000000000..8f74a5d7a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/qxmlstreamwriter/qxmlstreamwriter.pro
@@ -0,0 +1,2 @@
+SOURCES = main.cpp
+QT += xml
diff --git a/doc/codesnippets/doc/src/snippets/reading-selections/main.cpp b/doc/codesnippets/doc/src/snippets/reading-selections/main.cpp
new file mode 100644
index 000000000..3d3809fec
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/reading-selections/main.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ main.cpp
+
+ A simple example that shows how selections can be used directly on a model.
+ It shows the result of some selections made using a table view.
+*/
+
+#include <QApplication>
+
+#include "window.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QMainWindow *window = new MainWindow;
+ window->show();
+ window->resize(640, 480);
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/reading-selections/model.cpp b/doc/codesnippets/doc/src/snippets/reading-selections/model.cpp
new file mode 100644
index 000000000..2c5c81a21
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/reading-selections/model.cpp
@@ -0,0 +1,239 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ model.cpp
+
+ Provides a table model for use in various examples.
+*/
+
+#include <QtGui>
+
+#include "model.h"
+
+/*!
+ Constructs a table model with at least one row and one column.
+*/
+
+TableModel::TableModel(int rows, int columns, QObject *parent)
+ : QAbstractTableModel(parent)
+{
+ QStringList newList;
+
+ for (int column = 0; column < qMax(1, columns); ++column) {
+ newList.append("");
+ }
+
+ for (int row = 0; row < qMax(1, rows); ++row) {
+ rowList.append(newList);
+ }
+}
+
+
+/*!
+ Returns the number of items in the row list as the number of rows
+ in the model.
+*/
+
+int TableModel::rowCount(const QModelIndex &/*parent*/) const
+{
+ return rowList.size();
+}
+
+/*!
+ Returns the number of items in the first list item as the number of
+ columns in the model. All rows should have the same number of columns.
+*/
+
+int TableModel::columnCount(const QModelIndex &/*parent*/) const
+{
+ return rowList[0].size();
+}
+
+/*!
+ Returns an appropriate value for the requested data.
+ If the view requests an invalid index, an invalid variant is returned.
+ Any valid index that corresponds to a string in the list causes that
+ string to be returned for the display role; otherwise an invalid variant
+ is returned.
+*/
+
+QVariant TableModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ if (role == Qt::DisplayRole)
+ return rowList[index.row()][index.column()];
+ else
+ return QVariant();
+}
+
+/*!
+ Returns the appropriate header string depending on the orientation of
+ the header and the section. If anything other than the display role is
+ requested, we return an invalid variant.
+*/
+
+QVariant TableModel::headerData(int section, Qt::Orientation orientation,
+ int role) const
+{
+ if (role != Qt::DisplayRole)
+ return QVariant();
+
+ if (orientation == Qt::Horizontal)
+ return QString("Column %1").arg(section);
+ else
+ return QString("Row %1").arg(section);
+}
+
+/*!
+ Returns an appropriate value for the item's flags. Valid items are
+ enabled, selectable, and editable.
+*/
+
+Qt::ItemFlags TableModel::flags(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return Qt::ItemIsEnabled;
+
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+}
+
+/*!
+ Changes an item in the model, but only if the following conditions
+ are met:
+
+ * The index supplied is valid.
+ * The role associated with editing text is specified.
+
+ The dataChanged() signal is emitted if the item is changed.
+*/
+
+bool TableModel::setData(const QModelIndex &index,
+ const QVariant &value, int role)
+{
+ if (!index.isValid() || role != Qt::EditRole)
+ return false;
+
+ rowList[index.row()][index.column()] = value.toString();
+ emit dataChanged(index, index);
+ return true;
+}
+
+/*!
+ Inserts a number of rows into the model at the specified position.
+*/
+
+bool TableModel::insertRows(int position, int rows, const QModelIndex &parent)
+{
+ int columns = columnCount();
+ beginInsertRows(parent, position, position + rows - 1);
+
+ for (int row = 0; row < rows; ++row) {
+ QStringList items;
+ for (int column = 0; column < columns; ++column)
+ items.append("");
+ rowList.insert(position, items);
+ }
+
+ endInsertRows();
+ return true;
+}
+
+/*!
+ Inserts a number of columns into the model at the specified position.
+ Each entry in the list is extended in turn with the required number of
+ empty strings.
+*/
+
+bool TableModel::insertColumns(int position, int columns,
+ const QModelIndex &parent)
+{
+ int rows = rowCount();
+ beginInsertColumns(parent, position, position + columns - 1);
+
+ for (int row = 0; row < rows; ++row) {
+ for (int column = position; column < columns; ++column) {
+ rowList[row].insert(position, "");
+ }
+ }
+
+ endInsertColumns();
+ return true;
+}
+
+/*!
+ Removes a number of rows from the model at the specified position.
+*/
+
+bool TableModel::removeRows(int position, int rows, const QModelIndex &parent)
+{
+ beginRemoveRows(parent, position, position + rows - 1);
+
+ for (int row = 0; row < rows; ++row) {
+ rowList.removeAt(position);
+ }
+
+ endRemoveRows();
+ return true;
+}
+
+/*!
+ Removes a number of columns from the model at the specified position.
+ Each row is shortened by the number of columns specified.
+*/
+
+bool TableModel::removeColumns(int position, int columns,
+ const QModelIndex &parent)
+{
+ int rows = rowCount();
+ beginRemoveColumns(parent, position, position + columns - 1);
+
+ for (int row = 0; row < rows; ++row) {
+ for (int column = 0; column < columns; ++column) {
+ rowList[row].removeAt(position);
+ }
+ }
+
+ endRemoveColumns();
+ return true;
+}
diff --git a/doc/codesnippets/doc/src/snippets/reading-selections/model.h b/doc/codesnippets/doc/src/snippets/reading-selections/model.h
new file mode 100644
index 000000000..1bb4441ef
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/reading-selections/model.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MODEL_H
+#define MODEL_H
+
+#include <QAbstractTableModel>
+#include <QStringList>
+#include <QVariant>
+
+class TableModel : public QAbstractTableModel
+{
+ Q_OBJECT
+
+public:
+ TableModel(int rows = 1, int columns = 1, QObject *parent = 0);
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = Qt::EditRole);
+
+ bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex());
+ bool insertColumns(int position, int columns, const QModelIndex &parent = QModelIndex());
+ bool removeRows(int position, int rows, const QModelIndex &parent = QModelIndex());
+ bool removeColumns(int position, int columns, const QModelIndex &parent = QModelIndex());
+
+private:
+ QList<QStringList> rowList;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/reading-selections/reading-selections.pro b/doc/codesnippets/doc/src/snippets/reading-selections/reading-selections.pro
new file mode 100644
index 000000000..91ebd3e84
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/reading-selections/reading-selections.pro
@@ -0,0 +1,2 @@
+HEADERS += model.h window.h
+SOURCES += main.cpp model.cpp window.cpp
diff --git a/doc/codesnippets/doc/src/snippets/reading-selections/window.cpp b/doc/codesnippets/doc/src/snippets/reading-selections/window.cpp
new file mode 100644
index 000000000..41a187a00
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/reading-selections/window.cpp
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ window.cpp
+
+ A minimal subclass of QTableView with slots to allow the selection model
+ to be monitored.
+*/
+
+#include <QAbstractItemModel>
+#include <QItemSelection>
+#include <QItemSelectionModel>
+#include <QMenu>
+#include <QMenuBar>
+#include <QStatusBar>
+
+#include "model.h"
+#include "window.h"
+
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+{
+ setWindowTitle("Selected Items in a Table Model");
+
+ model = new TableModel(8, 4, this);
+
+ table = new QTableView(this);
+ table->setModel(model);
+
+ QMenu *actionMenu = new QMenu(tr("&Actions"), this);
+ QAction *fillAction = actionMenu->addAction(tr("&Fill Selection"));
+ QAction *clearAction = actionMenu->addAction(tr("&Clear Selection"));
+ QAction *selectAllAction = actionMenu->addAction(tr("&Select All"));
+ menuBar()->addMenu(actionMenu);
+
+ connect(fillAction, SIGNAL(triggered()), this, SLOT(fillSelection()));
+ connect(clearAction, SIGNAL(triggered()), this, SLOT(clearSelection()));
+ connect(selectAllAction, SIGNAL(triggered()), this, SLOT(selectAll()));
+
+ selectionModel = table->selectionModel();
+
+ statusBar();
+ setCentralWidget(table);
+}
+
+void MainWindow::fillSelection()
+{
+//! [0]
+ QModelIndexList indexes = selectionModel->selectedIndexes();
+ QModelIndex index;
+
+ foreach(index, indexes) {
+ QString text = QString("(%1,%2)").arg(index.row()).arg(index.column());
+ model->setData(index, text);
+ }
+//! [0]
+}
+
+void MainWindow::clearSelection()
+{
+ QModelIndexList indexes = selectionModel->selectedIndexes();
+ QModelIndex index;
+
+ foreach(index, indexes)
+ model->setData(index, "");
+}
+
+void MainWindow::selectAll()
+{
+//! [1]
+ QModelIndex parent = QModelIndex();
+//! [1] //! [2]
+ QModelIndex topLeft = model->index(0, 0, parent);
+ QModelIndex bottomRight = model->index(model->rowCount(parent)-1,
+ model->columnCount(parent)-1, parent);
+//! [2]
+
+//! [3]
+ QItemSelection selection(topLeft, bottomRight);
+ selectionModel->select(selection, QItemSelectionModel::Select);
+//! [3]
+}
diff --git a/doc/codesnippets/doc/src/snippets/reading-selections/window.h b/doc/codesnippets/doc/src/snippets/reading-selections/window.h
new file mode 100644
index 000000000..e4d2741ca
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/reading-selections/window.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QItemSelection>
+#include <QMainWindow>
+#include <QAbstractItemModel>
+#include <QWidget>
+#include <QTableView>
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+public:
+ MainWindow(QWidget *parent = 0);
+
+private slots:
+ void fillSelection();
+ void clearSelection();
+ void selectAll();
+
+private:
+ QAbstractItemModel *model;
+ QItemSelectionModel *selectionModel;
+ QTableView *table;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/scribe-overview/main.cpp b/doc/codesnippets/doc/src/snippets/scribe-overview/main.cpp
new file mode 100644
index 000000000..116bfec95
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/scribe-overview/main.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+from PySide.QtGui import *
+
+# edit : QTextEdit
+def mergeFormat(edit):
+//! [0]
+ document = edit.document()
+ cursor = QTextCursor(document)
+
+ cursor.movePosition(QTextCursor.Start)
+ cursor.movePosition(QTextCursor.EndOfLine, QTextCursor.KeepAnchor)
+
+ format = QTextCharFormat()
+ format.setFontWeight(QFont.Bold)
+
+ cursor.mergeCharFormat(format)
+//! [0]
+
+def main():
+ aStringContainingHTMLtext QString("<h1>Scribe Overview</h1>")
+
+ app = QApplication(sys.argv)
+
+//! [1]
+ editor = QTextEdit(None)
+ editor.setHtml(aStringContainingHTMLtext)
+ editor.show()
+//! [1]
+
+ return app.exec_()
+
diff --git a/doc/codesnippets/doc/src/snippets/scribe-overview/scribe-overview.pro b/doc/codesnippets/doc/src/snippets/scribe-overview/scribe-overview.pro
new file mode 100644
index 000000000..16181f21c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/scribe-overview/scribe-overview.pro
@@ -0,0 +1 @@
+SOURCES = main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/scriptdebugger.cpp b/doc/codesnippets/doc/src/snippets/scriptdebugger.cpp
new file mode 100644
index 000000000..dcb81b532
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/scriptdebugger.cpp
@@ -0,0 +1,64 @@
+
+#include <QtGui>
+#include <QtScript>
+#include <QtScriptTools>
+
+// Perhaps shpw entire example for getting debugger up with script
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+
+ QString fileName("helloscript.qs");
+ QFile scriptFile(fileName);
+ scriptFile.open(QIODevice::ReadOnly);
+ QTextStream stream(&scriptFile);
+ QString contents = stream.readAll();
+ scriptFile.close();
+
+ QScriptEngine *engine = new QScriptEngine();
+
+ QScriptEngineDebugger *debugger = new QScriptEngineDebugger();
+ debugger->attachTo(engine);
+
+ // Set up configuration with only stack and code
+ QWidget *widget = new QWidget;
+//![0]
+ codeWindow = debugger.widget(QScriptEngineDebugger.CodeWidget)
+ stackWidget = debugger.widget(QScriptEngineDebugger.StackWidget)
+
+ layout = QHBoxLayout()
+ layout.addWidget(codeWindow)
+ layout.addWidget(stackWidget)
+//![0]
+
+//![1]
+ continueAction = debugger.action(QScriptEngineDebugger.ContinueAction)
+ stepOverAction = debugger.action(QScriptEngineDebugger.StepOverAction)
+ stepIntoAction = debugger.action(QScriptEngineDebugger.StepIntoAction)
+
+ toolBar = QToolBar()
+ toolBar.addAction(continueAction)
+//![1]
+ toolBar->addAction(stepOverAction);
+ toolBar->addAction(stepIntoAction);
+
+ layout->addWidget(toolBar);
+ continueAction->setIcon(QIcon("copy.png"));
+
+ debugger->setAutoShowStandardWindow(false);
+
+ widget->setLayout(layout);
+ widget->show();
+
+ QPushButton button;
+ QScriptValue scriptButton = engine->newQObject(&button);
+ engine->globalObject().setProperty("button", scriptButton);
+
+//![2]
+ debugger.action(QScriptEngineDebugger.InterruptAction).trigger()
+ engine.evaluate(contents, fileName)
+//![2]
+
+ return app.exec();
+}
+
diff --git a/doc/codesnippets/doc/src/snippets/seekslider.cpp b/doc/codesnippets/doc/src/snippets/seekslider.cpp
new file mode 100644
index 000000000..c03efe186
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/seekslider.cpp
@@ -0,0 +1,26 @@
+#include <QtGui>
+
+#include <phonon/audiooutput.h>
+#include <phonon/seekslider.h>
+#include <phonon/mediaobject.h>
+#include <phonon/audiooutput.h>
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args)
+
+//![0]
+ moo = Phonon.MediaObject()
+ device = Phonon.AudioOutput()
+ Phonon.createPath(moo, device)
+ moo.setCurrentSource(QString("/home/gvatteka/Music/Lumme-Badloop.ogg"))
+
+ slider = Phonon.SeekSlider()
+ slider.setMediaObject(moo)
+
+ slider.show()
+ moo.play()
+//![0]
+
+ app.exec()
+}
diff --git a/doc/codesnippets/doc/src/snippets/separations/finalwidget.cpp b/doc/codesnippets/doc/src/snippets/separations/finalwidget.cpp
new file mode 100644
index 000000000..9e5538632
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/separations/finalwidget.cpp
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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]
+ output = QByteArray()
+ outputBuffer = QBuffer(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/codesnippets/doc/src/snippets/separations/finalwidget.h b/doc/codesnippets/doc/src/snippets/separations/finalwidget.h
new file mode 100644
index 000000000..2a75903da
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/separations/finalwidget.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef FINALWIDGET_H
+#define FINALWIDGET_H
+
+#include <QFrame>
+#include <QImage>
+#include <QPoint>
+#include <QSize>
+
+class QGridLayout;
+class QLabel;
+class QMouseEvent;
+class QWidget;
+
+class FinalWidget : public QFrame
+{
+ Q_OBJECT
+
+public:
+ FinalWidget(QWidget *parent, const QString &name, const QSize &labelSize);
+ void setPixmap(const QPixmap &pixmap);
+ const QPixmap *pixmap() const;
+
+protected:
+ void mouseMoveEvent(QMouseEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+
+private:
+ void createImage();
+
+ bool hasImage;
+ QImage originalImage;
+ QLabel *imageLabel;
+ QLabel *nameLabel;
+ QPoint dragStartPosition;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/separations/main.cpp b/doc/codesnippets/doc/src/snippets/separations/main.cpp
new file mode 100644
index 000000000..441c4edfd
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/separations/main.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include "viewer.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Viewer viewer;
+ viewer.show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/separations/screenwidget.cpp b/doc/codesnippets/doc/src/snippets/separations/screenwidget.cpp
new file mode 100644
index 000000000..4bf942e2b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/separations/screenwidget.cpp
@@ -0,0 +1,218 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+screenwidget.cpp
+
+A widget to display colour components from an image using independently
+selected colors. Controls are provided to allow the image to be inverted, and
+the color to be selection via a standard dialog. The image is displayed in a
+label widget.
+*/
+
+#include <QApplication>
+#include <QColorDialog>
+#include <QGridLayout>
+#include <QImage>
+#include <QLabel>
+#include <QMenu>
+#include <QMimeData>
+#include <QMouseEvent>
+#include <QPixmap>
+#include <QPushButton>
+#include <QWidget>
+
+#include "screenwidget.h"
+
+/*!
+Initializes the paint color, the mask color (cyan, magenta,
+or yellow), connects the color selector and invert checkbox to functions,
+and creates a two-by-two grid layout.
+*/
+
+ScreenWidget::ScreenWidget(QWidget *parent, QColor initialColor,
+ const QString &name, Separation mask,
+ const QSize &labelSize)
+ : QFrame(parent)
+{
+ paintColor = initialColor;
+ maskColor = mask;
+ inverted = false;
+
+ imageLabel = new QLabel;
+ imageLabel->setFrameShadow(QFrame::Sunken);
+ imageLabel->setFrameShape(QFrame::StyledPanel);
+ imageLabel->setMinimumSize(labelSize);
+
+ nameLabel = new QLabel(name);
+ colorButton = new QPushButton(tr("Modify..."));
+ colorButton->setBackgroundRole(QPalette::Button);
+ colorButton->setMinimumSize(32, 32);
+
+ QPalette palette(colorButton->palette());
+ palette.setColor(QPalette::Button, initialColor);
+ colorButton->setPalette(palette);
+
+ invertButton = new QPushButton(tr("Invert"));
+ //invertButton->setToggleButton(true);
+ //invertButton->setOn(inverted);
+ invertButton->setEnabled(false);
+
+ connect(colorButton, SIGNAL(clicked()), this, SLOT(setColor()));
+ connect(invertButton, SIGNAL(clicked()), this, SLOT(invertImage()));
+
+ QGridLayout *gridLayout = new QGridLayout;
+ gridLayout->addWidget(imageLabel, 0, 0, 1, 2);
+ gridLayout->addWidget(nameLabel, 1, 0);
+ gridLayout->addWidget(colorButton, 1, 1);
+ gridLayout->addWidget(invertButton, 2, 1, 1, 1);
+ setLayout(gridLayout);
+}
+
+/*!
+ Creates a new image by separating out the cyan, magenta, or yellow
+ component, depending on the mask color specified in the constructor.
+
+ The amount of the component found in each pixel of the image is used
+ to determine how much of a user-selected ink is used for each pixel
+ in the new image for the label widget.
+*/
+
+void ScreenWidget::createImage()
+{
+ newImage = originalImage.copy();
+
+ // Create CMY components for the ink being used.
+ float cyanInk = (255 - paintColor.red())/255.0;
+ float magentaInk = (255 - paintColor.green())/255.0;
+ float yellowInk = (255 - paintColor.blue())/255.0;
+
+ int (*convert)(QRgb);
+
+ switch (maskColor) {
+ case Cyan:
+ convert = qRed;
+ break;
+ case Magenta:
+ convert = qGreen;
+ break;
+ case Yellow:
+ convert = qBlue;
+ break;
+ }
+
+ for (int y = 0; y < newImage.height(); ++y) {
+ for (int x = 0; x < newImage.width(); ++x) {
+ QRgb p(originalImage.pixel(x, y));
+
+ // Separate the source pixel into its cyan component.
+ int amount;
+
+ if (inverted)
+ amount = convert(p);
+ else
+ amount = 255 - convert(p);
+
+ QColor newColor(
+ 255 - qMin(int(amount * cyanInk), 255),
+ 255 - qMin(int(amount * magentaInk), 255),
+ 255 - qMin(int(amount * yellowInk), 255));
+
+ newImage.setPixel(x, y, newColor.rgb());
+ }
+ }
+
+ imageLabel->setPixmap(QPixmap::fromImage(newImage));
+}
+
+/*!
+ Returns a pointer to the modified image.
+*/
+
+QImage* ScreenWidget::image()
+{
+ return &newImage;
+}
+
+/*!
+ Sets whether the amount of ink applied to the canvas is to be inverted
+ (subtracted from the maximum value) before the ink is applied.
+*/
+
+void ScreenWidget::invertImage()
+{
+ //inverted = invertButton->isOn();
+ inverted = !inverted;
+ createImage();
+ emit imageChanged();
+}
+
+/*!
+ Separate the current image into cyan, magenta, and yellow components.
+ Create a representation of how each component might appear when applied
+ to a blank white piece of paper.
+*/
+
+void ScreenWidget::setColor()
+{
+ QColor newColor = QColorDialog::getColor(paintColor);
+
+ if (newColor.isValid()) {
+ paintColor = newColor;
+ QPalette palette(colorButton->palette());
+ palette.setColor(QPalette::Button, paintColor);
+ colorButton->setPalette(palette);
+ createImage();
+ emit imageChanged();
+ }
+}
+
+/*!
+ Records the original image selected by the user, creates a color
+ separation, and enables the invert image checkbox.
+*/
+
+void ScreenWidget::setImage(QImage &image)
+{
+ originalImage = image;
+ createImage();
+ invertButton->setEnabled(true);
+}
diff --git a/doc/codesnippets/doc/src/snippets/separations/screenwidget.h b/doc/codesnippets/doc/src/snippets/separations/screenwidget.h
new file mode 100644
index 000000000..c03ebd9fc
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/separations/screenwidget.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SCREENWIDGET_H
+#define SCREENWIDGET_H
+
+#include <QColor>
+#include <QFrame>
+#include <QImage>
+#include <QSize>
+
+class QGridLayout;
+class QLabel;
+class QPushButton;
+class QWidget;
+
+class ScreenWidget : public QFrame
+{
+ Q_OBJECT
+public:
+ enum Separation { Cyan, Magenta, Yellow };
+
+ ScreenWidget(QWidget *parent, QColor initialColor, const QString &name,
+ Separation mask, const QSize &labelSize);
+ void setImage(QImage &image);
+ QImage* image();
+
+signals:
+ void imageChanged();
+
+public slots:
+ void setColor();
+ void invertImage();
+
+private:
+ void createImage();
+
+ bool inverted;
+ QColor paintColor;
+ QImage newImage;
+ QImage originalImage;
+ QLabel *imageLabel;
+ QLabel *nameLabel;
+ QPushButton *colorButton;
+ QPushButton *invertButton;
+ Separation maskColor;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/separations/separations.pro b/doc/codesnippets/doc/src/snippets/separations/separations.pro
new file mode 100644
index 000000000..48af2c847
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/separations/separations.pro
@@ -0,0 +1,7 @@
+HEADERS = finalwidget.h \
+ screenwidget.h \
+ viewer.h
+SOURCES = finalwidget.cpp \
+ main.cpp \
+ screenwidget.cpp \
+ viewer.cpp
diff --git a/doc/codesnippets/doc/src/snippets/separations/separations.qdoc b/doc/codesnippets/doc/src/snippets/separations/separations.qdoc
new file mode 100644
index 000000000..fd143c40e
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/separations/separations.qdoc
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ \example painting/separations
+ \title Color Separations Example
+
+ This example enables simple color manipulation of images and demonstrates a
+ number of image-related features of Qt, from per-pixel image manipulation to
+ drag and drop handling of images.
+
+ \image separations-example.png
+
+ The application allows the user to load an image, shown in the top-left
+ part of the main window, and to adjust its color balance by replacing its
+ initial cyan, magenta, and yellow components with different colors.
+*/
diff --git a/doc/codesnippets/doc/src/snippets/separations/viewer.cpp b/doc/codesnippets/doc/src/snippets/separations/viewer.cpp
new file mode 100644
index 000000000..494c34b1f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/separations/viewer.cpp
@@ -0,0 +1,329 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+viewer.cpp
+
+Provides a main window for displaying a user-specified original image
+with three color separations in a grid layout.
+
+A main menu provides entries for selecting files, and adjusting the
+brightness of the separations.
+*/
+
+#include <QtGui>
+
+#include "finalwidget.h"
+#include "screenwidget.h"
+#include "viewer.h"
+
+/*
+ Constructor: initializes a default value for the brightness, creates
+ the main menu entries, and constructs a central widget that contains
+ enough space for images to be displayed.
+*/
+
+Viewer::Viewer()
+{
+ setWindowTitle(tr("QImage Color Separations"));
+
+ brightness = 255;
+
+ createMenus();
+ setCentralWidget(createCentralWidget());
+}
+
+/*
+ Creates a main menu with two entries: a File menu, to allow the image
+ to be selected, and a Brightness menu to allow the brightness of the
+ separations to be changed.
+
+ Initially, the Brightness menu items are disabled, but the first entry in
+ the menu is checked to reflect the default brightness.
+*/
+
+void Viewer::createMenus()
+{
+ fileMenu = new QMenu(tr("&File"), this);
+ brightnessMenu = new QMenu(tr("&Brightness"), this);
+
+ QAction *openAction = fileMenu->addAction(tr("&Open..."));
+ openAction->setShortcut(QKeySequence("Ctrl+O"));
+ saveAction = fileMenu->addAction(tr("&Save..."));
+ saveAction->setShortcut(QKeySequence("Ctrl+S"));
+ saveAction->setEnabled(false);
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(QKeySequence("Ctrl+Q"));
+
+ QAction *noBrightness = brightnessMenu->addAction(tr("&0%"));
+ noBrightness->setCheckable(true);
+ QAction *quarterBrightness = brightnessMenu->addAction(tr("&25%"));
+ quarterBrightness->setCheckable(true);
+ QAction *halfBrightness = brightnessMenu->addAction(tr("&50%"));
+ halfBrightness->setCheckable(true);
+ QAction *threeQuartersBrightness = brightnessMenu->addAction(tr("&75%"));
+ threeQuartersBrightness->setCheckable(true);
+ QAction *fullBrightness = brightnessMenu->addAction(tr("&100%"));
+ fullBrightness->setCheckable(true);
+
+ menuMap[noBrightness] = None;
+ menuMap[quarterBrightness] = Quarter;
+ menuMap[halfBrightness] = Half;
+ menuMap[threeQuartersBrightness] = ThreeQuarters;
+ menuMap[fullBrightness] = Full;
+
+ currentBrightness = fullBrightness;
+ currentBrightness->setChecked(true);
+ brightnessMenu->setEnabled(false);
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(brightnessMenu);
+
+ connect(openAction, SIGNAL(triggered()), this, SLOT(chooseFile()));
+ connect(saveAction, SIGNAL(triggered()), this, SLOT(saveImage()));
+ connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
+ connect(brightnessMenu, SIGNAL(triggered(QAction *)), this,
+ SLOT(setBrightness(QAction *)));
+}
+
+/*
+ Constructs a central widget for the window consisting of a two-by-two
+ grid of labels, each of which will contain an image. We restrict the
+ size of the labels to 256 pixels, and ensure that the window cannot
+ be resized.
+*/
+
+QFrame* Viewer::createCentralWidget()
+{
+ QFrame* frame = new QFrame(this);
+ grid = new QGridLayout(frame);
+ grid->setSpacing(8);
+ grid->setMargin(4);
+
+ layout()->setSizeConstraint(QLayout::SetFixedSize);
+
+ QSize labelSize(256, 256);
+
+ finalWidget = new FinalWidget(frame, tr("Final image"), labelSize);
+
+ cyanWidget = new ScreenWidget(frame, Qt::cyan, tr("Cyan"),
+ ScreenWidget::Cyan, labelSize);
+ magentaWidget = new ScreenWidget(frame, Qt::magenta, tr("Magenta"),
+ ScreenWidget::Magenta, labelSize);
+ yellowWidget = new ScreenWidget(frame, Qt::yellow, tr("Yellow"),
+ ScreenWidget::Yellow, labelSize);
+
+ connect(cyanWidget, SIGNAL(imageChanged()), this, SLOT(createImage()));
+ connect(magentaWidget, SIGNAL(imageChanged()), this, SLOT(createImage()));
+ connect(yellowWidget, SIGNAL(imageChanged()), this, SLOT(createImage()));
+
+ grid->addWidget(finalWidget, 0, 0, Qt::AlignTop | Qt::AlignHCenter);
+ grid->addWidget(cyanWidget, 0, 1, Qt::AlignTop | Qt::AlignHCenter);
+ grid->addWidget(magentaWidget, 1, 0, Qt::AlignTop | Qt::AlignHCenter);
+ grid->addWidget(yellowWidget, 1, 1, Qt::AlignTop | Qt::AlignHCenter);
+
+ return frame;
+}
+
+/*
+ Provides a dialog window to allow the user to specify an image file.
+ If a file is selected, the appropriate function is called to process
+ and display it.
+*/
+
+void Viewer::chooseFile()
+{
+ QString imageFile = QFileDialog::getOpenFileName(this,
+ tr("Choose an image file to open"), path, tr("Images (*.*)"));
+
+ if (!imageFile.isEmpty()) {
+ openImageFile(imageFile);
+ path = imageFile;
+ }
+}
+
+/*
+ Changes the value of the brightness according to the entry selected in the
+ Brightness menu. The selected entry is checked, and the previously selected
+ entry is unchecked.
+
+ The color separations are updated to use the new value for the brightness.
+*/
+
+void Viewer::setBrightness(QAction *action)
+{
+ if (!menuMap.contains(action) || scaledImage.isNull())
+ return;
+
+ Brightness amount = menuMap[action];
+
+ switch (amount) {
+ case None:
+ brightness = 0; break;
+ case Quarter:
+ brightness = 64; break;
+ case Half:
+ brightness = 128; break;
+ case ThreeQuarters:
+ brightness = 191; break;
+ case Full:
+ brightness = 255; break;
+ default: return;
+ }
+
+ currentBrightness->setChecked(false);
+ currentBrightness = action;
+ currentBrightness->setChecked(true);
+
+ createImage();
+}
+
+/*
+ Load the image from the file given, and create four pixmaps based
+ on the original image.
+
+ The window caption is set, and the Brightness menu enabled if the image file
+ can be loaded.
+*/
+
+void Viewer::openImageFile(QString &imageFile)
+{
+ QImage originalImage;
+
+ if (originalImage.load(imageFile)) {
+ setWindowTitle(imageFile);
+ //menuBar()->setItemEnabled(brightnessMenuId, true);
+ saveAction->setEnabled(true);
+ brightnessMenu->setEnabled(true);
+
+ /* Note: the ScaleMin value may be different for Qt 4. */
+ scaledImage = originalImage.scaled(256, 256, Qt::KeepAspectRatio);
+
+ cyanWidget->setImage(scaledImage);
+ magentaWidget->setImage(scaledImage);
+ yellowWidget->setImage(scaledImage);
+ createImage();
+ }
+ else
+ (void) QMessageBox::warning(this, tr("Cannot open file"),
+ tr("The selected file could not be opened."),
+ QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton);
+}
+
+/*
+ Creates an image by combining the contents of the three screens
+ to present a page preview.
+
+ The image associated with each screen is separated into cyan,
+ magenta, and yellow components. We add up the values for each
+ component from the three screen images, and subtract the totals
+ from the maximum value for each corresponding primary color.
+*/
+
+void Viewer::createImage()
+{
+ QImage newImage = scaledImage.copy();
+
+ QImage *image1 = cyanWidget->image();
+ QImage *image2 = magentaWidget->image();
+ QImage *image3 = yellowWidget->image();
+ int darkness = 255 - brightness;
+
+ for (int y = 0; y < newImage.height(); ++y) {
+ for (int x = 0; x < newImage.width(); ++x) {
+
+ // Create three screens, using the quantities of the source
+ // CMY components to determine how much of each of the
+ // inks are to be put on each screen.
+ QRgb p1(image1->pixel(x, y));
+ float cyan1 = 255 - qRed(p1);
+ float magenta1 = 255 - qGreen(p1);
+ float yellow1 = 255 - qBlue(p1);
+
+ QRgb p2(image2->pixel(x, y));
+ float cyan2 = 255 - qRed(p2);
+ float magenta2 = 255 - qGreen(p2);
+ float yellow2 = 255 - qBlue(p2);
+
+ QRgb p3(image3->pixel(x, y));
+ float cyan3 = 255 - qRed(p3);
+ float magenta3 = 255 - qGreen(p3);
+ float yellow3 = 255 - qBlue(p3);
+
+ QColor newColor(
+ qMax(255 - int(cyan1+cyan2+cyan3) - darkness, 0),
+ qMax(255 - int(magenta1+magenta2+magenta3) - darkness, 0),
+ qMax(255 - int(yellow1+yellow2+yellow3) - darkness, 0));
+
+ newImage.setPixel(x, y, newColor.rgb());
+ }
+ }
+
+ finalWidget->setPixmap(QPixmap::fromImage(newImage));
+}
+
+/*
+ Provides a dialog window to allow the user to save the image file.
+*/
+
+void Viewer::saveImage()
+{
+ QString imageFile = QFileDialog::getSaveFileName(this,
+ tr("Choose a filename to save the image"), "", tr("Images (*.png)"));
+
+ QFileInfo info(imageFile);
+
+ if (!info.baseName().isEmpty()) {
+ QString newImageFile = QFileInfo(info.absoluteDir(),
+ info.baseName() + ".png").absoluteFilePath();
+
+ if (!finalWidget->pixmap()->save(newImageFile, "PNG"))
+ (void) QMessageBox::warning(this, tr("Cannot save file"),
+ tr("The file could not be saved."),
+ QMessageBox::Cancel, QMessageBox::NoButton,
+ QMessageBox::NoButton);
+ }
+ else
+ (void) QMessageBox::warning(this, tr("Cannot save file"),
+ tr("Please enter a valid filename."),
+ QMessageBox::Cancel, QMessageBox::NoButton,
+ QMessageBox::NoButton);
+}
diff --git a/doc/codesnippets/doc/src/snippets/separations/viewer.h b/doc/codesnippets/doc/src/snippets/separations/viewer.h
new file mode 100644
index 000000000..f910d643e
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/separations/viewer.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef VIEWER_H
+#define VIEWER_H
+
+#include <QImage>
+#include <QMainWindow>
+#include <QMap>
+
+class QAction;
+class QFrame;
+class QGridLayout;
+class QLabel;
+class QMenu;
+class FinalWidget;
+class ScreenWidget;
+
+class Viewer : public QMainWindow
+{
+ Q_OBJECT
+public:
+ enum Brightness { None, Quarter, Half, ThreeQuarters, Full };
+ Viewer();
+
+public slots:
+ void chooseFile();
+ void setBrightness(QAction *action);
+ void createImage();
+ void saveImage();
+
+private:
+ void createMenus();
+ QFrame *createCentralWidget();
+ void openImageFile(QString &filePath);
+
+ FinalWidget *finalWidget;
+ int brightness;
+ QAction *currentBrightness;
+ QAction *saveAction;
+ QGridLayout *grid;
+ QImage scaledImage;
+ QMap <QAction*,Brightness> menuMap;
+ QMenu *brightnessMenu;
+ QMenu *fileMenu;
+ QString path;
+ ScreenWidget *cyanWidget;
+ ScreenWidget *magentaWidget;
+ ScreenWidget *yellowWidget;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/settings/settings.cpp b/doc/codesnippets/doc/src/snippets/settings/settings.cpp
new file mode 100644
index 000000000..549beb6db
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/settings/settings.cpp
@@ -0,0 +1,179 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+QWidget *win
+QWidget *panel
+
+void snippet_ctor1()
+{
+//! [0]
+ settings = QSettings("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]
+ settings = QSettings()
+//! [4]
+
+//! [5]
+ settings.setValue("editor/wrapMargin", 68)
+//! [5] //! [6]
+ margin = settings.value("editor/wrapMargin").toInt()
+//! [6]
+ {
+//! [7]
+ 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]
+ obj1 = QSettings("MySoft", "Star Runner")
+//! [13] //! [14]
+ obj2 = QSettings("MySoft")
+ obj3 = QSettings(QSettings.SystemScope, "MySoft", "Star Runner")
+ obj4 = QSettings(QSettings.SystemScope, "MySoft")
+//! [14]
+
+ {
+//! [15]
+ settings = QSettings(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]
+class MainWindow(QMainWindow):
+ ...
+ def writeSettings(self):
+ self.settings = QSettings("Moose Soft", "Clipper")
+ self.settings.beginGroup("MainWindow")
+ self.settings.setValue("size", self.size())
+ self.settings.setValue("pos", self.pos())
+ self.settings.endGroup()
+//! [16]
+
+//! [17]
+ def readSettings(self):
+ self.settings = QSettings("Moose Soft", "Clipper")
+ self.settings.beginGroup("MainWindow")
+ self.resize(settings.value("size", QSize(400, 400)).toSize())
+ self.move(settings.value("pos", QPoint(200, 200)).toPoint())
+ self.settings.endGroup()
+//! [17]
+
+//! [18]
+ def __init__(self):
+ self.settings = None
+//! [18] //! [19]
+ self.readSettings()
+//! [19] //! [20]
+
+//! [20]
+
+bool userReallyWantsToQuit() { return true; }
+
+//! [21]
+ # event : QCloseEvent
+ def closeEvent(self, event):
+ if self.userReallyWantsToQuit():
+ self.writeSettings()
+ event.accept()
+ else:
+ event.ignore()
+//! [21]
diff --git a/doc/codesnippets/doc/src/snippets/shareddirmodel/main.cpp b/doc/codesnippets/doc/src/snippets/shareddirmodel/main.cpp
new file mode 100644
index 000000000..afb2b060b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/shareddirmodel/main.cpp
@@ -0,0 +1,80 @@
+############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Nokia Corporation (qt-info@nokia.com)
+##
+## This file is part of the documentation of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at http://www.qtsoftware.com/contact.
+## $QT_END_LICENSE$
+##
+############################################################################
+
+"""
+ main.cpp
+
+ A simple example of how to view a model in several views, and share a
+ selection model.
+"""
+
+from PySide.QtGui import *
+
+
+//! [0] //! [1]
+def main():
+ app = QApplication(sys.argv)
+ splitter = QSplitter()
+
+//! [2] //! [3]
+ model = QDirModel()
+//! [0] //! [2] //! [4] //! [5]
+ tree = QTreeView(splitter)
+//! [3] //! [6]
+ tree.setModel(model)
+//! [4] //! [6] //! [7]
+ tree.setRootIndex(model.index(QDir.currentPath()))
+//! [7]
+
+ list = QListView(splitter)
+ list.setModel(model)
+ list.setRootIndex(model.index(QDir.currentPath()))
+
+//! [5]
+ selection = QItemSelectionModel(model)
+ tree.setSelectionModel(selection)
+ list.setSelectionModel(selection)
+
+//! [8]
+ splitter.setWindowTitle("Two views onto the same directory model")
+ splitter.show()
+ return app.exec_()
+//! [1] //! [8]
diff --git a/doc/codesnippets/doc/src/snippets/shareddirmodel/shareddirmodel.pro b/doc/codesnippets/doc/src/snippets/shareddirmodel/shareddirmodel.pro
new file mode 100644
index 000000000..28dcadcbf
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/shareddirmodel/shareddirmodel.pro
@@ -0,0 +1 @@
+SOURCES += main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/sharedemployee/employee.cpp b/doc/codesnippets/doc/src/snippets/sharedemployee/employee.cpp
new file mode 100644
index 000000000..5eb74ea12
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/sharedemployee/employee.cpp
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "employee.h"
diff --git a/doc/codesnippets/doc/src/snippets/sharedemployee/employee.h b/doc/codesnippets/doc/src/snippets/sharedemployee/employee.h
new file mode 100644
index 000000000..fd56fec6e
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/sharedemployee/employee.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef EMPLOYEE_H
+#define EMPLOYEE_H
+
+//! [0]
+#include <QSharedData>
+#include <QString>
+
+class EmployeeData : public QSharedData
+{
+ public:
+ EmployeeData() : id(-1) { name.clear(); }
+ 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/codesnippets/doc/src/snippets/sharedemployee/main.cpp b/doc/codesnippets/doc/src/snippets/sharedemployee/main.cpp
new file mode 100644
index 000000000..68f6a647c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/sharedemployee/main.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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/codesnippets/doc/src/snippets/sharedemployee/sharedemployee.pro b/doc/codesnippets/doc/src/snippets/sharedemployee/sharedemployee.pro
new file mode 100644
index 000000000..536a77de5
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/sharedemployee/sharedemployee.pro
@@ -0,0 +1,3 @@
+HEADERS = employee.h
+SOURCES = employee.cpp \
+ main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/sharedtablemodel/main.cpp b/doc/codesnippets/doc/src/snippets/sharedtablemodel/main.cpp
new file mode 100644
index 000000000..bc98938de
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/sharedtablemodel/main.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ main.cpp
+
+ A simple example that shows how a single model can be shared between
+ multiple views.
+*/
+
+#include <QApplication>
+#include <QHeaderView>
+#include <QItemSelectionModel>
+#include <QTableView>
+
+#include "model.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ TableModel *model = new TableModel(4, 2, &app);
+
+//! [0]
+ QTableView *firstTableView = new QTableView;
+ QTableView *secondTableView = new QTableView;
+//! [0]
+
+//! [1]
+ firstTableView->setModel(model);
+ secondTableView->setModel(model);
+//! [1]
+
+ firstTableView->horizontalHeader()->setModel(model);
+
+ for (int row = 0; row < 4; ++row) {
+ for (int column = 0; column < 2; ++column) {
+ QModelIndex index = model->index(row, column, QModelIndex());
+ model->setData(index, QVariant(QString("(%1, %2)").arg(row).arg(column)));
+ }
+ }
+
+//! [2]
+ secondTableView->setSelectionModel(firstTableView->selectionModel());
+//! [2]
+
+ firstTableView->setWindowTitle("First table view");
+ secondTableView->setWindowTitle("Second table view");
+ firstTableView->show();
+ secondTableView->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/sharedtablemodel/model.cpp b/doc/codesnippets/doc/src/snippets/sharedtablemodel/model.cpp
new file mode 100644
index 000000000..0fe0249f6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/sharedtablemodel/model.cpp
@@ -0,0 +1,237 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ model.cpp
+
+ Provides a table model for use in various examples.
+*/
+
+#include <QtGui>
+
+#include "model.h"
+
+/*!
+ Constructs a table model with at least one row and one column.
+*/
+
+TableModel::TableModel(int rows, int columns, QObject *parent)
+ : QAbstractTableModel(parent)
+{
+ QStringList newList;
+
+ for (int column = 0; column < qMax(1, columns); ++column) {
+ newList.append("");
+ }
+
+ for (int row = 0; row < qMax(1, rows); ++row) {
+ rowList.append(newList);
+ }
+}
+
+
+/*!
+ Returns the number of items in the row list as the number of rows
+ in the model.
+*/
+
+int TableModel::rowCount(const QModelIndex &/*parent*/) const
+{
+ return rowList.size();
+}
+
+/*!
+ Returns the number of items in the first list item as the number of
+ columns in the model. All rows should have the same number of columns.
+*/
+
+int TableModel::columnCount(const QModelIndex &/*parent*/) const
+{
+ return rowList[0].size();
+}
+
+/*!
+ Returns an appropriate value for the requested data.
+ If the view requests an invalid index, an invalid variant is returned.
+ Any valid index that corresponds to a string in the list causes that
+ string to be returned for the display role; otherwise an invalid variant
+ is returned.
+*/
+
+QVariant TableModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ if (role == Qt::DisplayRole)
+ return rowList[index.row()][index.column()];
+ else
+ return QVariant();
+}
+
+/*!
+ Returns the appropriate header string depending on the orientation of
+ the header and the section. If anything other than the display role is
+ requested, we return an invalid variant.
+*/
+
+QVariant TableModel::headerData(int section, Qt::Orientation orientation,
+ int role) const
+{
+ if (role != Qt::DisplayRole)
+ return QVariant();
+
+ if (orientation == Qt::Horizontal)
+ return QString("Column %1").arg(section);
+ else
+ return QString("Row %1").arg(section);
+}
+
+/*!
+ Returns an appropriate value for the item's flags. Valid items are
+ enabled, selectable, and editable.
+*/
+
+Qt::ItemFlags TableModel::flags(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return Qt::ItemIsEnabled;
+
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
+}
+
+/*!
+ Changes an item in the model, but only if the following conditions
+ are met:
+
+ * The index supplied is valid.
+ * The role associated with editing text is specified.
+
+ The dataChanged() signal is emitted if the item is changed.
+*/
+
+bool TableModel::setData(const QModelIndex &index,
+ const QVariant &value, int role)
+{
+ if (!index.isValid() || role != Qt::EditRole)
+ return false;
+
+ rowList[index.row()][index.column()] = value.toString();
+ emit dataChanged(index, index);
+ return true;
+}
+
+/*!
+ Inserts a number of rows into the model at the specified position.
+*/
+
+bool TableModel::insertRows(int position, int rows, const QModelIndex &parent)
+{
+ int columns = columnCount();
+ beginInsertRows(parent, position, position + rows - 1);
+
+ for (int row = 0; row < rows; ++row) {
+ QStringList items;
+ for (int column = 0; column < columns; ++column)
+ items.append("");
+ rowList.insert(position, items);
+ }
+
+ endInsertRows();
+ return true;
+}
+
+/*!
+ Inserts a number of columns into the model at the specified position.
+ Each entry in the list is extended in turn with the required number of
+ empty strings.
+*/
+
+bool TableModel::insertColumns(int position, int columns, const QModelIndex &parent)
+{
+ int rows = rowCount();
+ beginInsertColumns(parent, position, position + columns - 1);
+
+ for (int row = 0; row < rows; ++row) {
+ for (int column = position; column < columns; ++column) {
+ rowList[row].insert(position, "");
+ }
+ }
+
+ endInsertColumns();
+ return true;
+}
+
+/*!
+ Removes a number of rows from the model at the specified position.
+*/
+
+bool TableModel::removeRows(int position, int rows, const QModelIndex &parent)
+{
+ beginRemoveRows(parent, position, position + rows - 1);
+
+ for (int row = 0; row < rows; ++row) {
+ rowList.removeAt(position);
+ }
+
+ endRemoveRows();
+ return true;
+}
+
+/*!
+ Removes a number of columns from the model at the specified position.
+ Each row is shortened by the number of columns specified.
+*/
+
+bool TableModel::removeColumns(int position, int columns, const QModelIndex &parent)
+{
+ int rows = rowCount();
+ beginRemoveColumns(parent, position, position + columns - 1);
+
+ for (int row = 0; row < rows; ++row) {
+ for (int column = 0; column < columns; ++column) {
+ rowList[row].removeAt(position);
+ }
+ }
+
+ endRemoveColumns();
+ return true;
+}
diff --git a/doc/codesnippets/doc/src/snippets/sharedtablemodel/model.h b/doc/codesnippets/doc/src/snippets/sharedtablemodel/model.h
new file mode 100644
index 000000000..1bb4441ef
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/sharedtablemodel/model.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MODEL_H
+#define MODEL_H
+
+#include <QAbstractTableModel>
+#include <QStringList>
+#include <QVariant>
+
+class TableModel : public QAbstractTableModel
+{
+ Q_OBJECT
+
+public:
+ TableModel(int rows = 1, int columns = 1, QObject *parent = 0);
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = Qt::EditRole);
+
+ bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex());
+ bool insertColumns(int position, int columns, const QModelIndex &parent = QModelIndex());
+ bool removeRows(int position, int rows, const QModelIndex &parent = QModelIndex());
+ bool removeColumns(int position, int columns, const QModelIndex &parent = QModelIndex());
+
+private:
+ QList<QStringList> rowList;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/sharedtablemodel/sharedtablemodel.pro b/doc/codesnippets/doc/src/snippets/sharedtablemodel/sharedtablemodel.pro
new file mode 100644
index 000000000..10671e6e2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/sharedtablemodel/sharedtablemodel.pro
@@ -0,0 +1,2 @@
+HEADERS += model.h
+SOURCES += main.cpp model.cpp
diff --git a/doc/codesnippets/doc/src/snippets/signalmapper/accountsfile.txt b/doc/codesnippets/doc/src/snippets/signalmapper/accountsfile.txt
new file mode 100644
index 000000000..2ec5ffbc1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/signalmapper/accountsfile.txt
@@ -0,0 +1 @@
+1 + 1 = 2
diff --git a/doc/codesnippets/doc/src/snippets/signalmapper/filereader.cpp b/doc/codesnippets/doc/src/snippets/signalmapper/filereader.cpp
new file mode 100644
index 000000000..8732dab34
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/signalmapper/filereader.cpp
@@ -0,0 +1,59 @@
+#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(const QString &)),
+ this, SLOT(readFile(const QString &)));
+//! [1]
+
+ 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/codesnippets/doc/src/snippets/signalmapper/filereader.h b/doc/codesnippets/doc/src/snippets/signalmapper/filereader.h
new file mode 100644
index 000000000..a3be08829
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/signalmapper/filereader.h
@@ -0,0 +1,28 @@
+#ifndef FILEREADER_H
+#define FILEREADER_H
+
+#include <QTextEdit>
+#include <QPushButton>
+#include <QSignalMapper>
+
+class FileReader : public QWidget
+{
+ Q_OBJECT
+
+public:
+ FileReader(QWidget *parent=0);
+ void readFromFile(QString filename);
+
+public slots:
+ void readFile(const QString &);
+
+private:
+ QTextEdit *textEdit;
+ QPushButton *taxFileButton;
+ QPushButton *accountFileButton;
+ QPushButton *reportFileButton;
+ QSignalMapper *signalMapper;
+};
+
+#endif
+
diff --git a/doc/codesnippets/doc/src/snippets/signalmapper/main.cpp b/doc/codesnippets/doc/src/snippets/signalmapper/main.cpp
new file mode 100644
index 000000000..ebc601b7b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/signalmapper/main.cpp
@@ -0,0 +1,13 @@
+#include <QtGui>
+#include "filereader.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ FileReader *reader = new FileReader;
+ reader->show();
+
+ return app.exec();
+}
+
diff --git a/doc/codesnippets/doc/src/snippets/signalmapper/reportfile.txt b/doc/codesnippets/doc/src/snippets/signalmapper/reportfile.txt
new file mode 100644
index 000000000..30123cc60
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/signalmapper/reportfile.txt
@@ -0,0 +1,2 @@
+Tax this year = 50%
+Total profit = 2
diff --git a/doc/codesnippets/doc/src/snippets/signalmapper/signalmapper.pro b/doc/codesnippets/doc/src/snippets/signalmapper/signalmapper.pro
new file mode 100644
index 000000000..9a9d66955
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/signalmapper/signalmapper.pro
@@ -0,0 +1,12 @@
+######################################################################
+# Automatically generated by qmake (2.01a) Wed Jul 2 14:50:56 2008
+######################################################################
+
+TEMPLATE = app
+TARGET =
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+HEADERS += filereader.h
+SOURCES += filereader.cpp main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/signalmapper/taxfile.txt b/doc/codesnippets/doc/src/snippets/signalmapper/taxfile.txt
new file mode 100644
index 000000000..a682e0aaa
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/signalmapper/taxfile.txt
@@ -0,0 +1 @@
+Tax this year = 50%
diff --git a/doc/codesnippets/doc/src/snippets/signalsandslots/lcdnumber.cpp b/doc/codesnippets/doc/src/snippets/signalsandslots/lcdnumber.cpp
new file mode 100644
index 000000000..4a3dffd7a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/signalsandslots/lcdnumber.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "lcdnumber.h"
+
+LcdNumber::LcdNumber(QWidget *parent)
+{
+}
+
+void LcdNumber::display(int)
+{
+}
+
+void LcdNumber::display(double)
+{
+}
+
+void LcdNumber::display(const QString &)
+{
+}
+
+void LcdNumber::setHexMode()
+{
+}
+
+void LcdNumber::setDecMode()
+{
+}
+
+void LcdNumber::setOctMode()
+{
+}
+
+void LcdNumber::setBinMode()
+{
+}
+
+void LcdNumber::setSmallDecimalPoint(bool)
+{
+}
diff --git a/doc/codesnippets/doc/src/snippets/signalsandslots/lcdnumber.h b/doc/codesnippets/doc/src/snippets/signalsandslots/lcdnumber.h
new file mode 100644
index 000000000..49df495ff
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/signalsandslots/lcdnumber.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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/codesnippets/doc/src/snippets/signalsandslots/signalsandslots.cpp b/doc/codesnippets/doc/src/snippets/signalsandslots/signalsandslots.cpp
new file mode 100644
index 000000000..741b08caf
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/signalsandslots/signalsandslots.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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/codesnippets/doc/src/snippets/signalsandslots/signalsandslots.h b/doc/codesnippets/doc/src/snippets/signalsandslots/signalsandslots.h
new file mode 100644
index 000000000..f25bc8439
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/signalsandslots/signalsandslots.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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/codesnippets/doc/src/snippets/simplemodel-use/main.cpp b/doc/codesnippets/doc/src/snippets/simplemodel-use/main.cpp
new file mode 100644
index 000000000..ebaee4ae0
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/simplemodel-use/main.cpp
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ main.cpp
+
+ A simple example of how to access items from an existing model.
+*/
+
+#include <QtGui>
+
+/*!
+ Create a default directory model and, using the index-based interface to
+ the model and some QLabel widgets, populate the window's layout with the
+ names of objects in the directory.
+
+ Note that we only want to read the filenames in the highest level of the
+ directory, so we supply a default (invalid) QModelIndex to the model in
+ order to indicate that we want top-level items.
+*/
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QWidget *window = new QWidget;
+ QVBoxLayout *layout = new QVBoxLayout(window);
+ QLabel *title = new QLabel("Some items from the directory model", window);
+ title->setBackgroundRole(QPalette::Base);
+ title->setMargin(8);
+ layout->addWidget(title);
+
+//! [0]
+ QDirModel *model = new QDirModel;
+ QModelIndex parentIndex = model->index(QDir::currentPath());
+ int numRows = model->rowCount(parentIndex);
+//! [0]
+
+//! [1]
+ for (int row = 0; row < numRows; ++row) {
+ QModelIndex index = model->index(row, 0, parentIndex);
+//! [1]
+
+//! [2]
+ QString text = model->data(index, Qt::DisplayRole).toString();
+ // Display the text in a widget.
+//! [2]
+
+ QLabel *label = new QLabel(text, window);
+ layout->addWidget(label);
+//! [3]
+ }
+//! [3]
+
+ window->setWindowTitle("A simple model example");
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/simplemodel-use/simplemodel-use.pro b/doc/codesnippets/doc/src/snippets/simplemodel-use/simplemodel-use.pro
new file mode 100644
index 000000000..28dcadcbf
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/simplemodel-use/simplemodel-use.pro
@@ -0,0 +1 @@
+SOURCES += main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/snippets.pro b/doc/codesnippets/doc/src/snippets/snippets.pro
new file mode 100644
index 000000000..50e33b322
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/snippets.pro
@@ -0,0 +1,109 @@
+### A qmake file for the snippets. *** This is not for distribution. ***
+#
+# Snippets that don't work are commented out and marked with "broken";
+# other commented out snippets were probably not designed to be built.
+
+TEMPLATE = subdirs
+SUBDIRS = brush \
+ buffer \
+# clipboard \ # broken
+ coordsys \
+# customstyle \
+ designer \
+ dialogs \
+ dockwidgets \
+ draganddrop \
+ dragging \
+ dropactions \
+ dropevents \
+ droprectangle \
+ events \
+# file \
+ image \
+ inherited-slot \
+ itemselection \
+ layouts \
+ matrix \
+ moc \
+# modelview-subclasses \ # broken
+ painterpath \
+ persistentindexes \
+ picture \
+ plaintextlayout \
+# pointer \
+ polygon \
+ process \
+ qdbusextratypes \
+ qcalendarwidget \
+ qdir-filepaths \
+ qdir-listfiles \
+ qdir-namefilters \
+ qfontdatabase \
+ qlabel \
+ qlineargradient \
+ qlistview-dnd \
+ qlistview-using \
+ qlistwidget-dnd \
+ qlistwidget-using \
+# qmake \ # not designed to be built
+ qmetaobject-invokable \
+ qprocess \
+ qprocess-environment \
+# qsignalmapper \
+ qsortfilterproxymodel-details \
+ qsplashscreen \
+ qstack \
+ qstackedlayout \
+ qstackedwidget \
+ qstandarditemmodel \
+ qstatustipevent \
+ qstring \
+ qstringlist \
+ qstringlistmodel \
+ qstyleoption \
+ qstyleplugin \
+ qsvgwidget \
+ qtablewidget-dnd \
+ qtablewidget-resizing \
+ qtablewidget-using \
+ qtcast \
+ qtreeview-dnd \
+ qtreewidgetitemiterator-using \
+ qtreewidget-using \
+ quiloader \
+ qx11embedcontainer \
+ qx11embedwidget \
+ reading-selections \
+ scribe-overview \
+ separations \
+# settings \ # not designed to be built
+ shareddirmodel \
+ sharedemployee \
+ sharedtablemodel \
+# signalsandslots \
+ simplemodel-use \
+# splitter \
+ sqldatabase \
+ stringlistmodel \
+# styles \
+ textblock-formats \
+ textblock-fragments \
+ textdocument-blocks \
+ textdocument-charformats \
+ textdocument-cursors \
+ textdocument-find \
+ textdocument-frames \
+ textdocument-imageformat \
+ textdocument-images \
+ textdocument-listitems \
+ textdocument-lists \
+ textdocument-printing \
+# textdocument-resources \
+ textdocument-selections \
+ textdocument-tables \
+# threads \
+ timers \
+ updating-selections \
+# whatsthis \
+ widget-mask \
+ xml
diff --git a/doc/codesnippets/doc/src/snippets/splitter/splitter.cpp b/doc/codesnippets/doc/src/snippets/splitter/splitter.cpp
new file mode 100644
index 000000000..a9d4af3a4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/splitter/splitter.cpp
@@ -0,0 +1,67 @@
+############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Nokia Corporation (qt-info@nokia.com)
+##
+## This file is part of the documentation of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at http://www.qtsoftware.com/contact.
+## $QT_END_LICENSE$
+##
+############################################################################
+
+
+//! [0]
+ splitter = QSplitter(parent)
+ listview = QListView()
+ treeview = QTreeView()
+ textedit = QTextEdit()
+ splitter.addWidget(listview)
+ splitter.addWidget(treeview)
+ splitter.addWidget(textedit)
+//! [0]
+
+//! [1]
+ settings = QSettings()
+ settings.setValue("splitterSizes", splitter.saveState())
+//! [1]
+
+//! [2]
+ settings = QSettings()
+ splitter.restoreState(settings.value("splitterSizes").toByteArray())
+//! [2]
+
+//! [3]
+ for it in splitter.sizes():
+ processSize(it.next())
+//! [3]
+
diff --git a/doc/codesnippets/doc/src/snippets/splitter/splitter.pro b/doc/codesnippets/doc/src/snippets/splitter/splitter.pro
new file mode 100644
index 000000000..2414a914a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/splitter/splitter.pro
@@ -0,0 +1 @@
+SOURCES += splitter.cpp
diff --git a/doc/codesnippets/doc/src/snippets/splitterhandle/main.cpp b/doc/codesnippets/doc/src/snippets/splitterhandle/main.cpp
new file mode 100644
index 000000000..f9b3b6834
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/splitterhandle/main.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QLabel>
+
+#include "splitter.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Splitter splitter(Qt::Horizontal);
+ splitter.addWidget(new QLabel("Hello"));
+ splitter.addWidget(new QLabel("World"));
+ Splitter verticalSplitter(Qt::Vertical, &splitter);
+ verticalSplitter.addWidget(new QLabel("A"));
+ verticalSplitter.addWidget(new QLabel("B"));
+ splitter.show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/splitterhandle/splitter.cpp b/doc/codesnippets/doc/src/snippets/splitterhandle/splitter.cpp
new file mode 100644
index 000000000..5e15b7c6a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/splitterhandle/splitter.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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/codesnippets/doc/src/snippets/splitterhandle/splitter.h b/doc/codesnippets/doc/src/snippets/splitterhandle/splitter.h
new file mode 100644
index 000000000..400ce781f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/splitterhandle/splitter.h
@@ -0,0 +1,52 @@
+/############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Nokia Corporation (qt-info@nokia.com)
+##
+## This file is part of the documentation of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at http://www.qtsoftware.com/contact.
+## $QT_END_LICENSE$
+##
+############################################################################/
+
+//! [0]
+class Splitter(QSplitter):
+ def __init__(self, orientation, parent):
+ ...
+
+ def createHandle(self):
+ ...
+}
+//! [0]
+
+
diff --git a/doc/codesnippets/doc/src/snippets/splitterhandle/splitterhandle.pro b/doc/codesnippets/doc/src/snippets/splitterhandle/splitterhandle.pro
new file mode 100644
index 000000000..0c2a999c1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/splitterhandle/splitterhandle.pro
@@ -0,0 +1,3 @@
+HEADERS = splitter.h
+SOURCES = main.cpp \
+ splitter.cpp
diff --git a/doc/codesnippets/doc/src/snippets/sqldatabase/sqldatabase.cpp b/doc/codesnippets/doc/src/snippets/sqldatabase/sqldatabase.cpp
new file mode 100644
index 000000000..e21cb9c6b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/sqldatabase/sqldatabase.cpp
@@ -0,0 +1,480 @@
+######################################
+#
+# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# Contact: Nokia Corporation (qt-info@nokia.com)
+#
+# This file is part of the documentation of the Qt Toolkit.
+#
+# $QT_BEGIN_LICENSE:LGPL$
+# Commercial Usage
+# Licensees holding valid Qt Commercial licenses may use self file in
+# accordance with the Qt Commercial License Agreement provided with the
+# Software or, alternatively, in accordance with the terms contained in
+# a written agreement between you and Nokia.
+#
+# GNU Lesser General Public License Usage
+# Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+# package.
+#
+# GNU General Public License Usage
+# Alternatively, self file may be used under the terms of the GNU
+# General Public License version 3.0 as published by the Free Software
+# Foundation and appearing in the file LICENSE.GPL included in the
+# packaging of self file. Please review the following information to
+# ensure the GNU General Public License version 3.0 requirements will be
+# met: http://www.gnu.org/copyleft/gpl.html.
+#
+# If you are unsure which license is appropriate for your use, please
+# contact the sales department at http://www.qtsoftware.com/contact.
+# $QT_END_LICENSE$
+#
+######################################
+
+from PySide.QtGui import *
+from PySide.QtSql import *
+
+
+def tr(text):
+ return QApplication.translate(text, text)
+
+def QSqlDatabase_snippets():
+//! [0]
+ db = QSqlDatabase.addDatabase("QPSQL")
+ db.setHostName("acidalia")
+ db.setDatabaseName("customdb")
+ db.setUserName("mojito")
+ db.setPassword("J0a1m8")
+ ok = db.open()
+//! [0]
+
+//! [1]
+ db = QSqlDatabase.database()
+//! [1]
+
+def QSqlField_snippets():
+//! [2]
+ field = QSqlField("age", QVariant.Int)
+ field.setValue(QPixmap()) # WRONG
+//! [2]
+
+//! [3]
+ field = QSqlField("age", QVariant.Int)
+ field.setValue(QString("123")) # casts QString to int
+//! [3]
+
+//! [4]
+ query = QSqlQuery()
+//! [4] //! [5]
+ record = query.record()
+//! [5] //! [6]
+ field = record.field("country")
+//! [6]
+
+def doSomething(str):
+ pass
+
+def QSqlQuery_snippets():
+ # typical loop
+//! [7]
+ query = QSqlQuery("SELECT country FROM artist")
+ while query.next():
+ country = query.value(0).toString()
+ doSomething(country)
+//! [7]
+
+
+ # field index lookup
+//! [8]
+ query = QSqlQuery("SELECT * FROM artist")
+ fieldNo = query.record().indexOf("country")
+ while query.next():
+ country = query.value(fieldNo).toString()
+ doSomething(country)
+//! [8]
+
+ # named with named
+//! [9]
+ query = QSqlQuery()
+ 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]
+ query = QSqlQuery()
+ 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]
+ query = QSqlQuery()
+ 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]
+ query = QSqlQuery()
+ query.prepare("INSERT INTO person (id, forename, surname) "
+ "VALUES (?, ?, ?)")
+ query.addBindValue(1001)
+ query.addBindValue("Bart")
+ query.addBindValue("Simpson")
+ query.exec_()
+//! [12]
+
+ # stored
+//! [13]
+ query = QSqlQuery()
+ query.prepare("CALL AsciiToInt(?, ?)")
+ query.bindValue(0, "A")
+ query.bindValue(1, 0, QSql.Out)
+ query.exec_()
+ i = query.boundValue(1).toInt() # i is 65
+//! [13]
+
+ query = QSqlQuery()
+
+ # examine with named binding
+//! [14]
+ i = query.boundValues()
+ while i.hasNext():
+ i.next()
+ print i.key().toAscii().data(), ": ", i.value().toString().toAscii().data()
+//! [14]
+
+ # examine with positional binding
+//! [15]
+ list_ = query.boundValues().values()
+ for item in list:
+ print item
+//! [15]
+
+def QSqlQueryModel_snippets():
+
+//! [16]
+ model = QSqlQueryModel()
+ model.setQuery("SELECT name, salary FROM employee")
+ model.setHeaderData(0, Qt.Horizontal, tr("Name"))
+ model.setHeaderData(1, Qt.Horizontal, tr("Salary"))
+
+//! [17]
+ view = QTableView()
+//! [17] //! [18]
+ view.setModel(model)
+//! [18] //! [19]
+ view.show()
+//! [16] //! [19] //! [20]
+ view.setEditTriggers(QAbstractItemView.NoEditTriggers)
+//! [20]
+
+//! [21]
+ model = QSqlQueryModel()
+ model.setQuery("SELECT * FROM employee")
+ salary = model.record(4).value("salary").toInt()
+//! [21]
+
+//! [22]
+ salary = model.data(model.index(4, 2)).toInt()
+//! [22]
+
+ for row in range(model.rowCount()):
+ for (col in range(model.columnCount())):
+ print model.data(model.index(row, col))
+
+
+class MyModel(QSqlQueryModel)
+ m_specialColumnNo = 0
+ def data(item, role):
+//! [23]
+ if item.column() == self.m_specialColumnNo:
+ # handle column separately
+ pass
+
+ return QSqlQueryModel.data(item, role)
+
+//! [23]
+
+
+def QSqlTableModel_snippets():
+
+//! [24]
+ model = QSqlTableModel()
+ 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"))
+
+ view = QTableView()
+ view.setModel(model)
+ view.show()
+//! [24]
+
+
+//! [25]
+ model = QSqlTableModel()
+ model.setTable("employee")
+ QString name = model.record(4).value("name").toString()
+//! [25]
+
+def sql_intro_snippets():
+
+//! [26]
+ db = QSqlDatabase.addDatabase("QMYSQL")
+ db.setHostName("bigblue")
+ db.setDatabaseName("flightdb")
+ db.setUserName("acarlson")
+ db.setPassword("1uTbSbAs")
+ ok = db.open()
+//! [26]
+
+//! [27]
+ firstDB = QSqlDatabase.addDatabase("QMYSQL", "first")
+ secondDB = QSqlDatabase.addDatabase("QMYSQL", "second")
+//! [27]
+
+//! [28]
+ defaultDB = QSqlDatabase.database()
+//! [28] //! [29]
+ firstDB = QSqlDatabase.database("first")
+//! [29] //! [30]
+ secondDB = QSqlDatabase.database("second")
+//! [30]
+
+ # SELECT1
+//! [31]
+ query = QSqlQuery()
+ query.exec_("SELECT name, salary FROM employee WHERE salary > 50000")
+//! [31]
+
+//! [32]
+ while query.next():
+ name = query.value(0).toString()
+ salary = query.value(1).toInt()
+ print name, salary
+//! [32]
+
+ # FEATURE
+//! [33]
+ query = QSqlQuery()
+ query.exec_("SELECT name, salary FROM employee WHERE salary > 50000")
+
+ defaultDB = QSqlDatabase.database()
+ if defaultDB.driver().hasFeature(QSqlDriver.QuerySize):
+ numRows = query.size()
+ else:
+ # self can be very slow
+ query.last()
+ numRows = query.at() + 1
+//! [33]
+
+ # INSERT1
+//! [34]
+ query = QSqlQuery()
+ query.exec_("INSERT INTO employee (id, name, salary) "
+ "VALUES (1001, 'Thad Beaumont', 65000)")
+//! [34]
+
+ # NAMED BINDING
+//! [35]
+ query = QSqlQuery()
+ 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]
+ query = QSqlQuery()
+ query.prepare("INSERT INTO employee (id, name, salary) "
+ "VALUES (?, ?, ?)")
+ query.addBindValue(1001)
+ query.addBindValue("Thad Beaumont")
+ query.addBindValue(65000)
+ query.exec_()
+//! [36]
+
+ # UPDATE1
+//! [37]
+ query = QSqlQuery()
+ query.exec_("UPDATE employee SET salary = 70000 WHERE id = 1003")
+//! [37]
+
+ # DELETE1
+//! [38]
+ query = QSqlQuery()
+ query.exec_("DELETE FROM employee WHERE id = 1007")
+//! [38]
+
+ # TRANSACTION
+//! [39]
+ QSqlDatabase.database().transaction()
+ query = QSqlQuery()
+ query.exec_("SELECT id FROM employee WHERE name = 'Torild Halvorsen'")
+ if query.next():
+ 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]
+ model = QSqlQueryModel()
+ model.setQuery("SELECT * FROM employee")
+
+ for i in range(model.rowCount()):
+ _id = model.record(i).value("id").toInt()
+ name = model.record(i).value("name").toString()
+ print _id, name
+
+//! [40]
+ }
+
+ {
+ # SQLTABLEMODEL1
+//! [41]
+ model = QSqlTableModel()
+ model.setTable("employee")
+ model.setFilter("salary > 50000")
+ model.setSort(2, Qt.DescendingOrder)
+ model.select()
+
+ for i in range(model.rowCount()):
+ name = model.record(i).value("name").toString()
+ salary = model.record(i).value("salary").toInt()
+ print "%s: %d" % (name, salary)
+
+//! [41]
+
+ # SQLTABLEMODEL2
+ model = QSqlTableModel()
+ model.setTable("employee")
+
+//! [42]
+ for i in range(model.rowCount()):
+ record = model.record(i)
+ salary = record.value("salary").toInt()
+ salary *= 1.1
+ record.setValue("salary", salary)
+ model.setRecord(i, record)
+
+ model.submitAll()
+//! [42]
+
+ # SQLTABLEMODEL3
+ row = 1
+ 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(QSqlResult):
+ def __init__(driver):
+ QSqlResult.__init__(self, driver)
+ pass
+
+ def data(self, index):
+ return QVariant()
+
+ def isNull(self, index):
+ return False
+
+ def reset(self, query):
+ return False
+
+ def fetch(self, index):
+ return False
+
+ def fetchFirst(self):
+ return False
+
+ def fetchLast(self):
+ return False
+
+ def size(self):
+ return 0
+
+ def numRowsAffected(self):
+ return 0
+
+ def record(self):
+ return QSqlRecord()
+
+//! [47]
+
+//! [48]
+class XyzDriver(QSqlDriver)
+ def hasFeature(self, feature):
+ return False
+
+ def open(self, db, user, password, host, port, options):
+ return False
+
+ def close(self):
+ pass
+
+ def createResult(self):
+ return XyzResult(self)
+
+//! [48]
+
+def main():
+ app = QApplication([])
+
+ QSqlDatabase_snippets()
+ QSqlField_snippets()
+ QSqlQuery_snippets()
+ QSqlQueryModel_snippets()
+ QSqlTableModel_snippets()
+
+ driver = XyzDriver()
+ result = XyzResult(driver)
diff --git a/doc/codesnippets/doc/src/snippets/sqldatabase/sqldatabase.pro b/doc/codesnippets/doc/src/snippets/sqldatabase/sqldatabase.pro
new file mode 100644
index 000000000..43996956b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/sqldatabase/sqldatabase.pro
@@ -0,0 +1,2 @@
+SOURCES += sqldatabase.cpp
+QT += sql
diff --git a/doc/codesnippets/doc/src/snippets/streaming/main.cpp b/doc/codesnippets/doc/src/snippets/streaming/main.cpp
new file mode 100644
index 000000000..c55494937
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/streaming/main.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QByteArray>
+#include <QDataStream>
+
+//! [0]
+struct Movie
+{
+ int id;
+ QString title;
+ QDate releaseDate;
+};
+//! [0]
+
+//! [1]
+QDataStream &operator<<(QDataStream &out, const Movie &movie)
+{
+ out << (quint32)movie.id << movie.title
+ << movie.releaseDate;
+ return out;
+}
+//! [1]
+
+//! [2]
+QDataStream &operator>>(QDataStream &in, Movie &movie)
+{
+ quint32 id;
+ QDate date;
+
+ in >> id >> movie.title >> date;
+ movie.id = (int)id;
+ movie.releaseDate = date;
+ return in;
+}
+//! [2]
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ Movie m;
+ m.id = 0001;
+ m.title = "Happy Meal";
+ m.releaseDate = QDate(1995, 5, 17);
+
+ QByteArray byteArray;
+ QDataStream stream(&byteArray, QIODevice::WriteOnly);
+ stream << m;
+
+ // display
+ qDebug() << m.id << m.releaseDate << m.title;
+
+ Movie m2;
+
+ int id2;
+ QString title2;
+ QDate date2;
+
+ QDataStream stream2(byteArray);
+ stream2 >> id2 >> title2 >> date2;
+
+ m2.id = id2;
+ m2.title = title2;
+ m2.releaseDate = date2;
+
+ qDebug() << id2 << " " << date2 << " " << title2;
+
+ return 0;
+}
diff --git a/doc/codesnippets/doc/src/snippets/streaming/streaming.pro b/doc/codesnippets/doc/src/snippets/streaming/streaming.pro
new file mode 100644
index 000000000..8c5eb91f0
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/streaming/streaming.pro
@@ -0,0 +1,2 @@
+SOURCES = main.cpp
+CONFIG += CONSOLE \ No newline at end of file
diff --git a/doc/codesnippets/doc/src/snippets/stringlistmodel/main.cpp b/doc/codesnippets/doc/src/snippets/stringlistmodel/main.cpp
new file mode 100644
index 000000000..17d6be896
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/stringlistmodel/main.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ The main function for the string list model example. This creates and
+ populates a model with values from a string list then displays the
+ contents of the model using a QListView widget.
+*/
+
+#include <QAbstractItemModel>
+#include <QApplication>
+#include <QListView>
+
+#include "model.h"
+
+//! [0]
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+// Unindented for quoting purposes:
+//! [1]
+QStringList numbers;
+numbers << "One" << "Two" << "Three" << "Four" << "Five";
+
+QAbstractItemModel *model = new StringListModel(numbers);
+//! [0] //! [1] //! [2] //! [3]
+QListView *view = new QListView;
+//! [2]
+view->setWindowTitle("View onto a string list model");
+//! [4]
+view->setModel(model);
+//! [3] //! [4]
+
+ model->insertRows(5, 7, QModelIndex());
+
+ for (int row = 5; row < 12; ++row) {
+ QModelIndex index = model->index(row, 0, QModelIndex());
+ model->setData(index, QString::number(row+1));
+ }
+
+//! [5]
+ view->show();
+ return app.exec();
+}
+//! [5]
diff --git a/doc/codesnippets/doc/src/snippets/stringlistmodel/model.cpp b/doc/codesnippets/doc/src/snippets/stringlistmodel/model.cpp
new file mode 100644
index 000000000..124c3283d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/stringlistmodel/model.cpp
@@ -0,0 +1,182 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ model.cpp
+
+ A simple model that uses a QStringList as its data source.
+*/
+
+#include "model.h"
+
+/*!
+ Returns the number of items in the string list as the number of rows
+ in the model.
+*/
+
+//! [0]
+int StringListModel::rowCount(const QModelIndex &parent) const
+{
+ return stringList.count();
+}
+//! [0]
+
+/*!
+ Returns an appropriate value for the requested data.
+ If the view requests an invalid index, an invalid variant is returned.
+ Any valid index that corresponds to a string in the list causes that
+ string to be returned.
+*/
+
+//! [1]
+QVariant StringListModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ if (index.row() >= stringList.size())
+ return QVariant();
+
+ if (role == Qt::DisplayRole)
+ return stringList.at(index.row());
+ else
+ return QVariant();
+}
+//! [1]
+
+/*!
+ Returns the appropriate header string depending on the orientation of
+ the header and the section. If anything other than the display role is
+ requested, we return an invalid variant.
+*/
+
+//! [2]
+QVariant StringListModel::headerData(int section, Qt::Orientation orientation,
+ int role) const
+{
+ if (role != Qt::DisplayRole)
+ return QVariant();
+
+ if (orientation == Qt::Horizontal)
+ return QString("Column %1").arg(section);
+ else
+ return QString("Row %1").arg(section);
+}
+//! [2]
+
+/*!
+ Returns an appropriate value for the item's flags. Valid items are
+ enabled, selectable, and editable.
+*/
+
+//! [3]
+Qt::ItemFlags StringListModel::flags(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return Qt::ItemIsEnabled;
+
+ return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
+}
+//! [3]
+
+/*!
+ Changes an item in the string list, but only if the following conditions
+ are met:
+
+ * The index supplied is valid.
+ * The index corresponds to an item to be shown in a view.
+ * The role associated with editing text is specified.
+
+ The dataChanged() signal is emitted if the item is changed.
+*/
+
+//! [4]
+bool StringListModel::setData(const QModelIndex &index,
+ const QVariant &value, int role)
+{
+ if (index.isValid() && role == Qt::EditRole) {
+
+ stringList.replace(index.row(), value.toString());
+ emit dataChanged(index, index);
+ return true;
+ }
+//! [4] //! [5]
+ return false;
+}
+//! [5]
+
+/*!
+ Inserts a number of rows into the model at the specified position.
+*/
+
+//! [6]
+bool StringListModel::insertRows(int position, int rows, const QModelIndex &parent)
+{
+ beginInsertRows(QModelIndex(), position, position+rows-1);
+
+ for (int row = 0; row < rows; ++row) {
+ stringList.insert(position, "");
+ }
+
+ endInsertRows();
+ return true;
+//! [6] //! [7]
+}
+//! [7]
+
+/*!
+ Removes a number of rows from the model at the specified position.
+*/
+
+//! [8]
+bool StringListModel::removeRows(int position, int rows, const QModelIndex &parent)
+{
+ beginRemoveRows(QModelIndex(), position, position+rows-1);
+
+ for (int row = 0; row < rows; ++row) {
+ stringList.removeAt(position);
+ }
+
+ endRemoveRows();
+ return true;
+//! [8] //! [9]
+}
+//! [9]
diff --git a/doc/codesnippets/doc/src/snippets/stringlistmodel/model.h b/doc/codesnippets/doc/src/snippets/stringlistmodel/model.h
new file mode 100644
index 000000000..30f76114b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/stringlistmodel/model.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MODEL_H
+#define MODEL_H
+
+#include <QAbstractListModel>
+#include <QObject>
+#include <QStringList>
+
+//! [0]
+class StringListModel : public QAbstractListModel
+{
+ Q_OBJECT
+
+public:
+ StringListModel(const QStringList &strings, QObject *parent = 0)
+ : QAbstractListModel(parent), stringList(strings) {}
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+//! [0] //! [1]
+ int role = Qt::DisplayRole) const;
+//! [1]
+
+//! [2]
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ bool setData(const QModelIndex &index, const QVariant &value,
+//! [2] //! [3]
+ int role = Qt::EditRole);
+//! [3]
+
+//! [4]
+ bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex());
+ bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex());
+//! [4]
+
+//! [5]
+private:
+ QStringList stringList;
+};
+//! [5]
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/stringlistmodel/stringlistmodel.pro b/doc/codesnippets/doc/src/snippets/stringlistmodel/stringlistmodel.pro
new file mode 100644
index 000000000..b1126bfe7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/stringlistmodel/stringlistmodel.pro
@@ -0,0 +1,3 @@
+HEADERS = model.h
+SOURCES = main.cpp \
+ model.cpp
diff --git a/doc/codesnippets/doc/src/snippets/styles/styles.cpp b/doc/codesnippets/doc/src/snippets/styles/styles.cpp
new file mode 100644
index 000000000..cdbea76db
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/styles/styles.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0] //! [1]
+def paintEvent(self, event):
+//! [0]
+//! [2]
+ painter = QPainter(self)
+//! [2]
+
+ option = QStyleOptionFocusRect()
+ option.initFrom(self)
+ option.backgroundColor = palette().color(QPalette.Background)
+
+//! [3]
+ style().drawPrimitive(QStyle.PE_FrameFocusRect, option, painter, self)
+//! [3]
+//! [1]
+
+def paintEvent2(event):
+//! [4]
+//! [4] //! [5] //! [6]
+ painter = QStylePainter(self)
+//! [5]
+
+ option = QStyleOptionFocusRect()
+ option.initFrom(self)
+ option.backgroundColor = palette().color(QPalette.Background)
+
+//! [7]
+ painter.drawPrimitive(QStyle.PE_FrameFocusRect, option)
+//! [7]
+//! [6]
diff --git a/doc/codesnippets/doc/src/snippets/stylesheet/common-mistakes.cpp b/doc/codesnippets/doc/src/snippets/stylesheet/common-mistakes.cpp
new file mode 100644
index 000000000..1c7e3a8de
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/stylesheet/common-mistakes.cpp
@@ -0,0 +1,12 @@
+//! [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/codesnippets/doc/src/snippets/textblock-formats/main.cpp b/doc/codesnippets/doc/src/snippets/textblock-formats/main.cpp
new file mode 100644
index 000000000..9f7778a15
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textblock-formats/main.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+QString tr(const char *text)
+{
+ return QApplication::translate(text, text);
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+//! [0]
+ QTextEdit *editor = new QTextEdit();
+ QTextCursor cursor(editor->textCursor());
+//! [0]
+ cursor.movePosition(QTextCursor::Start);
+
+ QTextBlockFormat blockFormat = cursor.blockFormat();
+ blockFormat.setTopMargin(4);
+ blockFormat.setLeftMargin(4);
+ blockFormat.setRightMargin(4);
+ blockFormat.setBottomMargin(4);
+
+ cursor.setBlockFormat(blockFormat);
+ cursor.insertText(tr("This contains plain text inside a "
+ "text block with margins to keep it separate "
+ "from other parts of the document."));
+
+ cursor.insertBlock();
+
+//! [1]
+ QTextBlockFormat backgroundFormat = blockFormat;
+ backgroundFormat.setBackground(QColor("lightGray"));
+
+ cursor.setBlockFormat(backgroundFormat);
+//! [1]
+ cursor.insertText(tr("The background color of a text block can be "
+ "changed to highlight text."));
+
+ cursor.insertBlock();
+
+ QTextBlockFormat rightAlignedFormat = blockFormat;
+ rightAlignedFormat.setAlignment(Qt::AlignRight);
+
+ cursor.setBlockFormat(rightAlignedFormat);
+ cursor.insertText(tr("The alignment of the text within a block is "
+ "controlled by the alignment properties of "
+ "the block itself. This text block is "
+ "right-aligned."));
+
+ cursor.insertBlock();
+
+ QTextBlockFormat paragraphFormat = blockFormat;
+ paragraphFormat.setAlignment(Qt::AlignJustify);
+ paragraphFormat.setTextIndent(32);
+
+ cursor.setBlockFormat(paragraphFormat);
+ cursor.insertText(tr("Text can be formatted so that the first "
+ "line in a paragraph has its own margin. "
+ "This makes the text more readable."));
+
+ cursor.insertBlock();
+
+ QTextBlockFormat reverseFormat = blockFormat;
+ reverseFormat.setAlignment(Qt::AlignJustify);
+ reverseFormat.setTextIndent(32);
+
+ cursor.setBlockFormat(reverseFormat);
+ cursor.insertText(tr("The direction of the text can be reversed. "
+ "This is useful for right-to-left "
+ "languages."));
+
+ editor->setWindowTitle(tr("Text Block Formats"));
+ editor->resize(480, 480);
+ editor->show();
+
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/textblock-formats/textblock-formats.pro b/doc/codesnippets/doc/src/snippets/textblock-formats/textblock-formats.pro
new file mode 100644
index 000000000..d664835b0
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textblock-formats/textblock-formats.pro
@@ -0,0 +1,2 @@
+QT += xml
+SOURCES = main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/textblock-fragments/main.cpp b/doc/codesnippets/doc/src/snippets/textblock-fragments/main.cpp
new file mode 100644
index 000000000..b95f1b7d7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textblock-fragments/main.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->resize(640, 480);
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/textblock-fragments/mainwindow.cpp b/doc/codesnippets/doc/src/snippets/textblock-fragments/mainwindow.cpp
new file mode 100644
index 000000000..cb2c1c65e
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textblock-fragments/mainwindow.cpp
@@ -0,0 +1,149 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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 *insertMenu = new QMenu(tr("&Insert"));
+
+ QAction *calendarAction = insertMenu->addAction(tr("&Calendar"));
+ calendarAction->setShortcut(tr("Ctrl+I"));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(insertMenu);
+
+ editor = new QTextEdit(this);
+
+ connect(saveAction, SIGNAL(triggered()), this, SLOT(saveFile()));
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+ connect(calendarAction, SIGNAL(triggered()), this, SLOT(insertCalendar()));
+
+ setCentralWidget(editor);
+ setWindowTitle(tr("Text Document Writer"));
+}
+
+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::insertCalendar()
+{
+ QTextCursor cursor(editor->textCursor());
+ cursor.movePosition(QTextCursor::Start);
+
+ QTextCharFormat format(cursor.charFormat());
+ format.setFontFamily("Courier");
+
+ QTextCharFormat boldFormat = format;
+ boldFormat.setFontWeight(QFont::Bold);
+
+ cursor.insertBlock();
+ cursor.insertText(" ", boldFormat);
+
+ QDate date = QDate::currentDate();
+ int year = date.year(), month = date.month();
+
+ for (int weekDay = 1; weekDay <= 7; ++weekDay) {
+ cursor.insertText(QString("%1 ").arg(QDate::shortDayName(weekDay), 3),
+ boldFormat);
+ }
+
+ cursor.insertBlock();
+ cursor.insertText(" ", format);
+
+ for (int column = 1; column < QDate(year, month, 1).dayOfWeek(); ++column) {
+ cursor.insertText(" ", format);
+ }
+
+ for (int day = 1; day <= date.daysInMonth(); ++day) {
+ int weekDay = QDate(year, month, day).dayOfWeek();
+
+ if (QDate(year, month, day) == date)
+ cursor.insertText(QString("%1 ").arg(day, 3), boldFormat);
+ else
+ cursor.insertText(QString("%1 ").arg(day, 3), format);
+
+ if (weekDay == 7) {
+ cursor.insertBlock();
+ cursor.insertText(" ", format);
+ }
+ }
+}
+
+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 << domDocument->toByteArray(1);
+ return true;
+ }
+ else
+ return false;
+}
diff --git a/doc/codesnippets/doc/src/snippets/textblock-fragments/mainwindow.h b/doc/codesnippets/doc/src/snippets/textblock-fragments/mainwindow.h
new file mode 100644
index 000000000..dc2c3682c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textblock-fragments/mainwindow.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+
+class QTextEdit;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void insertCalendar();
+ void saveFile();
+
+private:
+ bool writeXml(const QString &fileName);
+
+ QTextEdit *editor;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/textblock-fragments/textblock-fragments.pro b/doc/codesnippets/doc/src/snippets/textblock-fragments/textblock-fragments.pro
new file mode 100644
index 000000000..83ed78e57
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textblock-fragments/textblock-fragments.pro
@@ -0,0 +1,6 @@
+QT += xml
+HEADERS = mainwindow.h \
+ xmlwriter.h
+SOURCES = main.cpp \
+ mainwindow.cpp \
+ xmlwriter.cpp
diff --git a/doc/codesnippets/doc/src/snippets/textblock-fragments/xmlwriter.cpp b/doc/codesnippets/doc/src/snippets/textblock-fragments/xmlwriter.cpp
new file mode 100644
index 000000000..190c0e44d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textblock-fragments/xmlwriter.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "xmlwriter.h"
+
+QDomDocument *XmlWriter::toXml()
+{
+ QDomImplementation implementation;
+ QDomDocumentType docType = implementation.createDocumentType(
+ "scribe-document", "scribe", "qtsoftware.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]
+ }
+//! [6] //! [7]
+}
+
+void XmlWriter::processBlock(const QTextBlock &currentBlock)
+{
+}
+
+void XmlWriter::processFragment(const QTextFragment &currentFragment)
+{
+}
diff --git a/doc/codesnippets/doc/src/snippets/textblock-fragments/xmlwriter.h b/doc/codesnippets/doc/src/snippets/textblock-fragments/xmlwriter.h
new file mode 100644
index 000000000..5bf523314
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textblock-fragments/xmlwriter.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef XMLWRITER_H
+#define XMLWRITER_H
+
+#include <QDomDocument>
+
+class QTextDocument;
+
+class XmlWriter
+{
+public:
+ XmlWriter(QTextDocument *document) : textDocument(document) {}
+ QDomDocument *toXml();
+
+private:
+ void readFragment(const QTextBlock &currentBlock, QDomElement blockElement,
+ QDomDocument *document);
+ void processBlock(const QTextBlock &currentBlock);
+ void processFragment(const QTextFragment &currentFragment);
+
+ QDomDocument *document;
+ QTextDocument *textDocument;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-blocks/main.cpp b/doc/codesnippets/doc/src/snippets/textdocument-blocks/main.cpp
new file mode 100644
index 000000000..b95f1b7d7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-blocks/main.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->resize(640, 480);
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-blocks/mainwindow.cpp b/doc/codesnippets/doc/src/snippets/textdocument-blocks/mainwindow.cpp
new file mode 100644
index 000000000..cc957c229
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-blocks/mainwindow.cpp
@@ -0,0 +1,157 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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 *insertMenu = new QMenu(tr("&Insert"));
+
+ QAction *calendarAction = insertMenu->addAction(tr("&Calendar"));
+ calendarAction->setShortcut(tr("Ctrl+I"));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(insertMenu);
+
+//! [0]
+ editor = new QTextEdit(this);
+//! [0]
+
+ connect(saveAction, SIGNAL(triggered()), this, SLOT(saveFile()));
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+ connect(calendarAction, SIGNAL(triggered()), this, SLOT(insertCalendar()));
+
+ setCentralWidget(editor);
+ setWindowTitle(tr("Text Document Writer"));
+}
+
+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::insertCalendar()
+{
+//! [1]
+ QTextCursor cursor(editor->textCursor());
+ cursor.movePosition(QTextCursor::Start);
+
+ QTextCharFormat format(cursor.charFormat());
+ format.setFontFamily("Courier");
+
+ QTextCharFormat boldFormat = format;
+ boldFormat.setFontWeight(QFont::Bold);
+
+ cursor.insertBlock();
+ cursor.insertText(" ", boldFormat);
+
+ QDate date = QDate::currentDate();
+ int year = date.year(), month = date.month();
+
+ for (int weekDay = 1; weekDay <= 7; ++weekDay) {
+ cursor.insertText(QString("%1 ").arg(QDate::shortDayName(weekDay), 3),
+ boldFormat);
+ }
+
+ cursor.insertBlock();
+ cursor.insertText(" ", format);
+
+ for (int column = 1; column < QDate(year, month, 1).dayOfWeek(); ++column) {
+ cursor.insertText(" ", format);
+ }
+
+ for (int day = 1; day <= date.daysInMonth(); ++day) {
+//! [1] //! [2]
+ int weekDay = QDate(year, month, day).dayOfWeek();
+
+ if (QDate(year, month, day) == date)
+ cursor.insertText(QString("%1 ").arg(day, 3), boldFormat);
+ else
+ cursor.insertText(QString("%1 ").arg(day, 3), format);
+
+ if (weekDay == 7) {
+ cursor.insertBlock();
+ cursor.insertText(" ", format);
+ }
+//! [2] //! [3]
+ }
+//! [3]
+}
+
+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/codesnippets/doc/src/snippets/textdocument-blocks/mainwindow.h b/doc/codesnippets/doc/src/snippets/textdocument-blocks/mainwindow.h
new file mode 100644
index 000000000..dc2c3682c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-blocks/mainwindow.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+
+class QTextEdit;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void insertCalendar();
+ void saveFile();
+
+private:
+ bool writeXml(const QString &fileName);
+
+ QTextEdit *editor;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-blocks/textdocument-blocks.pro b/doc/codesnippets/doc/src/snippets/textdocument-blocks/textdocument-blocks.pro
new file mode 100644
index 000000000..83ed78e57
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-blocks/textdocument-blocks.pro
@@ -0,0 +1,6 @@
+QT += xml
+HEADERS = mainwindow.h \
+ xmlwriter.h
+SOURCES = main.cpp \
+ mainwindow.cpp \
+ xmlwriter.cpp
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-blocks/xmlwriter.cpp b/doc/codesnippets/doc/src/snippets/textdocument-blocks/xmlwriter.cpp
new file mode 100644
index 000000000..8741f23a1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-blocks/xmlwriter.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "xmlwriter.h"
+
+QDomDocument *XmlWriter::toXml()
+{
+ QDomImplementation implementation;
+ QDomDocumentType docType = implementation.createDocumentType(
+ "scribe-document", "scribe", "qtsoftware.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);
+
+ QTextBlock firstBlock = textDocument->begin();
+ createItems(documentElement, firstBlock);
+
+ return document;
+}
+
+void XmlWriter::createItems(QDomElement &parent, const QTextBlock &block)
+{
+ QTextBlock currentBlock = block;
+
+ while (currentBlock.isValid()) {
+ QDomElement blockElement = document->createElement("block");
+ blockElement.setAttribute("length", currentBlock.length());
+ parent.appendChild(blockElement);
+
+ if (!(currentBlock.text().isNull())) {
+ QDomText textNode = document->createTextNode(currentBlock.text());
+ blockElement.appendChild(textNode);
+ }
+
+ currentBlock = currentBlock.next();
+ }
+}
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-blocks/xmlwriter.h b/doc/codesnippets/doc/src/snippets/textdocument-blocks/xmlwriter.h
new file mode 100644
index 000000000..ed83a86c3
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-blocks/xmlwriter.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef XMLWRITER_H
+#define XMLWRITER_H
+
+#include <QDomDocument>
+
+class QTextDocument;
+
+class XmlWriter
+{
+public:
+ XmlWriter(QTextDocument *document) : textDocument(document) {}
+ QDomDocument *toXml();
+
+private:
+ void createItems(QDomElement &parent, const QTextBlock &block);
+
+ QDomDocument *document;
+ QTextDocument *textDocument;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-charformats/main.cpp b/doc/codesnippets/doc/src/snippets/textdocument-charformats/main.cpp
new file mode 100644
index 000000000..1252ca24d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-charformats/main.cpp
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+QString tr(const char *text)
+{
+ return QApplication::translate(text, text);
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QTextEdit *editor = new QTextEdit();
+
+ QTextCursor cursor(editor->textCursor());
+ cursor.movePosition(QTextCursor::Start);
+
+ QTextCharFormat plainFormat(cursor.charFormat());
+
+ QTextCharFormat headingFormat = plainFormat;
+ headingFormat.setFontWeight(QFont::Bold);
+ headingFormat.setFontPointSize(16);
+
+ QTextCharFormat emphasisFormat = plainFormat;
+ emphasisFormat.setFontItalic(true);
+
+ QTextCharFormat qtFormat = plainFormat;
+ qtFormat.setForeground(QColor("#990000"));
+
+ QTextCharFormat underlineFormat = plainFormat;
+ underlineFormat.setFontUnderline(true);
+
+//! [0]
+ cursor.insertText(tr("Character formats"),
+ headingFormat);
+
+ cursor.insertBlock();
+
+ cursor.insertText(tr("Text can be displayed in a variety of "
+ "different character formats. "), plainFormat);
+ cursor.insertText(tr("We can emphasize text by "));
+ cursor.insertText(tr("making it italic"), emphasisFormat);
+//! [0]
+ cursor.insertText(tr(", give it a "), plainFormat);
+ cursor.insertText(tr("different color "), qtFormat);
+ cursor.insertText(tr("to the default text color, "), plainFormat);
+ cursor.insertText(tr("underline it"), underlineFormat);
+ cursor.insertText(tr(", and use many other effects."), plainFormat);
+
+ editor->setWindowTitle(tr("Text Document Character Formats"));
+ editor->resize(320, 480);
+ editor->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-charformats/textdocument-charformats.pro b/doc/codesnippets/doc/src/snippets/textdocument-charformats/textdocument-charformats.pro
new file mode 100644
index 000000000..16181f21c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-charformats/textdocument-charformats.pro
@@ -0,0 +1 @@
+SOURCES = main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-css/main.cpp b/doc/codesnippets/doc/src/snippets/textdocument-css/main.cpp
new file mode 100644
index 000000000..7968f8cd2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-css/main.cpp
@@ -0,0 +1,49 @@
+############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Nokia Corporation (qt-info@nokia.com)
+##
+## This file is part of the documentation of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at http://www.qtsoftware.com/contact.
+## $QT_END_LICENSE$
+##
+############################################################################
+
+
+//! [0]
+ browser = QTextBrowser()
+ linkColor = QColor(Qt.red)
+ sheet = QString.fromLatin1("a { text-decoration: underline color: %1 }").arg(linkColor.name())
+ browser.document().setDefaultStyleSheet(sheet)
+//! [0]
+
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-css/textdocument-css.pro b/doc/codesnippets/doc/src/snippets/textdocument-css/textdocument-css.pro
new file mode 100644
index 000000000..28dcadcbf
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-css/textdocument-css.pro
@@ -0,0 +1 @@
+SOURCES += main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-cursors/main.cpp b/doc/codesnippets/doc/src/snippets/textdocument-cursors/main.cpp
new file mode 100644
index 000000000..3e36f212c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-cursors/main.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+QString tr(const char *text)
+{
+ return QApplication::translate(text, text);
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QTextEdit *editor = new QTextEdit;
+
+//! [0]
+ QTextDocument *document = editor->document();
+ QTextCursor redCursor(document);
+//! [0] //! [1]
+ QTextCursor blueCursor(document);
+//! [1]
+
+ QTextCharFormat redFormat(redCursor.charFormat());
+ redFormat.setForeground(Qt::red);
+ QTextCharFormat blueFormat(blueCursor.charFormat());
+ blueFormat.setForeground(Qt::blue);
+
+ redCursor.setCharFormat(redFormat);
+ blueCursor.setCharFormat(blueFormat);
+
+ for (int i = 0; i < 20; ++i) {
+ if (i % 2 == 0)
+ redCursor.insertText(tr("%1 ").arg(i), redFormat);
+ if (i % 5 == 0)
+ blueCursor.insertText(tr("%1 ").arg(i), blueFormat);
+ }
+
+ editor->setWindowTitle(tr("Text Document Cursors"));
+ editor->resize(320, 480);
+ editor->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-cursors/textdocument-cursors.pro b/doc/codesnippets/doc/src/snippets/textdocument-cursors/textdocument-cursors.pro
new file mode 100644
index 000000000..16181f21c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-cursors/textdocument-cursors.pro
@@ -0,0 +1 @@
+SOURCES = main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-find/main.cpp b/doc/codesnippets/doc/src/snippets/textdocument-find/main.cpp
new file mode 100644
index 000000000..68d9e8e67
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-find/main.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+QString tr(const char *text)
+{
+ return QApplication::translate(text, text);
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QTextEdit *editor = new QTextEdit();
+
+ QTextCursor cursor(editor->textCursor());
+ cursor.movePosition(QTextCursor::Start);
+
+ QTextCharFormat plainFormat(cursor.charFormat());
+ QTextCharFormat colorFormat = plainFormat;
+ colorFormat.setForeground(Qt::red);
+
+ cursor.insertText(tr("Text can be displayed in a variety of "
+ "different character "
+ "formats. "), plainFormat);
+ cursor.insertText(tr("We can emphasize text by making it "));
+ cursor.insertText(tr("italic, give it a different color "));
+ cursor.insertText(tr("to the default text color, underline it, "));
+ cursor.insertText(tr("and use many other effects."));
+
+ QString searchString = tr("text");
+
+ QTextDocument *document = editor->document();
+//! [0]
+ QTextCursor newCursor(document);
+
+ while (!newCursor.isNull() && !newCursor.atEnd()) {
+ newCursor = document->find(searchString, newCursor);
+
+ if (!newCursor.isNull()) {
+ newCursor.movePosition(QTextCursor::WordRight,
+ QTextCursor::KeepAnchor);
+
+ newCursor.mergeCharFormat(colorFormat);
+ }
+//! [0] //! [1]
+ }
+//! [1]
+
+ editor->setWindowTitle(tr("Text Document Find"));
+ editor->resize(320, 480);
+ editor->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-find/textdocument-find.pro b/doc/codesnippets/doc/src/snippets/textdocument-find/textdocument-find.pro
new file mode 100644
index 000000000..16181f21c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-find/textdocument-find.pro
@@ -0,0 +1 @@
+SOURCES = main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-frames/main.cpp b/doc/codesnippets/doc/src/snippets/textdocument-frames/main.cpp
new file mode 100644
index 000000000..90d56e766
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-frames/main.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->resize(480, 480);
+ window->show();
+ return app.exec();
+}
+
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-frames/mainwindow.cpp b/doc/codesnippets/doc/src/snippets/textdocument-frames/mainwindow.cpp
new file mode 100644
index 000000000..b625ca3b4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-frames/mainwindow.cpp
@@ -0,0 +1,162 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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"));
+
+ menuBar()->addMenu(fileMenu);
+ editor = new QTextEdit();
+
+ QTextCursor cursor(editor->textCursor());
+ cursor.movePosition(QTextCursor::Start);
+
+ QTextFrame *mainFrame = cursor.currentFrame();
+
+ QTextCharFormat plainCharFormat;
+ QTextCharFormat boldCharFormat;
+ boldCharFormat.setFontWeight(QFont::Bold);
+/* main frame
+//! [0]
+ QTextFrame *mainFrame = cursor.currentFrame();
+ cursor.insertText(...);
+//! [0]
+*/
+ cursor.insertText("Text documents are represented by the "
+ "QTextDocument class, rather than by QString objects. "
+ "Each QTextDocument object contains information about "
+ "the document's internal representation, its structure, "
+ "and keeps track of modifications to provide undo/redo "
+ "facilities. This approach allows features such as the "
+ "layout management to be delegated to specialized "
+ "classes, but also provides a focus for the framework.",
+ plainCharFormat);
+
+//! [1]
+ QTextFrameFormat frameFormat;
+ frameFormat.setMargin(32);
+ frameFormat.setPadding(8);
+ frameFormat.setBorder(4);
+//! [1]
+ cursor.insertFrame(frameFormat);
+
+/* insert frame
+//! [2]
+ cursor.insertFrame(frameFormat);
+ cursor.insertText(...);
+//! [2]
+*/
+ cursor.insertText("Documents are either converted from external sources "
+ "or created from scratch using Qt. The creation process "
+ "can done by an editor widget, such as QTextEdit, or by "
+ "explicit calls to the Scribe API.", boldCharFormat);
+
+ cursor = mainFrame->lastCursorPosition();
+/* last cursor
+//! [3]
+ cursor = mainFrame->lastCursorPosition();
+ cursor.insertText(...);
+//! [3]
+*/
+ cursor.insertText("There are two complementary ways to visualize the "
+ "contents of a document: as a linear buffer that is "
+ "used by editors to modify the contents, and as an "
+ "object hierarchy containing structural information "
+ "that is useful to layout engines. In the hierarchical "
+ "model, the objects generally correspond to visual "
+ "elements such as frames, tables, and lists. At a lower "
+ "level, these elements describe properties such as the "
+ "style of text used and its alignment. The linear "
+ "representation of the document is used for editing and "
+ "manipulation of the document's contents.",
+ plainCharFormat);
+
+
+ connect(saveAction, SIGNAL(triggered()), this, SLOT(saveFile()));
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+
+ setCentralWidget(editor);
+ setWindowTitle(tr("Text Document Frames"));
+}
+
+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);
+ }
+}
+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/codesnippets/doc/src/snippets/textdocument-frames/mainwindow.h b/doc/codesnippets/doc/src/snippets/textdocument-frames/mainwindow.h
new file mode 100644
index 000000000..49e9157a7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-frames/mainwindow.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+
+class QTextEdit;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void saveFile();
+
+private:
+ bool writeXml(const QString &fileName);
+
+ QTextEdit *editor;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-frames/textdocument-frames.pro b/doc/codesnippets/doc/src/snippets/textdocument-frames/textdocument-frames.pro
new file mode 100644
index 000000000..91ae50f49
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-frames/textdocument-frames.pro
@@ -0,0 +1,6 @@
+SOURCES = main.cpp \
+ mainwindow.cpp \
+ xmlwriter.cpp
+HEADERS = mainwindow.h \
+ xmlwriter.h
+QT += xml
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-frames/xmlwriter.cpp b/doc/codesnippets/doc/src/snippets/textdocument-frames/xmlwriter.cpp
new file mode 100644
index 000000000..455b2ea58
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-frames/xmlwriter.cpp
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "xmlwriter.h"
+
+QDomDocument *XmlWriter::toXml()
+{
+ QDomImplementation implementation;
+ QDomDocumentType docType = implementation.createDocumentType(
+ "scribe-document", "scribe", "qtsoftware.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]
+ QTextFrame *root = textDocument->rootFrame();
+//! [0]
+
+ if (root)
+ processFrame(documentElement, root);
+
+ return document;
+}
+
+void XmlWriter::processBlock(QDomElement &parent, const QTextBlock &block)
+{
+ QDomElement blockElement = document->createElement("block");
+ blockElement.setAttribute("position", block.position());
+ blockElement.setAttribute("length", block.length());
+ parent.appendChild(blockElement);
+
+ QTextBlock::iterator it;
+ for (it = block.begin(); !(it.atEnd()); ++it) {
+ QTextFragment fragment = it.fragment();
+
+ if (fragment.isValid()) {
+ QDomElement fragmentElement = document->createElement("fragment");
+ blockElement.appendChild(fragmentElement);
+
+ fragmentElement.setAttribute("length", fragment.length());
+ QDomText fragmentText = document->createTextNode(fragment.text());
+
+ fragmentElement.appendChild(fragmentText);
+ }
+ }
+}
+
+void XmlWriter::processFrame(QDomElement &parent, QTextFrame *frame)
+{
+ QDomElement frameElement = document->createElement("frame");
+ frameElement.setAttribute("begin", frame->firstPosition());
+ frameElement.setAttribute("end", frame->lastPosition());
+ parent.appendChild(frameElement);
+
+//! [1]
+ QTextFrame::iterator it;
+ for (it = frame->begin(); !(it.atEnd()); ++it) {
+
+ QTextFrame *childFrame = it.currentFrame();
+ QTextBlock childBlock = it.currentBlock();
+
+ if (childFrame)
+//! [1] //! [2]
+ processFrame(frameElement, childFrame);
+ else if (childBlock.isValid())
+ processBlock(frameElement, childBlock);
+ }
+//! [2]
+}
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-frames/xmlwriter.h b/doc/codesnippets/doc/src/snippets/textdocument-frames/xmlwriter.h
new file mode 100644
index 000000000..893f1f597
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-frames/xmlwriter.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef XMLWRITER_H
+#define XMLWRITER_H
+
+#include <QDomDocument>
+
+class QTextDocument;
+
+class XmlWriter
+{
+public:
+ XmlWriter(QTextDocument *document) : textDocument(document) {}
+ QDomDocument *toXml();
+
+private:
+ void processBlock(QDomElement &parent, const QTextBlock &block);
+ void processFrame(QDomElement &parent, QTextFrame *frame);
+
+ QDomDocument *document;
+//! [0]
+ QTextDocument *textDocument;
+//! [0]
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-imagedrop/main.cpp b/doc/codesnippets/doc/src/snippets/textdocument-imagedrop/main.cpp
new file mode 100644
index 000000000..5715453d0
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-imagedrop/main.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include "textedit.h"
+
+int main(int argc, char * argv[])
+{
+ QApplication app(argc, argv);
+
+ TextEdit *textEdit = new TextEdit;
+ textEdit->show();
+
+ return app.exec();
+} \ No newline at end of file
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-imagedrop/textdocument-imagedrop.pro b/doc/codesnippets/doc/src/snippets/textdocument-imagedrop/textdocument-imagedrop.pro
new file mode 100644
index 000000000..96d3038a0
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-imagedrop/textdocument-imagedrop.pro
@@ -0,0 +1,2 @@
+SOURCES = textedit.cpp main.cpp
+HEADERS = textedit.h \ No newline at end of file
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-imagedrop/textedit.cpp b/doc/codesnippets/doc/src/snippets/textdocument-imagedrop/textedit.cpp
new file mode 100644
index 000000000..edfb71ec9
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-imagedrop/textedit.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "textedit.h"
+#include <QtGui>
+
+TextEdit::TextEdit(QWidget *parent)
+ : QTextEdit(parent)
+{
+}
+
+//! [0]
+
+def canInsertFromMimeData(source):
+ 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/codesnippets/doc/src/snippets/textdocument-imagedrop/textedit.h b/doc/codesnippets/doc/src/snippets/textdocument-imagedrop/textedit.h
new file mode 100644
index 000000000..990960ba7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-imagedrop/textedit.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TEXTEDIT_H
+#define TEXTEDIT_H
+
+#include <QTextEdit>
+
+class TextEdit : public QTextEdit
+{
+ Q_OBJECT
+
+public:
+ TextEdit(QWidget *parent=0);
+ bool canInsertFromMimeData( const QMimeData *source ) const;
+ void insertFromMimeData( const QMimeData *source );
+};
+
+#endif \ No newline at end of file
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-imageformat/images.qrc b/doc/codesnippets/doc/src/snippets/textdocument-imageformat/images.qrc
new file mode 100644
index 000000000..6473daf34
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-imageformat/images.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>images/advert.png</file>
+ <file>images/newimage.png</file>
+</qresource>
+</RCC>
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-imageformat/images/advert.png b/doc/codesnippets/doc/src/snippets/textdocument-imageformat/images/advert.png
new file mode 100644
index 000000000..40e10d522
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-imageformat/images/advert.png
Binary files differ
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-imageformat/images/newimage.png b/doc/codesnippets/doc/src/snippets/textdocument-imageformat/images/newimage.png
new file mode 100644
index 000000000..0eec048a7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-imageformat/images/newimage.png
Binary files differ
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-imageformat/main.cpp b/doc/codesnippets/doc/src/snippets/textdocument-imageformat/main.cpp
new file mode 100644
index 000000000..dfb5f16cf
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-imageformat/main.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+QString tr(const char *text)
+{
+ return QApplication::translate(text, text);
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QTextEdit *editor = new QTextEdit;
+
+ QTextDocument *document = new QTextDocument(editor);
+ QTextCursor cursor(document);
+
+ QTextImageFormat imageFormat;
+ imageFormat.setName(":/images/advert.png");
+ cursor.insertImage(imageFormat);
+
+ QTextBlock block = cursor.block();
+ QTextFragment fragment;
+ QTextBlock::iterator it;
+
+ for (it = block.begin(); !(it.atEnd()); ++it) {
+ fragment = it.fragment();
+
+ if (fragment.contains(cursor.position()))
+ break;
+ }
+
+//! [0]
+ if (fragment.isValid()) {
+ QTextImageFormat newImageFormat = fragment.charFormat().toImageFormat();
+
+ if (newImageFormat.isValid()) {
+ newImageFormat.setName(":/images/newimage.png");
+ QTextCursor helper = cursor;
+
+ helper.setPosition(fragment.position());
+ helper.setPosition(fragment.position() + fragment.length(),
+ QTextCursor::KeepAnchor);
+ helper.setCharFormat(newImageFormat);
+//! [0] //! [1]
+ }
+//! [1] //! [2]
+ }
+//! [2]
+
+ cursor.insertBlock();
+ cursor.insertText("Code less. Create more.");
+
+ editor->setDocument(document);
+ editor->setWindowTitle(tr("Text Document Image Format"));
+ editor->resize(320, 480);
+ editor->show();
+
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-imageformat/textdocument-imageformat.pro b/doc/codesnippets/doc/src/snippets/textdocument-imageformat/textdocument-imageformat.pro
new file mode 100644
index 000000000..1c6437050
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-imageformat/textdocument-imageformat.pro
@@ -0,0 +1,2 @@
+SOURCES = main.cpp
+RESOURCES += images.qrc
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-images/images.qrc b/doc/codesnippets/doc/src/snippets/textdocument-images/images.qrc
new file mode 100644
index 000000000..09e305e8f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-images/images.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>images/advert.png</file>
+</qresource>
+</RCC>
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-images/images/advert.png b/doc/codesnippets/doc/src/snippets/textdocument-images/images/advert.png
new file mode 100644
index 000000000..40e10d522
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-images/images/advert.png
Binary files differ
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-images/main.cpp b/doc/codesnippets/doc/src/snippets/textdocument-images/main.cpp
new file mode 100644
index 000000000..d5ef15828
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-images/main.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+QString tr(const char *text)
+{
+ return QApplication::translate(text, text);
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QTextEdit *editor = new QTextEdit;
+
+//! [0]
+ QTextDocument *document = new QTextDocument(editor);
+ QTextCursor cursor(document);
+//! [0]
+
+//! [1]
+ QTextImageFormat imageFormat;
+ imageFormat.setName(":/images/advert.png");
+ cursor.insertImage(imageFormat);
+//! [1]
+
+ cursor.insertBlock();
+ cursor.insertText("Code less. Create more.");
+
+ editor->setDocument(document);
+ editor->setWindowTitle(tr("Text Document Images"));
+ editor->resize(320, 480);
+ editor->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-images/textdocument-images.pro b/doc/codesnippets/doc/src/snippets/textdocument-images/textdocument-images.pro
new file mode 100644
index 000000000..1c6437050
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-images/textdocument-images.pro
@@ -0,0 +1,2 @@
+SOURCES = main.cpp
+RESOURCES += images.qrc
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-listitems/main.cpp b/doc/codesnippets/doc/src/snippets/textdocument-listitems/main.cpp
new file mode 100644
index 000000000..b95f1b7d7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-listitems/main.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->resize(640, 480);
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-listitems/mainwindow.cpp b/doc/codesnippets/doc/src/snippets/textdocument-listitems/mainwindow.cpp
new file mode 100644
index 000000000..1ceec16a2
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-listitems/mainwindow.cpp
@@ -0,0 +1,198 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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 *actionsMenu = new QMenu(tr("&Actions"));
+ actionsMenu->addAction(tr("&Highlight List Items"),
+ this, SLOT(highlightListItems()));
+ actionsMenu->addAction(tr("&Show Current List"), this, SLOT(showList()));
+
+ QMenu *insertMenu = new QMenu(tr("&Insert"));
+
+ insertMenu->addAction(tr("&List"), this, SLOT(insertList()),
+ QKeySequence(tr("Ctrl+L", "Insert|List")));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(insertMenu);
+ menuBar()->addMenu(actionsMenu);
+
+ editor = new QTextEdit(this);
+ document = new QTextDocument(this);
+ editor->setDocument(document);
+
+ setCentralWidget(editor);
+ setWindowTitle(tr("Text Document List Items"));
+}
+
+void MainWindow::highlightListItems()
+{
+ QTextCursor cursor = editor->textCursor();
+ QTextList *list = cursor.currentList();
+
+ if (!list)
+ return;
+
+ cursor.beginEditBlock();
+//! [0]
+ for (int index = 0; index < list->count(); ++index) {
+ QTextBlock listItem = list->item(index);
+//! [0]
+ QTextBlockFormat newBlockFormat = listItem.blockFormat();
+ newBlockFormat.setBackground(Qt::lightGray);
+ QTextCursor itemCursor = cursor;
+ itemCursor.setPosition(listItem.position());
+ //itemCursor.movePosition(QTextCursor::StartOfBlock);
+ itemCursor.movePosition(QTextCursor::EndOfBlock,
+ QTextCursor::KeepAnchor);
+ itemCursor.setBlockFormat(newBlockFormat);
+ /*
+//! [1]
+ processListItem(listItem);
+//! [1]
+ */
+//! [2]
+ }
+//! [2]
+ cursor.endEditBlock();
+}
+
+void MainWindow::showList()
+{
+ QTextCursor cursor = editor->textCursor();
+ QTextFrame *frame = cursor.currentFrame();
+
+ if (!frame)
+ return;
+
+ QTreeWidget *treeWidget = new QTreeWidget;
+ treeWidget->setColumnCount(1);
+ QStringList headerLabels;
+ headerLabels << tr("Lists");
+ treeWidget->setHeaderLabels(headerLabels);
+
+ QTreeWidgetItem *parentItem = 0;
+ QTreeWidgetItem *item;
+ QTreeWidgetItem *lastItem = 0;
+ parentItems.clear();
+ previousItems.clear();
+
+//! [3]
+ QTextFrame::iterator it;
+ for (it = frame->begin(); !(it.atEnd()); ++it) {
+
+ QTextBlock block = it.currentBlock();
+
+ if (block.isValid()) {
+
+ QTextList *list = block.textList();
+
+ if (list) {
+ int index = list->itemNumber(block);
+//! [3]
+ if (index == 0) {
+ parentItems.append(parentItem);
+ previousItems.append(lastItem);
+ listStructures.append(list);
+ parentItem = lastItem;
+ lastItem = 0;
+
+ if (parentItem != 0)
+ item = new QTreeWidgetItem(parentItem, lastItem);
+ else
+ item = new QTreeWidgetItem(treeWidget, lastItem);
+
+ } else {
+
+ while (parentItem != 0 && listStructures.last() != list) {
+ listStructures.pop_back();
+ parentItem = parentItems.takeLast();
+ lastItem = previousItems.takeLast();
+ }
+ if (parentItem != 0)
+ item = new QTreeWidgetItem(parentItem, lastItem);
+ else
+ item = new QTreeWidgetItem(treeWidget, lastItem);
+ }
+ item->setText(0, block.text());
+ lastItem = item;
+ /*
+//! [4]
+ processListItem(list, index);
+//! [4]
+ */
+//! [5]
+ }
+//! [5] //! [6]
+ }
+//! [6] //! [7]
+ }
+//! [7]
+
+ treeWidget->setWindowTitle(tr("List Contents"));
+ treeWidget->show();
+}
+
+void MainWindow::insertList()
+{
+ QTextCursor cursor = editor->textCursor();
+ cursor.beginEditBlock();
+
+ QTextList *list = cursor.currentList();
+ QTextListFormat listFormat;
+ if (list)
+ listFormat = list->format();
+
+ listFormat.setStyle(QTextListFormat::ListDisc);
+ listFormat.setIndent(listFormat.indent() + 1);
+ cursor.insertList(listFormat);
+
+ cursor.endEditBlock();
+}
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-listitems/mainwindow.h b/doc/codesnippets/doc/src/snippets/textdocument-listitems/mainwindow.h
new file mode 100644
index 000000000..6ac6d753c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-listitems/mainwindow.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QList>
+#include <QMainWindow>
+#include <QString>
+
+class QAction;
+class QTextDocument;
+class QTextEdit;
+class QTextList;
+class QTreeWidgetItem;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void insertList();
+ void highlightListItems();
+ void showList();
+
+private:
+ QString currentFile;
+ QTextEdit *editor;
+ QTextDocument *document;
+ QList<QTextList*> listStructures;
+ QList<QTreeWidgetItem*> previousItems;
+ QList<QTreeWidgetItem*> parentItems;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-listitems/textdocument-listitems.pro b/doc/codesnippets/doc/src/snippets/textdocument-listitems/textdocument-listitems.pro
new file mode 100644
index 000000000..5da8d6e1a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-listitems/textdocument-listitems.pro
@@ -0,0 +1,3 @@
+HEADERS = mainwindow.h
+SOURCES = main.cpp \
+ mainwindow.cpp
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-lists/main.cpp b/doc/codesnippets/doc/src/snippets/textdocument-lists/main.cpp
new file mode 100644
index 000000000..b95f1b7d7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-lists/main.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->resize(640, 480);
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-lists/mainwindow.cpp b/doc/codesnippets/doc/src/snippets/textdocument-lists/mainwindow.cpp
new file mode 100644
index 000000000..78b592862
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-lists/mainwindow.cpp
@@ -0,0 +1,192 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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]
+ listFormat = QTextListFormat()
+ 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/codesnippets/doc/src/snippets/textdocument-lists/mainwindow.h b/doc/codesnippets/doc/src/snippets/textdocument-lists/mainwindow.h
new file mode 100644
index 000000000..dc1e0e436
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-lists/mainwindow.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+#include <QTextDocumentFragment>
+
+class QAction;
+class QTextDocument;
+class QTextEdit;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void cutSelection();
+ void copySelection();
+ void insertList();
+ void pasteSelection();
+ void selectWord();
+ void selectLine();
+ void selectBlock();
+ void selectFrame();
+ void updateMenus();
+
+private:
+ QAction *cutAction;
+ QAction *copyAction;
+ QAction *pasteAction;
+ QString currentFile;
+ QTextEdit *editor;
+ QTextDocument *document;
+ QTextDocumentFragment selection;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-lists/textdocument-lists.pro b/doc/codesnippets/doc/src/snippets/textdocument-lists/textdocument-lists.pro
new file mode 100644
index 000000000..5da8d6e1a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-lists/textdocument-lists.pro
@@ -0,0 +1,3 @@
+HEADERS = mainwindow.h
+SOURCES = main.cpp \
+ mainwindow.cpp
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-printing/main.cpp b/doc/codesnippets/doc/src/snippets/textdocument-printing/main.cpp
new file mode 100644
index 000000000..b95f1b7d7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-printing/main.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->resize(640, 480);
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-printing/mainwindow.cpp b/doc/codesnippets/doc/src/snippets/textdocument-printing/mainwindow.cpp
new file mode 100644
index 000000000..973e91787
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-printing/mainwindow.cpp
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ fileMenu->addAction(tr("&Open..."), this, SLOT(openFile()),
+ QKeySequence(tr("Ctrl+O", "File|Open")));
+
+ printAction = fileMenu->addAction(tr("&Print..."), this, SLOT(printFile()));
+ printAction->setEnabled(false);
+
+ pdfPrintAction = fileMenu->addAction(tr("Print as P&DF..."), this, SLOT(printPdf()));
+ pdfPrintAction->setEnabled(false);
+
+ fileMenu->addAction(tr("E&xit"), this, SLOT(close()),
+ QKeySequence(tr("Ctrl+Q", "File|Exit")));
+
+ menuBar()->addMenu(fileMenu);
+
+ editor = new QTextEdit(this);
+ document = new QTextDocument(this);
+ editor->setDocument(document);
+
+ connect(editor, SIGNAL(selectionChanged()), this, SLOT(updateMenus()));
+
+ setCentralWidget(editor);
+ setWindowTitle(tr("Text Document Writer"));
+}
+
+void MainWindow::openFile()
+{
+ QString fileName = QFileDialog::getOpenFileName(this,
+ tr("Open file"), currentFile, "HTML files (*.html);;Text files (*.txt)");
+
+ if (!fileName.isEmpty()) {
+ QFileInfo info(fileName);
+ if (info.completeSuffix() == "html") {
+ QFile file(fileName);
+
+ if (file.open(QIODevice::ReadOnly)) {
+ editor->setHtml(file.readAll());
+ file.close();
+ currentFile = fileName;
+ }
+ } else if (info.completeSuffix() == "txt") {
+ QFile file(fileName);
+
+ if (file.open(QIODevice::ReadOnly)) {
+ editor->setPlainText(file.readAll());
+ file.close();
+ currentFile = fileName;
+ }
+ }
+ printAction->setEnabled(true);
+ pdfPrintAction->setEnabled(true);
+ }
+}
+
+void MainWindow::printFile()
+{
+//! [0]
+ QTextDocument *document = editor->document();
+ QPrinter printer;
+
+ QPrintDialog *dlg = new QPrintDialog(&printer, this);
+ if (dlg->exec() != QDialog::Accepted)
+ return;
+
+ document->print(&printer);
+//! [0]
+}
+
+void MainWindow::printPdf()
+{
+ QPrinter printer(QPrinter::HighResolution);
+ printer.setOutputFormat(QPrinter::PdfFormat);
+
+ QPrintDialog *printDialog = new QPrintDialog(&printer, this);
+ if (printDialog->exec() == QDialog::Accepted)
+ editor->document()->print(&printer);
+}
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-printing/mainwindow.h b/doc/codesnippets/doc/src/snippets/textdocument-printing/mainwindow.h
new file mode 100644
index 000000000..33defa54d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-printing/mainwindow.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QHash>
+#include <QMainWindow>
+#include <QTextDocumentFragment>
+
+class QAction;
+class QTextDocument;
+class QTextEdit;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void openFile();
+ void printFile();
+ void printPdf();
+
+private:
+ QAction *printAction;
+ QAction *pdfPrintAction;
+ QString currentFile;
+ QTextEdit *editor;
+ QTextDocument *document;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-printing/textdocument-printing.pro b/doc/codesnippets/doc/src/snippets/textdocument-printing/textdocument-printing.pro
new file mode 100644
index 000000000..5da8d6e1a
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-printing/textdocument-printing.pro
@@ -0,0 +1,3 @@
+HEADERS = mainwindow.h
+SOURCES = main.cpp \
+ mainwindow.cpp
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-selections/main.cpp b/doc/codesnippets/doc/src/snippets/textdocument-selections/main.cpp
new file mode 100644
index 000000000..b95f1b7d7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-selections/main.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->resize(640, 480);
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-selections/mainwindow.cpp b/doc/codesnippets/doc/src/snippets/textdocument-selections/mainwindow.cpp
new file mode 100644
index 000000000..95f6a119d
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-selections/mainwindow.cpp
@@ -0,0 +1,204 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ fileMenu->addAction(tr("&Open..."), this, SLOT(openFile()),
+ QKeySequence(tr("Ctrl+O", "File|Open")));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"), this, SLOT(close()));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ QMenu *editMenu = new QMenu(tr("&Edit"));
+
+ cutAction = editMenu->addAction(tr("Cu&t"), this, SLOT(cutSelection()));
+ cutAction->setShortcut(tr("Ctrl+X"));
+ cutAction->setEnabled(false);
+
+ copyAction = editMenu->addAction(tr("&Copy"), this, SLOT(copySelection()));
+ copyAction->setShortcut(tr("Ctrl+C"));
+ copyAction->setEnabled(false);
+
+ pasteAction = editMenu->addAction(tr("&Paste"), this, SLOT(pasteSelection()));
+ pasteAction->setShortcut(tr("Ctrl+V"));
+ pasteAction->setEnabled(false);
+
+ 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()));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(editMenu);
+ menuBar()->addMenu(selectMenu);
+
+ editor = new QTextEdit(this);
+ document = new QTextDocument(this);
+ editor->setDocument(document);
+
+ connect(editor, SIGNAL(selectionChanged()), this, SLOT(updateMenus()));
+
+ setCentralWidget(editor);
+ setWindowTitle(tr("Text Document Writer"));
+}
+
+void MainWindow::openFile()
+{
+ QString fileName = QFileDialog::getOpenFileName(this,
+ tr("Open file"), currentFile, "HTML files (*.html);;Text files (*.txt)");
+
+ if (!fileName.isEmpty()) {
+ QFileInfo info(fileName);
+ if (info.completeSuffix() == "html") {
+ QFile file(fileName);
+
+ if (file.open(QFile::ReadOnly)) {
+ editor->setHtml(QString(file.readAll()));
+ file.close();
+ currentFile = fileName;
+ }
+ } else if (info.completeSuffix() == "txt") {
+ QFile file(fileName);
+
+ if (file.open(QFile::ReadOnly)) {
+ editor->setPlainText(file.readAll());
+ file.close();
+ currentFile = fileName;
+ }
+ }
+ }
+}
+
+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();
+
+//! [0]
+ cursor.beginEditBlock();
+//! [1]
+ cursor.movePosition(QTextCursor::StartOfWord);
+ cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
+//! [1]
+ cursor.endEditBlock();
+//! [0]
+
+ 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::updateMenus()
+{
+ QTextCursor cursor = editor->textCursor();
+ cutAction->setEnabled(cursor.hasSelection());
+ copyAction->setEnabled(cursor.hasSelection());
+
+ pasteAction->setEnabled(!selection.isEmpty());
+}
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-selections/mainwindow.h b/doc/codesnippets/doc/src/snippets/textdocument-selections/mainwindow.h
new file mode 100644
index 000000000..1e1e10836
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-selections/mainwindow.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+#include <QTextDocumentFragment>
+
+class QAction;
+class QTextDocument;
+class QTextEdit;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void cutSelection();
+ void copySelection();
+ void openFile();
+ void pasteSelection();
+ void selectWord();
+ void selectLine();
+ void selectBlock();
+ void selectFrame();
+ void updateMenus();
+
+private:
+ QAction *cutAction;
+ QAction *copyAction;
+ QAction *pasteAction;
+ QString currentFile;
+ QTextEdit *editor;
+ QTextDocument *document;
+ QTextDocumentFragment selection;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-selections/textdocument-selections.pro b/doc/codesnippets/doc/src/snippets/textdocument-selections/textdocument-selections.pro
new file mode 100644
index 000000000..253c45272
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-selections/textdocument-selections.pro
@@ -0,0 +1,4 @@
+QT += xml
+HEADERS = mainwindow.h
+SOURCES = main.cpp \
+ mainwindow.cpp
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-tables/main.cpp b/doc/codesnippets/doc/src/snippets/textdocument-tables/main.cpp
new file mode 100644
index 000000000..6541faa19
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-tables/main.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->resize(480, 480);
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-tables/mainwindow.cpp b/doc/codesnippets/doc/src/snippets/textdocument-tables/mainwindow.cpp
new file mode 100644
index 000000000..45be2c2ee
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-tables/mainwindow.cpp
@@ -0,0 +1,116 @@
+############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Nokia Corporation (qt-info@nokia.com)
+##
+## This file is part of the documentation of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at http://www.qtsoftware.com/contact.
+## $QT_END_LICENSE$
+##
+###########################################################################
+
+//! [0] //! [1]
+ cursor = QTextCursor(editor.textCursor())
+//! [0]
+ cursor.movePosition(QTextCursor.Start)
+//! [1]
+
+//! [2]
+ tableFormat = QTextTableFormat()
+ 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]
+ table = cursor.insertTable(rows, columns, tableFormat)
+//! [2] //! [3]
+
+//! [4]
+ cell = table.cellAt(0, 0)
+ cellCursor = cell.firstCursorPosition()
+ cellCursor.insertText(tr("Week"), charFormat)
+//! [4]
+
+//! [5]
+ for column in range(columns):
+ cell = table.cellAt(0, column)
+ cellCursor = cell.firstCursorPosition()
+ cellCursor.insertText(tr("Team %1").arg(column), charFormat)
+
+
+ for row in range(rows):
+ cell = table.cellAt(row, 0)
+ cellCursor = cell.firstCursorPosition()
+ cellCursor.insertText(tr("%1").arg(row), charFormat)
+
+ for column in range(columns)
+ if (row-1) % 3 == column-1:
+//! [5] //! [6]
+ cell = table.cellAt(row, column)
+ cellCursor = cell.firstCursorPosition()
+ cellCursor.insertText(tr("On duty"), charFormat)
+
+//! [6] //! [7]
+
+//! [7] //! [8]
+
+//! [8]
+
+//! [9]
+ for row in range(table.rows()):
+ for column in range(table.columns()):
+ 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()
+
+ Item = QTableWidgetItem(text)
+ tableWidget.setItem(row, column, Item)
+
+//! [10]
+ processTableCell(tableCell)
+//! [10]
+
+//! [11]
+
+//! [11] //! [12]
+
+//! [12]
+
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-tables/mainwindow.h b/doc/codesnippets/doc/src/snippets/textdocument-tables/mainwindow.h
new file mode 100644
index 000000000..38e9ed369
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-tables/mainwindow.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+
+class QTextEdit;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void saveFile();
+ void showTable();
+
+private:
+ bool writeXml(const QString &fileName);
+
+ QTextEdit *editor;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-tables/textdocument-tables.pro b/doc/codesnippets/doc/src/snippets/textdocument-tables/textdocument-tables.pro
new file mode 100644
index 000000000..91ae50f49
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-tables/textdocument-tables.pro
@@ -0,0 +1,6 @@
+SOURCES = main.cpp \
+ mainwindow.cpp \
+ xmlwriter.cpp
+HEADERS = mainwindow.h \
+ xmlwriter.h
+QT += xml
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-tables/xmlwriter.cpp b/doc/codesnippets/doc/src/snippets/textdocument-tables/xmlwriter.cpp
new file mode 100644
index 000000000..30621986c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-tables/xmlwriter.cpp
@@ -0,0 +1,154 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "xmlwriter.h"
+
+QDomDocument *XmlWriter::toXml()
+{
+ QDomImplementation implementation;
+ QDomDocumentType docType = implementation.createDocumentType(
+ "scribe-document", "scribe", "qtsoftware.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);
+
+ QTextFrame *root = textDocument->rootFrame();
+
+ if (root)
+ processFrame(documentElement, root);
+
+ return document;
+}
+
+void XmlWriter::processBlock(QDomElement &parent, const QTextBlock &block)
+{
+ QDomElement blockElement = document->createElement("block");
+ blockElement.setAttribute("position", block.position());
+ blockElement.setAttribute("length", block.length());
+ parent.appendChild(blockElement);
+
+ QTextBlock::iterator it;
+ for (it = block.begin(); !(it.atEnd()); ++it) {
+ QTextFragment fragment = it.fragment();
+
+ if (fragment.isValid()) {
+ QDomElement fragmentElement = document->createElement("fragment");
+ blockElement.appendChild(fragmentElement);
+
+ fragmentElement.setAttribute("length", fragment.length());
+ QDomText fragmentText = document->createTextNode(fragment.text());
+
+ fragmentElement.appendChild(fragmentText);
+ }
+ }
+}
+
+void XmlWriter::processFrame(QDomElement &parent, QTextFrame *frame)
+{
+ QDomElement frameElement = document->createElement("frame");
+ frameElement.setAttribute("begin", frame->firstPosition());
+ frameElement.setAttribute("end", frame->lastPosition());
+ parent.appendChild(frameElement);
+
+//! [0]
+ QTextFrame::iterator it;
+ for (it = frame->begin(); !(it.atEnd()); ++it) {
+
+ QTextFrame *childFrame = it.currentFrame();
+ QTextBlock childBlock = it.currentBlock();
+
+ if (childFrame) {
+ QTextTable *childTable = qobject_cast<QTextTable*>(childFrame);
+
+ if (childTable)
+ processTable(frameElement, childTable);
+ else
+ processFrame(frameElement, childFrame);
+
+ } else if (childBlock.isValid())
+//! [0] //! [1]
+ processBlock(frameElement, childBlock);
+ }
+//! [1]
+}
+
+void XmlWriter::processTable(QDomElement &parent, QTextTable *table)
+{
+ QDomElement element = document->createElement("table");
+
+ for (int row = 0; row < table->rows(); ++row) {
+ for (int column = 0; column < table->columns(); ++column) {
+ QTextTableCell cell = table->cellAt(row, column);
+ processTableCell(element, cell);
+ }
+ }
+ parent.appendChild(element);
+}
+
+void XmlWriter::processTableCell(QDomElement &parent, const QTextTableCell &cell)
+{
+ QDomElement element = document->createElement("cell");
+ element.setAttribute("row", cell.row());
+ element.setAttribute("column", cell.column());
+
+ QTextFrame::iterator it;
+ for (it = cell.begin(); !(it.atEnd()); ++it) {
+
+ QTextFrame *childFrame = it.currentFrame();
+ QTextBlock childBlock = it.currentBlock();
+
+ if (childFrame)
+ processFrame(element, childFrame);
+ else if (childBlock.isValid())
+ processBlock(element, childBlock);
+ }
+ parent.appendChild(element);
+}
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-tables/xmlwriter.h b/doc/codesnippets/doc/src/snippets/textdocument-tables/xmlwriter.h
new file mode 100644
index 000000000..c675cbe27
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-tables/xmlwriter.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef XMLWRITER_H
+#define XMLWRITER_H
+
+#include <QDomDocument>
+
+class QTextDocument;
+
+class XmlWriter
+{
+public:
+ XmlWriter(QTextDocument *document) : textDocument(document) {}
+ QDomDocument *toXml();
+
+private:
+ void processBlock(QDomElement &parent, const QTextBlock &block);
+ void processFrame(QDomElement &parent, QTextFrame *frame);
+ void processTable(QDomElement &parent, QTextTable *table);
+ void processTableCell(QDomElement &parent, const QTextTableCell &cell);
+
+ QDomDocument *document;
+ QTextDocument *textDocument;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/textdocument-texttable/main.cpp b/doc/codesnippets/doc/src/snippets/textdocument-texttable/main.cpp
new file mode 100644
index 000000000..732304cd9
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocument-texttable/main.cpp
@@ -0,0 +1,47 @@
+############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Nokia Corporation (qt-info@nokia.com)
+##
+## This file is part of the documentation of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at http://www.qtsoftware.com/contact.
+## $QT_END_LICENSE$
+##
+############################################################################
+
+//! [0]
+ table.mergeCells(0, 0, 1, 2)
+//! [0] //! [1]
+ table.splitCell(0, 0, 1, 1)
+//! [1]
+
diff --git a/doc/codesnippets/doc/src/snippets/textdocumentendsnippet.cpp b/doc/codesnippets/doc/src/snippets/textdocumentendsnippet.cpp
new file mode 100644
index 000000000..d5273422c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/textdocumentendsnippet.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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]
+ it = doc.begin()
+ while it != doc.end():
+ print it.text()
+ it = it.next()
+//! [0]
+
+ return 0;
+}
diff --git a/doc/codesnippets/doc/src/snippets/threads/threads.cpp b/doc/codesnippets/doc/src/snippets/threads/threads.cpp
new file mode 100644
index 000000000..5eeb85b26
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/threads/threads.cpp
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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]
+{
+ if (!caches.hasLocalData())
+ caches.setLocalData(new QCache<QString, SomeClass>);
+
+ 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/codesnippets/doc/src/snippets/threads/threads.h b/doc/codesnippets/doc/src/snippets/threads/threads.h
new file mode 100644
index 000000000..5db775244
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/threads/threads.h
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QThread>
+
+//! [0]
+class MyThread : public QThread
+{
+ Q_OBJECT
+
+protected:
+ void run();
+};
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/timeline/main.cpp b/doc/codesnippets/doc/src/snippets/timeline/main.cpp
new file mode 100644
index 000000000..d6fec6fc7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/timeline/main.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <math.h>
+
+int main(int argv, char *args[])
+{
+ QApplication app(argv, args)
+
+//! [0]
+ ball = QGraphicsEllipseItem(0, 0, 20, 20)
+
+ timer = QTimeLine(5000)
+ timer.setFrameRange(0, 100)
+
+ animation = QGraphicsItemAnimation()
+ animation.setItem(ball)
+ animation.setTimeLine(timer)
+
+ for i in range(200):
+ animation.setPosAt(i / 200.0, QPointF(i, i))
+
+ scene = QGraphicsScene()
+ scene.setSceneRect(0, 0, 250, 250)
+ scene.addItem(ball)
+
+ view = QGraphicsView(scene)
+ view.show()
+
+ timer.start()
+//! [0]
+
+ return app.exec()
+}
diff --git a/doc/codesnippets/doc/src/snippets/timeline/timeline.pro b/doc/codesnippets/doc/src/snippets/timeline/timeline.pro
new file mode 100644
index 000000000..bba41b9c1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/timeline/timeline.pro
@@ -0,0 +1 @@
+SOURCES = main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/timers/timers.cpp b/doc/codesnippets/doc/src/snippets/timers/timers.cpp
new file mode 100644
index 000000000..3e5e1ace7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/timers/timers.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QTimer>
+
+class Foo : public QObject
+{
+public:
+ Foo()
+}
+
+Foo::Foo()
+{
+//! [0]
+ timer = QTimer(self)
+//! [0] //! [1]
+ self.connect(timer, SIGNAL("timeout()"), self.updateCaption)
+//! [1] //! [2]
+ timer.start(1000)
+//! [2]
+
+//! [3]
+ QTimer.singleShot(200, self.updateCaption)
+//! [3]
+
+ {
+ // ZERO-CASE
+//! [4]
+ timer = QTimer(self)
+//! [4] //! [5]
+ self.connect(timer, SIGNAL("timeout()"), self.processOneThing)
+//! [5] //! [6]
+ timer.start()
+//! [6]
+ }
+}
+
+int main()
+{
+
+}
diff --git a/doc/codesnippets/doc/src/snippets/timers/timers.pro b/doc/codesnippets/doc/src/snippets/timers/timers.pro
new file mode 100644
index 000000000..8cb4eecef
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/timers/timers.pro
@@ -0,0 +1 @@
+SOURCES += timers.cpp
diff --git a/doc/codesnippets/doc/src/snippets/transform/main.cpp b/doc/codesnippets/doc/src/snippets/transform/main.cpp
new file mode 100644
index 000000000..bdeec6cae
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/transform/main.cpp
@@ -0,0 +1,101 @@
+############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Nokia Corporation (qt-info@nokia.com)
+##
+## This file is part of the documentation of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at http://www.qtsoftware.com/contact.
+## $QT_END_LICENSE$
+##
+###########################################################################
+
+
+//! [0]
+def paintEvent(self, event)
+ painter = QPainter(self)
+ 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]
+
+//! [1]
+def paintEvent(self, event)
+ painter = QPainter(self)
+ painter.setPen(QPen(Qt.blue, 1, Qt.DashLine))
+ painter.drawRect(0, 0, 100, 100)
+
+ transform = QTransform()
+ 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]
+
+
+//! [2]
+def paintEvent(self, event)
+ pi = 3.14
+
+ a = pi/180 * 45.0
+ sina = sin(a)
+ cosa = cos(a)
+
+ translationTransform = QTransform(1, 0, 0, 1, 50.0, 50.0)
+ rotationTransform = QTransform(cosa, sina, -sina, cosa, 0, 0)
+ scalingTransform = QTransform(0.5, 0, 0, 1.0, 0, 0)
+
+ transform = QTransform()
+ transform = scalingTransform * rotationTransform * translationTransform
+
+ painter = QPainter(self)
+ 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]
+
+
diff --git a/doc/codesnippets/doc/src/snippets/transform/transform.pro b/doc/codesnippets/doc/src/snippets/transform/transform.pro
new file mode 100644
index 000000000..5254077af
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/transform/transform.pro
@@ -0,0 +1 @@
+SOURCES = main.cpp \ No newline at end of file
diff --git a/doc/codesnippets/doc/src/snippets/uitools/calculatorform/calculatorform.pro b/doc/codesnippets/doc/src/snippets/uitools/calculatorform/calculatorform.pro
new file mode 100644
index 000000000..1a18378f8
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/uitools/calculatorform/calculatorform.pro
@@ -0,0 +1,5 @@
+#! [0]
+TEMPLATE = app
+FORMS = calculatorform.ui
+SOURCES = main.cpp
+#! [0]
diff --git a/doc/codesnippets/doc/src/snippets/uitools/calculatorform/calculatorform.ui b/doc/codesnippets/doc/src/snippets/uitools/calculatorform/calculatorform.ui
new file mode 100644
index 000000000..dda0e62dd
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/uitools/calculatorform/calculatorform.ui
@@ -0,0 +1,303 @@
+<ui version="4.0" >
+ <author></author>
+ <comment></comment>
+ <exportmacro></exportmacro>
+ <class>CalculatorForm</class>
+ <widget class="QWidget" name="CalculatorForm" >
+ <property name="objectName" >
+ <string notr="true" >CalculatorForm</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>276</width>
+ <height>98</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="windowTitle" >
+ <string>Calculator Builder</string>
+ </property>
+ <layout class="QGridLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>9</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item row="0" column="0" >
+ <layout class="QHBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <layout class="QVBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label" >
+ <property name="objectName" >
+ <string notr="true" >label</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>1</y>
+ <width>45</width>
+ <height>19</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>Input 1</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="inputSpinBox1" >
+ <property name="objectName" >
+ <string notr="true" >inputSpinBox1</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>26</y>
+ <width>45</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <property name="mouseTracking" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_3" >
+ <property name="objectName" >
+ <string notr="true" >label_3</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>54</x>
+ <y>1</y>
+ <width>7</width>
+ <height>52</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>+</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label_2" >
+ <property name="objectName" >
+ <string notr="true" >label_2</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>1</y>
+ <width>45</width>
+ <height>19</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>Input 2</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="inputSpinBox2" >
+ <property name="objectName" >
+ <string notr="true" >inputSpinBox2</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>26</y>
+ <width>45</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <property name="mouseTracking" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_3_2" >
+ <property name="objectName" >
+ <string notr="true" >label_3_2</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>120</x>
+ <y>1</y>
+ <width>7</width>
+ <height>52</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>=</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label_2_2_2" >
+ <property name="objectName" >
+ <string notr="true" >label_2_2_2</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>1</y>
+ <width>37</width>
+ <height>17</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>Output</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="outputWidget" >
+ <property name="objectName" >
+ <string notr="true" >outputWidget</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>24</y>
+ <width>37</width>
+ <height>27</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::Box</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Sunken</enum>
+ </property>
+ <property name="text" >
+ <string>0</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignAbsolute|Qt::AlignBottom|Qt::AlignCenter|Qt::AlignHCenter|Qt::AlignHorizontal_Mask|Qt::AlignJustify|Qt::AlignLeading|Qt::AlignLeft|Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing|Qt::AlignVCenter|Qt::AlignVertical_Mask</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0" >
+ <spacer>
+ <property name="objectName" >
+ <string notr="true" >verticalSpacer</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>85</x>
+ <y>69</y>
+ <width>20</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="0" column="1" >
+ <spacer>
+ <property name="objectName" >
+ <string notr="true" >horizontalSpacer</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>188</x>
+ <y>26</y>
+ <width>79</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <pixmapfunction></pixmapfunction>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/doc/codesnippets/doc/src/snippets/uitools/calculatorform/main.cpp b/doc/codesnippets/doc/src/snippets/uitools/calculatorform/main.cpp
new file mode 100644
index 000000000..be850aac3
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/uitools/calculatorform/main.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+#include "ui_calculatorform.h"
+//! [0]
+#include <QApplication>
+
+//! [1]
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QWidget *widget = new QWidget;
+ Ui::CalculatorForm ui;
+ ui.setupUi(widget);
+
+ widget->show();
+ return app.exec();
+}
+//! [1]
diff --git a/doc/codesnippets/doc/src/snippets/updating-selections/main.cpp b/doc/codesnippets/doc/src/snippets/updating-selections/main.cpp
new file mode 100644
index 000000000..3d3809fec
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/updating-selections/main.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ main.cpp
+
+ A simple example that shows how selections can be used directly on a model.
+ It shows the result of some selections made using a table view.
+*/
+
+#include <QApplication>
+
+#include "window.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QMainWindow *window = new MainWindow;
+ window->show();
+ window->resize(640, 480);
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/updating-selections/model.cpp b/doc/codesnippets/doc/src/snippets/updating-selections/model.cpp
new file mode 100644
index 000000000..0fe0249f6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/updating-selections/model.cpp
@@ -0,0 +1,237 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ model.cpp
+
+ Provides a table model for use in various examples.
+*/
+
+#include <QtGui>
+
+#include "model.h"
+
+/*!
+ Constructs a table model with at least one row and one column.
+*/
+
+TableModel::TableModel(int rows, int columns, QObject *parent)
+ : QAbstractTableModel(parent)
+{
+ QStringList newList;
+
+ for (int column = 0; column < qMax(1, columns); ++column) {
+ newList.append("");
+ }
+
+ for (int row = 0; row < qMax(1, rows); ++row) {
+ rowList.append(newList);
+ }
+}
+
+
+/*!
+ Returns the number of items in the row list as the number of rows
+ in the model.
+*/
+
+int TableModel::rowCount(const QModelIndex &/*parent*/) const
+{
+ return rowList.size();
+}
+
+/*!
+ Returns the number of items in the first list item as the number of
+ columns in the model. All rows should have the same number of columns.
+*/
+
+int TableModel::columnCount(const QModelIndex &/*parent*/) const
+{
+ return rowList[0].size();
+}
+
+/*!
+ Returns an appropriate value for the requested data.
+ If the view requests an invalid index, an invalid variant is returned.
+ Any valid index that corresponds to a string in the list causes that
+ string to be returned for the display role; otherwise an invalid variant
+ is returned.
+*/
+
+QVariant TableModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ if (role == Qt::DisplayRole)
+ return rowList[index.row()][index.column()];
+ else
+ return QVariant();
+}
+
+/*!
+ Returns the appropriate header string depending on the orientation of
+ the header and the section. If anything other than the display role is
+ requested, we return an invalid variant.
+*/
+
+QVariant TableModel::headerData(int section, Qt::Orientation orientation,
+ int role) const
+{
+ if (role != Qt::DisplayRole)
+ return QVariant();
+
+ if (orientation == Qt::Horizontal)
+ return QString("Column %1").arg(section);
+ else
+ return QString("Row %1").arg(section);
+}
+
+/*!
+ Returns an appropriate value for the item's flags. Valid items are
+ enabled, selectable, and editable.
+*/
+
+Qt::ItemFlags TableModel::flags(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return Qt::ItemIsEnabled;
+
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
+}
+
+/*!
+ Changes an item in the model, but only if the following conditions
+ are met:
+
+ * The index supplied is valid.
+ * The role associated with editing text is specified.
+
+ The dataChanged() signal is emitted if the item is changed.
+*/
+
+bool TableModel::setData(const QModelIndex &index,
+ const QVariant &value, int role)
+{
+ if (!index.isValid() || role != Qt::EditRole)
+ return false;
+
+ rowList[index.row()][index.column()] = value.toString();
+ emit dataChanged(index, index);
+ return true;
+}
+
+/*!
+ Inserts a number of rows into the model at the specified position.
+*/
+
+bool TableModel::insertRows(int position, int rows, const QModelIndex &parent)
+{
+ int columns = columnCount();
+ beginInsertRows(parent, position, position + rows - 1);
+
+ for (int row = 0; row < rows; ++row) {
+ QStringList items;
+ for (int column = 0; column < columns; ++column)
+ items.append("");
+ rowList.insert(position, items);
+ }
+
+ endInsertRows();
+ return true;
+}
+
+/*!
+ Inserts a number of columns into the model at the specified position.
+ Each entry in the list is extended in turn with the required number of
+ empty strings.
+*/
+
+bool TableModel::insertColumns(int position, int columns, const QModelIndex &parent)
+{
+ int rows = rowCount();
+ beginInsertColumns(parent, position, position + columns - 1);
+
+ for (int row = 0; row < rows; ++row) {
+ for (int column = position; column < columns; ++column) {
+ rowList[row].insert(position, "");
+ }
+ }
+
+ endInsertColumns();
+ return true;
+}
+
+/*!
+ Removes a number of rows from the model at the specified position.
+*/
+
+bool TableModel::removeRows(int position, int rows, const QModelIndex &parent)
+{
+ beginRemoveRows(parent, position, position + rows - 1);
+
+ for (int row = 0; row < rows; ++row) {
+ rowList.removeAt(position);
+ }
+
+ endRemoveRows();
+ return true;
+}
+
+/*!
+ Removes a number of columns from the model at the specified position.
+ Each row is shortened by the number of columns specified.
+*/
+
+bool TableModel::removeColumns(int position, int columns, const QModelIndex &parent)
+{
+ int rows = rowCount();
+ beginRemoveColumns(parent, position, position + columns - 1);
+
+ for (int row = 0; row < rows; ++row) {
+ for (int column = 0; column < columns; ++column) {
+ rowList[row].removeAt(position);
+ }
+ }
+
+ endRemoveColumns();
+ return true;
+}
diff --git a/doc/codesnippets/doc/src/snippets/updating-selections/model.h b/doc/codesnippets/doc/src/snippets/updating-selections/model.h
new file mode 100644
index 000000000..1bb4441ef
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/updating-selections/model.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MODEL_H
+#define MODEL_H
+
+#include <QAbstractTableModel>
+#include <QStringList>
+#include <QVariant>
+
+class TableModel : public QAbstractTableModel
+{
+ Q_OBJECT
+
+public:
+ TableModel(int rows = 1, int columns = 1, QObject *parent = 0);
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = Qt::EditRole);
+
+ bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex());
+ bool insertColumns(int position, int columns, const QModelIndex &parent = QModelIndex());
+ bool removeRows(int position, int rows, const QModelIndex &parent = QModelIndex());
+ bool removeColumns(int position, int columns, const QModelIndex &parent = QModelIndex());
+
+private:
+ QList<QStringList> rowList;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/updating-selections/updating-selections.pro b/doc/codesnippets/doc/src/snippets/updating-selections/updating-selections.pro
new file mode 100644
index 000000000..91ebd3e84
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/updating-selections/updating-selections.pro
@@ -0,0 +1,2 @@
+HEADERS += model.h window.h
+SOURCES += main.cpp model.cpp window.cpp
diff --git a/doc/codesnippets/doc/src/snippets/updating-selections/window.cpp b/doc/codesnippets/doc/src/snippets/updating-selections/window.cpp
new file mode 100644
index 000000000..331b16001
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/updating-selections/window.cpp
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ window.cpp
+
+ A minimal subclass of QTableView with slots to allow the selection model
+ to be monitored.
+*/
+
+#include <QAbstractItemModel>
+#include <QItemSelection>
+#include <QItemSelectionModel>
+#include <QStatusBar>
+
+#include "model.h"
+#include "window.h"
+
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+{
+ setWindowTitle("Selected items in a table model");
+
+ model = new TableModel(8, 4, this);
+
+ table = new QTableView(this);
+ table->setModel(model);
+
+ selectionModel = table->selectionModel();
+ connect(selectionModel,
+ SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
+ this, SLOT(updateSelection(const QItemSelection &, const QItemSelection &)));
+ connect(selectionModel,
+ SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
+ this, SLOT(changeCurrent(const QModelIndex &, const QModelIndex &)));
+
+ statusBar();
+ setCentralWidget(table);
+}
+
+//! [0]
+void MainWindow::updateSelection(const QItemSelection &selected,
+ const QItemSelection &deselected)
+{
+ QModelIndex index;
+ QModelIndexList items = selected.indexes();
+
+ foreach (index, items) {
+ QString text = QString("(%1,%2)").arg(index.row()).arg(index.column());
+ model->setData(index, text);
+//! [0] //! [1]
+ }
+//! [1]
+
+//! [2]
+ items = deselected.indexes();
+
+ foreach (index, items)
+ model->setData(index, "");
+}
+//! [2]
+
+//! [3]
+void MainWindow::changeCurrent(const QModelIndex &current,
+ const QModelIndex &previous)
+{
+ statusBar()->showMessage(
+ tr("Moved from (%1,%2) to (%3,%4)")
+ .arg(previous.row()).arg(previous.column())
+ .arg(current.row()).arg(current.column()));
+}
+//! [3]
diff --git a/doc/codesnippets/doc/src/snippets/updating-selections/window.h b/doc/codesnippets/doc/src/snippets/updating-selections/window.h
new file mode 100644
index 000000000..03e22fd6e
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/updating-selections/window.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QItemSelection>
+#include <QMainWindow>
+#include <QModelIndex>
+#include <QWidget>
+#include <QTableView>
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+public:
+ MainWindow(QWidget *parent = 0);
+
+public slots:
+ void updateSelection(const QItemSelection &selected,
+ const QItemSelection &deselected);
+ void changeCurrent(const QModelIndex &current, const QModelIndex &previous);
+
+private:
+ QAbstractItemModel *model;
+ QItemSelectionModel *selectionModel;
+ QTableView *table;
+};
+
+#endif
diff --git a/doc/codesnippets/doc/src/snippets/videomedia.cpp b/doc/codesnippets/doc/src/snippets/videomedia.cpp
new file mode 100644
index 000000000..323aca9f4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/videomedia.cpp
@@ -0,0 +1,19 @@
+
+
+#include <QtGui>
+#include <phonon>
+
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+
+ Phonon::VideoPlayer *player = new Phonon::VideoPlayer(Phonon::VideoCategory, 0);
+
+//![0]
+ player->mediaObject()->isSeekable();
+//![0]
+
+ return app.exec();
+}
+
diff --git a/doc/codesnippets/doc/src/snippets/volumeslider.cpp b/doc/codesnippets/doc/src/snippets/volumeslider.cpp
new file mode 100644
index 000000000..960ca59c6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/volumeslider.cpp
@@ -0,0 +1,29 @@
+#include <QtGui>
+
+#include <phonon/audiooutput.h>
+#include <phonon/mediaobject.h>
+#include <phonon/volumeslider.h>
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+ app.setApplicationName("Volume slider tester");
+
+ Phonon::MediaObject *mediaObject = new Phonon::MediaObject;
+ mediaObject->setCurrentSource(QString("/home/gvatteka/Music/Lumme-Badloop.ogg"));
+
+//! [0]
+ Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory);
+ Phonon::createPath(mediaObject, audioOutput);
+
+ Phonon::VolumeSlider *volumeSlider = new Phonon::VolumeSlider;
+ volumeSlider->setAudioOutput(audioOutput);
+//! [0]
+
+ mediaObject->play();
+
+ volumeSlider->show();
+
+ return app.exec();
+}
+
diff --git a/doc/codesnippets/doc/src/snippets/webkit/webpage/main.cpp b/doc/codesnippets/doc/src/snippets/webkit/webpage/main.cpp
new file mode 100644
index 000000000..239309e65
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/webkit/webpage/main.cpp
@@ -0,0 +1,44 @@
+
+from PySide.QtGui import *
+from PySide.QWebKit import QWebPage
+from PySide.QWebKit import QWebFrame
+
+
+//! [0]
+class Thumbnailer(QObject):
+ page = QWebPage()
+//! [1]
+ def __init__(self, url):
+ page.mainFrame().load(url)
+ connect(page, SIGNAL("loadFinished(bool)"),
+ self, SLOT("render()"))
+//! [1]
+
+//! [2]
+ def render(self):
+ page.setViewportSize(page.mainFrame().contentsSize())
+ image = QImage(page.viewportSize(), QImage.Format_ARGB32)
+ painter = QPainter(image)
+
+ page.mainFrame().render(painter)
+ painter.end()
+
+ thumbnail = image.scaled(400, 400)
+ thumbnail.save("thumbnail.png")
+
+ self.finished()
+//! [2]
+
+//! [0]
+
+def main():
+ app = QApplication([])
+ thumbnail = Thumbnailer(QUrl("http://qtsoftware.com"))
+ QObject.connect(thumbnail, SIGNAL("finished()"),
+ app, SLOT("quit()"))
+
+ return app.exec_()
+
+
+
+#include "main.moc"
diff --git a/doc/codesnippets/doc/src/snippets/whatsthis/whatsthis.cpp b/doc/codesnippets/doc/src/snippets/whatsthis/whatsthis.cpp
new file mode 100644
index 000000000..4bd1961ab
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/whatsthis/whatsthis.cpp
@@ -0,0 +1,48 @@
+############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Nokia Corporation (qt-info@nokia.com)
+##
+## This file is part of the documentation of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at http://www.qtsoftware.com/contact.
+## $QT_END_LICENSE$
+##
+############################################################################
+
+//! [0]
+ Act = QAction(tr("&New"), self)
+ Act.setShortcut(tr("Ctrl+N"))
+ Act.setStatusTip(tr("Create a new file"))
+ Act.setWhatsThis(tr("Click self option to create a new file."))
+//! [0]
+
diff --git a/doc/codesnippets/doc/src/snippets/whatsthis/whatsthis.pro b/doc/codesnippets/doc/src/snippets/whatsthis/whatsthis.pro
new file mode 100644
index 000000000..1310a4f92
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/whatsthis/whatsthis.pro
@@ -0,0 +1 @@
+SOURCES += whatsthis.cpp
diff --git a/doc/codesnippets/doc/src/snippets/widget-mask/main.cpp b/doc/codesnippets/doc/src/snippets/widget-mask/main.cpp
new file mode 100644
index 000000000..9f540b607
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/widget-mask/main.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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/codesnippets/doc/src/snippets/widget-mask/mask.qrc b/doc/codesnippets/doc/src/snippets/widget-mask/mask.qrc
new file mode 100644
index 000000000..92f227253
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/widget-mask/mask.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/images" >
+ <file>tux.png</file>
+</qresource>
+</RCC>
diff --git a/doc/codesnippets/doc/src/snippets/widget-mask/tux.png b/doc/codesnippets/doc/src/snippets/widget-mask/tux.png
new file mode 100644
index 000000000..a95527f3f
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/widget-mask/tux.png
Binary files differ
diff --git a/doc/codesnippets/doc/src/snippets/widget-mask/widget-mask.pro b/doc/codesnippets/doc/src/snippets/widget-mask/widget-mask.pro
new file mode 100644
index 000000000..f0807a5e1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/widget-mask/widget-mask.pro
@@ -0,0 +1,3 @@
+SOURCES = main.cpp
+RESOURCES = mask.qrc
+CONFIG += qt
diff --git a/doc/codesnippets/doc/src/snippets/widgetdelegate.cpp b/doc/codesnippets/doc/src/snippets/widgetdelegate.cpp
new file mode 100644
index 000000000..0bce466c4
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/widgetdelegate.cpp
@@ -0,0 +1,23 @@
+
+//![0]
+class WidgetDelegate (QStyledItemDelegate):
+ # ...
+
+ def paint(painter, option, index):
+ if index.column() == 1:
+ progress = index.data().toInt()
+
+ progressBarOption = QStyleOptionProgressBar()
+ 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(self, painter, option, index)
+
+//![0]
+
diff --git a/doc/codesnippets/doc/src/snippets/widgets-tutorial/childwidget/childwidget.pro b/doc/codesnippets/doc/src/snippets/widgets-tutorial/childwidget/childwidget.pro
new file mode 100644
index 000000000..bba41b9c1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/widgets-tutorial/childwidget/childwidget.pro
@@ -0,0 +1 @@
+SOURCES = main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/widgets-tutorial/childwidget/main.cpp b/doc/codesnippets/doc/src/snippets/widgets-tutorial/childwidget/main.cpp
new file mode 100644
index 000000000..8a97810f0
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/widgets-tutorial/childwidget/main.cpp
@@ -0,0 +1,17 @@
+#include <QtGui>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QWidget *window = new QWidget();
+ window->resize(320, 240);
+ window->setWindowTitle(tr("Child widget"));
+ window->show();
+
+//! [create, position and show]
+ QPushButton *button = new QPushButton(tr("Press me"), window);
+ button->move(100, 100);
+ button->show();
+//! [create, position and show]
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/widgets-tutorial/nestedlayouts/main.cpp b/doc/codesnippets/doc/src/snippets/widgets-tutorial/nestedlayouts/main.cpp
new file mode 100644
index 000000000..f54146490
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/widgets-tutorial/nestedlayouts/main.cpp
@@ -0,0 +1,48 @@
+#include <QtGui>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QWidget *window = new QWidget();
+//! [create, lay out widgets and show]
+ QLabel *queryLabel = new QLabel(tr("Query:"));
+ QLineEdit *queryEdit = new QLineEdit();
+ QTableView *resultView = new QTableView();
+
+ QHBoxLayout *queryLayout = new QHBoxLayout();
+ queryLayout->addWidget(queryLabel);
+ queryLayout->addWidget(queryEdit);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout();
+ mainLayout->addLayout(queryLayout);
+ mainLayout->addWidget(resultView);
+ window->setLayout(mainLayout);
+//! [create, lay out widgets and show]
+
+ QStandardItemModel model;
+ model.setHorizontalHeaderLabels(QStringList() << tr("Name") << tr("Office"));
+ QList<QStringList> rows = QList<QStringList>()
+ << (QStringList() << "Verne Nilsen" << "123")
+ << (QStringList() << "Carlos Tang" << "77")
+ << (QStringList() << "Bronwyn Hawcroft" << "119")
+ << (QStringList() << "Alessandro Hanssen" << "32")
+ << (QStringList() << "Andrew John Bakken" << "54")
+ << (QStringList() << "Vanessa Weatherley" << "85")
+ << (QStringList() << "Rebecca Dickens" << "17")
+ << (QStringList() << "David Bradley" << "42")
+ << (QStringList() << "Knut Walters" << "25")
+ << (QStringList() << "Andrea Jones" << "34");
+ foreach (QStringList row, rows) {
+ QList<QStandardItem *> items;
+ foreach (QString text, row)
+ items.append(new QStandardItem(text));
+ model.appendRow(items);
+ }
+
+ resultView->setModel(&model);
+ resultView->verticalHeader()->hide();
+ resultView->horizontalHeader()->setStretchLastSection(true);
+ window->setWindowTitle(tr("Nested layouts"));
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/widgets-tutorial/nestedlayouts/nestedlayouts.pro b/doc/codesnippets/doc/src/snippets/widgets-tutorial/nestedlayouts/nestedlayouts.pro
new file mode 100644
index 000000000..bba41b9c1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/widgets-tutorial/nestedlayouts/nestedlayouts.pro
@@ -0,0 +1 @@
+SOURCES = main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/widgets-tutorial/toplevel/main.cpp b/doc/codesnippets/doc/src/snippets/widgets-tutorial/toplevel/main.cpp
new file mode 100644
index 000000000..cffdff885
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/widgets-tutorial/toplevel/main.cpp
@@ -0,0 +1,13 @@
+#include <QtGui>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+//! [create, resize and show]
+ QWidget *window = new QWidget();
+ window->resize(320, 240);
+ window->show();
+//! [create, resize and show]
+ window->setWindowTitle(tr("Top-level widget"));
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/widgets-tutorial/toplevel/toplevel.pro b/doc/codesnippets/doc/src/snippets/widgets-tutorial/toplevel/toplevel.pro
new file mode 100644
index 000000000..bba41b9c1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/widgets-tutorial/toplevel/toplevel.pro
@@ -0,0 +1 @@
+SOURCES = main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/widgets-tutorial/windowlayout/main.cpp b/doc/codesnippets/doc/src/snippets/widgets-tutorial/windowlayout/main.cpp
new file mode 100644
index 000000000..0c6e81475
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/widgets-tutorial/windowlayout/main.cpp
@@ -0,0 +1,19 @@
+#include <QtGui>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QWidget *window = new QWidget();
+//! [create, lay out widgets and show]
+ QLabel *label = new QLabel(tr("Name:"));
+ QLineEdit *lineEdit = new QLineEdit();
+
+ QHBoxLayout *layout = new QHBoxLayout();
+ layout->addWidget(label);
+ layout->addWidget(lineEdit);
+ window->setLayout(layout);
+//! [create, lay out widgets and show]
+ window->setWindowTitle(tr("Window layout"));
+ window->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/widgets-tutorial/windowlayout/windowlayout.pro b/doc/codesnippets/doc/src/snippets/widgets-tutorial/windowlayout/windowlayout.pro
new file mode 100644
index 000000000..bba41b9c1
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/widgets-tutorial/windowlayout/windowlayout.pro
@@ -0,0 +1 @@
+SOURCES = main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/xml/prettyprint/main.cpp b/doc/codesnippets/doc/src/snippets/xml/prettyprint/main.cpp
new file mode 100644
index 000000000..33875ae28
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/xml/prettyprint/main.cpp
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QCoreApplication>
+#include <QFile>
+#include <QHash>
+#include <QPair>
+#include <QStringList>
+#include <QTextStream>
+#include <QXmlStreamReader>
+
+/*
+ This class exists for the sole purpose of creating a translation context.
+ */
+class PrettyPrint
+{
+ Q_DECLARE_TR_FUNCTIONS(PrettyPrint)
+};
+
+int main(int argc, char *argv[])
+{
+ enum ExitCode
+ {
+ Success,
+ ParseFailure,
+ ArgumentError,
+ WriteError,
+ FileFailure
+ };
+
+ QCoreApplication app(argc, argv);
+
+ QTextStream errorStream(stderr);
+
+ if (argc != 2)
+ {
+ errorStream << PrettyPrint::tr(
+ "Usage: prettyprint <path to XML file>\n");
+ return ArgumentError;
+ }
+
+ QString inputFilePath(QCoreApplication::arguments().at(1));
+ QFile inputFile(inputFilePath);
+
+ if (!QFile::exists(inputFilePath))
+ {
+ errorStream << PrettyPrint::tr(
+ "File %1 does not exist.\n").arg(inputFilePath);
+ return FileFailure;
+
+ } else if (!inputFile.open(QIODevice::ReadOnly)) {
+ errorStream << PrettyPrint::tr(
+ "Failed to open file %1.\n").arg(inputFilePath);
+ return FileFailure;
+ }
+
+ QFile outputFile;
+ if (!outputFile.open(stdout, QIODevice::WriteOnly))
+ {
+ QTextStream(stderr) << PrettyPrint::tr("Failed to open stdout.");
+ return WriteError;
+ }
+
+ QXmlStreamReader reader(&inputFile);
+ int indentation = 0;
+ QHash<int,QPair<int, int> > indentationStack;
+
+ while (!reader.atEnd())
+ {
+ reader.readNext();
+ if (reader.isStartElement()) {
+ indentationStack[indentation] = QPair<int,int>(
+ reader.lineNumber(), reader.columnNumber());
+ indentation += 1;
+ } else if (reader.isEndElement()) {
+ indentationStack.remove(indentation);
+ indentation -= 1;
+ }
+
+ if (reader.error())
+ {
+ errorStream << PrettyPrint::tr(
+ "Error: %1 in file %2 at line %3, column %4.\n").arg(
+ reader.errorString(), inputFilePath,
+ QString::number(reader.lineNumber()),
+ QString::number(reader.columnNumber()));
+ if (indentationStack.contains(indentation-1)) {
+ int line = indentationStack[indentation-1].first;
+ int column = indentationStack[indentation-1].second;
+ errorStream << PrettyPrint::tr(
+ "Opened at line %1, column %2.\n").arg(
+ QString::number(line),
+ QString::number(column));
+ }
+ return ParseFailure;
+
+ } else if (reader.isStartElement() && !reader.name().isEmpty()) {
+ outputFile.write(QByteArray().fill(' ', indentation));
+ outputFile.write(reader.name().toString().toLocal8Bit());
+ outputFile.write(QString(" line %1, column %2\n").arg(
+ reader.lineNumber()).arg(reader.columnNumber()).toLocal8Bit());
+ }
+ }
+
+ return Success;
+}
diff --git a/doc/codesnippets/doc/src/snippets/xml/prettyprint/prettyprint.pro b/doc/codesnippets/doc/src/snippets/xml/prettyprint/prettyprint.pro
new file mode 100644
index 000000000..61945e065
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/xml/prettyprint/prettyprint.pro
@@ -0,0 +1,4 @@
+CONFIG += console
+QT -= gui
+QT += xml
+SOURCES += main.cpp
diff --git a/doc/codesnippets/doc/src/snippets/xml/rsslisting/handler.cpp b/doc/codesnippets/doc/src/snippets/xml/rsslisting/handler.cpp
new file mode 100644
index 000000000..3ba8d34e7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/xml/rsslisting/handler.cpp
@@ -0,0 +1,179 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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]
+def fatalError(self, exception):
+ qWarning("Fatal error on line %d, column %d:%s" % (exception.lineNumber(), exception.columnNumber(), exception.message())
+
+ return False
+//! [0]
diff --git a/doc/codesnippets/doc/src/snippets/xml/rsslisting/handler.h b/doc/codesnippets/doc/src/snippets/xml/rsslisting/handler.h
new file mode 100644
index 000000000..5eb6284a8
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/xml/rsslisting/handler.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef HANDLER_H
+#define HANDLER_H
+
+#include <QObject>
+#include <QString>
+#include <QXmlDefaultHandler>
+
+/* Note that QObject must precede QXmlDefaultHandler in the following list. */
+
+class Handler : public QObject, public QXmlDefaultHandler
+{
+ Q_OBJECT
+public:
+ bool startDocument();
+ bool startElement(const QString &, const QString &, const QString &qName,
+ const QXmlAttributes &attr);
+ bool endElement(const QString &, const QString &, const QString &qName);
+ bool characters(const QString &chars);
+
+ bool fatalError(const QXmlParseException &exception);
+
+signals:
+ void newItem(QString &title, QString &link);
+
+private:
+ QString titleString;
+ QString linkString;
+ bool inItem;
+ bool inTitle;
+ bool inLink;
+};
+
+#endif
+
diff --git a/doc/codesnippets/doc/src/snippets/xml/rsslisting/main.cpp b/doc/codesnippets/doc/src/snippets/xml/rsslisting/main.cpp
new file mode 100644
index 000000000..1b556dac7
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/xml/rsslisting/main.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+main.cpp
+
+Provides the main function for the RSS news reader example.
+*/
+
+#include <QtGui>
+
+#include "rsslisting.h"
+
+/*!
+ Create an application and a main widget. Open the main widget for
+ user input, and exit with an appropriate return value when it is
+ closed.
+*/
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+ RSSListing *rsslisting = new RSSListing;
+ rsslisting->show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/doc/src/snippets/xml/rsslisting/rsslisting.cpp b/doc/codesnippets/doc/src/snippets/xml/rsslisting/rsslisting.cpp
new file mode 100644
index 000000000..2740bd2c9
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/xml/rsslisting/rsslisting.cpp
@@ -0,0 +1,246 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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]
+def readData(self, resp):
+ if resp.statusCode() != 200:
+ self.http.abort()
+ else:
+ xmlInput.setData(self.http.readAll())
+
+ if newInformation:
+ ok = xmlReader.parse(xmlInput, True)
+ newInformation = False
+ else:
+ ok = xmlReader.parseContinue()
+
+ if not ok:
+ self.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/codesnippets/doc/src/snippets/xml/rsslisting/rsslisting.h b/doc/codesnippets/doc/src/snippets/xml/rsslisting/rsslisting.h
new file mode 100644
index 000000000..01250dbb5
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/xml/rsslisting/rsslisting.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef RSSLISTING_H
+#define RSSLISTING_H
+
+#include <QHttp>
+#include <QWidget>
+#include <QXmlInputSource>
+#include <QXmlSimpleReader>
+
+#include "handler.h"
+
+class QLineEdit;
+class QTreeWidget;
+class QTreeWidgetItem;
+class QPushButton;
+
+class RSSListing : public QWidget
+{
+ Q_OBJECT
+public:
+ RSSListing(QWidget *widget = 0);
+
+public slots:
+ void addItem(QString &title, QString &link);
+ void fetch();
+ void finished(int id, bool error);
+ void readData(const QHttpResponseHeader &);
+
+private:
+ Handler *handler;
+ QXmlInputSource xmlInput;
+ QXmlSimpleReader xmlReader;
+
+ bool newInformation;
+
+ QHttp http;
+ int connectionId;
+
+ QLineEdit *lineEdit;
+ QTreeWidget *treeWidget;
+ QTreeWidgetItem *lastItemCreated;
+ QPushButton *abortButton;
+ QPushButton *fetchButton;
+};
+
+#endif
+
diff --git a/doc/codesnippets/doc/src/snippets/xml/simpleparse/handler.cpp b/doc/codesnippets/doc/src/snippets/xml/simpleparse/handler.cpp
new file mode 100644
index 000000000..214451e4e
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/xml/simpleparse/handler.cpp
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+handler.cpp
+
+Provides a handler for processing XML elements found by the reader.
+
+The handler stores the names of elements it finds and their indentation
+levels. The indentation level is initially set to zero.
+When a starting element is found, the indentation level is increased;
+when an ending element is found, the indentation level is decreased.
+*/
+
+#include <QDebug>
+#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()
+{
+ elementName.clear();
+ elementIndentation.clear();
+ indentationLevel = 0;
+
+ return true;
+}
+
+/*!
+ Process each starting element in the XML document.
+
+ Append the element name to the list of elements found; add its
+ corresponding indentation level to the list of indentation levels.
+
+ Increase the level of indentation by one column.
+
+ We return true to indicate that parsing should continue.
+*/
+
+bool Handler::startElement(const QString &, const QString &,
+ const QString & qName, const QXmlAttributes &)
+{
+ elementName.append(qName);
+ elementIndentation.append(indentationLevel);
+ indentationLevel += 1;
+
+ return true;
+}
+
+/*!
+ Process each ending element in the XML document.
+
+ Decrease the level of indentation by one column.
+
+ We return true to indicate that parsing should continue.
+*/
+
+bool Handler::endElement(const QString &, const QString &,
+ const QString &)
+{
+ indentationLevel -= 1;
+
+ return true;
+}
+
+/*!
+ Report a fatal parsing error, and return false to indicate to the reader
+ that parsing should stop.
+*/
+
+bool Handler::fatalError (const QXmlParseException & exception)
+{
+ qWarning() << QString("Fatal error on line %1, column %2: %3").arg(
+ exception.lineNumber()).arg(exception.columnNumber()).arg(
+ exception.message());
+
+ return false;
+}
+
+/*!
+ Return the list of element names found.
+*/
+
+QStringList& Handler::names ()
+{
+ return elementName;
+}
+
+/*!
+ Return the list of indentations used for each element found.
+*/
+
+QList<int>& Handler::indentations ()
+{
+ return elementIndentation;
+}
diff --git a/doc/codesnippets/doc/src/snippets/xml/simpleparse/handler.h b/doc/codesnippets/doc/src/snippets/xml/simpleparse/handler.h
new file mode 100644
index 000000000..b298dedd6
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/xml/simpleparse/handler.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef HANDLER_H
+#define HANDLER_H
+
+#include <qstring.h>
+#include <qxml.h>
+
+class Handler : public QXmlDefaultHandler
+{
+public:
+ bool startDocument();
+ bool startElement(const QString &, const QString &, const QString &qName,
+ const QXmlAttributes &);
+ bool endElement(const QString &, const QString &, const QString &);
+
+ bool fatalError(const QXmlParseException &exception);
+
+ QStringList& names();
+ QList<int>& indentations();
+
+private:
+ int indentationLevel;
+ QStringList elementName;
+ QList<int> elementIndentation;
+};
+
+#endif
+
diff --git a/doc/codesnippets/doc/src/snippets/xml/simpleparse/main.cpp b/doc/codesnippets/doc/src/snippets/xml/simpleparse/main.cpp
new file mode 100644
index 000000000..4b2f2827e
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/xml/simpleparse/main.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $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]
+ xmlReader = QXmlSimpleReader()
+ source = QXmlInputSource(filename)
+//! [0]
+
+//! [1]
+ handler = Handler()
+ xmlReader.setContentHandler(handler)
+ xmlReader.setErrorHandler(handler)
+//! [1]
+
+//! [2]
+ ok = xmlReader.parse(source)
+
+ if not ok:
+ print "Parsing failed."
+//! [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;
+}
diff --git a/doc/codesnippets/doc/src/snippets/xml/simpleparse/simpleparse.pro b/doc/codesnippets/doc/src/snippets/xml/simpleparse/simpleparse.pro
new file mode 100644
index 000000000..fbea770b9
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/xml/simpleparse/simpleparse.pro
@@ -0,0 +1,4 @@
+HEADERS = handler.h
+SOURCES = handler.cpp \
+ main.cpp
+QT += xml
diff --git a/doc/codesnippets/doc/src/snippets/xml/xml.pro b/doc/codesnippets/doc/src/snippets/xml/xml.pro
new file mode 100644
index 000000000..a321badb3
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/xml/xml.pro
@@ -0,0 +1,8 @@
+### A qmake file for the snippets. *** This is not for distribution. ***
+#
+# The snippets that don't work are commented out.
+
+TEMPLATE = subdirs
+SUBDIRS = prettyprint
+# rsslisting
+# simpleparse
diff --git a/doc/codesnippets/examples/dialogs/classwizard/classwizard.cpp b/doc/codesnippets/examples/dialogs/classwizard/classwizard.cpp
new file mode 100644
index 000000000..5814d5f44
--- /dev/null
+++ b/doc/codesnippets/examples/dialogs/classwizard/classwizard.cpp
@@ -0,0 +1,250 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0] //! [1]
+def __init__(self, parent):
+ QWizard.__init__(self, parent):
+ self.addPage(IntroPage())
+ self.addPage(ClassInfoPage())
+ self.addPage(CodeStylePage())
+ self.addPage(OutputFilesPage())
+ self.addPage(ConclusionPage())
+//! [0]
+
+ self.setPixmap(QWizard.BannerPixmap, QPixmap(":/images/banner.png"))
+ self.setPixmap(QWizard.BackgroundPixmap, QPixmap(":/images/background.png"))
+
+ self.setWindowTitle(self.tr("Class Wizard"))
+//! [2]
+
+//! [1] //! [2]
+
+//! [3]
+def accept(self):
+//! [3] //! [4]
+ className = self.field("className").toByteArray()
+ baseClass = self.field("baseClass").toByteArray()
+ macroName = self.field("macroName").toByteArray()
+ baseInclude = self.field("baseInclude").toByteArray()
+
+ outputDir = self.field("outputDir").toString()
+ header = self.field("header").toString()
+ implementation = self.field("implementation").toString()
+//! [4]
+
+...
+
+//! [5]
+ QDialog.accept(self)
+//! [5] //! [6]
+}
+//! [6]
+
+//! [7]
+class IntroPage (QWizardPage):
+
+ def __init__(self, parent):
+ QWizardPage.__init__(self, parent)
+
+ self.setTitle(tr("Introduction"))
+ self.setPixmap(QWizard.WatermarkPixmap, QPixmap(":/images/watermark1.png"))
+
+ label = QLabel(self.tr("This wizard will generate a skeleton C++ class " \
+ "definition, including a few functions. You simply " \
+ "need to specify the class name and set a few " \
+ "options to produce a header file and an " \
+ "implementation file for your new C++ class."))
+ label.setWordWrap(True)
+
+ layout = QVBoxLayout()
+ layout.addWidget(label)
+ self.setLayout(layout)
+}
+//! [7]
+
+//! [8] //! [9]
+class ClassInfoPage(QWizardPage):
+
+ def __init__(self, parent):
+ QWizardPage.__init__(self, parent)
+//! [8]
+ self.setTitle(self.tr("Class Information"))
+ self.setSubTitle(self.tr("Specify basic information about the class for which you " \
+ "want to generate skeleton source code files."))
+ self.setPixmap(QWizard.LogoPixmap, QPixmap(":/images/logo1.png"))
+
+//! [10]
+ classNameLabel = QLabel(self.tr("&Class name:"))
+ classNameLineEdit = QLineEdit()
+ classNameLabel.setBuddy(classNameLineEdit)
+
+ baseClassLabel = QLabel(self.tr("B&ase class:"))
+ baseClassLineEdit = QLineEdit()
+ baseClassLabel.setBuddy(baseClassLineEdit)
+
+ qobjectMacroCheckBox = QCheckBox(self.tr("Generate Q_OBJECT &macro"))
+
+//! [10]
+ groupBox = QGroupBox(self.tr("C&onstructor"))
+//! [9]
+
+ qobjectCtorRadioButton = QRadioButton(self.tr("&QObject-style constructor"))
+ qwidgetCtorRadioButton = QRadioButton(self.tr("Q&Widget-style constructor"))
+ defaultCtorRadioButton = QRadioButton(self.tr("&Default constructor"))
+ copyCtorCheckBox = QCheckBox(self.tr("&Generate copy constructor and operator="))
+
+ defaultCtorRadioButton.setChecked(True)
+
+ self.connect(defaultCtorRadioButton, SIGNAL("toggled(bool)"),
+ copyCtorCheckBox, SLOT("setEnabled(bool)"))
+
+//! [11] //! [12]
+ registerField("className*", classNameLineEdit)
+ registerField("baseClass", baseClassLineEdit)
+ registerField("qobjectMacro", qobjectMacroCheckBox)
+//! [11]
+ registerField("qobjectCtor", qobjectCtorRadioButton)
+ registerField("qwidgetCtor", qwidgetCtorRadioButton)
+ registerField("defaultCtor", defaultCtorRadioButton)
+ registerField("copyCtor", copyCtorCheckBox)
+
+ groupBoxLayout = QVBoxLayout()
+//! [12]
+ groupBoxLayout.addWidget(qobjectCtorRadioButton)
+ groupBoxLayout.addWidget(qwidgetCtorRadioButton)
+ groupBoxLayout.addWidget(defaultCtorRadioButton)
+ groupBoxLayout.addWidget(copyCtorCheckBox)
+ groupBox.setLayout(groupBoxLayout)
+
+ layout = QGridLayout()
+ layout.addWidget(classNameLabel, 0, 0)
+ layout.addWidget(classNameLineEdit, 0, 1)
+ layout.addWidget(baseClassLabel, 1, 0)
+ layout.addWidget(baseClassLineEdit, 1, 1)
+ layout.addWidget(qobjectMacroCheckBox, 2, 0, 1, 2)
+ layout.addWidget(groupBox, 3, 0, 1, 2)
+ self.setLayout(layout)
+//! [13]
+
+//! [13]
+
+//! [14]
+class CodeStylePage(QWizardPage):
+
+ def __init__(self, parent):
+ QWizardPage.__init__(self, parent)
+ self.setTitle(tr("Code Style Options"))
+ self.setSubTitle(tr("Choose the formatting of the generated code."))
+ self.setPixmap(QWizard.LogoPixmap, QPixmap(":/images/logo2.png"))
+
+ commentCheckBox = QCheckBox(self.tr("&Start generated files with a comment"))
+//! [14]
+ commentCheckBox.setChecked(True)
+
+ protectCheckBox = QCheckBox(self.tr("&Protect header file against multiple " \
+ "inclusions"))
+ protectCheckBox.setChecked(True)
+
+ macroNameLabel = QLabel(self.tr("&Macro name:"))
+ macroNameLineEdit = QLineEdit()
+ macroNameLabel.setBuddy(macroNameLineEdit)
+
+ includeBaseCheckBox = QCheckBox(self.tr("&Include base class definition"))
+ baseIncludeLabel = QLabel(self.tr("Base class include:"))
+ baseIncludeLineEdit = QLineEdit()
+ baseIncludeLabel.setBuddy(baseIncludeLineEdit)
+
+ self.connect(protectCheckBox, SIGNAL("toggled(bool)"),
+ macroNameLabel, SLOT("setEnabled(bool)"))
+ self.connect(protectCheckBox, SIGNAL("toggled(bool)"),
+ macroNameLineEdit, SLOT("setEnabled(bool)"))
+ self.connect(includeBaseCheckBox, SIGNAL("toggled(bool)"),
+ baseIncludeLabel, SLOT("setEnabled(bool)"))
+ self.connect(includeBaseCheckBox, SIGNAL(toggled(bool)),
+ baseIncludeLineEdit, SLOT("setEnabled(bool)"))
+
+ self.registerField("comment", commentCheckBox)
+ self.registerField("protect", protectCheckBox)
+ self.registerField("macroName", macroNameLineEdit)
+ self.registerField("includeBase", includeBaseCheckBox)
+ self.registerField("baseInclude", baseIncludeLineEdit)
+
+ layout = QGridLayout()
+ layout.setColumnMinimumWidth(0, 20)
+ layout.addWidget(commentCheckBox, 0, 0, 1, 3)
+ layout.addWidget(protectCheckBox, 1, 0, 1, 3)
+ layout.addWidget(macroNameLabel, 2, 1)
+ layout.addWidget(macroNameLineEdit, 2, 2)
+ layout.addWidget(includeBaseCheckBox, 3, 0, 1, 3)
+ layout.addWidget(baseIncludeLabel, 4, 1)
+ layout.addWidget(baseIncludeLineEdit, 4, 2)
+//! [15]
+ self.setLayout(layout)
+}
+//! [15]
+
+//! [16]
+ def initializePage(self):
+ className = self.field("className").toString()
+ self.macroNameLineEdit.setText(className.toUpper() + "_H")
+
+ baseClass = self.field("baseClass").toString()
+
+ self.includeBaseCheckBox.setChecked(not baseClass.isEmpty())
+ self.includeBaseCheckBox.setEnabled(not baseClass.isEmpty())
+ self.baseIncludeLabel.setEnabled(not baseClass.isEmpty())
+ self.baseIncludeLineEdit.setEnabled(not baseClass.isEmpty())
+
+ if baseClass.isEmpty():
+ self.baseIncludeLineEdit.clear()
+ elsif QRegExp("Q[A-Z].*").exactMatch(baseClass):
+ baseIncludeLineEdit.setText("<" + baseClass + ">")
+ else:
+ baseIncludeLineEdit.setText("\"" + baseClass.toLower() + ".h\"")
+//! [16]
+
+//! [17]
+ def initializePage(self):
+ className = field("className").toString()
+ self.headerLineEdit.setText(className.toLower() + ".h")
+ self.implementationLineEdit.setText(className.toLower() + ".cpp")
+ self.outputDirLineEdit.setText(QDir.convertSeparators(QDir.tempPath()))
+//! [17]
diff --git a/doc/codesnippets/examples/dialogs/classwizard/classwizard.qrc b/doc/codesnippets/examples/dialogs/classwizard/classwizard.qrc
new file mode 100644
index 000000000..41a5ddc7d
--- /dev/null
+++ b/doc/codesnippets/examples/dialogs/classwizard/classwizard.qrc
@@ -0,0 +1,11 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>images/background.png</file>
+ <file>images/banner.png</file>
+ <file>images/logo1.png</file>
+ <file>images/logo2.png</file>
+ <file>images/logo3.png</file>
+ <file>images/watermark1.png</file>
+ <file>images/watermark2.png</file>
+</qresource>
+</RCC>
diff --git a/doc/codesnippets/examples/dialogs/classwizard/images/background.png b/doc/codesnippets/examples/dialogs/classwizard/images/background.png
new file mode 100644
index 000000000..44c7badb8
--- /dev/null
+++ b/doc/codesnippets/examples/dialogs/classwizard/images/background.png
Binary files differ
diff --git a/doc/codesnippets/examples/dialogs/classwizard/images/banner.png b/doc/codesnippets/examples/dialogs/classwizard/images/banner.png
new file mode 100644
index 000000000..3169152b8
--- /dev/null
+++ b/doc/codesnippets/examples/dialogs/classwizard/images/banner.png
Binary files differ
diff --git a/doc/codesnippets/examples/dialogs/classwizard/images/logo1.png b/doc/codesnippets/examples/dialogs/classwizard/images/logo1.png
new file mode 100644
index 000000000..f9b594aaf
--- /dev/null
+++ b/doc/codesnippets/examples/dialogs/classwizard/images/logo1.png
Binary files differ
diff --git a/doc/codesnippets/examples/dialogs/classwizard/images/logo2.png b/doc/codesnippets/examples/dialogs/classwizard/images/logo2.png
new file mode 100644
index 000000000..5dcbd4669
--- /dev/null
+++ b/doc/codesnippets/examples/dialogs/classwizard/images/logo2.png
Binary files differ
diff --git a/doc/codesnippets/examples/dialogs/classwizard/images/logo3.png b/doc/codesnippets/examples/dialogs/classwizard/images/logo3.png
new file mode 100644
index 000000000..9fd3ea235
--- /dev/null
+++ b/doc/codesnippets/examples/dialogs/classwizard/images/logo3.png
Binary files differ
diff --git a/doc/codesnippets/examples/dialogs/classwizard/images/watermark1.png b/doc/codesnippets/examples/dialogs/classwizard/images/watermark1.png
new file mode 100644
index 000000000..0091f5c17
--- /dev/null
+++ b/doc/codesnippets/examples/dialogs/classwizard/images/watermark1.png
Binary files differ
diff --git a/doc/codesnippets/examples/dialogs/classwizard/images/watermark2.png b/doc/codesnippets/examples/dialogs/classwizard/images/watermark2.png
new file mode 100644
index 000000000..3b88f2e36
--- /dev/null
+++ b/doc/codesnippets/examples/dialogs/classwizard/images/watermark2.png
Binary files differ
diff --git a/doc/codesnippets/examples/dialogs/classwizard/main.cpp b/doc/codesnippets/examples/dialogs/classwizard/main.cpp
new file mode 100644
index 000000000..b6107dd6f
--- /dev/null
+++ b/doc/codesnippets/examples/dialogs/classwizard/main.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QTranslator>
+#include <QLocale>
+#include <QLibraryInfo>
+
+#include "classwizard.h"
+
+int main(int argc, char *argv[])
+{
+ Q_INIT_RESOURCE(classwizard);
+
+ QApplication app(argc, argv);
+
+ QString translatorFileName = QLatin1String("qt_");
+ translatorFileName += QLocale::system().name();
+ QTranslator *translator = new QTranslator(&app);
+ if (translator->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
+ app.installTranslator(translator);
+
+ ClassWizard wizard;
+ wizard.show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/examples/dialogs/extension/finddialog.cpp b/doc/codesnippets/examples/dialogs/extension/finddialog.cpp
new file mode 100644
index 000000000..3ccf8471e
--- /dev/null
+++ b/doc/codesnippets/examples/dialogs/extension/finddialog.cpp
@@ -0,0 +1,110 @@
+############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Qt Software Information (qt-info@nokia.com)
+##
+## This file is part of the example classes of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at qt-sales@nokia.com.
+## $QT_END_LICENSE$
+##
+############################################################################
+
+
+from PySide.QtGui import *
+
+//! [0]
+def __init__(self, parent):
+ QDialog.__init__(self, parent)
+ label = QLabel(self.tr("Find &what:"))
+ lineEdit = QLineEdit()
+ label.setBuddy(lineEdit)
+
+ caseCheckBox = QCheckBox(self.tr("Match &case"))
+ fromStartCheckBox = QCheckBox(self.tr("Search from &start"))
+ fromStartCheckBox.setChecked(True)
+
+//! [1]
+ findButton = QPushButton(self.tr("&Find"))
+ findButton.setDefault(True)
+
+ moreButton = QPushButton(self.tr("&More"))
+ moreButton.setCheckable(True)
+//! [0]
+ moreButton.setAutoDefault(False)
+
+ buttonBox = QDialogButtonBox(Qt.Vertical)
+ buttonBox.addButton(findButton, QDialogButtonBox.ActionRole)
+ buttonBox.addButton(moreButton, QDialogButtonBox.ActionRole)
+//! [1]
+
+//! [2]
+ extension = QWidget()
+
+ wholeWordsCheckBox = QCheckBox(self.tr("&Whole words"))
+ backwardCheckBox = QCheckBox(self.tr("Search &backward"))
+ searchSelectionCheckBox = QCheckBox(self.tr("Search se&lection"))
+//! [2]
+
+//! [3]
+ connect(moreButton, SIGNAL("toggled(bool)"), extension, SLOT("setVisible(bool)"))
+
+ QVBoxLayout *extensionLayout = QVBoxLayout
+ extensionLayout.setMargin(0)
+ extensionLayout.addWidget(wholeWordsCheckBox)
+ extensionLayout.addWidget(backwardCheckBox)
+ extensionLayout.addWidget(searchSelectionCheckBox)
+ extension.setLayout(extensionLayout)
+//! [3]
+
+//! [4]
+ topLeftLayout = QHBoxLayout
+ topLeftLayout.addWidget(label)
+ topLeftLayout.addWidget(lineEdit)
+
+ leftLayout = QVBoxLayout
+ leftLayout.addLayout(topLeftLayout)
+ leftLayout.addWidget(caseCheckBox)
+ leftLayout.addWidget(fromStartCheckBox)
+ leftLayout.addSself.tretch(1)
+
+ mainLayout = QGridLayout
+ mainLayout.setSizeConsself.traint(QLayout.SetFixedSize)
+ mainLayout.addLayout(leftLayout, 0, 0)
+ mainLayout.addWidget(buttonBox, 0, 1)
+ mainLayout.addWidget(extension, 1, 0, 1, 2)
+ setLayout(mainLayout)
+
+ setWindowTitle(self.tr("Extension"))
+//! [4] //! [5]
+ extension.hide()
+//! [5]
diff --git a/doc/codesnippets/examples/dialogs/licensewizard/images/logo.png b/doc/codesnippets/examples/dialogs/licensewizard/images/logo.png
new file mode 100644
index 000000000..56f17a3e5
--- /dev/null
+++ b/doc/codesnippets/examples/dialogs/licensewizard/images/logo.png
Binary files differ
diff --git a/doc/codesnippets/examples/dialogs/licensewizard/images/watermark.png b/doc/codesnippets/examples/dialogs/licensewizard/images/watermark.png
new file mode 100644
index 000000000..124a05068
--- /dev/null
+++ b/doc/codesnippets/examples/dialogs/licensewizard/images/watermark.png
Binary files differ
diff --git a/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.cpp b/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.cpp
new file mode 100644
index 000000000..5229acdf3
--- /dev/null
+++ b/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.cpp
@@ -0,0 +1,349 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "licensewizard.h"
+
+//! [0] //! [1] //! [2]
+# class LicenseWizard
+def __init__(self, parent)
+ QWizard(self, parent)
+//! [0]
+ self.setPage(self.Page_Intro, IntroPage())
+ self.setPage(self.Page_Evaluate, EvaluatePage())
+ self.setPage(self.Page_Register, RegisterPage())
+ self.setPage(self.Page_Details, DetailsPage())
+ self.setPage(self.Page_Conclusion, ConclusionPage())
+//! [1]
+
+ self.setStartId(self.Page_Intro);
+//! [2]
+
+//! [3]
+
+//! [3] //! [4]
+ self.setWizardStyle(QWizard.ModernStyle);
+
+//! [4] //! [5]
+ self.setOption(HaveHelpButton, True);
+//! [5] //! [6]
+ self.setPixmap(QWizard.LogoPixmap, QPixmap(":/images/logo.png"));
+
+//! [7]
+ connect(this, SIGNAL(helpRequested()), this, SLOT(showHelp()));
+//! [7]
+
+ setWindowTitle(tr("License Wizard"));
+//! [8]
+}
+//! [6] //! [8]
+
+//! [9] //! [10]
+void LicenseWizard::showHelp()
+//! [9] //! [11]
+{
+ static QString lastHelpMessage;
+
+ QString message;
+
+ switch (currentId()) {
+ case Page_Intro:
+ message = tr("The decision you make here will affect which page you "
+ "get to see next.");
+ break;
+//! [10] //! [11]
+ case Page_Evaluate:
+ message = tr("Make sure to provide a valid email address, such as "
+ "toni.buddenbrook@example.de.");
+ break;
+ case Page_Register:
+ message = tr("If you don't provide an upgrade key, you will be "
+ "asked to fill in your details.");
+ break;
+ case Page_Details:
+ message = tr("Make sure to provide a valid email address, such as "
+ "thomas.gradgrind@example.co.uk.");
+ break;
+ case Page_Conclusion:
+ message = tr("You must accept the terms and conditions of the "
+ "license to proceed.");
+ break;
+//! [12] //! [13]
+ default:
+ message = tr("This help is likely not to be of any help.");
+ }
+//! [12]
+
+ if (lastHelpMessage == message)
+ message = tr("Sorry, I already gave what help I could. "
+ "Maybe you should try asking a human?");
+
+//! [14]
+ QMessageBox::information(this, tr("License Wizard Help"), message);
+//! [14]
+
+ lastHelpMessage = message;
+//! [15]
+}
+//! [13] //! [15]
+
+//! [16]
+IntroPage::IntroPage(QWidget *parent)
+ : QWizardPage(parent)
+{
+ setTitle(tr("Introduction"));
+ setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/watermark.png"));
+
+ topLabel = new QLabel(tr("This wizard will help you register your copy of "
+ "<i>Super Product One</i>&trade; or start "
+ "evaluating the product."));
+ topLabel->setWordWrap(true);
+
+ registerRadioButton = new QRadioButton(tr("&Register your copy"));
+ evaluateRadioButton = new QRadioButton(tr("&Evaluate the product for 30 "
+ "days"));
+ registerRadioButton->setChecked(true);
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(topLabel);
+ layout->addWidget(registerRadioButton);
+ layout->addWidget(evaluateRadioButton);
+ setLayout(layout);
+}
+//! [16] //! [17]
+
+//! [18]
+# class IntroPage
+def nextId(self):
+//! [17] //! [19]
+ if evaluateRadioButton.isChecked():
+ return LicenseWizard.Page_Evaluate
+ else:
+ return LicenseWizard.Page_Register
+//! [18] //! [19]
+
+//! [20]
+EvaluatePage::EvaluatePage(QWidget *parent)
+ : QWizardPage(parent)
+{
+ setTitle(tr("Evaluate <i>Super Product One</i>&trade;"));
+ setSubTitle(tr("Please fill both fields. Make sure to provide a valid "
+ "email address (e.g., john.smith@example.com)."));
+
+ nameLabel = new QLabel(tr("N&ame:"));
+ nameLineEdit = new QLineEdit;
+//! [20]
+ nameLabel->setBuddy(nameLineEdit);
+
+ emailLabel = new QLabel(tr("&Email address:"));
+ emailLineEdit = new QLineEdit;
+ emailLineEdit->setValidator(new QRegExpValidator(QRegExp(".*@.*"), this));
+ emailLabel->setBuddy(emailLineEdit);
+
+//! [21]
+ registerField("evaluate.name*", nameLineEdit);
+ registerField("evaluate.email*", emailLineEdit);
+//! [21]
+
+ QGridLayout *layout = new QGridLayout;
+ layout->addWidget(nameLabel, 0, 0);
+ layout->addWidget(nameLineEdit, 0, 1);
+ layout->addWidget(emailLabel, 1, 0);
+ layout->addWidget(emailLineEdit, 1, 1);
+ setLayout(layout);
+//! [22]
+}
+//! [22]
+
+//! [23]
+# class EvaluatePage
+def nextId(self):
+ return LicenseWizard.Page_Conclusion
+//! [23]
+
+RegisterPage::RegisterPage(QWidget *parent)
+ : QWizardPage(parent)
+{
+ setTitle(tr("Register Your Copy of <i>Super Product One</i>&trade;"));
+ setSubTitle(tr("If you have an upgrade key, please fill in "
+ "the appropriate field."));
+
+ nameLabel = new QLabel(tr("N&ame:"));
+ nameLineEdit = new QLineEdit;
+ nameLabel->setBuddy(nameLineEdit);
+
+ upgradeKeyLabel = new QLabel(tr("&Upgrade key:"));
+ upgradeKeyLineEdit = new QLineEdit;
+ upgradeKeyLabel->setBuddy(upgradeKeyLineEdit);
+
+ registerField("register.name*", nameLineEdit);
+ registerField("register.upgradeKey", upgradeKeyLineEdit);
+
+ QGridLayout *layout = new QGridLayout;
+ layout->addWidget(nameLabel, 0, 0);
+ layout->addWidget(nameLineEdit, 0, 1);
+ layout->addWidget(upgradeKeyLabel, 1, 0);
+ layout->addWidget(upgradeKeyLineEdit, 1, 1);
+ setLayout(layout);
+}
+
+//! [24]
+# class RegisterPage
+def nextId(self):
+ if self.upgradeKeyLineEdit.text().isEmpty():
+ return LicenseWizard::Page_Details
+ else:
+ return LicenseWizard::Page_Conclusion
+//! [24]
+
+DetailsPage::DetailsPage(QWidget *parent)
+ : QWizardPage(parent)
+{
+ setTitle(tr("Fill In Your Details"));
+ setSubTitle(tr("Please fill all three fields. Make sure to provide a valid "
+ "email address (e.g., tanaka.aya@example.co.jp)."));
+
+ companyLabel = new QLabel(tr("&Company name:"));
+ companyLineEdit = new QLineEdit;
+ companyLabel->setBuddy(companyLineEdit);
+
+ emailLabel = new QLabel(tr("&Email address:"));
+ emailLineEdit = new QLineEdit;
+ emailLineEdit->setValidator(new QRegExpValidator(QRegExp(".*@.*"), this));
+ emailLabel->setBuddy(emailLineEdit);
+
+ postalLabel = new QLabel(tr("&Postal address:"));
+ postalLineEdit = new QLineEdit;
+ postalLabel->setBuddy(postalLineEdit);
+
+ registerField("details.company*", companyLineEdit);
+ registerField("details.email*", emailLineEdit);
+ registerField("details.postal*", postalLineEdit);
+
+ QGridLayout *layout = new QGridLayout;
+ layout->addWidget(companyLabel, 0, 0);
+ layout->addWidget(companyLineEdit, 0, 1);
+ layout->addWidget(emailLabel, 1, 0);
+ layout->addWidget(emailLineEdit, 1, 1);
+ layout->addWidget(postalLabel, 2, 0);
+ layout->addWidget(postalLineEdit, 2, 1);
+ setLayout(layout);
+}
+
+//! [25]
+# class DetailsPage
+def nextId(self):
+ return LicenseWizard.Page_Conclusion
+//! [25]
+
+ConclusionPage::ConclusionPage(QWidget *parent)
+ : QWizardPage(parent)
+{
+ setTitle(tr("Complete Your Registration"));
+ setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/watermark.png"));
+
+ bottomLabel = new QLabel;
+ bottomLabel->setWordWrap(true);
+
+ agreeCheckBox = new QCheckBox(tr("I agree to the terms of the license"));
+
+ registerField("conclusion.agree*", agreeCheckBox);
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(bottomLabel);
+ layout->addWidget(agreeCheckBox);
+ setLayout(layout);
+}
+
+//! [26]
+#class ConclusionPage
+def nextId(self):
+ return -1
+//! [26]
+
+//! [27]
+# class ConclusionPage
+def initializePage(self):
+ if wizard().hasVisitedPage(LicenseWizard::Page_Evaluate):
+ licenseText = self.tr("<u>Evaluation License Agreement:</u> " \
+ "You can use this software for 30 days and make one " \
+ "backup, but you are not allowed to distribute it.")
+ elsif wizard().hasVisitedPage(LicenseWizard.Page_Details):
+ licenseText = self.tr("<u>First-Time License Agreement:</u> " \
+ "You can use this software subject to the license " \
+ "you will receive by email.")
+ else:
+ licenseText = self.tr("<u>Upgrade License Agreement:</u> " \
+ "This software is licensed under the terms of your " \
+ "current license.")
+ }
+ bottomLabel.setText(licenseText)
+//! [27]
+
+//! [28]
+void ConclusionPage::setVisible(bool visible)
+{
+ QWizardPage::setVisible(visible);
+
+ if (visible) {
+//! [29]
+ self.wizard().setButtonText(QWizard.CustomButton1, self.tr("&Print"))
+ self.wizard().setOption(QWizard.HaveCustomButton1, True)
+ self.connect(wizard(), SIGNAL("customButtonClicked(int)"), self, SLOT("printButtonClicked()"))
+//! [29]
+ } else {
+ wizard()->setOption(QWizard::HaveCustomButton1, false);
+ disconnect(wizard(), SIGNAL(customButtonClicked(int)),
+ this, SLOT(printButtonClicked()));
+ }
+}
+//! [28]
+
+void ConclusionPage::printButtonClicked()
+{
+ QPrinter printer;
+ QPrintDialog dialog(&printer, this);
+ if (dialog.exec())
+ QMessageBox::warning(this, tr("Print License"),
+ tr("As an environmentally friendly measure, the "
+ "license text will not actually be printed."));
+}
diff --git a/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.h b/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.h
new file mode 100644
index 000000000..b35337715
--- /dev/null
+++ b/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.h
@@ -0,0 +1,164 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef LICENSEWIZARD_H
+#define LICENSEWIZARD_H
+
+#include <QWizard>
+
+QT_BEGIN_NAMESPACE
+class QCheckBox;
+class QLabel;
+class QLineEdit;
+class QRadioButton;
+QT_END_NAMESPACE
+
+//! [0] //! [1]
+class LicenseWizard (QWizard):
+//! [0]
+//! [2]
+ Page_Intro = 1
+ Page_Evaluate = 2
+ Page_Register = 3
+ Page_Details = 4
+ Page_Conclusion = 5
+//! [2]
+
+ def __init__(self, parent):
+ ...
+
+ def showHelp(self):
+ ...
+//! [3]
+
+//! [1] //! [3]
+
+//! [4]
+class IntroPage : public QWizardPage
+{
+ Q_OBJECT
+
+public:
+ IntroPage(QWidget *parent = 0);
+
+ int nextId() const;
+
+private:
+ QLabel *topLabel;
+ QRadioButton *registerRadioButton;
+ QRadioButton *evaluateRadioButton;
+};
+//! [4]
+
+//! [5]
+class EvaluatePage : public QWizardPage
+{
+ Q_OBJECT
+
+public:
+ EvaluatePage(QWidget *parent = 0);
+
+ int nextId() const;
+
+private:
+ QLabel *nameLabel;
+ QLabel *emailLabel;
+ QLineEdit *nameLineEdit;
+ QLineEdit *emailLineEdit;
+};
+//! [5]
+
+class RegisterPage : public QWizardPage
+{
+ Q_OBJECT
+
+public:
+ RegisterPage(QWidget *parent = 0);
+
+ int nextId() const;
+
+private:
+ QLabel *nameLabel;
+ QLabel *upgradeKeyLabel;
+ QLineEdit *nameLineEdit;
+ QLineEdit *upgradeKeyLineEdit;
+};
+
+class DetailsPage : public QWizardPage
+{
+ Q_OBJECT
+
+public:
+ DetailsPage(QWidget *parent = 0);
+
+ int nextId() const;
+
+private:
+ QLabel *companyLabel;
+ QLabel *emailLabel;
+ QLabel *postalLabel;
+ QLineEdit *companyLineEdit;
+ QLineEdit *emailLineEdit;
+ QLineEdit *postalLineEdit;
+};
+
+//! [6]
+class ConclusionPage : public QWizardPage
+{
+ Q_OBJECT
+
+public:
+ ConclusionPage(QWidget *parent = 0);
+
+ void initializePage();
+ int nextId() const;
+ void setVisible(bool visible);
+
+private slots:
+ void printButtonClicked();
+
+private:
+ QLabel *bottomLabel;
+ QCheckBox *agreeCheckBox;
+};
+//! [6]
+
+#endif
diff --git a/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.pro b/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.pro
new file mode 100644
index 000000000..fd5e37ccf
--- /dev/null
+++ b/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.pro
@@ -0,0 +1,10 @@
+HEADERS = licensewizard.h
+SOURCES = licensewizard.cpp \
+ main.cpp
+RESOURCES = licensewizard.qrc
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/dialogs/licensewizard
+sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro images
+sources.path = $$[QT_INSTALL_EXAMPLES]/dialogs/licensewizard
+INSTALLS += target sources
diff --git a/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.qrc b/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.qrc
new file mode 100644
index 000000000..b06993851
--- /dev/null
+++ b/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>images/logo.png</file>
+ <file>images/watermark.png</file>
+</qresource>
+</RCC>
diff --git a/doc/codesnippets/examples/dialogs/licensewizard/main.cpp b/doc/codesnippets/examples/dialogs/licensewizard/main.cpp
new file mode 100644
index 000000000..ab2327b42
--- /dev/null
+++ b/doc/codesnippets/examples/dialogs/licensewizard/main.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QTranslator>
+#include <QLocale>
+#include <QLibraryInfo>
+
+#include "licensewizard.h"
+
+int main(int argc, char *argv[])
+{
+ Q_INIT_RESOURCE(licensewizard);
+
+ QApplication app(argc, argv);
+
+ QString translatorFileName = QLatin1String("qt_");
+ translatorFileName += QLocale::system().name();
+ QTranslator *translator = new QTranslator(&app);
+ if (translator->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
+ app.installTranslator(translator);
+
+ LicenseWizard wizard;
+ wizard.show();
+ return app.exec();
+}
diff --git a/doc/codesnippets/examples/dialogs/standarddialogs/dialog.cpp b/doc/codesnippets/examples/dialogs/standarddialogs/dialog.cpp
new file mode 100644
index 000000000..bf196edc5
--- /dev/null
+++ b/doc/codesnippets/examples/dialogs/standarddialogs/dialog.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the example classes of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+ i = QInputDialog().getInteger(self, self.tr("QInputDialog().getInteger()"),
+ self.tr("Percentage:"), 25, 0, 100, 1, ok)
+ if ok:
+ self.integerLabel.setText(self.tr("%1%").arg(i))
+//! [0]
+
+//! [1]
+ d = QInputDialog().getDouble(self, self.tr("QInputDialog().getDouble()"),
+ self.tr("Amount:"), 37.56, -10000, 10000, 2, ok)
+ if ok:
+ doubleLabel.setText(QString("$%1").arg(d))
+//! [1]
+
+//! [2]
+ items = [self.tr("Spring"), self.tr("Summer"), self.tr("Fall"), self.tr("Winter")]
+
+ item = QInputDialog().getItem(self, self.tr("QInputDialog().getItem()"),
+ selftr("Season:"), items, 0, False, ok)
+ if ok and not item.isEmpty():
+ itemLabel.setText(item)
+//! [2]
+
+//! [3]
+ QString text = QInputDialog::getText(self, self.tr("QInputDialog().getText()"),
+ self.tr("User name:"), QLineEdit.Normal,
+ QDir().home().dirName(), ok)
+ if ok and not text.isEmpty():
+ textLabel.setText(text)
+//! [3]
diff --git a/doc/codesnippets/examples/dialogs/trivialwizard/trivialwizard.cpp b/doc/codesnippets/examples/dialogs/trivialwizard/trivialwizard.cpp
new file mode 100644
index 000000000..bcae8c8f3
--- /dev/null
+++ b/doc/codesnippets/examples/dialogs/trivialwizard/trivialwizard.cpp
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QTranslator>
+#include <QLocale>
+#include <QLibraryInfo>
+
+//! [0] //! [1]
+def createIntroPage(self):
+ page = QWizardPage()
+ page.setTitle("Introduction")
+
+ label = QLabel("This wizard will help you register your copy of Super Product Two.")
+ label.setWordWrap(True)
+
+ layout = QVBoxLayout()
+ layout.addWidget(label)
+ page.setLayout(layout)
+
+ return page
+//! [0]
+
+//! [2]
+QWizardPage *createRegistrationPage()
+//! [1] //! [3]
+
+//! [3]
+ QWizardPage *page = new QWizardPage;
+ page->setTitle("Registration");
+ page->setSubTitle("Please fill both fields.");
+
+ QLabel *nameLabel = new QLabel("Name:");
+ QLineEdit *nameLineEdit = new QLineEdit;
+
+ QLabel *emailLabel = new QLabel("Email address:");
+ QLineEdit *emailLineEdit = new QLineEdit;
+
+ QGridLayout *layout = new QGridLayout;
+ layout->addWidget(nameLabel, 0, 0);
+ layout->addWidget(nameLineEdit, 0, 1);
+ layout->addWidget(emailLabel, 1, 0);
+ layout->addWidget(emailLineEdit, 1, 1);
+ page->setLayout(layout);
+
+ return page;
+//! [4]
+
+//! [2] //! [4]
+
+//! [5] //! [6]
+def createConclusionPage(self):
+//! [5] //! [7]
+
+//! [7]
+ QWizardPage *page = new QWizardPage;
+ page->setTitle("Conclusion");
+
+ QLabel *label = new QLabel("You are now successfully registered. Have a "
+ "nice day!");
+ label->setWordWrap(true);
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(label);
+ page->setLayout(layout);
+
+ return page;
+//! [8]
+
+//! [6] //! [8]
+
+//! [9] //! [10]
+
+//! [9] //! [11]
+def main():
+ app = QApplication(sys.argv)
+
+ translatorFileName = QLatin1String("qt_")
+ translatorFileName += QLocale.system().name()
+ translator = QTranslator(app)
+ if translator.load(translatorFileName, QLibraryInfo.location(QLibraryInfo.TranslationsPath)):
+ app.installTranslator(translator)
+
+ wizard = QWizard()
+ wizard.addPage(createIntroPage())
+ wizard.addPage(createRegistrationPage())
+ wizard.addPage(createConclusionPage())
+
+ wizard.setWindowTitle("Trivial Wizard")
+ wizard.show()
+
+ return app.exec_()
+
+if __name__ == "__main__":
+ main()
+//! [10] //! [11]
diff --git a/doc/codesnippets/examples/dialogs/trivialwizard/trivialwizard.pro b/doc/codesnippets/examples/dialogs/trivialwizard/trivialwizard.pro
new file mode 100644
index 000000000..970e12f25
--- /dev/null
+++ b/doc/codesnippets/examples/dialogs/trivialwizard/trivialwizard.pro
@@ -0,0 +1,7 @@
+SOURCES = trivialwizard.cpp
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/dialogs/trivialwizard
+sources.files = $$SOURCES $$HEADERS *.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/dialogs/trivialwizard
+INSTALLS += target sources
diff --git a/doc/codesnippets/examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp b/doc/codesnippets/examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp
new file mode 100644
index 000000000..da1c2ddeb
--- /dev/null
+++ b/doc/codesnippets/examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp
@@ -0,0 +1,102 @@
+############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Qt Software Information (qt-info@nokia.com)
+##
+## This file is part of the example classes of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at qt-sales@nokia.com.
+## $QT_END_LICENSE$
+##
+############################################################################
+
+//! [0]
+def __init__(self, parent):
+ QSortFilterProxyModel.__init__(self, parent)
+//! [0]
+
+//! [1]
+def setFilterMinimumDate(self, date):
+ self.minDate = date
+ self.invalidateFilter()
+
+//! [1]
+
+//! [2]
+def setFilterMaximumDate(self, date):
+ self.maxDate = date
+ self.invalidateFilter()
+
+//! [2]
+
+//! [3]
+def filterAcceptsRow(self, sourceRow, sourceParent):
+ index0 = sourceModel().index(sourceRow, 0, sourceParent)
+ index1 = sourceModel().index(sourceRow, 1, sourceParent)
+ index2 = sourceModel().index(sourceRow, 2, sourceParent)
+
+ return (sourceModel().data(index0).toString().contains(filterRegExp())
+ || sourceModel().data(index1).toString().contains(filterRegExp()))
+ && dateInRange(sourceModel().data(index2).toDate())
+
+//! [3]
+
+//! [4] //! [5]
+def lessThan(self, left, right):
+ leftData = sourceModel().data(left)
+ rightData = sourceModel().data(right)
+//! [4]
+
+//! [6]
+ if leftData.type() == QVariant.DateTime:
+ return leftData.toDateTime() < rightData.toDateTime()
+ else:
+ emailPattern = QRegExp("([\\w\\.]*@[\\w\\.]*)")
+
+ leftString = leftData.toString()
+ if left.column() == 1 && emailPattern.indexIn(leftString) != -1:
+ leftString = emailPattern.cap(1)
+
+ rightString = rightData.toString()
+ if right.column() == 1 && emailPattern.indexIn(rightString) != -1:
+ rightString = emailPattern.cap(1)
+
+ return QString.localeAwareCompare(leftString, rightString) < 0
+
+//! [5] //! [6]
+
+//! [7]
+def dateInRange(self, date):
+ return (!minDate.isValid() || date > minDate)
+ && (!maxDate.isValid() || date < maxDate)
+
+//! [7]
diff --git a/doc/codesnippets/examples/itemviews/pixelator/pixeldelegate.cpp b/doc/codesnippets/examples/itemviews/pixelator/pixeldelegate.cpp
new file mode 100644
index 000000000..93cdc1535
--- /dev/null
+++ b/doc/codesnippets/examples/itemviews/pixelator/pixeldelegate.cpp
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the example classes of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+def __init__(self, parent):
+ QAbstractItemDelegate.__init__(self, parent)
+ self.pixelSize = 12
+//! [0]
+
+//! [1]
+def paint(self, painter, option, index):
+//! [2]
+ if option.state and QStyle.State_Selected:
+ painter.fillRect(option.rect, option.palette.highlight())
+//! [1]
+
+//! [3]
+ size = qMin(option.rect.width(), option.rect.height())
+//! [3] //! [4]
+ brightness = index.model().data(index, Qt.DisplayRole).toInt()
+ radius = (size/2.0) - (brightness/255.0 * size/2.0)
+ if radius == 0.0:
+ return
+//! [4]
+
+//! [5]
+ painter.save()
+//! [5] //! [6]
+ painter.setRenderHint(QPainter.Antialiasing, true)
+//! [6] //! [7]
+ painter.setPen(Qt.NoPen)
+//! [7] //! [8]
+ if option.state and QStyle.State_Selected:
+//! [8] //! [9]
+ painter.setBrush(option.palette.highlightedText())
+ else
+//! [2]
+ painter.setBrush(QBrush(Qt.black))
+//! [9]
+
+//! [10]
+ painter.drawEllipse(QRectF(option.rect.x() + option.rect.width()/2 - radius,
+ option.rect.y() + option.rect.height()/2 - radius,
+ 2*radius, 2*radius))
+ painter.restore()
+//! [10]
+
+//! [11]
+def sizeHint(self, option, index):
+ return QSize(self.pixelSize, self.pixelSize)
+//! [11]
+
+//! [12]
+def setPixelSize(self, size):
+ self.pixelSize = size
+//! [12]
diff --git a/doc/codesnippets/examples/itemviews/simpledommodel/dommodel.cpp b/doc/codesnippets/examples/itemviews/simpledommodel/dommodel.cpp
new file mode 100644
index 000000000..940487a9d
--- /dev/null
+++ b/doc/codesnippets/examples/itemviews/simpledommodel/dommodel.cpp
@@ -0,0 +1,188 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QtXml>
+
+#include "domitem.h"
+#include "dommodel.h"
+
+//! [0]
+DomModel::DomModel(QDomDocument document, QObject *parent)
+ : QAbstractItemModel(parent), domDocument(document)
+{
+ rootItem = new DomItem(domDocument, 0);
+}
+//! [0]
+
+//! [1]
+DomModel::~DomModel()
+{
+ delete rootItem;
+}
+//! [1]
+
+//! [2]
+def columnCount(self, parent):
+ return 3
+//! [2]
+
+//! [3]
+QVariant DomModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ if (role != Qt::DisplayRole)
+ return QVariant();
+
+ DomItem *item = static_cast<DomItem*>(index.internalPointer());
+
+ QDomNode node = item->node();
+//! [3] //! [4]
+ QStringList attributes;
+ QDomNamedNodeMap attributeMap = node.attributes();
+
+ switch (index.column()) {
+ case 0:
+ return node.nodeName();
+ case 1:
+ for (int i = 0; i < attributeMap.count(); ++i) {
+ QDomNode attribute = attributeMap.item(i);
+ attributes << attribute.nodeName() + "=\""
+ +attribute.nodeValue() + "\"";
+ }
+ return attributes.join(" ");
+ case 2:
+ return node.nodeValue().split("\n").join(" ");
+ default:
+ return QVariant();
+ }
+}
+//! [4]
+
+//! [5]
+Qt::ItemFlags DomModel::flags(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return 0;
+
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+}
+//! [5]
+
+//! [6]
+QVariant DomModel::headerData(int section, Qt::Orientation orientation,
+ int role) const
+{
+ if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
+ switch (section) {
+ case 0:
+ return tr("Name");
+ case 1:
+ return tr("Attributes");
+ case 2:
+ return tr("Value");
+ default:
+ return QVariant();
+ }
+ }
+
+ return QVariant();
+}
+//! [6]
+
+//! [7]
+QModelIndex DomModel::index(int row, int column, const QModelIndex &parent)
+ const
+{
+ if (!hasIndex(row, column, parent))
+ return QModelIndex();
+
+ DomItem *parentItem;
+
+ if (!parent.isValid())
+ parentItem = rootItem;
+ else
+ parentItem = static_cast<DomItem*>(parent.internalPointer());
+//! [7]
+
+//! [8]
+ DomItem *childItem = parentItem->child(row);
+ if (childItem)
+ return createIndex(row, column, childItem);
+ else
+ return QModelIndex();
+}
+//! [8]
+
+//! [9]
+QModelIndex DomModel::parent(const QModelIndex &child) const
+{
+ if (!child.isValid())
+ return QModelIndex();
+
+ DomItem *childItem = static_cast<DomItem*>(child.internalPointer());
+ DomItem *parentItem = childItem->parent();
+
+ if (!parentItem || parentItem == rootItem)
+ return QModelIndex();
+
+ return createIndex(parentItem->row(), 0, parentItem);
+}
+//! [9]
+
+//! [10]
+int DomModel::rowCount(const QModelIndex &parent) const
+{
+ if (parent.column() > 0)
+ return 0;
+
+ DomItem *parentItem;
+
+ if (!parent.isValid())
+ parentItem = rootItem;
+ else
+ parentItem = static_cast<DomItem*>(parent.internalPointer());
+
+ return parentItem->node().childNodes().count();
+}
+//! [10]
diff --git a/doc/codesnippets/examples/linguist/hellotr/main.cpp b/doc/codesnippets/examples/linguist/hellotr/main.cpp
new file mode 100644
index 000000000..86f32c5e3
--- /dev/null
+++ b/doc/codesnippets/examples/linguist/hellotr/main.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QPushButton>
+//! [0]
+from PySide.QtCore import QTranslator
+//! [0]
+
+//! [1] //! [2]
+def main(args):
+//! [1] //! [3] //! [4]
+ app = QApplication(args)
+//! [3]
+
+//! [5]
+ translator = QTranslator()
+//! [5] //! [6]
+ translator.load("hellotr_la")
+//! [6] //! [7]
+ app.installTranslator(translator)
+//! [4] //! [7]
+
+//! [8]
+ hello = QPushButton(QPushButton.tr("Hello world!"))
+//! [8]
+ hello.resize(100, 30)
+
+ hello.show()
+ return app.exec_()
+//! [2]
diff --git a/doc/codesnippets/examples/mainwindows/application/mainwindow.cpp b/doc/codesnippets/examples/mainwindows/application/mainwindow.cpp
new file mode 100644
index 000000000..574a1320f
--- /dev/null
+++ b/doc/codesnippets/examples/mainwindows/application/mainwindow.cpp
@@ -0,0 +1,350 @@
+######################################
+#
+# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# Contact: Qt Software Information (qt-info@nokia.com)
+#
+# This file is part of the example classes of the Qt Toolkit.
+#
+# $QT_BEGIN_LICENSE:LGPL$
+# Commercial Usage
+# Licensees holding valid Qt Commercial licenses may use self file in
+# accordance with the Qt Commercial License Agreement provided with the
+# Software or, alternatively, in accordance with the terms contained in
+# a written agreement between you and Nokia.
+#
+# GNU Lesser General Public License Usage
+# Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+# package.
+#
+# GNU General Public License Usage
+# Alternatively, self file may be used under the terms of the GNU
+# General Public License version 3.0 as published by the Free Software
+# Foundation and appearing in the file LICENSE.GPL included in the
+# packaging of self file. Please review the following information to
+# ensure the GNU General Public License version 3.0 requirements will be
+# met: http://www.gnu.org/copyleft/gpl.html.
+#
+# If you are unsure which license is appropriate for your use, please
+# contact the sales department at qt-sales@nokia.com.
+# $QT_END_LICENSE$
+#
+######################################
+
+//! [0]
+from PySide.QtGui import *
+//! [0]
+
+//! [1]
+def __init__(self):
+ QMainWindow.__init__(self)
+//! [1] //! [2]
+ textEdit = QPlainTextEdit()
+ setCentralWidget(textEdit)
+
+ createActions()
+ createMenus()
+ createToolBars()
+ createStatusBar()
+
+ readSettings()
+
+ connect(textEdit.document(), SIGNAL("contentsChanged()"),
+ self, SLOT("documentWasModified()"))
+
+ setCurrentFile("")
+ setUnifiedTitleAndToolBarOnMac(True)
+
+//! [2]
+
+//! [3]
+def closeEvent(self, event):
+//! [3] //! [4]
+ if maybeSave():
+ writeSettings()
+ event.accept()
+ else:
+ event.ignore()
+//! [4]
+
+//! [5]
+def File(self):
+//! [5] //! [6]
+ if maybeSave():
+ textEdit.clear()
+ setCurrentFile("")
+//! [6]
+
+//! [7]
+def open(self):
+//! [7] //! [8]
+ if maybeSave():
+ fileName = QFileDialog.getOpenFileName(self)
+ if !fileName.isEmpty():
+ loadFile(fileName)
+//! [8]
+
+//! [9]
+def save(self):
+//! [9] //! [10]
+ if curFile.isEmpty():
+ return saveAs()
+ else:
+ return saveFile(curFile)
+//! [10]
+
+//! [11]
+def saveAs(self):
+//! [11] //! [12]
+ fileName = QFileDialog.getSaveFileName(self)
+ if fileName.isEmpty():
+ return False
+
+ return saveFile(fileName)
+//! [12]
+
+//! [13]
+def about(self):
+//! [13] //! [14]
+ QMessageBox.about(self, tr("About Application"),
+ tr("The <b>Application</b> example demonstrates how to "
+ "write modern GUI applications using Qt, with a menu bar, "
+ "toolbars, and a status bar."))
+
+//! [14]
+
+//! [15]
+def documentWasModified(self):
+//! [15] //! [16]
+ setWindowModified(textEdit.document().isModified())
+//! [16]
+
+//! [17]
+def MainWindow.createActions(self):
+//! [17] //! [18]
+ Act = QAction(QIcon(":/images/new.png"), tr("&New"), self)
+ Act.setShortcuts(QKeySequence.New)
+ Act.setStatusTip(tr("Create a new file"))
+ connect(Act, SIGNAL("triggered()"), self, SLOT("newFile()"))
+
+//! [19]
+ openAct = QAction(QIcon(":/images/open.png"), tr("&Open..."), self)
+ openAct.setShortcuts(QKeySequence.Open)
+ openAct.setStatusTip(tr("Open an existing file"))
+ connect(openAct, SIGNAL("triggered()"), self, SLOT("open()"))
+//! [18] //! [19]
+
+ saveAct = QAction(QIcon(":/images/save.png"), tr("&Save"), self)
+ saveAct.setShortcuts(QKeySequence.Save)
+ saveAct.setStatusTip(tr("Save the document to disk"))
+ connect(saveAct, SIGNAL("triggered()"), self, SLOT("save()"))
+
+ saveAsAct = QAction(tr("Save &As..."), self)
+ saveAsAct.setShortcuts(QKeySequence.SaveAs)
+ saveAsAct.setStatusTip(tr("Save the document under a name"))
+ connect(saveAsAct, SIGNAL("triggered()"), self, SLOT("saveAs()"))
+
+//! [20]
+ exitAct = QAction(tr("E&xit"), self)
+ exitAct.setShortcut(tr("Ctrl+Q"))
+//! [20]
+ exitAct.setStatusTip(tr("Exit the application"))
+ connect(exitAct, SIGNAL("triggered()"), self, SLOT("close()"))
+
+//! [21]
+ cutAct = QAction(QIcon(":/images/cut.png"), tr("Cu&t"), self)
+//! [21]
+ cutAct.setShortcuts(QKeySequence.Cut)
+ cutAct.setStatusTip(tr("Cut the current selection's contents to the "
+ "clipboard"))
+ connect(cutAct, SIGNAL("triggered()"), textEdit, SLOT("cut()"))
+
+ copyAct = QAction(QIcon(":/images/copy.png"), tr("&Copy"), self)
+ copyAct.setShortcuts(QKeySequence.Copy)
+ copyAct.setStatusTip(tr("Copy the current selection's contents to the "
+ "clipboard"))
+ connect(copyAct, SIGNAL("triggered()"), textEdit, SLOT("copy()"))
+
+ pasteAct = QAction(QIcon(":/images/paste.png"), tr("&Paste"), self)
+ pasteAct.setShortcuts(QKeySequence.Paste)
+ pasteAct.setStatusTip(tr("Paste the clipboard's contents into the current "
+ "selection"))
+ connect(pasteAct, SIGNAL("triggered()"), textEdit, SLOT("paste()"))
+
+ aboutAct = QAction(tr("&About"), self)
+ aboutAct.setStatusTip(tr("Show the application's About box"))
+ connect(aboutAct, SIGNAL("triggered()"), self, SLOT("about()"))
+
+//! [22]
+ aboutQtAct = QAction(tr("About &Qt"), self)
+ aboutQtAct.setStatusTip(tr("Show the Qt library's About box"))
+ connect(aboutQtAct, SIGNAL("triggered()"), qApp, SLOT("aboutQt()"))
+//! [22]
+
+//! [23]
+ cutAct.setEnabled(False)
+//! [23] //! [24]
+ copyAct.setEnabled(False)
+ connect(textEdit, SIGNAL("copyAvailable(bool)"),
+ cutAct, SLOT("setEnabled(bool)"))
+ connect(textEdit, SIGNAL("copyAvailable(bool)"),
+ copyAct, SLOT("setEnabled(bool)"))
+}
+//! [24]
+
+//! [25] //! [26]
+def createMenus(self):
+//! [25] //! [27]
+ fileMenu = menuBar().addMenu(tr("&File"))
+ fileMenu.addAction(Act)
+//! [28]
+ fileMenu.addAction(openAct)
+//! [28]
+ fileMenu.addAction(saveAct)
+//! [26]
+ fileMenu.addAction(saveAsAct)
+ fileMenu.addSeparator()
+ fileMenu.addAction(exitAct)
+
+ editMenu = menuBar().addMenu(tr("&Edit"))
+ editMenu.addAction(cutAct)
+ editMenu.addAction(copyAct)
+ editMenu.addAction(pasteAct)
+
+ menuBar().addSeparator()
+
+ helpMenu = menuBar().addMenu(tr("&Help"))
+ helpMenu.addAction(aboutAct)
+ helpMenu.addAction(aboutQtAct)
+
+//! [27]
+
+//! [29] //! [30]
+def createToolBars(self):
+ fileToolBar = addToolBar(tr("File"))
+ fileToolBar.addAction(Act)
+//! [29] //! [31]
+ fileToolBar.addAction(openAct)
+//! [31]
+ fileToolBar.addAction(saveAct)
+
+ editToolBar = addToolBar(tr("Edit"))
+ editToolBar.addAction(cutAct)
+ editToolBar.addAction(copyAct)
+ editToolBar.addAction(pasteAct)
+//! [30]
+
+//! [32]
+def createStatusBar(self):
+//! [32] //! [33]
+ statusBar().showMessage(tr("Ready"))
+
+//! [33]
+
+//! [34] //! [35]
+def readSettings(self):
+//! [34] //! [36]
+ settings("Trolltech", "Application Example")
+ pos = settings.value("pos", QPoint(200, 200)).toPoint()
+ size = settings.value("size", QSize(400, 400)).toSize()
+ resize(size)
+ move(pos)
+
+//! [35] //! [36]
+
+//! [37] //! [38]
+def writeSettings(self):
+//! [37] //! [39]
+ settings = QSettings("Trolltech", "Application Example")
+ settings.setValue("pos", pos())
+ settings.setValue("size", size())
+
+//! [38] //! [39]
+
+//! [40]
+def maybeSave(self):
+//! [40] //! [41]
+ if textEdit.document()->isModified():
+ ret = QMessageBox.warning(self, tr("Application"),
+ tr("The document has been modified.\n"
+ "Do you want to save your changes?"),
+ QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel)
+ if ret == QMessageBox.Save:
+ return save()
+ elif ret == QMessageBox.Cancel:
+ return False
+ return True
+//! [41]
+
+//! [42]
+def loadFile(self, fileName):
+//! [42] //! [43]
+ file = QFile(fileName)
+ if !file.open(QFile.ReadOnly | QFile.Text):
+ QMessageBox.warning(self, tr("Application"),
+ tr("Cannot read file %1:\n%2.")
+ .arg(fileName)
+ .arg(file.errorString()))
+ return
+
+ in = QTextStream(file)
+ QApplication.setOverrideCursor(Qt::WaitCursor)
+ textEdit.setPlainText(in.readAll())
+ QApplication.restoreOverrideCursor()
+
+ setCurrentFile(fileName)
+ statusBar().showMessage(tr("File loaded"), 2000)
+
+//! [43]
+
+//! [44]
+def saveFile(self, fileName):
+//! [44] //! [45]
+ file = QFile(fileName)
+ if !file.open(QFile.WriteOnly | QFile::Text):
+ QMessageBox.warning(self, tr("Application"),
+ tr("Cannot write file %1:\n%2.")
+ .arg(fileName)
+ .arg(file.errorString()))
+ return False
+
+ out = QTextStream(file)
+ QApplication.setOverrideCursor(Qt.WaitCursor)
+ out << textEdit.toPlainText()
+ QApplication.restoreOverrideCursor()
+
+ setCurrentFile(fileName)
+ statusBar().showMessage(tr("File saved"), 2000)
+ return True
+
+//! [45]
+
+//! [46]
+def setCurrentFile(fileName):
+//! [46] //! [47]
+ curFile = fileName
+ textEdit.document().setModified(False)
+ setWindowModified(False)
+
+ if curFile.isEmpty():
+ shownName = "untitled.txt"
+ else:
+ shownName = strippedName(curFile)
+
+ setWindowTitle(tr("%1[*] - %2").arg(shownName).arg(tr("Application")))
+
+//! [47]
+
+//! [48]
+def strippedName(self, fullFileName):
+//! [48] //! [49]
+ return QFileInfo(fullFileName).fileName()
+//! [49]
diff --git a/doc/codesnippets/examples/mainwindows/dockwidgets/mainwindow.cpp b/doc/codesnippets/examples/mainwindows/dockwidgets/mainwindow.cpp
new file mode 100644
index 000000000..c6cafd26d
--- /dev/null
+++ b/doc/codesnippets/examples/mainwindows/dockwidgets/mainwindow.cpp
@@ -0,0 +1,246 @@
+############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Qt Software Information (qt-info@nokia.com)
+##
+## This file is part of the example classes of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at qt-sales@nokia.com.
+## $QT_END_LICENSE$
+##
+############################################################################
+
+//! [0]
+from PySide.QtGui import *
+//! [0]
+
+//! [1]
+def __init__(self):
+ textEdit = QTextEdit()
+ setCentralWidget(textEdit)
+
+ createActions()
+ createMenus()
+ createToolBars()
+ createStatusBar()
+ createDockWindows()
+
+ setWindowTitle(tr("Dock Widgets"))
+
+ Letter()
+ setUnifiedTitleAndToolBarOnMac(True)
+//! [1]
+
+//! [2]
+def Letter(self)
+ textEdit.clear()
+
+ cursor = QTextCursor(textEdit.textCursor())
+ cursor.movePosition(QTextCursor.Start)
+ topFrame = cursor.currentFrame()
+ topFrameFormat = topFrame.frameFormat()
+ topFrameFormat.setPadding(16)
+ topFrame.setFrameFormat(topFrameFormat)
+
+ textFormat = QTextCharFormat()
+ boldFormat = QTextCharFormat()
+ boldFormat.setFontWeight(QFont.Bold)
+ italicFormat = QTextCharFormat()
+ italicFormat.setFontItalic(True)
+
+ tableFormat = QTextTableFormat()
+ tableFormat.setBorder(1)
+ tableFormat.setCellPadding(16)
+ tableFormat.setAlignment(Qt.AlignRight)
+ cursor.insertTable(1, 1, tableFormat)
+ cursor.insertText("The Firm", boldFormat)
+ cursor.insertBlock()
+ cursor.insertText("321 City Street", textFormat)
+ cursor.insertBlock()
+ cursor.insertText("Industry Park")
+ cursor.insertBlock()
+ cursor.insertText("Some Country")
+ cursor.setPosition(topFrame.lastPosition())
+ cursor.insertText(QDate.currentDate().toString("d MMMM yyyy"), textFormat)
+ cursor.insertBlock()
+ cursor.insertBlock()
+ cursor.insertText("Dear ", textFormat)
+ cursor.insertText("NAME", italicFormat)
+ cursor.insertText(",", textFormat)
+ for i in range(3):
+ cursor.insertBlock()
+ cursor.insertText(tr("Yours sincerely,"), textFormat)
+ for i in range(3):
+ cursor.insertBlock()
+ cursor.insertText("The Boss", textFormat)
+ cursor.insertBlock()
+ cursor.insertText("ADDRESS", italicFormat)
+//! [2]
+
+//! [3]
+def print(self)
+ document = textEdit.document()
+ printer = QPrinter()
+
+ dlg = QPrintDialog(&printer, self)
+ if dlg.exec() != QDialog.Accepted:
+ return
+
+ document.print(printer)
+ statusBar().showMessage(tr("Ready"), 2000)
+//! [3]
+
+//! [4]
+def save(self):
+ fileName = QFileDialog.getSaveFileName(self,
+ tr("Choose a file name"), ".",
+ tr("HTML (*.html *.htm)"))
+ if fileName.isEmpty():
+ return
+ file = QFile(fileName)
+ if !file.open(QFile.WriteOnly | QFile::Text):
+ QMessageBox.warning(self, tr("Dock Widgets"),
+ tr("Cannot write file %1:\n%2.")
+ .arg(fileName)
+ .arg(file.errorString()))
+ return
+
+
+ out = QTextStream(file)
+ QApplication.setOverrideCursor(Qt::WaitCursor)
+ out << textEdit.toHtml()
+ QApplication.restoreOverrideCursor()
+
+ statusBar().showMessage(tr("Saved '%1'").arg(fileName), 2000)
+
+//! [4]
+
+//! [5]
+def undo(self):
+ document = textEdit.document()
+ document.undo()
+
+//! [5]
+
+//! [6]
+def insertCustomer(self, customer):
+ if customer.isEmpty():
+ return
+
+ customerList = customer.split(", ")
+ document = textEdit.document()
+ cursor = document.find("NAME")
+ if not cursor.isNull():
+ cursor.beginEditBlock()
+ cursor.insertText(customerList.at(0))
+ oldcursor = cursor
+ cursor = document.find("ADDRESS")
+ if not cursor.isNull():
+ for i in range(customerList.size()):
+ cursor.insertBlock()
+ cursor.insertText(customerList.at(i))
+
+ cursor.endEditBlock()
+ else:
+ oldcursor.endEditBlock()
+//! [6]
+
+//! [7]
+def addParagraph(self, paragraph):
+ if (paragraph.isEmpty())
+ return
+
+ document = textEdit.document()
+ cursor = document.find(tr("Yours sincerely,"))
+ if cursor.isNull():
+ return
+ cursor.beginEditBlock()
+ cursor.movePosition(QTextCursor.PreviousBlock, QTextCursor.MoveAnchor, 2)
+ cursor.insertBlock()
+ cursor.insertText(paragraph)
+ cursor.insertBlock()
+ cursor.endEditBlock()
+
+//! [7]
+
+
+//! [8]
+def createStatusBar(self):
+ statusBar().showMessage(tr("Ready"))
+
+//! [8]
+
+//! [9]
+def createDockWindows(self):
+ dock = QDockWidget(tr("Customers"), self)
+ dock.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
+ customerList = QListWidget(dock)
+ customerList.addItems(QStringList()
+ << "John Doe, Harmony Enterprises, 12 Lakeside, Ambleton"
+ << "Jane Doe, Memorabilia, 23 Watersedge, Beaton"
+ << "Tammy Shea, Tiblanka, 38 Sea Views, Carlton"
+ << "Tim Sheen, Caraba Gifts, 48 Ocean Way, Deal"
+ << "Sol Harvey, Chicos Coffee, 53 New Springs, Eccleston"
+ << "Sally Hobart, Tiroli Tea, 67 Long River, Fedula")
+ dock.setWidget(customerList)
+ addDockWidget(Qt.RightDockWidgetArea, dock)
+ viewMenu.addAction(dock.toggleViewAction())
+
+ dock = QDockWidget(tr("Paragraphs"), self)
+ paragraphsList = QListWidget(dock)
+ paragraphsList.addItems(QStringList()
+ << "Thank you for your payment which we have received today."
+ << "Your order has been dispatched and should be with you "
+ "within 28 days."
+ << "We have dispatched those items that were in stock. The "
+ "rest of your order will be dispatched once all the "
+ "remaining items have arrived at our warehouse. No "
+ "additional shipping charges will be made."
+ << "You made a small overpayment (less than $5) which we "
+ "will keep on account for you, or return at your request."
+ << "You made a small underpayment (less than $1), but we have "
+ "sent your order anyway. We'll add self underpayment to "
+ "your next bill."
+ << "Unfortunately you did not send enough money. Please remit "
+ "an additional $. Your order will be dispatched as soon as "
+ "the complete amount has been received."
+ << "You made an overpayment (more than $5). Do you wish to "
+ "buy more items, or should we return the excess to you?")
+ dock.setWidget(paragraphsList)
+ addDockWidget(Qt.RightDockWidgetArea, dock)
+ viewMenu.addAction(dock.toggleViewAction())
+
+ connect(customerList, SIGNAL("currentTextChanged(const QString &)"),
+ self, SLOT("insertCustomer(const QString &)"))
+ connect(paragraphsList, SIGNAL("currentTextChanged(const QString &)"),
+ self, SLOT("addParagraph(const QString &)"))
+//! [9]
diff --git a/doc/codesnippets/examples/mainwindows/mainwindow.cpp b/doc/codesnippets/examples/mainwindows/mainwindow.cpp
new file mode 100644
index 000000000..1dd12e1e1
--- /dev/null
+++ b/doc/codesnippets/examples/mainwindows/mainwindow.cpp
@@ -0,0 +1,358 @@
+######################################
+#
+# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# Contact: Qt Software Information (qt-info@nokia.com)
+#
+# This file is part of the example classes of the Qt Toolkit.
+#
+# $QT_BEGIN_LICENSE:LGPL$
+# Commercial Usage
+# Licensees holding valid Qt Commercial licenses may use self file in
+# accordance with the Qt Commercial License Agreement provided with the
+# Software or, alternatively, in accordance with the terms contained in
+# a written agreement between you and Nokia.
+#
+# GNU Lesser General Public License Usage
+# Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+# package.
+#
+# GNU General Public License Usage
+# Alternatively, self file may be used under the terms of the GNU
+# General Public License version 3.0 as published by the Free Software
+# Foundation and appearing in the file LICENSE.GPL included in the
+# packaging of self file. Please review the following information to
+# ensure the GNU General Public License version 3.0 requirements will be
+# met: http://www.gnu.org/copyleft/gpl.html.
+#
+# If you are unsure which license is appropriate for your use, please
+# contact the sales department at qt-sales@nokia.com.
+# $QT_END_LICENSE$
+#
+######################################
+
+from PySide.QtGui import *
+
+//! [0]
+def __init__(self):
+ Q__init__(self)
+
+ widget = QWidget()
+ setCentralWidget(widget)
+//! [0]
+
+//! [1]
+ topFiller = QWidget()
+ topFiller.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
+
+ infoLabel = QLabel(tr("<i>Choose a menu option, or right-click to "
+ "invoke a context menu</i>"))
+ infoLabel.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken)
+ infoLabel.setAlignment(Qt.AlignCenter)
+
+ bottomFiller = QWidget()
+ bottomFiller.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
+
+ layout = QVBoxLayout()
+ layout.setMargin(5)
+ layout.addWidget(topFiller)
+ layout.addWidget(infoLabel)
+ layout.addWidget(bottomFiller)
+ widget.setLayout(layout)
+//! [1]
+
+//! [2]
+ createActions()
+ createMenus()
+
+ message = tr("A context menu is available by right-clicking")
+ statusBar().showMessage(message)
+
+ setWindowTitle(tr("Menus"))
+ setMinimumSize(160, 160)
+ resize(480, 320)
+
+//! [2]
+
+//! [3]
+def contextMenuEvent(self, event):
+ menu = QMenu(self)
+ menu.addAction(cutAct)
+ menu.addAction(copyAct)
+ menu.addAction(pasteAct)
+ menu.exec_(event.globalPos()")
+
+//! [3]
+
+def File(self):
+ infoLabel.setText(tr("Invoked <b>File|New</b>"))
+
+
+def open(self):
+ infoLabel.setText(tr("Invoked <b>File|Open</b>"))
+
+
+def save(self):
+ infoLabel.setText(tr("Invoked <b>File|Save</b>"))
+
+def print_(self):
+ infoLabel.setText(tr("Invoked <b>File|Print</b>"))
+
+def undo(self):
+ infoLabel.setText(tr("Invoked <b>Edit|Undo</b>"))
+
+def redo(self):
+ infoLabel.setText(tr("Invoked <b>Edit|Redo</b>"))
+
+def cut(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Cut</b>"))
+
+
+def copy(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Copy</b>"))
+
+
+def paste(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Paste</b>"))
+
+
+def bold(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Bold</b>"))
+
+
+def italic(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Italic</b>"))
+
+
+def leftAlign(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Left Align</b>"))
+
+
+def rightAlign(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Right Align</b>"))
+
+
+def justify(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Justify</b>"))
+
+
+def center(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Center</b>"))
+
+
+def setLineSpacing(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Set Line Spacing</b>"))
+
+
+def setParagraphSpacing(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Set Paragraph Spacing</b>"))
+
+
+def about(self):
+
+ infoLabel.setText(tr("Invoked <b>Help|About</b>"))
+ QMessageBox.about(self, tr("About Menu"),
+ tr("The <b>Menu</b> example shows how to create "
+ "menu-bar menus and context menus."))
+
+
+def aboutQt(self):
+
+ infoLabel.setText(tr("Invoked <b>Help|About Qt</b>"))
+
+
+//! [4]
+def createActions(self):
+
+//! [5]
+ Act = new QAction(tr("&New"), self)
+ Act.setShortcuts(QKeySequence.New)
+ Act.setStatusTip(tr("Create a new file"))
+ connect(Act, SIGNAL("triggered()"), self, SLOT("newFile()"))
+//! [4]
+
+ openAct = QAction(tr("&Open..."), self)
+ openAct.setShortcuts(QKeySequence.Open)
+ openAct.setStatusTip(tr("Open an existing file"))
+ connect(openAct, SIGNAL("triggered()"), self, SLOT("open()"))
+//! [5]
+
+ saveAct = QAction(tr("&Save"), self)
+ saveAct.setShortcuts(QKeySequence.Save)
+ saveAct.setStatusTip(tr("Save the document to disk"))
+ connect(saveAct, SIGNAL("triggered()"), self, SLOT("save()"))
+
+ printAct = QAction(tr("&Print..."), self)
+ printAct.setShortcuts(QKeySequence.Print)
+ printAct.setStatusTip(tr("Print the document"))
+ connect(printAct, SIGNAL("triggered()"), self, SLOT("print_()"))
+
+ exitAct = QAction(tr("E&xit"), self)
+ exitAct.setShortcut(tr("Ctrl+Q"))
+ exitAct.setStatusTip(tr("Exit the application"))
+ connect(exitAct, SIGNAL("triggered()"), self, SLOT("close()"))
+
+ undoAct = QAction(tr("&Undo"), self)
+ undoAct.setShortcuts(QKeySequence.Undo)
+ undoAct.setStatusTip(tr("Undo the last operation"))
+ connect(undoAct, SIGNAL("triggered()"), self, SLOT("undo()"))
+
+ redoAct = QAction(tr("&Redo"), self)
+ redoAct.setShortcuts(QKeySequence.Redo)
+ redoAct.setStatusTip(tr("Redo the last operation"))
+ connect(redoAct, SIGNAL("triggered()"), self, SLOT("redo()"))
+
+ cutAct = QAction(tr("Cu&t"), self)
+ cutAct.setShortcuts(QKeySequence.Cut)
+ cutAct.setStatusTip(tr("Cut the current selection's contents to the "
+ "clipboard"))
+ connect(cutAct, SIGNAL("triggered()"), self, SLOT("cut()"))
+
+ copyAct = QAction(tr("&Copy"), self)
+ copyAct.setShortcut(tr("Ctrl+C"))
+ copyAct.setStatusTip(tr("Copy the current selection's contents to the "
+ "clipboard"))
+ connect(copyAct, SIGNAL("triggered()"), self, SLOT("copy()"))
+
+ pasteAct = QAction(tr("&Paste"), self)
+ pasteAct.setShortcuts(QKeySequence.Paste)
+ pasteAct.setStatusTip(tr("Paste the clipboard's contents into the current "
+ "selection"))
+ connect(pasteAct, SIGNAL("triggered()"), self, SLOT("paste()"))
+
+ boldAct = QAction(tr("&Bold"), self)
+ boldAct.setCheckable(True)
+ boldAct.setShortcut(tr("Ctrl+B"))
+ boldAct.setStatusTip(tr("Make the text bold"))
+ connect(boldAct, SIGNAL("triggered()"), self, SLOT("bold()"))
+
+ QFont boldFont = boldAct.font()
+ boldFont.setBold(True)
+ boldAct.setFont(boldFont)
+
+ italicAct = QAction(tr("&Italic"), self)
+ italicAct.setCheckable(True)
+ italicAct.setShortcut(tr("Ctrl+I"))
+ italicAct.setStatusTip(tr("Make the text italic"))
+ connect(italicAct, SIGNAL("triggered()"), self, SLOT("italic()"))
+
+ QFont italicFont = italicAct.font()
+ italicFont.setItalic(True)
+ italicAct.setFont(italicFont)
+
+ setLineSpacingAct = QAction(tr("Set &Line Spacing..."), self)
+ setLineSpacingAct.setStatusTip(tr("Change the gap between the lines of a "
+ "paragraph"))
+ connect(setLineSpacingAct, SIGNAL("triggered()"), self, SLOT("setLineSpacing()"))
+
+ setParagraphSpacingAct = QAction(tr("Set &Paragraph Spacing..."), self)
+ setLineSpacingAct.setStatusTip(tr("Change the gap between paragraphs"))
+ connect(setParagraphSpacingAct, SIGNAL("triggered()"),
+ self, SLOT("setParagraphSpacing()"))
+
+ aboutAct = QAction(tr("&About"), self)
+ aboutAct.setStatusTip(tr("Show the application's About box"))
+ connect(aboutAct, SIGNAL("triggered()"), self, SLOT("about()"))
+
+ aboutQtAct = QAction(tr("About &Qt"), self)
+ aboutQtAct.setStatusTip(tr("Show the Qt library's About box"))
+ connect(aboutQtAct, SIGNAL("triggered()"), qApp, SLOT("aboutQt()"))
+ connect(aboutQtAct, SIGNAL("triggered()"), self, SLOT("aboutQt()"))
+
+ leftAlignAct = QAction(tr("&Left Align"), self)
+ leftAlignAct.setCheckable(True)
+ leftAlignAct.setShortcut(tr("Ctrl+L"))
+ leftAlignAct.setStatusTip(tr("Left align the selected text"))
+ connect(leftAlignAct, SIGNAL("triggered()"), self, SLOT("leftAlign()"))
+
+ rightAlignAct = QAction(tr("&Right Align"), self)
+ rightAlignAct.setCheckable(True)
+ rightAlignAct.setShortcut(tr("Ctrl+R"))
+ rightAlignAct.setStatusTip(tr("Right align the selected text"))
+ connect(rightAlignAct, SIGNAL("triggered()"), self, SLOT("rightAlign()"))
+
+ justifyAct = QAction(tr("&Justify"), self)
+ justifyAct.setCheckable(True)
+ justifyAct.setShortcut(tr("Ctrl+J"))
+ justifyAct.setStatusTip(tr("Justify the selected text"))
+ connect(justifyAct, SIGNAL("triggered()"), self, SLOT("justify()"))
+
+ centerAct = QAction(tr("&Center"), self)
+ centerAct.setCheckable(True)
+ centerAct.setShortcut(tr("Ctrl+E"))
+ centerAct.setStatusTip(tr("Center the selected text"))
+ connect(centerAct, SIGNAL("triggered()"), self, SLOT("center()"))
+
+//! [6] //! [7]
+ alignmentGroup = QActionGroup(self)
+ alignmentGroup.addAction(leftAlignAct)
+ alignmentGroup.addAction(rightAlignAct)
+ alignmentGroup.addAction(justifyAct)
+ alignmentGroup.addAction(centerAct)
+ leftAlignAct.setChecked(True)
+//! [6]
+
+//! [7]
+
+//! [8]
+def createMenus(self):
+
+//! [9] //! [10]
+ fileMenu = menuBar().addMenu(tr("&File"))
+ fileMenu.addAction(Act)
+//! [9]
+ fileMenu.addAction(openAct)
+//! [10]
+ fileMenu.addAction(saveAct)
+ fileMenu.addAction(printAct)
+//! [11]
+ fileMenu.addSeparator()
+//! [11]
+ fileMenu.addAction(exitAct)
+
+ editMenu = menuBar().addMenu(tr("&Edit"))
+ editMenu.addAction(undoAct)
+ editMenu.addAction(redoAct)
+ editMenu.addSeparator()
+ editMenu.addAction(cutAct)
+ editMenu.addAction(copyAct)
+ editMenu.addAction(pasteAct)
+ editMenu.addSeparator()
+
+ helpMenu = menuBar().addMenu(tr("&Help"))
+ helpMenu.addAction(aboutAct)
+ helpMenu.addAction(aboutQtAct)
+//! [8]
+
+//! [12]
+ formatMenu = editMenu.addMenu(tr("&Format"))
+ formatMenu.addAction(boldAct)
+ formatMenu.addAction(italicAct)
+ formatMenu.addSeparator()->setText(tr("Alignment"))
+ formatMenu.addAction(leftAlignAct)
+ formatMenu.addAction(rightAlignAct)
+ formatMenu.addAction(justifyAct)
+ formatMenu.addAction(centerAct)
+ formatMenu.addSeparator()
+ formatMenu.addAction(setLineSpacingAct)
+ formatMenu.addAction(setParagraphSpacingAct)
+//! [12]
diff --git a/doc/codesnippets/examples/mainwindows/mdi/mainwindow.cpp b/doc/codesnippets/examples/mainwindows/mdi/mainwindow.cpp
new file mode 100644
index 000000000..c07f84c70
--- /dev/null
+++ b/doc/codesnippets/examples/mainwindows/mdi/mainwindow.cpp
@@ -0,0 +1,372 @@
+############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Qt Software Information (qt-info@nokia.com)
+##
+## This file is part of the example classes of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at qt-sales@nokia.com.
+## $QT_END_LICENSE$
+##
+############################################################################
+
+from PySide.QtGui import *
+
+def __init__(self):
+
+ mdiArea = QMdiArea()
+ mdiArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
+ mdiArea.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
+ setCentralWidget(mdiArea)
+ connect(mdiArea, SIGNAL("subWindowActivated(QMdiSubWindow *)"),
+ self, SLOT("updateMenus()"))
+ windowMapper = QSignalMapper(self)
+ connect(windowMapper, SIGNAL("mapped(QWidget *)"),
+ self, SLOT("setActiveSubWindow(QWidget *)"))
+
+ createActions()
+ createMenus()
+ createToolBars()
+ createStatusBar()
+ updateMenus()
+
+ readSettings()
+
+ setWindowTitle(tr("MDI"))
+ setUnifiedTitleAndToolBarOnMac(True)
+
+
+def closeEvent(self, event):
+ mdiArea.closeAllSubWindows()
+ if self.activeMdiChild():
+ event.ignore()
+ else:
+ self.writeSettings()
+ event.accept()
+
+def File(self):
+ child = self.createMdiChild()
+ child.File()
+ child.show()
+
+
+def open(self):
+ fileName = QFileDialog.getOpenFileName(self)
+ if !fileName.isEmpty()):
+ existing = self.findMdiChild(fileName)
+ if existing:
+ mdiArea.setActiveSubWindow(existing)
+ return
+
+ child = createMdiChild()
+ if child.loadFile(fileName)):
+ statusBar().showMessage(tr("File loaded"), 2000)
+ child.show()
+ else:
+ child.close()
+
+def save(self):
+ if self.activeMdiChild() && self.activeMdiChild().save():
+ self.statusBar().showMessage(tr("File saved"), 2000)
+
+def saveAs(self):
+ if self.activeMdiChild() && self.activeMdiChild().saveAs():
+ self.statusBar().showMessage(tr("File saved"), 2000)
+
+def cut(self):
+ if self.activeMdiChild():
+ self.activeMdiChild().cut()
+
+def copy(self):
+ if self.activeMdiChild():
+ activeMdiChild().copy()
+
+def paste(self):
+ if self.activeMdiChild():
+ activeMdiChild().paste()
+
+def about(self):
+ QMessageBox.about(self, tr("About MDI"),
+ tr("The <b>MDI</b> example demonstrates how to write multiple "
+ "document interface applications using Qt.")")
+
+def updateMenus(self):
+ hasMdiChild = (activeMdiChild() != 0)
+ self.saveAct.setEnabled(hasMdiChild)
+ self.saveAsAct.setEnabled(hasMdiChild)
+ self.pasteAct.setEnabled(hasMdiChild)
+ self.closeAct.setEnabled(hasMdiChild)
+ self.closeAllAct.setEnabled(hasMdiChild)
+ self.tileAct.setEnabled(hasMdiChild)
+ self.cascadeAct.setEnabled(hasMdiChild)
+ self.nextAct.setEnabled(hasMdiChild)
+ self.previousAct.setEnabled(hasMdiChild)
+ self.separatorAct.setVisible(hasMdiChild)
+
+ hasSelection = (self.activeMdiChild() &&
+ self.activeMdiChild().textCursor().hasSelection()")
+ self.cutAct.setEnabled(hasSelection)
+ self.copyAct.setEnabled(hasSelection)
+
+def updateWindowMenu(self):
+ self.windowMenu.clear()
+ self.windowMenu.addAction(closeAct)
+ self.windowMenu.addAction(closeAllAct)
+ self.windowMenu.addSeparator()
+ self.windowMenu.addAction(tileAct)
+ self.windowMenu.addAction(cascadeAct)
+ self.windowMenu.addSeparator()
+ self.windowMenu.addAction(nextAct)
+ self.windowMenu.addAction(previousAct)
+ self.windowMenu.addAction(separatorAct)
+
+ windows = mdiArea.subWindowList()
+ separatorAct.setVisible(!windows.isEmpty()")
+
+ for i in range((int i = 0 i < windows.size(); ++i)
+ MdiChild *child = qobject_cast<MdiChild *>(windows.at(i).widget()")
+
+ QString text
+ if (i < 9)
+ text = tr("&%1 %2").arg(i + 1)
+ .arg(child.userFriendlyCurrentFile()")
+ else
+ text = tr("%1 %2").arg(i + 1)
+ .arg(child.userFriendlyCurrentFile()")
+
+ QAction *action = windowMenu.addAction(text)
+ action.setCheckable(True)
+ action .setChecked(child == activeMdiChild()")
+ connect(action, SIGNAL("triggered()"), windowMapper, SLOT("map()"))
+ windowMapper.setMapping(action, windows.at(i)")
+
+
+
+MdiChild *createMdiChild()
+
+ MdiChild *child = MdiChild
+ mdiArea.addSubWindow(child)
+
+ connect(child, SIGNAL("copyAvailable(bool)"),
+ cutAct, SLOT("setEnabled(bool)"))
+ connect(child, SIGNAL("copyAvailable(bool)"),
+ copyAct, SLOT("setEnabled(bool)"))
+
+ return child
+
+
+def createActions()
+
+ Act = new QAction(QIcon(":/images/new.png"), tr("&New"), self)
+ Act.setShortcuts(QKeySequence.New)
+ Act.setStatusTip(tr("Create a new file")")
+ connect(Act, SIGNAL("triggered()"), self, SLOT("newFile()"))
+
+ openAct = QAction(QIcon(":/images/open.png"), tr("&Open..."), self)
+ openAct.setShortcuts(QKeySequence.Open)
+ openAct.setStatusTip(tr("Open an existing file")")
+ connect(openAct, SIGNAL("triggered()"), self, SLOT("open()"))
+
+ saveAct = QAction(QIcon(":/images/save.png"), tr("&Save"), self)
+ saveAct.setShortcuts(QKeySequence.Save)
+ saveAct.setStatusTip(tr("Save the document to disk")")
+ connect(saveAct, SIGNAL("triggered()"), self, SLOT("save()"))
+
+ saveAsAct = QAction(tr("Save &As..."), self)
+ saveAsAct.setShortcuts(QKeySequence.SaveAs)
+ saveAsAct.setStatusTip(tr("Save the document under a name")")
+ connect(saveAsAct, SIGNAL("triggered()"), self, SLOT("saveAs()"))
+
+//! [0]
+ exitAct = QAction(tr("E&xit"), self)
+ exitAct.setShortcut(tr("Ctrl+Q")")
+ exitAct.setStatusTip(tr("Exit the application")")
+ connect(exitAct, SIGNAL("triggered()"), qApp, SLOT("closeAllWindows()"))
+//! [0]
+
+ cutAct = QAction(QIcon(":/images/cut.png"), tr("Cu&t"), self)
+ cutAct.setShortcuts(QKeySequence.Cut)
+ cutAct.setStatusTip(tr("Cut the current selection's contents to the "
+ "clipboard")")
+ connect(cutAct, SIGNAL("triggered()"), self, SLOT("cut()"))
+
+ copyAct = QAction(QIcon(":/images/copy.png"), tr("&Copy"), self)
+ copyAct.setShortcuts(QKeySequence.Copy)
+ copyAct.setStatusTip(tr("Copy the current selection's contents to the "
+ "clipboard")")
+ connect(copyAct, SIGNAL("triggered()"), self, SLOT("copy()"))
+
+ pasteAct = QAction(QIcon(":/images/paste.png"), tr("&Paste"), self)
+ pasteAct.setShortcuts(QKeySequence.Paste)
+ pasteAct.setStatusTip(tr("Paste the clipboard's contents into the current "
+ "selection")")
+ connect(pasteAct, SIGNAL("triggered()"), self, SLOT("paste()"))
+
+ closeAct = QAction(tr("Cl&ose"), self)
+ closeAct.setShortcut(tr("Ctrl+F4")")
+ closeAct.setStatusTip(tr("Close the active window")")
+ connect(closeAct, SIGNAL("triggered()"),
+ mdiArea, SLOT("closeActiveSubWindow()"))
+
+ closeAllAct = QAction(tr("Close &All"), self)
+ closeAllAct.setStatusTip(tr("Close all the windows")")
+ connect(closeAllAct, SIGNAL("triggered()"),
+ mdiArea, SLOT("closeAllSubWindows()"))
+
+ tileAct = QAction(tr("&Tile"), self)
+ tileAct.setStatusTip(tr("Tile the windows")")
+ connect(tileAct, SIGNAL("triggered()"), mdiArea, SLOT("tileSubWindows()"))
+
+ cascadeAct = QAction(tr("&Cascade"), self)
+ cascadeAct.setStatusTip(tr("Cascade the windows")")
+ connect(cascadeAct, SIGNAL("triggered()"), mdiArea, SLOT("cascadeSubWindows()"))
+
+ nextAct = QAction(tr("Ne&xt"), self)
+ nextAct.setShortcuts(QKeySequence.NextChild)
+ nextAct.setStatusTip(tr("Move the focus to the next window")")
+ connect(nextAct, SIGNAL("triggered()"),
+ mdiArea, SLOT("activateNextSubWindow()"))
+
+ previousAct = QAction(tr("Pre&vious"), self)
+ previousAct.setShortcuts(QKeySequence.PreviousChild)
+ previousAct.setStatusTip(tr("Move the focus to the previous "
+ "window")")
+ connect(previousAct, SIGNAL("triggered()"),
+ mdiArea, SLOT("activatePreviousSubWindow()"))
+
+ separatorAct = QAction(self)
+ separatorAct.setSeparator(True)
+
+ aboutAct = QAction(tr("&About"), self)
+ aboutAct.setStatusTip(tr("Show the application's About box")")
+ connect(aboutAct, SIGNAL("triggered()"), self, SLOT("about()"))
+
+ aboutQtAct = QAction(tr("About &Qt"), self)
+ aboutQtAct.setStatusTip(tr("Show the Qt library's About box")")
+ connect(aboutQtAct, SIGNAL("triggered()"), qApp, SLOT("aboutQt()"))
+
+
+def createMenus()
+
+ fileMenu = menuBar().addMenu(tr("&File")")
+ fileMenu.addAction(Act)
+ fileMenu.addAction(openAct)
+ fileMenu.addAction(saveAct)
+ fileMenu.addAction(saveAsAct)
+ fileMenu.addSeparator()
+ QAction *action = fileMenu.addAction(tr("Switch layout direction")")
+ connect(action, SIGNAL("triggered()"), self, SLOT("switchLayoutDirection()"))
+ fileMenu.addAction(exitAct)
+
+ editMenu = menuBar().addMenu(tr("&Edit")")
+ editMenu.addAction(cutAct)
+ editMenu.addAction(copyAct)
+ editMenu.addAction(pasteAct)
+
+ windowMenu = menuBar().addMenu(tr("&Window")")
+ updateWindowMenu()
+ connect(windowMenu, SIGNAL("aboutToShow()"), self, SLOT("updateWindowMenu()"))
+
+ menuBar().addSeparator()
+
+ helpMenu = menuBar().addMenu(tr("&Help")")
+ helpMenu.addAction(aboutAct)
+ helpMenu.addAction(aboutQtAct)
+
+
+def createToolBars()
+
+ fileToolBar = addToolBar(tr("File")")
+ fileToolBar.addAction(Act)
+ fileToolBar.addAction(openAct)
+ fileToolBar.addAction(saveAct)
+
+ editToolBar = addToolBar(tr("Edit")")
+ editToolBar.addAction(cutAct)
+ editToolBar.addAction(copyAct)
+ editToolBar.addAction(pasteAct)
+
+
+def createStatusBar()
+
+ statusBar().showMessage(tr("Ready")")
+
+
+def readSettings()
+
+ QSettings settings("Trolltech", "MDI Example")
+ QPoint pos = settings.value("pos", QPoint(200, 200)").toPoint()
+ QSize size = settings.value("size", QSize(400, 400)").toSize()
+ move(pos)
+ resize(size)
+
+
+def writeSettings()
+
+ QSettings settings("Trolltech", "MDI Example")
+ settings.setValue("pos", pos()")
+ settings.setValue("size", size()")
+
+
+MdiChild *activeMdiChild()
+
+ if (QMdiSubWindow *activeSubWindow = mdiArea.activeSubWindow()")
+ return qobject_cast<MdiChild *>(activeSubWindow.widget()")
+ return 0
+
+
+QMdiSubWindow *findMdiChild(const QString &fileName)
+
+ QString canonicalFilePath = QFileInfo(fileName).canonicalFilePath()
+
+ foreach (QMdiSubWindow *window, mdiArea.subWindowList()")
+ MdiChild *mdiChild = qobject_cast<MdiChild *>(window.widget()")
+ if (mdiChild.currentFile() == canonicalFilePath)
+ return window
+
+ return 0
+
+
+def switchLayoutDirection()
+
+ if (layoutDirection() == Qt.LeftToRight)
+ qApp.setLayoutDirection(Qt.RightToLeft)
+ else
+ qApp.setLayoutDirection(Qt.LeftToRight)
+
+
+def setActiveSubWindow(QWidget *window)
+
+ if (!window)
+ return
+ mdiArea.setActiveSubWindow(qobject_cast<QMdiSubWindow *>(window)")
+
diff --git a/doc/codesnippets/examples/mainwindows/menus/mainwindow.cpp b/doc/codesnippets/examples/mainwindows/menus/mainwindow.cpp
new file mode 100644
index 000000000..1dd12e1e1
--- /dev/null
+++ b/doc/codesnippets/examples/mainwindows/menus/mainwindow.cpp
@@ -0,0 +1,358 @@
+######################################
+#
+# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# Contact: Qt Software Information (qt-info@nokia.com)
+#
+# This file is part of the example classes of the Qt Toolkit.
+#
+# $QT_BEGIN_LICENSE:LGPL$
+# Commercial Usage
+# Licensees holding valid Qt Commercial licenses may use self file in
+# accordance with the Qt Commercial License Agreement provided with the
+# Software or, alternatively, in accordance with the terms contained in
+# a written agreement between you and Nokia.
+#
+# GNU Lesser General Public License Usage
+# Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+# package.
+#
+# GNU General Public License Usage
+# Alternatively, self file may be used under the terms of the GNU
+# General Public License version 3.0 as published by the Free Software
+# Foundation and appearing in the file LICENSE.GPL included in the
+# packaging of self file. Please review the following information to
+# ensure the GNU General Public License version 3.0 requirements will be
+# met: http://www.gnu.org/copyleft/gpl.html.
+#
+# If you are unsure which license is appropriate for your use, please
+# contact the sales department at qt-sales@nokia.com.
+# $QT_END_LICENSE$
+#
+######################################
+
+from PySide.QtGui import *
+
+//! [0]
+def __init__(self):
+ Q__init__(self)
+
+ widget = QWidget()
+ setCentralWidget(widget)
+//! [0]
+
+//! [1]
+ topFiller = QWidget()
+ topFiller.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
+
+ infoLabel = QLabel(tr("<i>Choose a menu option, or right-click to "
+ "invoke a context menu</i>"))
+ infoLabel.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken)
+ infoLabel.setAlignment(Qt.AlignCenter)
+
+ bottomFiller = QWidget()
+ bottomFiller.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
+
+ layout = QVBoxLayout()
+ layout.setMargin(5)
+ layout.addWidget(topFiller)
+ layout.addWidget(infoLabel)
+ layout.addWidget(bottomFiller)
+ widget.setLayout(layout)
+//! [1]
+
+//! [2]
+ createActions()
+ createMenus()
+
+ message = tr("A context menu is available by right-clicking")
+ statusBar().showMessage(message)
+
+ setWindowTitle(tr("Menus"))
+ setMinimumSize(160, 160)
+ resize(480, 320)
+
+//! [2]
+
+//! [3]
+def contextMenuEvent(self, event):
+ menu = QMenu(self)
+ menu.addAction(cutAct)
+ menu.addAction(copyAct)
+ menu.addAction(pasteAct)
+ menu.exec_(event.globalPos()")
+
+//! [3]
+
+def File(self):
+ infoLabel.setText(tr("Invoked <b>File|New</b>"))
+
+
+def open(self):
+ infoLabel.setText(tr("Invoked <b>File|Open</b>"))
+
+
+def save(self):
+ infoLabel.setText(tr("Invoked <b>File|Save</b>"))
+
+def print_(self):
+ infoLabel.setText(tr("Invoked <b>File|Print</b>"))
+
+def undo(self):
+ infoLabel.setText(tr("Invoked <b>Edit|Undo</b>"))
+
+def redo(self):
+ infoLabel.setText(tr("Invoked <b>Edit|Redo</b>"))
+
+def cut(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Cut</b>"))
+
+
+def copy(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Copy</b>"))
+
+
+def paste(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Paste</b>"))
+
+
+def bold(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Bold</b>"))
+
+
+def italic(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Italic</b>"))
+
+
+def leftAlign(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Left Align</b>"))
+
+
+def rightAlign(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Right Align</b>"))
+
+
+def justify(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Justify</b>"))
+
+
+def center(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Center</b>"))
+
+
+def setLineSpacing(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Set Line Spacing</b>"))
+
+
+def setParagraphSpacing(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Set Paragraph Spacing</b>"))
+
+
+def about(self):
+
+ infoLabel.setText(tr("Invoked <b>Help|About</b>"))
+ QMessageBox.about(self, tr("About Menu"),
+ tr("The <b>Menu</b> example shows how to create "
+ "menu-bar menus and context menus."))
+
+
+def aboutQt(self):
+
+ infoLabel.setText(tr("Invoked <b>Help|About Qt</b>"))
+
+
+//! [4]
+def createActions(self):
+
+//! [5]
+ Act = new QAction(tr("&New"), self)
+ Act.setShortcuts(QKeySequence.New)
+ Act.setStatusTip(tr("Create a new file"))
+ connect(Act, SIGNAL("triggered()"), self, SLOT("newFile()"))
+//! [4]
+
+ openAct = QAction(tr("&Open..."), self)
+ openAct.setShortcuts(QKeySequence.Open)
+ openAct.setStatusTip(tr("Open an existing file"))
+ connect(openAct, SIGNAL("triggered()"), self, SLOT("open()"))
+//! [5]
+
+ saveAct = QAction(tr("&Save"), self)
+ saveAct.setShortcuts(QKeySequence.Save)
+ saveAct.setStatusTip(tr("Save the document to disk"))
+ connect(saveAct, SIGNAL("triggered()"), self, SLOT("save()"))
+
+ printAct = QAction(tr("&Print..."), self)
+ printAct.setShortcuts(QKeySequence.Print)
+ printAct.setStatusTip(tr("Print the document"))
+ connect(printAct, SIGNAL("triggered()"), self, SLOT("print_()"))
+
+ exitAct = QAction(tr("E&xit"), self)
+ exitAct.setShortcut(tr("Ctrl+Q"))
+ exitAct.setStatusTip(tr("Exit the application"))
+ connect(exitAct, SIGNAL("triggered()"), self, SLOT("close()"))
+
+ undoAct = QAction(tr("&Undo"), self)
+ undoAct.setShortcuts(QKeySequence.Undo)
+ undoAct.setStatusTip(tr("Undo the last operation"))
+ connect(undoAct, SIGNAL("triggered()"), self, SLOT("undo()"))
+
+ redoAct = QAction(tr("&Redo"), self)
+ redoAct.setShortcuts(QKeySequence.Redo)
+ redoAct.setStatusTip(tr("Redo the last operation"))
+ connect(redoAct, SIGNAL("triggered()"), self, SLOT("redo()"))
+
+ cutAct = QAction(tr("Cu&t"), self)
+ cutAct.setShortcuts(QKeySequence.Cut)
+ cutAct.setStatusTip(tr("Cut the current selection's contents to the "
+ "clipboard"))
+ connect(cutAct, SIGNAL("triggered()"), self, SLOT("cut()"))
+
+ copyAct = QAction(tr("&Copy"), self)
+ copyAct.setShortcut(tr("Ctrl+C"))
+ copyAct.setStatusTip(tr("Copy the current selection's contents to the "
+ "clipboard"))
+ connect(copyAct, SIGNAL("triggered()"), self, SLOT("copy()"))
+
+ pasteAct = QAction(tr("&Paste"), self)
+ pasteAct.setShortcuts(QKeySequence.Paste)
+ pasteAct.setStatusTip(tr("Paste the clipboard's contents into the current "
+ "selection"))
+ connect(pasteAct, SIGNAL("triggered()"), self, SLOT("paste()"))
+
+ boldAct = QAction(tr("&Bold"), self)
+ boldAct.setCheckable(True)
+ boldAct.setShortcut(tr("Ctrl+B"))
+ boldAct.setStatusTip(tr("Make the text bold"))
+ connect(boldAct, SIGNAL("triggered()"), self, SLOT("bold()"))
+
+ QFont boldFont = boldAct.font()
+ boldFont.setBold(True)
+ boldAct.setFont(boldFont)
+
+ italicAct = QAction(tr("&Italic"), self)
+ italicAct.setCheckable(True)
+ italicAct.setShortcut(tr("Ctrl+I"))
+ italicAct.setStatusTip(tr("Make the text italic"))
+ connect(italicAct, SIGNAL("triggered()"), self, SLOT("italic()"))
+
+ QFont italicFont = italicAct.font()
+ italicFont.setItalic(True)
+ italicAct.setFont(italicFont)
+
+ setLineSpacingAct = QAction(tr("Set &Line Spacing..."), self)
+ setLineSpacingAct.setStatusTip(tr("Change the gap between the lines of a "
+ "paragraph"))
+ connect(setLineSpacingAct, SIGNAL("triggered()"), self, SLOT("setLineSpacing()"))
+
+ setParagraphSpacingAct = QAction(tr("Set &Paragraph Spacing..."), self)
+ setLineSpacingAct.setStatusTip(tr("Change the gap between paragraphs"))
+ connect(setParagraphSpacingAct, SIGNAL("triggered()"),
+ self, SLOT("setParagraphSpacing()"))
+
+ aboutAct = QAction(tr("&About"), self)
+ aboutAct.setStatusTip(tr("Show the application's About box"))
+ connect(aboutAct, SIGNAL("triggered()"), self, SLOT("about()"))
+
+ aboutQtAct = QAction(tr("About &Qt"), self)
+ aboutQtAct.setStatusTip(tr("Show the Qt library's About box"))
+ connect(aboutQtAct, SIGNAL("triggered()"), qApp, SLOT("aboutQt()"))
+ connect(aboutQtAct, SIGNAL("triggered()"), self, SLOT("aboutQt()"))
+
+ leftAlignAct = QAction(tr("&Left Align"), self)
+ leftAlignAct.setCheckable(True)
+ leftAlignAct.setShortcut(tr("Ctrl+L"))
+ leftAlignAct.setStatusTip(tr("Left align the selected text"))
+ connect(leftAlignAct, SIGNAL("triggered()"), self, SLOT("leftAlign()"))
+
+ rightAlignAct = QAction(tr("&Right Align"), self)
+ rightAlignAct.setCheckable(True)
+ rightAlignAct.setShortcut(tr("Ctrl+R"))
+ rightAlignAct.setStatusTip(tr("Right align the selected text"))
+ connect(rightAlignAct, SIGNAL("triggered()"), self, SLOT("rightAlign()"))
+
+ justifyAct = QAction(tr("&Justify"), self)
+ justifyAct.setCheckable(True)
+ justifyAct.setShortcut(tr("Ctrl+J"))
+ justifyAct.setStatusTip(tr("Justify the selected text"))
+ connect(justifyAct, SIGNAL("triggered()"), self, SLOT("justify()"))
+
+ centerAct = QAction(tr("&Center"), self)
+ centerAct.setCheckable(True)
+ centerAct.setShortcut(tr("Ctrl+E"))
+ centerAct.setStatusTip(tr("Center the selected text"))
+ connect(centerAct, SIGNAL("triggered()"), self, SLOT("center()"))
+
+//! [6] //! [7]
+ alignmentGroup = QActionGroup(self)
+ alignmentGroup.addAction(leftAlignAct)
+ alignmentGroup.addAction(rightAlignAct)
+ alignmentGroup.addAction(justifyAct)
+ alignmentGroup.addAction(centerAct)
+ leftAlignAct.setChecked(True)
+//! [6]
+
+//! [7]
+
+//! [8]
+def createMenus(self):
+
+//! [9] //! [10]
+ fileMenu = menuBar().addMenu(tr("&File"))
+ fileMenu.addAction(Act)
+//! [9]
+ fileMenu.addAction(openAct)
+//! [10]
+ fileMenu.addAction(saveAct)
+ fileMenu.addAction(printAct)
+//! [11]
+ fileMenu.addSeparator()
+//! [11]
+ fileMenu.addAction(exitAct)
+
+ editMenu = menuBar().addMenu(tr("&Edit"))
+ editMenu.addAction(undoAct)
+ editMenu.addAction(redoAct)
+ editMenu.addSeparator()
+ editMenu.addAction(cutAct)
+ editMenu.addAction(copyAct)
+ editMenu.addAction(pasteAct)
+ editMenu.addSeparator()
+
+ helpMenu = menuBar().addMenu(tr("&Help"))
+ helpMenu.addAction(aboutAct)
+ helpMenu.addAction(aboutQtAct)
+//! [8]
+
+//! [12]
+ formatMenu = editMenu.addMenu(tr("&Format"))
+ formatMenu.addAction(boldAct)
+ formatMenu.addAction(italicAct)
+ formatMenu.addSeparator()->setText(tr("Alignment"))
+ formatMenu.addAction(leftAlignAct)
+ formatMenu.addAction(rightAlignAct)
+ formatMenu.addAction(justifyAct)
+ formatMenu.addAction(centerAct)
+ formatMenu.addSeparator()
+ formatMenu.addAction(setLineSpacingAct)
+ formatMenu.addAction(setParagraphSpacingAct)
+//! [12]
diff --git a/doc/codesnippets/examples/painting/svggenerator/window.cpp b/doc/codesnippets/examples/painting/svggenerator/window.cpp
new file mode 100644
index 000000000..79242e848
--- /dev/null
+++ b/doc/codesnippets/examples/painting/svggenerator/window.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QColorDialog>
+#include <QFileDialog>
+#include <QPainter>
+#include <QSvgGenerator>
+#include "window.h"
+#include "displaywidget.h"
+
+Window::Window(QWidget *parent)
+ : QWidget(parent)
+{
+ setupUi(this);
+}
+
+void Window::updateBackground(int background)
+{
+ displayWidget->setBackground(DisplayWidget::Background(background));
+}
+
+void Window::updateColor()
+{
+ QColor color = QColorDialog::getColor(displayWidget->color());
+ if (color.isValid())
+ displayWidget->setColor(color);
+}
+
+void Window::updateShape(int shape)
+{
+ displayWidget->setShape(DisplayWidget::Shape(shape));
+}
+
+//! [save SVG]
+def saveSvg(self):
+ newPath = QFileDialog.getSaveFileName(self, QObject.tr("Save SVG"), path, QObject.tr("SVG files (*.svg)"))
+
+ if newPath.isEmpty():
+ return
+
+ path = newPath
+
+//![configure SVG generator]
+ generator = QSvgGenerator()
+ generator.setFileName(path)
+ generator.setSize(QSize(200, 200))
+ generator.setViewBox(QRect(0, 0, 200, 200))
+ generator.setTitle(QObject.tr("SVG Generator Example Drawing"))
+ generator.setDescription(QObject.tr("An SVG drawing created by the SVG Generator Example provided with Qt."))
+//![configure SVG generator]
+//![begin painting]
+ painter = QPainter()
+ painter.begin(generator)
+//![begin painting]
+ displayWidget->paint(painter)
+//![end painting]
+ painter.end()
+//![end painting]
+
+//! [save SVG]
diff --git a/doc/codesnippets/examples/richtext/textobject/svgtextobject.h b/doc/codesnippets/examples/richtext/textobject/svgtextobject.h
new file mode 100644
index 000000000..8fcd11411
--- /dev/null
+++ b/doc/codesnippets/examples/richtext/textobject/svgtextobject.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the example classes of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SVGTEXTOBJECT_H
+#define SVGTEXTOBJECT_H
+
+#include <QTextObjectInterface>
+
+QT_BEGIN_NAMESPACE
+class QTextDocument;
+class QTextFormat;
+class QPainter;
+class QRectF;
+class QSizeF;
+QT_END_NAMESPACE
+
+//![0] //![1]
+class SvgTextObject(QObject, QTextObjectInterface):
+ def __init__(self,...):
+ super(SvgTextObject, self).__init__(...)
+ ...
+//![1]
+
+public:
+ QSizeF intrinsicSize(QTextDocument *doc, int posInDocument,
+ const QTextFormat &format);
+ void drawObject(QPainter *painter, const QRectF &rect, QTextDocument *doc,
+ int posInDocument, const QTextFormat &format);
+};
+//![0]
+
+#endif
diff --git a/doc/codesnippets/examples/sql/querymodel/editablesqlmodel.cpp b/doc/codesnippets/examples/sql/querymodel/editablesqlmodel.cpp
new file mode 100644
index 000000000..b1d14de07
--- /dev/null
+++ b/doc/codesnippets/examples/sql/querymodel/editablesqlmodel.cpp
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtSql>
+
+#include "editablesqlmodel.h"
+
+EditableSqlModel::EditableSqlModel(QObject *parent)
+ : QSqlQueryModel(parent)
+{
+}
+
+//! [0]
+def flags(self, index):
+ flags = QSqlQueryModel.flags(index)
+ if index.column() == 1 or index.column() == 2:
+ flags |= Qt.ItemIsEditable
+ return flags
+//! [0]
+
+//! [1]
+def setData(self, index, value, role):
+ if index.column() < 1 or index.column() > 2:
+ return False
+
+ primaryKeyIndex = QSqlQueryModel.index(index.row(), 0)
+ id = self.data(primaryKeyIndex).toInt()
+
+ self.clear()
+
+ ok = False
+ if index.column() == 1:
+ ok = self.setFirstName(id, value.toString())
+ else:
+ ok = self.setLastName(id, value.toString())
+ self.refresh()
+ return ok
+}
+//! [1]
+
+void EditableSqlModel::refresh()
+{
+ setQuery("select * from person");
+ setHeaderData(0, Qt::Horizontal, QObject::tr("ID"));
+ setHeaderData(1, Qt::Horizontal, QObject::tr("First name"));
+ setHeaderData(2, Qt::Horizontal, QObject::tr("Last name"));
+}
+
+//! [2]
+def setFirstName(self, personId, firstName):
+ query = QSqlQuery()
+ query.prepare("update person set firstname = ? where id = ?")
+ query.addBindValue(firstName)
+ query.addBindValue(personId)
+ return query.exec()
+//! [2]
+
+bool EditableSqlModel::setLastName(int personId, const QString &lastName)
+{
+ QSqlQuery query;
+ query.prepare("update person set lastname = ? where id = ?");
+ query.addBindValue(lastName);
+ query.addBindValue(personId);
+ return query.exec();
+}
diff --git a/doc/codesnippets/examples/sql/relationaltablemodel/relationaltablemodel.cpp b/doc/codesnippets/examples/sql/relationaltablemodel/relationaltablemodel.cpp
new file mode 100644
index 000000000..93c5209b2
--- /dev/null
+++ b/doc/codesnippets/examples/sql/relationaltablemodel/relationaltablemodel.cpp
@@ -0,0 +1,111 @@
+######################################
+#
+# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# Contact: Qt Software Information (qt-info@nokia.com)
+#
+# This file is part of the example classes of the Qt Toolkit.
+#
+# $QT_BEGIN_LICENSE:LGPL$
+# Commercial Usage
+# Licensees holding valid Qt Commercial licenses may use self file in
+# accordance with the Qt Commercial License Agreement provided with the
+# Software or, alternatively, in accordance with the terms contained in
+# a written agreement between you and Nokia.
+#
+# GNU Lesser General Public License Usage
+# Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+# package.
+#
+# GNU General Public License Usage
+# Alternatively, self file may be used under the terms of the GNU
+# General Public License version 3.0 as published by the Free Software
+# Foundation and appearing in the file LICENSE.GPL included in the
+# packaging of self file. Please review the following information to
+# ensure the GNU General Public License version 3.0 requirements will be
+# met: http://www.gnu.org/copyleft/gpl.html.
+#
+# If you are unsure which license is appropriate for your use, please
+# contact the sales department at qt-sales@nokia.com.
+# $QT_END_LICENSE$
+#
+######################################
+
+from PySide.QtGui import *
+from PySide.QtSql import *
+
+def initializeModel(model):
+//! [0]
+ model.setTable("employee")
+//! [0]
+
+ model.setEditStrategy(QSqlTableModel.OnManualSubmit)
+//! [1]
+ model.setRelation(2, QSqlRelation("city", "id", "name"))
+//! [1] //! [2]
+ model.setRelation(3, QSqlRelation("country", "id", "name"))
+//! [2]
+
+//! [3]
+ model.setHeaderData(0, Qt.Horizontal, QObject::tr("ID"))
+ model.setHeaderData(1, Qt.Horizontal, QObject::tr("Name"))
+ model.setHeaderData(2, Qt.Horizontal, QObject::tr("City"))
+ model.setHeaderData(3, Qt.Horizontal, QObject::tr("Country"))
+//! [3]
+
+ model.select()
+
+
+def createView(title, model):
+//! [4]
+ view = QTableView()
+ view.setModel(model)
+ view.setItemDelegate(QSqlRelationalDelegate(view))
+//! [4]
+ view.setWindowTitle(title)
+ return view
+
+
+def createRelationalTables():
+ query = QSqlQuery()
+ query.exec_("create table employee(id int primary key, name varchar(20), city int, country int)")
+ query.exec_("insert into employee values(1, 'Espen', 5000, 47)")
+ query.exec_("insert into employee values(2, 'Harald', 80000, 49)")
+ query.exec_("insert into employee values(3, 'Sam', 100, 1)")
+
+ query.exec_("create table city(id int, name varchar(20))")
+ query.exec_("insert into city values(100, 'San Jose')")
+ query.exec_("insert into city values(5000, 'Oslo')")
+ query.exec_("insert into city values(80000, 'Munich')")
+
+ query.exec_("create table country(id int, name varchar(20))")
+ query.exec_("insert into country values(1, 'USA')")
+ query.exec_("insert into country values(47, 'Norway')")
+ query.exec_("insert into country values(49, 'Germany')")
+
+
+def main():
+
+ app = QApplication([])
+ if !createConnection():
+ return 1
+
+ createRelationalTables()
+
+ QSqlRelationalTableModel model
+
+ initializeModel(&model)
+
+ view = createView(QObject.tr("Relational Table Model"), &model)
+ view.show()
+
+ return app.exec_()
+
diff --git a/doc/codesnippets/examples/widgets/analogclock/analogclock.cpp b/doc/codesnippets/examples/widgets/analogclock/analogclock.cpp
new file mode 100644
index 000000000..2e631a2dd
--- /dev/null
+++ b/doc/codesnippets/examples/widgets/analogclock/analogclock.cpp
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "analogclock.h"
+
+//! [0] //! [1]
+AnalogClock::AnalogClock(QWidget *parent)
+//! [0] //! [2]
+ : QWidget(parent)
+//! [2] //! [3]
+{
+//! [3] //! [4]
+ timer = QTimer(self)
+//! [4] //! [5]
+ self.connect(timer, SIGNAL("timeout()"), self.update)
+//! [5] //! [6]
+ timer.start(1000)
+//! [6]
+
+ setWindowTitle(tr("Analog Clock"));
+ resize(200, 200);
+//! [7]
+}
+//! [1] //! [7]
+
+//! [8] //! [9]
+void AnalogClock::paintEvent(QPaintEvent *)
+//! [8] //! [10]
+{
+ static const QPoint hourHand[3] = {
+ QPoint(7, 8),
+ QPoint(-7, 8),
+ QPoint(0, -40)
+ };
+ static const QPoint minuteHand[3] = {
+ QPoint(7, 8),
+ QPoint(-7, 8),
+ QPoint(0, -70)
+ };
+
+ QColor hourColor(127, 0, 127);
+ QColor minuteColor(0, 127, 127, 191);
+
+ int side = qMin(width(), height());
+ QTime time = QTime::currentTime();
+//! [10]
+
+//! [11]
+ QPainter painter(this);
+//! [11] //! [12]
+ painter.setRenderHint(QPainter::Antialiasing);
+//! [12] //! [13]
+ painter.translate(width() / 2, height() / 2);
+//! [13] //! [14]
+ painter.scale(side / 200.0, side / 200.0);
+//! [9] //! [14]
+
+//! [15]
+ painter.setPen(Qt::NoPen);
+//! [15] //! [16]
+ painter.setBrush(hourColor);
+//! [16]
+
+//! [17] //! [18]
+ painter.save();
+//! [17] //! [19]
+ painter.rotate(30.0 * ((time.hour() + time.minute() / 60.0)));
+ painter.drawConvexPolygon(hourHand, 3);
+ painter.restore();
+//! [18] //! [19]
+
+//! [20]
+ painter.setPen(hourColor);
+//! [20] //! [21]
+
+ for (int i = 0; i < 12; ++i) {
+ painter.drawLine(88, 0, 96, 0);
+ painter.rotate(30.0);
+ }
+//! [21]
+
+//! [22]
+ painter.setPen(Qt::NoPen);
+//! [22] //! [23]
+ painter.setBrush(minuteColor);
+
+//! [24]
+ painter.save();
+ painter.rotate(6.0 * (time.minute() + time.second() / 60.0));
+ painter.drawConvexPolygon(minuteHand, 3);
+ painter.restore();
+//! [23] //! [24]
+
+//! [25]
+ painter.setPen(minuteColor);
+//! [25] //! [26]
+
+//! [27]
+ for (int j = 0; j < 60; ++j) {
+ if ((j % 5) != 0)
+ painter.drawLine(92, 0, 96, 0);
+ painter.rotate(6.0);
+ }
+//! [27]
+}
+//! [26]
diff --git a/doc/codesnippets/examples/widgets/icons/iconsizespinbox.cpp b/doc/codesnippets/examples/widgets/icons/iconsizespinbox.cpp
new file mode 100644
index 000000000..2a518b7c1
--- /dev/null
+++ b/doc/codesnippets/examples/widgets/icons/iconsizespinbox.cpp
@@ -0,0 +1,63 @@
+############################################################################
+##
+## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: Qt Software Information (qt-info@nokia.com)
+##
+## This file is part of the example classes of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial Usage
+## Licensees holding valid Qt Commercial licenses may use self file in
+## accordance with the Qt Commercial License Agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Nokia.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+## package.
+##
+## GNU General Public License Usage
+## Alternatively, self file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of self file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+## If you are unsure which license is appropriate for your use, please
+## contact the sales department at qt-sales@nokia.com.
+## $QT_END_LICENSE$
+##
+############################################################################
+
+
+//! [0]
+def __init__(self, parent):
+ QSpinBox.__init__(self, parent)
+
+//! [0]
+
+//! [1]
+def valueFromText(self, text):
+ regExp = QRegExp(tr("(\\d+)(\\s*[xx]\\s*\\d+)?"))
+
+ if regExp.exactMatch(text):
+ return regExp.cap(1).toInt()
+ else:
+ return 0
+//! [1]
+
+//! [2]
+def textFromValue(self, value):
+ return self.tr("%1 x %1").arg(value)
+
+//! [2]
diff --git a/doc/codesnippets/examples/widgets/spinboxes/window.cpp b/doc/codesnippets/examples/widgets/spinboxes/window.cpp
new file mode 100644
index 000000000..03df1421d
--- /dev/null
+++ b/doc/codesnippets/examples/widgets/spinboxes/window.cpp
@@ -0,0 +1,240 @@
+######################################
+#
+# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# Contact: Qt Software Information (qt-info@nokia.com)
+#
+# This file is part of the example classes of the Qt Toolkit.
+#
+# $QT_BEGIN_LICENSE:LGPL$
+# Commercial Usage
+# Licensees holding valid Qt Commercial licenses may use self file in
+# accordance with the Qt Commercial License Agreement provided with the
+# Software or, alternatively, in accordance with the terms contained in
+# a written agreement between you and Nokia.
+#
+# GNU Lesser General Public License Usage
+# Alternatively, self 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 self 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.0, included in the file LGPL_EXCEPTION.txt in self
+# package.
+#
+# GNU General Public License Usage
+# Alternatively, self file may be used under the terms of the GNU
+# General Public License version 3.0 as published by the Free Software
+# Foundation and appearing in the file LICENSE.GPL included in the
+# packaging of self file. Please review the following information to
+# ensure the GNU General Public License version 3.0 requirements will be
+# met: http://www.gnu.org/copyleft/gpl.html.
+#
+# If you are unsure which license is appropriate for your use, please
+# contact the sales department at qt-sales@nokia.com.
+# $QT_END_LICENSE$
+#
+######################################
+
+from PySide.QtGui import *
+
+//! [0]
+def __init__(self):
+ createSpinBoxes()
+ createDateTimeEdits()
+ createDoubleSpinBoxes()
+
+ layout = QHBoxLayout()
+ layout.addWidget(spinBoxesGroup)
+ layout.addWidget(editsGroup)
+ layout.addWidget(doubleSpinBoxesGroup)
+ setLayout(layout)
+
+ setWindowTitle(tr("Spin Boxes"))
+//! [0]
+
+//! [1]
+def createSpinBoxes(self):
+ spinBoxesGroup = QGroupBox(tr("Spinboxes"))
+
+ integerLabel = QLabel(tr("Enter a value between "
+ "%1 and %2:").arg(-20).arg(20))
+ integerSpinBox = QSpinBox()
+ integerSpinBox.setRange(-20, 20)
+ integerSpinBox.setSingleStep(1)
+ integerSpinBox.setValue(0)
+//! [1]
+
+//! [2]
+ zoomLabel = QLabel(tr("Enter a zoom value between "
+ "%1 and %2:").arg(0).arg(1000))
+//! [3]
+ zoomSpinBox = QSpinBox()
+ zoomSpinBox.setRange(0, 1000)
+ zoomSpinBox.setSingleStep(10)
+ zoomSpinBox.setSuffix("%")
+ zoomSpinBox.setSpecialValueText(tr("Automatic"))
+ zoomSpinBox.setValue(100)
+//! [2] //! [3]
+
+//! [4]
+ priceLabel = QLabel(tr("Enter a price between "
+ "%1 and %2:").arg(0).arg(999))
+ priceSpinBox = QSpinBox()
+ priceSpinBox.setRange(0, 999)
+ priceSpinBox.setSingleStep(1)
+ priceSpinBox.setPrefix("$")
+ priceSpinBox.setValue(99)
+//! [4] //! [5]
+
+ spinBoxLayout = QVBoxLayout()
+ spinBoxLayout.addWidget(integerLabel)
+ spinBoxLayout.addWidget(integerSpinBox)
+ spinBoxLayout.addWidget(zoomLabel)
+ spinBoxLayout.addWidget(zoomSpinBox)
+ spinBoxLayout.addWidget(priceLabel)
+ spinBoxLayout.addWidget(priceSpinBox)
+ spinBoxesGroup.setLayout(spinBoxLayout)
+
+//! [5]
+
+//! [6]
+def createDateTimeEdits(self):
+ editsGroup = QGroupBox(tr("Date and time spin boxes"))
+
+ dateLabel = QLabel()
+ dateEdit = QDateEdit(QDate.currentDate())
+ dateEdit.setDateRange(QDate(2005, 1, 1), QDate(2010, 12, 31))
+ dateLabel.setText(tr("Appointment date (between %0 and %1):")
+ .arg(dateEdit.minimumDate().toString(Qt.ISODate))
+ .arg(dateEdit.maximumDate().toString(Qt.ISODate)))
+//! [6]
+
+//! [7]
+ timeLabel = QLabel()
+ timeEdit = QTimeEdit(QTime.currentTime())
+ timeEdit.setTimeRange(QTime(9, 0, 0, 0), QTime(16, 30, 0, 0))
+ timeLabel.setText(tr("Appointment time (between %0 and %1):")
+ .arg(timeEdit.minimumTime().toString(Qt.ISODate))
+ .arg(timeEdit.maximumTime().toString(Qt.ISODate)))
+//! [7]
+
+//! [8]
+ meetingLabel = QLabel()
+ meetingEdit = QDateTimeEdit(QDateTime.currentDateTime())
+//! [8]
+
+//! [9]
+ formatLabel = QLabel(tr("Format string for the meeting date "
+ "and time:"))
+ formatComboBox = QComboBox()
+ formatComboBox.addItem("yyyy-MM-dd hh:mm:ss (zzz 'ms')")
+ formatComboBox.addItem("hh:mm:ss MM/dd/yyyy")
+ formatComboBox.addItem("hh:mm:ss dd/MM/yyyy")
+ formatComboBox.addItem("hh:mm:ss")
+ formatComboBox.addItem("hh:mm ap")
+//! [9] //! [10]
+
+ connect(formatComboBox, SIGNAL("activated(const QString &)"),
+ self, SLOT("setFormatString(const QString &)"))
+//! [10]
+
+ setFormatString(formatComboBox.currentText())
+
+//! [11]
+ editsLayout = QVBoxLayout()
+ editsLayout.addWidget(dateLabel)
+ editsLayout.addWidget(dateEdit)
+ editsLayout.addWidget(timeLabel)
+ editsLayout.addWidget(timeEdit)
+ editsLayout.addWidget(meetingLabel)
+ editsLayout.addWidget(meetingEdit)
+ editsLayout.addWidget(formatLabel)
+ editsLayout.addWidget(formatComboBox)
+ editsGroup.setLayout(editsLayout)
+//! [11]
+
+//! [12]
+def setFormatString(self, formatString):
+ meetingEdit.setDisplayFormat(formatString)
+//! [12] //! [13]
+ if meetingEdit.displayedSections() & QDateTimeEdit.DateSections_Mask:
+ meetingEdit.setDateRange(QDate(2004, 11, 1), QDate(2005, 11, 30))
+ meetingLabel.setText(tr("Meeting date (between %0 and %1):")
+ .arg(meetingEdit.minimumDate().toString(Qt.ISODate))
+ .arg(meetingEdit.maximumDate().toString(Qt.ISODate)))
+ else:
+ meetingEdit.setTimeRange(QTime(0, 7, 20, 0), QTime(21, 0, 0, 0))
+ meetingLabel.setText(tr("Meeting time (between %0 and %1):")
+ .arg(meetingEdit.minimumTime().toString(Qt.ISODate))
+ .arg(meetingEdit.maximumTime().toString(Qt.ISODate)))
+//! [13]
+
+//! [14]
+def createDoubleSpinBoxes():
+ doubleSpinBoxesGroup = QGroupBox(tr("Double precision spinboxes"))
+
+ precisionLabel = QLabel(tr("Number of decimal places "
+ "to show:"))
+ precisionSpinBox = QSpinBox()
+ precisionSpinBox.setRange(0, 100)
+ precisionSpinBox.setValue(2)
+//! [14]
+
+//! [15]
+ doubleLabel = QLabel(tr("Enter a value between "
+ "%1 and %2:").arg(-20).arg(20))
+ doubleSpinBox = QDoubleSpinBox ()
+ doubleSpinBox.setRange(-20.0, 20.0)
+ doubleSpinBox.setSingleStep(1.0)
+ doubleSpinBox.setValue(0.0)
+//! [15]
+
+//! [16]
+ scaleLabel = QLabel(tr("Enter a scale factor between "
+ "%1 and %2:").arg(0).arg(1000.0))
+ scaleSpinBox = QDoubleSpinBox()
+ scaleSpinBox.setRange(0.0, 1000.0)
+ scaleSpinBox.setSingleStep(10.0)
+ scaleSpinBox.setSuffix("%")
+ scaleSpinBox.setSpecialValueText(tr("No scaling"))
+ scaleSpinBox.setValue(100.0)
+//! [16]
+
+//! [17]
+ priceLabel = QLabel(tr("Enter a price between "
+ "%1 and %2:").arg(0).arg(1000))
+ priceSpinBox = QDoubleSpinBox()
+ priceSpinBox.setRange(0.0, 1000.0)
+ priceSpinBox.setSingleStep(1.0)
+ priceSpinBox.setPrefix("$")
+ priceSpinBox.setValue(99.99)
+
+ connect(precisionSpinBox, SIGNAL("valueChanged(int)"),
+//! [17]
+ self, SLOT("changePrecision(int))")
+
+//! [18]
+ spinBoxLayout = QVBoxLayout()
+ spinBoxLayout.addWidget(precisionLabel)
+ spinBoxLayout.addWidget(precisionSpinBox)
+ spinBoxLayout.addWidget(doubleLabel)
+ spinBoxLayout.addWidget(doubleSpinBox)
+ spinBoxLayout.addWidget(scaleLabel)
+ spinBoxLayout.addWidget(scaleSpinBox)
+ spinBoxLayout.addWidget(priceLabel)
+ spinBoxLayout.addWidget(priceSpinBox)
+ doubleSpinBoxesGroup.setLayout(spinBoxLayout)
+}
+//! [18]
+
+//! [19]
+def changePrecision(self, int)
+ doubleSpinBox.setDecimals(decimals)
+ scaleSpinBox.setDecimals(decimals)
+ priceSpinBox.setDecimals(decimals)
+
+//! [19]
diff --git a/doc/codesnippets/examples/xml/streambookmarks/xbelreader.cpp b/doc/codesnippets/examples/xml/streambookmarks/xbelreader.cpp
new file mode 100644
index 000000000..c6fa9d193
--- /dev/null
+++ b/doc/codesnippets/examples/xml/streambookmarks/xbelreader.cpp
@@ -0,0 +1,201 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "xbelreader.h"
+
+//! [0]
+XbelReader::XbelReader(QTreeWidget *treeWidget)
+ : treeWidget(treeWidget)
+{
+ QStyle *style = treeWidget->style();
+
+ folderIcon.addPixmap(style->standardPixmap(QStyle::SP_DirClosedIcon),
+ QIcon::Normal, QIcon::Off);
+ folderIcon.addPixmap(style->standardPixmap(QStyle::SP_DirOpenIcon),
+ QIcon::Normal, QIcon::On);
+ bookmarkIcon.addPixmap(style->standardPixmap(QStyle::SP_FileIcon));
+}
+//! [0]
+
+//! [1]
+def read(self, device):
+ self.setDevice(device)
+
+ while not atEnd():
+ readNext()
+
+ if isStartElement():
+ if self.name() == "xbel" and self.attributes().value("version") == "1.0":
+ self.readXBEL()
+ else:
+ self.raiseError(QObject.tr("The file is not an XBEL version 1.0 file."));
+
+ return not self.error();
+//! [1]
+
+//! [2]
+void XbelReader::readUnknownElement()
+{
+ Q_ASSERT(isStartElement());
+
+ while (!atEnd()) {
+ readNext();
+
+ if (isEndElement())
+ break;
+
+ if (isStartElement())
+ readUnknownElement();
+ }
+}
+//! [2]
+
+//! [3]
+void XbelReader::readXBEL()
+{
+ Q_ASSERT(isStartElement() && name() == "xbel");
+
+ while (!atEnd()) {
+ readNext();
+
+ if (isEndElement())
+ break;
+
+ if (isStartElement()) {
+ if (name() == "folder")
+ readFolder(0);
+ else if (name() == "bookmark")
+ readBookmark(0);
+ else if (name() == "separator")
+ readSeparator(0);
+ else
+ readUnknownElement();
+ }
+ }
+}
+//! [3]
+
+//! [4]
+void XbelReader::readTitle(QTreeWidgetItem *item)
+{
+ Q_ASSERT(isStartElement() && name() == "title");
+
+ QString title = readElementText();
+ item->setText(0, title);
+}
+//! [4]
+
+//! [5]
+void XbelReader::readSeparator(QTreeWidgetItem *item)
+{
+ QTreeWidgetItem *separator = createChildItem(item);
+ separator->setFlags(item->flags() & ~Qt::ItemIsSelectable);
+ separator->setText(0, QString(30, 0xB7));
+ readElementText();
+}
+//! [5]
+
+void XbelReader::readFolder(QTreeWidgetItem *item)
+{
+ Q_ASSERT(isStartElement() && name() == "folder");
+
+ QTreeWidgetItem *folder = createChildItem(item);
+ bool folded = (attributes().value("folded") != "no");
+ treeWidget->setItemExpanded(folder, !folded);
+
+ while (!atEnd()) {
+ readNext();
+
+ if (isEndElement())
+ break;
+
+ if (isStartElement()) {
+ if (name() == "title")
+ readTitle(folder);
+ else if (name() == "folder")
+ readFolder(folder);
+ else if (name() == "bookmark")
+ readBookmark(folder);
+ else if (name() == "separator")
+ readSeparator(folder);
+ else
+ readUnknownElement();
+ }
+ }
+}
+
+void XbelReader::readBookmark(QTreeWidgetItem *item)
+{
+ Q_ASSERT(isStartElement() && name() == "bookmark");
+
+ QTreeWidgetItem *bookmark = createChildItem(item);
+ bookmark->setFlags(bookmark->flags() | Qt::ItemIsEditable);
+ bookmark->setIcon(0, bookmarkIcon);
+ bookmark->setText(0, QObject::tr("Unknown title"));
+ bookmark->setText(1, attributes().value("href").toString());
+ while (!atEnd()) {
+ readNext();
+
+ if (isEndElement())
+ break;
+
+ if (isStartElement()) {
+ if (name() == "title")
+ readTitle(bookmark);
+ else
+ readUnknownElement();
+ }
+ }
+}
+
+QTreeWidgetItem *XbelReader::createChildItem(QTreeWidgetItem *item)
+{
+ QTreeWidgetItem *childItem;
+ if (item) {
+ childItem = new QTreeWidgetItem(item);
+ } else {
+ childItem = new QTreeWidgetItem(treeWidget);
+ }
+ childItem->setData(0, Qt::UserRole, name().toString());
+ return childItem;
+}
diff --git a/doc/codesnippets/examples/xml/streambookmarks/xbelreader.h b/doc/codesnippets/examples/xml/streambookmarks/xbelreader.h
new file mode 100644
index 000000000..666261443
--- /dev/null
+++ b/doc/codesnippets/examples/xml/streambookmarks/xbelreader.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef XBELREADER_H
+#define XBELREADER_H
+
+#include <QIcon>
+#include <QXmlStreamReader>
+
+QT_BEGIN_NAMESPACE
+class QTreeWidget;
+class QTreeWidgetItem;
+QT_END_NAMESPACE
+
+//! [0]
+class XbelReader (QXmlStreamReader):
+//! [1]
+ def __init__(self, treeWidget):
+ ...
+//! [1]
+
+ def read(self, device);
+ ...
+
+//! [2]
+ def readUnknownElement(self):
+ ...
+ def readXBEL(self):
+ ...
+ def readTitle(self, item):
+ ...
+ def readSeparator(self, item):
+ ...
+ def readFolder(self, item):
+ ...
+ def readBookmark(self, item):
+ ...
+ def createChildItem(self, item):
+ ...
+//! [2]
+//! [0]
+
+#endif
diff --git a/doc/codesnippets/examples/xml/streambookmarks/xbelwriter.cpp b/doc/codesnippets/examples/xml/streambookmarks/xbelwriter.cpp
new file mode 100644
index 000000000..ada7f9f87
--- /dev/null
+++ b/doc/codesnippets/examples/xml/streambookmarks/xbelwriter.cpp
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "xbelwriter.h"
+
+//! [0]
+XbelWriter::XbelWriter(QTreeWidget *treeWidget)
+ : treeWidget(treeWidget)
+{
+ setAutoFormatting(true);
+}
+//! [0]
+
+//! [1]
+def writeFile(self, device):
+ self.setDevice(device)
+
+ self.writeStartDocument()
+ self.writeDTD("<!DOCTYPE xbel>")
+ self.writeStartElement("xbel")
+ self.writeAttribute("version", "1.0")
+ for i in range(0, self.treeWidget.topLevelItemCount()):
+ self.writeItem(self.treeWidget.topLevelItem(i))
+
+ self.writeEndDocument()
+ return True;
+//! [1]
+
+//! [2]
+void XbelWriter::writeItem(QTreeWidgetItem *item)
+{
+ QString tagName = item->data(0, Qt::UserRole).toString();
+ if (tagName == "folder") {
+ bool folded = !treeWidget->isItemExpanded(item);
+ writeStartElement(tagName);
+ writeAttribute("folded", folded ? "yes" : "no");
+ writeTextElement("title", item->text(0));
+ for (int i = 0; i < item->childCount(); ++i)
+ writeItem(item->child(i));
+ writeEndElement();
+ } else if (tagName == "bookmark") {
+ writeStartElement(tagName);
+ if (!item->text(1).isEmpty())
+ writeAttribute("href", item->text(1));
+ writeTextElement("title", item->text(0));
+ writeEndElement();
+ } else if (tagName == "separator") {
+ writeEmptyElement(tagName);
+ }
+}
+//! [2]
diff --git a/doc/codesnippets/snippets/textdocument-resources/main.cpp b/doc/codesnippets/snippets/textdocument-resources/main.cpp
new file mode 100644
index 000000000..e8f010aee
--- /dev/null
+++ b/doc/codesnippets/snippets/textdocument-resources/main.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+QString tr(const char *text)
+{
+ return QApplication::translate(text, text);
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QTextEdit *editor = new QTextEdit;
+
+ QTextDocument *document = new QTextDocument(editor);
+ QTextCursor cursor(document);
+
+ QImage image(64, 64, QImage::Format_RGB32);
+ image.fill(qRgb(255, 160, 128));
+
+//! [Adding a resource]
+ document.addResource(QTextDocument.ImageResource,
+ QUrl("mydata://image.png"), QVariant(image))
+//! [Adding a resource]
+
+//! [Inserting an image with a cursor]
+ imageFormat = QTextImageFormat()
+ imageFormat.setName("mydata://image.png")
+ cursor.insertImage(imageFormat)
+//! [Inserting an image with a cursor]
+
+ cursor.insertBlock();
+ cursor.insertText("Code less. Create more.");
+
+ editor->setDocument(document);
+ editor->setWindowTitle(tr("Text Document Images"));
+ editor->resize(320, 480);
+ editor->show();
+
+//! [Inserting an image using HTML]
+ editor.append("<img src=\"mydata://image.png\" />")
+//! [Inserting an image using HTML]
+
+ return app.exec();
+}
diff --git a/doc/codesnippets/snippets/textdocument-resources/textdocument-resources.pro b/doc/codesnippets/snippets/textdocument-resources/textdocument-resources.pro
new file mode 100644
index 000000000..16181f21c
--- /dev/null
+++ b/doc/codesnippets/snippets/textdocument-resources/textdocument-resources.pro
@@ -0,0 +1 @@
+SOURCES = main.cpp
diff --git a/doc/conf.py b/doc/conf.py
new file mode 100644
index 000000000..e8f79e5d0
--- /dev/null
+++ b/doc/conf.py
@@ -0,0 +1,166 @@
+# -*- coding: utf-8 -*-
+#
+# PySide documentation build configuration file, created by
+# sphinx-quickstart on Wed Apr 22 15:04:20 2009.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+sys.path.append(os.path.abspath('.'))
+
+# -- General configuration -----------------------------------------------------
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = ['sphinx.ext.todo', 'sphinx.ext.graphviz', 'inheritance_diagram']
+
+rst_epilog = """
+.. |project| replace:: PySide
+"""
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+source_encoding = 'utf-8'
+
+# The master toctree document.
+#master_doc = 'contents'
+
+# General information about the project.
+project = u'PySide'
+copyright = u'2009, Nokia Corporation'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '0.2.3'
+# The full version, including alpha/beta/rc tags.
+release = '0.2.3'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of documents that shouldn't be included in the build.
+#unused_docs = []
+
+# List of directories, relative to source directory, that shouldn't be searched
+# for source files.
+exclude_trees = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. Major themes that come with
+# Sphinx are currently 'default' and 'sphinxdoc'.
+html_theme = 'pysidedocs'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further. For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {
+#}
+
+# Add any paths that contain custom themes here, relative to this directory.
+html_theme_path = ['_themes']
+
+# The name for this set of Sphinx documents. If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar. Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = { '' : ''}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+html_additional_pages = { 'index' : 'index.html'}
+
+# If false, no module index is generated.
+#html_use_modindex = True
+
+# If false, no index is generated.
+html_use_index = False
+
+# If true, the index is split into individual pages for each letter.
+html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+html_show_sourcelink = False
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it. The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = ''
+
+# Output file base name for HTML help builder.
+#htmlhelp_basename = 'PySideDoc'
diff --git a/doc/contents.rst b/doc/contents.rst
new file mode 100644
index 000000000..aa2b645ec
--- /dev/null
+++ b/doc/contents.rst
@@ -0,0 +1,20 @@
+PySide Documentation contents
+*****************************
+
+.. toctree::
+ :maxdepth: 2
+
+ howto-build/index.rst
+ generatingdocs.rst
+ issuesdiff.rst
+ dbus.rst
+
+ modules.rst
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+
diff --git a/doc/dbus.rst b/doc/dbus.rst
new file mode 100644
index 000000000..8d1d22dc9
--- /dev/null
+++ b/doc/dbus.rst
@@ -0,0 +1,30 @@
+DBUS integration
+****************
+
+To get PySide and DBus working toghether you can use the glib mainloop integration already done in pydbus.
+
+The example above show how to export Qt objects to python and emit an DBus signal when a Qtsignal is emited. The code comments explains what you need to know about PySide and dbus, any doubts, see the python-dbus help.
+
+DBUS Client
+-----------
+
+.. literalinclude:: ../examples/dbus/example-client.py
+
+
+DBUS Server
+-----------
+
+.. literalinclude:: ../examples/dbus/example-server.py
+
+
+Running the example
+-------------------
+
+Copy the client code to a file called ``example-client.py`` and the server to a file called ``example-server.py`` and type:
+
+::
+
+ $ python example-server.py &
+ $ python example-client.py
+
+A litle window should appear on screen. Click on the button to emit a Qt signal, this signal will be converted to a DBus signal that will be caught by our dbus client. That's all.
diff --git a/doc/generatingdocs.rst b/doc/generatingdocs.rst
new file mode 100644
index 000000000..7d33cb817
--- /dev/null
+++ b/doc/generatingdocs.rst
@@ -0,0 +1,56 @@
+How to generate this documentation
+**********************************
+
+Pre-requisites
+--------------
+
+You will need:
+
+1. Qt4 source code (for API documentation).
+2. boostpythongenerator
+3. PySide source code
+4. cmake
+5. sphinx
+
+Extracting documentation from Qt4
+---------------------------------
+
+The API documentation is generated from source code comments (for now, just
+``qdoc3`` tool is supported, ``doxygen`` support will be added soon).
+
+``qdoc3`` is the tool used to generate the oficial Qt4 documentation, you will
+use it to generate a bunch of XML files that will be used by boostpythongenerator
+to create the documentation.
+
+So, go to Qt4 source directory and type:
+
+::
+
+ $ cp /path/to/pyside/sources/doc/pyside.qdocconf tools/qdoc3/test/pyside.qdocconf
+ $ QTDIR=`pwd` qdoc3 tools/qdoc3/test/pyside.qdocconf
+ $ export QT_SRC_DIR=`pwd` # the next step uses this variable.
+
+The xml files now can be found at ``$QT_SRC_DIR/qt4xmldoc``.
+
+Last step
+---------
+
+You need to tell PySide where it can find the generated XML files and the Qt4
+source directory (XML files refers to it in some tags). So, go to the PySide
+directory and type:
+
+::
+
+ $ mkdir build
+ $ cmake -DCMAKE_INSTALL_PREFIX=/usr -DDOC_DATA_DIR=$QT_SRC_DIR/qt4xmldoc -DQT_SRC_DIR=$QT_SRC_DIR ..
+ $ make apidoc
+ $ make apidocinstall
+
+Where:
+ * *PATH_TO_QT_SOURCE_DIR* is the path to the Qt4 sources.
+ * *PATH_TO_XMLS* is the path to the xml's generated by qdoc3 tool.
+
+The documentation will be installed at ``/usr/share/doc/pyside/index.html``, change
+the *CMAKE_INSTALL_PREFIX* value if you want to install the documentation in another
+directory.
+
diff --git a/doc/howto-build/cmake-primer.rst b/doc/howto-build/cmake-primer.rst
new file mode 100644
index 000000000..e839ffc66
--- /dev/null
+++ b/doc/howto-build/cmake-primer.rst
@@ -0,0 +1,72 @@
+
+.. _cmake-primer:
+
+************
+CMake primer
+************
+
+This chapter is a basic introduction to CMake, the build system used by PySide
+and the boost binding generator.
+
+The practical steps will focus on how to use cmake on a Unix-like (GNU/Linux)
+environment.
+
+
+Configuring
+===========
+
+Project file - CMakeLists.txt
+-----------------------------
+
+CMake parses the file CMakeLists.txt for information about the project,
+like project name, dependencies, what should be compiled, what should be
+shipped.
+
+
+CMake variables
+---------------
+
+CMake can have its default behavior modified by providing some
+
+* ``CMAKE_INSTALL_PREFIX=<some path here>`` sets the install prefix to
+ the specified path.
+* ``CMAKE_MODULE_PATH=<some path here>`` sets the extra directories
+ where CMake will try to find its modules.
+* ``CMAKE_TOOLCHAIN_FILE=<file path>`` sets the path to the file that
+ describes the toolchain used to compile this project. It is very useful
+ when using CMake with icecc to speedup compilation.
+
+You can define a variable using the ``-D<VARIABLE>`` switch like the example
+below.
+
+* ``-DCMAKE_BUILD_TYPE=Release|Debug`` sets the building behavior. Default
+ value is Release.
+
+Invoking CMake
+--------------
+
+After writing the CMakeLists.txt and deciding which flags will be used,
+you can invoke CMake using::
+
+ cmake <CMake flags> <path to toplevel CMakeLists.txt file>
+
+For example, if you use the ``build/`` folder to build the project and
+want it to be installed into ``/opt/sandbox/``, use the following lines::
+
+ cd build/
+ cmake -DCMAKE_INSTALL_PREFIX=/opt/sandbox ..
+
+CMake will process the project file and write the output files in the
+current directory
+
+Building
+========
+
+After the configuration process, the Makefiles are written and you can build
+the project using :program:`make`.
+
+Installing
+==========
+
+As in the building process, ``make install`` will install the files into
+the target directory.
diff --git a/doc/howto-build/index.rst b/doc/howto-build/index.rst
new file mode 100644
index 000000000..986dba505
--- /dev/null
+++ b/doc/howto-build/index.rst
@@ -0,0 +1,19 @@
+.. PySide documentation master file, created by sphinx-quickstart on Fri Mar 6 11:45:08 2009.
+ You can adapt this file completely to your liking, but it should at least
+ contain the root `toctree` directive.
+
+Getting started with PySide
+===========================
+
+Contents:
+
+.. toctree::
+ :maxdepth: 2
+
+ cmake-primer
+ setup-apiextractor
+ setup-generator
+ setup-boostpython
+ setup-bindings
+
+
diff --git a/doc/howto-build/setup-apiextractor.rst b/doc/howto-build/setup-apiextractor.rst
new file mode 100644
index 000000000..3a662337a
--- /dev/null
+++ b/doc/howto-build/setup-apiextractor.rst
@@ -0,0 +1,49 @@
+
+.. _api-extractor:
+
+**************
+API Extractor
+**************
+
+Overview
+========
+
+The **API Extractor** library is used by the binding generator to
+parse the header and typesystem files to create an internal
+representation of the API. It is based on the
+`QtScriptGenerator <http://labs.trolltech.com/page/Projects/QtScript/Generator>`_
+codebase.
+
+Getting the sources
+===================
+
+* Download URL: http://www.pyside.org/downloads/
+
+Build requirements
+==================
+
++ CMake >= 2.6.0
++ Qt4.5 libraries and development headers >= 4.5.0
++ libboost-graph >= 1.38.0
+
+Building and installing
+=======================
+
+To build and install just follow the generic cmake instructions in section
+:ref:`cmake-primer`.
+
+Debian packaging
+================
+
+In order to compile this package in a debian environment, make sure the
+following packages are installed:
+
+* debhelper (>= 5)
+* cdbs
+* cmake (>= 2.6.0)
+* libboost-graph1.38-dev (>= 1.38.0)
+* libqt4-dev (>= 4.5)
+
+And then you can build the package using::
+
+ $ dpkg-buildpackage -rfakeroot
diff --git a/doc/howto-build/setup-bindings.rst b/doc/howto-build/setup-bindings.rst
new file mode 100644
index 000000000..9e574cde5
--- /dev/null
+++ b/doc/howto-build/setup-bindings.rst
@@ -0,0 +1,76 @@
+***************
+Qt 4.6 Bindings
+***************
+
+Overview
+========
+
+These bindings allow access of Qt 4.6 libraries as Python modules,
+making them available just using the ``import`` command.
+
+The build process is comprised of two stages: in a first moment the
+bindings source code are created from the Qt 4.6 headers by calling
+the :ref:`boost-python-generator` with apropriate parameters; the
+generated files are then compiled and linked together to form the
+bindings libraries.
+
+The bindings available at the moment are listed below:
+
+ + QtCore
+ + QtGui
+ + QtHelp
+ + QtMultimedia
+ + QtNetwork
+ + QtOpenGL
+ + QtScript
+ + QtScriptTools
+ + QtSql
+ + QtSvg
+ + QtUiTools
+ + QtWebKit
+ + QtXml
+ + QtXmlPatterns
+
+Getting the sources
+===================
+
+* Download URL: http://www.pyside.org/downloads/
+
+Build requirements
+==================
+
+ + CMake (>= 2.6.0)
+ + Qt 4.6 libraries + headers
+ + Boost.Python + headers (>= 1.40.0)
+ + :ref:`boost-python-generator`
+
+
+Building and installing
+=======================
+
+To build and install just follow the generic cmake instructions in
+section :ref:`cmake-primer`.
+
+Be advised that the build process can be rather lenghty because of the
+number of source files that will be compiled.
+
+Debian packaging
+================
+
+.. note:: For the time being the Debian packaging uses Qt 4.5 as dependency, therefore the generated bindings will be for this version of Qt.
+
+In order to compile this package in a debian environment, make sure the
+following packages are installed:
+
+* debhelper (>= 5)
+* cdbs
+* cmake (>= 2.6.0)
+* python-all-dev
+* python-central (>= 0.6)
+* boostpythongenerator (>= 0.3)
+* libboost-python1.40-dev (>= 1.40.0)
+* libqt4-dev (>= 4.5)
+
+And then you can build the package using::
+
+ $ dpkg-buildpackage -rfakeroot
diff --git a/doc/howto-build/setup-boostpython.rst b/doc/howto-build/setup-boostpython.rst
new file mode 100644
index 000000000..a70840ae3
--- /dev/null
+++ b/doc/howto-build/setup-boostpython.rst
@@ -0,0 +1,51 @@
+
+.. _boost-python-generator:
+
+**********************
+Boost.Python Generator
+**********************
+
+Overview
+=========================================
+
+The **Boost::Python Generator** (A.K.A. :program:`boostpythongenerator`) is
+the program that creates the Boost.Python bindings source files from Qt headers
+and auxiliary files (typesystems, ``global.h`` and glue files). It depends on
+:ref:`generator-runner` and :ref:`api-extractor` library.
+
+
+Getting the sources
+===================
+
+* Download URL: http://www.pyside.org/downloads/
+
+Build requirements
+==================
+
++ CMake >= 2.6.0
++ Qt4.5 libraries and development headers >= 4.5.0
++ :ref:`api-extractor` + development headers
++ :ref:`generator-runner` + development headers
+
+Building and installing
+=======================
+
+To build and install just follow the generic cmake instructions in
+section :ref:`cmake-primer`.
+
+Debian packaging
+================
+
+In order to compile this package in a debian environment, make sure the
+following packages are installed:
+
+* debhelper (>= 5)
+* cdbs
+* cmake (>= 2.6.0)
+* libqt4-dev (>= 4.5)
+* libapiextractor-dev (>= 0.3.2)
+* libgenrunner-dev (>= 0.3.2a1)
+
+And then you can build the package using::
+
+ $ dpkg-buildpackage -rfakeroot
diff --git a/doc/howto-build/setup-generator.rst b/doc/howto-build/setup-generator.rst
new file mode 100644
index 000000000..c3f321c3c
--- /dev/null
+++ b/doc/howto-build/setup-generator.rst
@@ -0,0 +1,50 @@
+
+.. _generator-runner:
+
+****************
+Generator Runner
+****************
+
+Overview
+=========================================
+
+The **Generator Runner** (A.K.A. :program:`generatorrunner`) is the
+program that controls the binding generation process according to the
+rules given by the user through headers, type system files and generator
+front-ends (such as :ref:`boost-python-generator`). It depends on
+:ref:`api-extractor` library.
+
+
+Getting the sources
+===================
+
+* Download URL: http://www.pyside.org/downloads/
+
+Build requirements
+==================
+
++ CMake >= 2.6.0
++ Qt4.5 libraries and development headers >= 4.5.0
++ :ref:`api-extractor` + development headers
+
+Building and installing
+=======================
+
+To build and install just follow the generic cmake instructions in
+section :ref:`cmake-primer`.
+
+Debian packaging
+================
+
+In order to compile this package in a debian environment, make sure the
+following packages are installed:
+
+* debhelper (>= 5)
+* cdbs
+* cmake (>= 2.6.0)
+* libqt4-dev (>= 4.5)
+* libapiextractor-dev (>= 0.3.2)
+
+And then you can build the package using::
+
+ $ dpkg-buildpackage -rfakeroot
diff --git a/doc/inheritance_diagram.py b/doc/inheritance_diagram.py
new file mode 100644
index 000000000..ae248edd8
--- /dev/null
+++ b/doc/inheritance_diagram.py
@@ -0,0 +1,369 @@
+"""
+ sphinx.ext.inheritance_diagram
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ Defines a docutils directive for inserting inheritance diagrams.
+
+ Provide the directive with one or more classes or modules (separated
+ by whitespace). For modules, all of the classes in that module will
+ be used.
+
+ Example::
+
+ Given the following classes:
+
+ class A: pass
+ class B(A): pass
+ class C(A): pass
+ class D(B, C): pass
+ class E(B): pass
+
+ .. inheritance-diagram: D E
+
+ Produces a graph like the following:
+
+ A
+ / \
+ B C
+ / \ /
+ E D
+
+ The graph is inserted as a PNG+image map into HTML and a PDF in
+ LaTeX.
+
+ :copyright: Copyright 2007-2009 by the Sphinx team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
+
+import os
+import re
+import sys
+import inspect
+import subprocess
+try:
+ from hashlib import md5
+except ImportError:
+ from md5 import md5
+
+from docutils import nodes
+from docutils.parsers.rst import directives
+
+from sphinx.roles import xfileref_role
+from sphinx.ext.graphviz import render_dot_html, render_dot_latex
+from sphinx.util.compat import Directive
+
+
+class_sig_re = re.compile(r'''^([\w.]*\.)? # module names
+ (\w+) \s* $ # class/final module name
+ ''', re.VERBOSE)
+
+
+class InheritanceException(Exception):
+ pass
+
+
+class InheritanceGraph(object):
+ """
+ Given a list of classes, determines the set of classes that they inherit
+ from all the way to the root "object", and then is able to generate a
+ graphviz dot graph from them.
+ """
+ def __init__(self, class_names, currmodule, show_builtins=False):
+ """
+ *class_names* is a list of child classes to show bases from.
+
+ If *show_builtins* is True, then Python builtins will be shown
+ in the graph.
+ """
+ self.class_names = class_names
+ self.classes = self._import_classes(class_names, currmodule)
+ self.all_classes = self._all_classes(self.classes)
+ if len(self.all_classes) == 0:
+ raise InheritanceException('No classes found for '
+ 'inheritance diagram')
+ self.show_builtins = show_builtins
+
+ def _import_class_or_module(self, name, currmodule):
+ """
+ Import a class using its fully-qualified *name*.
+ """
+ try:
+ path, base = class_sig_re.match(name).groups()
+ except ValueError:
+ raise InheritanceException('Invalid class or module %r specified '
+ 'for inheritance diagram' % name)
+
+ fullname = (path or '') + base
+ path = (path and path.rstrip('.') or '')
+
+ # two possibilities: either it is a module, then import it
+ try:
+ module = __import__(fullname)
+ todoc = sys.modules[fullname]
+ except ImportError:
+ # else it is a class, then import the module
+ if not path:
+ if currmodule:
+ # try the current module
+ path = currmodule
+ else:
+ raise InheritanceException(
+ 'Could not import class %r specified for '
+ 'inheritance diagram' % base)
+ try:
+ module = __import__(path)
+ todoc = getattr(sys.modules[path], base)
+ except (ImportError, AttributeError):
+ raise InheritanceException(
+ 'Could not import class or module %r specified for '
+ 'inheritance diagram' % (path + '.' + base))
+
+ # If a class, just return it
+ if inspect.isclass(todoc):
+ return [todoc]
+ elif inspect.ismodule(todoc):
+ classes = []
+ for cls in todoc.__dict__.values():
+ if inspect.isclass(cls) and cls.__module__ == todoc.__name__:
+ classes.append(cls)
+ return classes
+ raise InheritanceException('%r specified for inheritance diagram is '
+ 'not a class or module' % name)
+
+ def _import_classes(self, class_names, currmodule):
+ """
+ Import a list of classes.
+ """
+ classes = []
+ for name in class_names:
+ classes.extend(self._import_class_or_module(name, currmodule))
+ return classes
+
+ def _all_classes(self, classes):
+ """
+ Return a list of all classes that are ancestors of *classes*.
+ """
+ all_classes = {}
+
+ def recurse(cls):
+ all_classes[cls] = None
+ for c in cls.__bases__:
+ if c not in all_classes and c.__name__ != "instance":
+ recurse(c)
+
+ for cls in classes:
+ recurse(cls)
+
+ return all_classes.keys()
+
+ def class_name(self, cls, parts=0):
+ """
+ Given a class object, return a fully-qualified name. This
+ works for things I've tested in matplotlib so far, but may not
+ be completely general.
+ """
+ module = cls.__module__
+ if module == '__builtin__':
+ fullname = cls.__name__
+ else:
+ fullname = '%s.%s' % (module, cls.__name__)
+ if parts == 0:
+ return fullname
+ name_parts = fullname.split('.')
+ return '.'.join(name_parts[-parts:])
+
+ def get_all_class_names(self):
+ """
+ Get all of the class names involved in the graph.
+ """
+ return [self.class_name(x) for x in self.all_classes]
+
+ # These are the default attrs for graphviz
+ default_graph_attrs = {
+ 'rankdir': 'LR',
+ 'size': '"8.0, 12.0"',
+ }
+ default_node_attrs = {
+ 'shape': 'box',
+ 'fontsize': 10,
+ 'height': 0.25,
+ 'fontname': 'Vera Sans, DejaVu Sans, Liberation Sans, '
+ 'Arial, Helvetica, sans',
+ 'style': '"setlinewidth(0.5)"',
+ }
+ default_edge_attrs = {
+ 'arrowsize': 0.5,
+ 'style': '"setlinewidth(0.5)"',
+ }
+
+ def _format_node_attrs(self, attrs):
+ return ','.join(['%s=%s' % x for x in attrs.items()])
+
+ def _format_graph_attrs(self, attrs):
+ return ''.join(['%s=%s;\n' % x for x in attrs.items()])
+
+ def generate_dot(self, name, parts=0, urls={}, env=None,
+ graph_attrs={}, node_attrs={}, edge_attrs={}):
+ """
+ Generate a graphviz dot graph from the classes that
+ were passed in to __init__.
+
+ *name* is the name of the graph.
+
+ *urls* is a dictionary mapping class names to HTTP URLs.
+
+ *graph_attrs*, *node_attrs*, *edge_attrs* are dictionaries containing
+ key/value pairs to pass on as graphviz properties.
+ """
+ g_attrs = self.default_graph_attrs.copy()
+ n_attrs = self.default_node_attrs.copy()
+ e_attrs = self.default_edge_attrs.copy()
+ g_attrs.update(graph_attrs)
+ n_attrs.update(node_attrs)
+ e_attrs.update(edge_attrs)
+ if env:
+ g_attrs.update(env.config.inheritance_graph_attrs)
+ n_attrs.update(env.config.inheritance_node_attrs)
+ e_attrs.update(env.config.inheritance_edge_attrs)
+
+ res = []
+ res.append('digraph %s {\n' % name)
+ res.append(self._format_graph_attrs(g_attrs))
+
+ for cls in self.all_classes:
+ if not self.show_builtins and cls in __builtins__.values():
+ continue
+
+ name = self.class_name(cls, parts)
+
+ # Write the node
+ this_node_attrs = n_attrs.copy()
+ url = urls.get(self.class_name(cls))
+ if url is not None:
+ this_node_attrs['URL'] = '"%s"' % url
+ res.append(' "%s" [%s];\n' %
+ (name, self._format_node_attrs(this_node_attrs)))
+
+ # Write the edges
+ for base in cls.__bases__:
+ if base.__name__ == "instance":
+ continue
+ if not self.show_builtins and base in __builtins__.values():
+ continue
+
+ base_name = self.class_name(base, parts)
+ res.append(' "%s" -> "%s" [%s];\n' %
+ (base_name, name,
+ self._format_node_attrs(e_attrs)))
+ res.append('}\n')
+ return ''.join(res)
+
+
+class inheritance_diagram(nodes.General, nodes.Element):
+ """
+ A docutils node to use as a placeholder for the inheritance diagram.
+ """
+ pass
+
+
+class InheritanceDiagram(Directive):
+ """
+ Run when the inheritance_diagram directive is first encountered.
+ """
+ has_content = False
+ required_arguments = 1
+ optional_arguments = 0
+ final_argument_whitespace = True
+ option_spec = {
+ 'parts': directives.nonnegative_int,
+ }
+
+ def run(self):
+ node = inheritance_diagram()
+ node.document = self.state.document
+ env = self.state.document.settings.env
+ class_names = self.arguments[0].split()
+
+ # Create a graph starting with the list of classes
+ try:
+ graph = InheritanceGraph(class_names, env.currmodule)
+ except InheritanceException, err:
+ return [node.document.reporter.warning(err.args[0],
+ line=self.lineno)]
+
+ # Create xref nodes for each target of the graph's image map and
+ # add them to the doc tree so that Sphinx can resolve the
+ # references to real URLs later. These nodes will eventually be
+ # removed from the doctree after we're done with them.
+ for name in graph.get_all_class_names():
+ refnodes, x = xfileref_role(
+ 'class', ':class:`%s`' % name, name, 0, self.state)
+ node.extend(refnodes)
+ # Store the graph object so we can use it to generate the
+ # dot file later
+ node['graph'] = graph
+ # Store the original content for use as a hash
+ node['parts'] = self.options.get('parts', 0)
+ node['content'] = ' '.join(class_names)
+ return [node]
+
+
+def get_graph_hash(node):
+ return md5(node['content'] + str(node['parts'])).hexdigest()[-10:]
+
+
+def html_visit_inheritance_diagram(self, node):
+ """
+ Output the graph for HTML. This will insert a PNG with clickable
+ image map.
+ """
+ graph = node['graph']
+ parts = node['parts']
+
+ graph_hash = get_graph_hash(node)
+ name = 'inheritance%s' % graph_hash
+
+ # Create a mapping from fully-qualified class names to URLs.
+ urls = {}
+ for child in node:
+ if child.get('refuri') is not None:
+ urls[child['reftitle']] = child.get('refuri')
+ elif child.get('refid') is not None:
+ urls[child['reftitle']] = '#' + child.get('refid')
+
+ dotcode = graph.generate_dot(name, parts, urls, env=self.builder.env)
+ render_dot_html(self, node, dotcode, [], 'inheritance', 'inheritance')
+ raise nodes.SkipNode
+
+
+def latex_visit_inheritance_diagram(self, node):
+ """
+ Output the graph for LaTeX. This will insert a PDF.
+ """
+ graph = node['graph']
+ parts = node['parts']
+
+ graph_hash = get_graph_hash(node)
+ name = 'inheritance%s' % graph_hash
+
+ dotcode = graph.generate_dot(name, parts, env=self.builder.env,
+ graph_attrs={'size': '"6.0,6.0"'})
+ render_dot_latex(self, node, dotcode, [], 'inheritance')
+ raise nodes.SkipNode
+
+
+def skip(self, node):
+ raise nodes.SkipNode
+
+
+def setup(app):
+ app.setup_extension('sphinx.ext.graphviz')
+ app.add_node(
+ inheritance_diagram,
+ latex=(latex_visit_inheritance_diagram, None),
+ html=(html_visit_inheritance_diagram, None),
+ text=(skip, None))
+ app.add_directive('inheritance-diagram', InheritanceDiagram)
+ app.add_config_value('inheritance_graph_attrs', {}, False),
+ app.add_config_value('inheritance_node_attrs', {}, False),
+ app.add_config_value('inheritance_edge_attrs', {}, False),
diff --git a/doc/issuesdiff.rst b/doc/issuesdiff.rst
new file mode 100644
index 000000000..480ad6c8c
--- /dev/null
+++ b/doc/issuesdiff.rst
@@ -0,0 +1,26 @@
+PySide issues and specificities
+*******************************
+
+This document shows some points not supported yet by Boost.python
+and PySide.
+
+Deprecated Methods
+------------------
+
+The deprecated methods before Qt 4.4 is not supported by PySide,
+e.g.: `QColor.dark()` and `QColor.light()`.
+
+**How to solve:** update the methods with new ones like `QColor.darker()`
+and `QColor.lighter()`.
+
+Class methods with static and normal methods with the same signature
+--------------------------------------------------------------------
+
+Boost.Python does not support static methods and member methods
+with the same signature. The static versions is renamed to
+*classMethodName*.
+
+**Example:** QFile.permissions() and QFile.permissions(QString)
+
+**How to solve:** for static methods use QFile.filePermissions(QString)
+
diff --git a/doc/modules.rst b/doc/modules.rst
new file mode 100644
index 000000000..f3d9cc2b1
--- /dev/null
+++ b/doc/modules.rst
@@ -0,0 +1,19 @@
+PySide modules
+**************
+
+.. toctree::
+
+ PySide/QtCore/index.rst
+ PySide/QtGui/index.rst
+ PySide/QtHelp/index.rst
+ PySide/QtMultimedia/index.rst
+ PySide/QtNetwork/index.rst
+ PySide/QtOpenGL/index.rst
+ PySide/QtScript/index.rst
+ PySide/QtScriptTools/index.rst
+ PySide/QtSql/index.rst
+ PySide/QtSvg/index.rst
+ PySide/QtUiTools/index.rst
+ PySide/QtXml/index.rst
+ PySide/QtWebKit/index.rst
+ PySide/phonon/index.rst
diff --git a/doc/pyhtml2devhelp.py b/doc/pyhtml2devhelp.py
new file mode 100644
index 000000000..2d78896ef
--- /dev/null
+++ b/doc/pyhtml2devhelp.py
@@ -0,0 +1,225 @@
+#! /usr/bin/python
+
+# This script is based on Python2.6 Ubuntu package script by Marc Deslauriers
+
+import formatter, htmllib
+import os, sys, re
+
+class PyHTMLParser(htmllib.HTMLParser):
+ pages_to_include = set(('index.html', 'PySide/QtHelp/index.html', 'PySide/QtSvg/index.html',
+ 'PySide/QtGui/index.html', 'PySide/QtNetwork/index.html', 'PySide/QtWebKit/index.html',
+ 'PySide/QtUiTools/index.html', 'PySide/QtXml/index.html', 'PySide/QtCore/index.html',
+ 'PySide/QtScriptTools/index.html', 'PySide/QtOpenGL/index.html', 'PySide/QtScript/index.html',
+ 'PySide/QtSql/index.html', 'howto-build/index.html'))
+
+ def __init__(self, formatter, basedir, fn, indent, parents=set()):
+ htmllib.HTMLParser.__init__(self, formatter)
+ self.basedir = basedir
+ self.dir, self.fn = os.path.split(fn)
+ self.data = ''
+ self.parents = parents
+ self.link = {}
+ self.indent = indent
+ self.last_indent = indent - 1
+ self.sub_indent = 0
+ self.sub_count = 0
+ self.next_link = False
+
+ def process_link(self):
+ new_href = os.path.join(self.dir, self.link['href'])
+ text = self.link['text']
+ indent = self.indent + self.sub_indent
+ if self.last_indent == indent:
+ print '%s</sub>' % (' ' * self.last_indent)
+ self.sub_count -= 1
+ print '%s<sub link="%s" name="%s">' % (' ' * indent, new_href, text)
+ self.sub_count += 1
+ self.last_indent = self.indent + self.sub_indent
+
+ def start_li(self, attrs):
+ self.sub_indent += 1
+ self.next_link = True
+
+ def end_li(self):
+ indent = self.indent + self.sub_indent
+ if self.sub_count > 0:
+ print '%s</sub>' % (' ' * self.last_indent)
+ self.sub_count -= 1
+ self.last_indent -= 1
+ self.sub_indent -= 1
+
+ def start_a(self, attrs):
+ self.link = {}
+ for attr in attrs:
+ self.link[attr[0]] = attr[1]
+ self.data = ''
+
+ def end_a(self):
+ process = False
+ text = self.data.replace('\t', '').replace('\n', ' ').replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
+ self.link['text'] = text
+ # handle a tag without href attribute
+ try:
+ href = self.link['href']
+ except KeyError:
+ return
+
+ abs_href = os.path.join(self.basedir, href)
+ if abs_href in self.parents:
+ return
+ if href.startswith('..') or href.startswith('http:') \
+ or href.startswith('mailto:') or href.startswith('news:'):
+ return
+ if href in ('', 'about.html', 'modindex.html', 'genindex.html', 'glossary.html',
+ 'search.html', 'contents.html', 'download.html', 'bugs.html',
+ 'license.html', 'copyright.html'):
+ return
+
+ if self.link.has_key('class'):
+ if self.link['class'] in ('biglink'):
+ process = True
+ if self.link['class'] in ('reference external'):
+ if self.next_link:
+ process = True
+ next_link = False
+
+ if process == True:
+ self.process_link()
+ if href in self.pages_to_include:
+ self.parse_file(os.path.join(self.dir, href))
+
+ def finish(self):
+ if self.sub_count > 0:
+ print '%s</sub>' % (' ' * self.last_indent)
+
+ def handle_data(self, data):
+ self.data += data
+
+ def parse_file(self, href):
+ # TODO basedir bestimmen
+ parent = os.path.join(self.basedir, self.fn)
+ self.parents.add(parent)
+ parser = PyHTMLParser(formatter.NullFormatter(),
+ self.basedir, href, self.indent + 1,
+ self.parents)
+ text = file(self.basedir + '/' + href).read()
+ parser.feed(text)
+ parser.finish()
+ parser.close()
+ if parent in self.parents:
+ self.parents.remove(parent)
+
+class PyIdxHTMLParser(htmllib.HTMLParser):
+ def __init__(self, formatter, basedir, fn, indent):
+ htmllib.HTMLParser.__init__(self, formatter)
+ self.basedir = basedir
+ self.dir, self.fn = os.path.split(fn)
+ self.data = ''
+ self.link = {}
+ self.indent = indent
+ self.active = False
+ self.indented = False
+ self.nolink = False
+ self.header = ''
+ self.last_letter = 'Z'
+ self.last_text = ''
+
+ def process_link(self):
+ new_href = os.path.join(self.dir, self.link['href'])
+ text = self.link['text']
+ if not self.active:
+ return
+ if text.startswith('['):
+ return
+ if self.link.get('rel', None) in ('prev', 'parent', 'next', 'contents', 'index'):
+ return
+ if self.indented:
+ text = self.last_text + ' ' + text
+ else:
+ # Save it in case we need it again
+ self.last_text = re.sub(' \([\w\-\.\s]+\)', '', text)
+ indent = self.indent
+ print '%s<function link="%s" name="%s"/>' % (' ' * indent, new_href, text)
+
+ def start_dl(self, attrs):
+ if self.last_text:
+ # Looks like we found the second part to a command
+ self.indented = True
+
+ def end_dl(self):
+ self.indented = False
+
+ def start_dt(self, attrs):
+ self.data = ''
+ self.nolink = True
+
+ def end_dt(self):
+ if not self.active:
+ return
+ if self.nolink == True:
+ # Looks like we found the first part to a command
+ self.last_text = re.sub(' \([\w\-\.\s]+\)', '', self.data)
+ self.nolink = False
+
+ def start_h2(self, attrs):
+ for k, v in attrs:
+ if k == 'id':
+ self.header = v
+ if v == '_':
+ self.active = True
+
+ def start_td(self, attrs):
+ self.indented = False
+ self.last_text = ''
+
+ def start_table(self, attrs):
+ pass
+
+ def end_table(self):
+ if self.header == self.last_letter:
+ self.active = False
+
+ def start_a(self, attrs):
+ self.nolink = False
+ self.link = {}
+ for attr in attrs:
+ self.link[attr[0]] = attr[1]
+ self.data = ''
+
+ def end_a(self):
+ text = self.data.replace('\t', '').replace('\n', ' ').replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
+ self.link['text'] = text
+ # handle a tag without href attribute
+ try:
+ href = self.link['href']
+ except KeyError:
+ return
+ self.process_link()
+
+ def handle_data(self, data):
+ self.data += data
+
+def main():
+ base = sys.argv[1]
+ fn = sys.argv[2]
+
+ parser = PyHTMLParser(formatter.NullFormatter(), base, fn, indent=0)
+ print '<?xml version="1.0" encoding="iso-8859-1"?>'
+ print '<book title="PySide %s Documentation" name="PySide" version="%s" link="index.html">' % (sys.argv[3], sys.argv[3])
+ print '<chapters>'
+ parser.parse_file(fn)
+ print '</chapters>'
+
+ print '<functions>'
+
+ fn = 'genindex.html'
+ parser = PyIdxHTMLParser(formatter.NullFormatter(), base, fn, indent=1)
+ text = file(base + '/' + fn).read()
+ parser.feed(text)
+ parser.close()
+
+ print '</functions>'
+ print '</book>'
+
+main()
+
diff --git a/doc/pyside.qdocconf b/doc/pyside.qdocconf
new file mode 100644
index 000000000..24a6f63b2
--- /dev/null
+++ b/doc/pyside.qdocconf
@@ -0,0 +1,11 @@
+include(qt.qdocconf)
+
+quotinginformation = true
+imagedirs = $QTDIR/doc/src/images \
+ $QTDIR/examples
+
+outputdir = @CMAKE_CURRENT_BINARY_DIR@/qt4xmldoc
+outputformats = WebXML
+
+generateindex = false
+url = .